summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/ISSUE_TEMPLATE/bug_report.yml21
-rw-r--r--.github/workflows/static_checks.yml9
-rw-r--r--.gitignore4
-rw-r--r--CHANGELOG.md4
-rw-r--r--CONTRIBUTING.md81
-rw-r--r--SConstruct16
-rw-r--r--core/SCsub25
-rw-r--r--core/core_bind.cpp19
-rw-r--r--core/core_bind.h3
-rw-r--r--core/debugger/remote_debugger_peer.cpp4
-rw-r--r--core/doc_data.h55
-rw-r--r--core/input/input.cpp25
-rw-r--r--core/io/compression.cpp218
-rw-r--r--core/io/compression.h3
-rw-r--r--core/io/dir_access.h2
-rw-r--r--core/io/file_access.cpp1
-rw-r--r--core/io/file_access.h5
-rw-r--r--core/io/file_access_compressed.cpp8
-rw-r--r--core/io/json.cpp8
-rw-r--r--core/io/packed_data_container.cpp11
-rw-r--r--core/io/packed_data_container.h1
-rw-r--r--core/math/a_star_grid_2d.cpp74
-rw-r--r--core/math/a_star_grid_2d.h15
-rw-r--r--core/math/bvh_debug.inc6
-rw-r--r--core/object/class_db.cpp15
-rw-r--r--core/object/class_db.h1
-rw-r--r--core/object/message_queue.cpp5
-rw-r--r--core/object/message_queue.h2
-rw-r--r--core/object/object.cpp74
-rw-r--r--core/object/object.h5
-rw-r--r--core/os/os.cpp9
-rw-r--r--core/os/os.h1
-rw-r--r--core/os/thread.cpp39
-rw-r--r--core/os/thread.h24
-rw-r--r--core/string/translation.cpp17
-rw-r--r--core/string/ustring.cpp47
-rw-r--r--core/string/ustring.h1
-rw-r--r--core/templates/hashfuncs.h6
-rw-r--r--core/variant/variant_call.cpp1
-rw-r--r--doc/classes/AStarGrid2D.xml13
-rw-r--r--doc/classes/Animation.xml36
-rw-r--r--doc/classes/AnimationNode.xml4
-rw-r--r--doc/classes/AnimationNodeAdd2.xml2
-rw-r--r--doc/classes/AnimationNodeAdd3.xml2
-rw-r--r--doc/classes/AnimationNodeAnimation.xml6
-rw-r--r--doc/classes/AnimationNodeBlend2.xml2
-rw-r--r--doc/classes/AnimationNodeBlend3.xml2
-rw-r--r--doc/classes/AnimationNodeBlendSpace1D.xml11
-rw-r--r--doc/classes/AnimationNodeBlendSpace2D.xml10
-rw-r--r--doc/classes/AnimationNodeBlendTree.xml6
-rw-r--r--doc/classes/AnimationNodeOneShot.xml4
-rw-r--r--doc/classes/AnimationNodeOutput.xml5
-rw-r--r--doc/classes/AnimationNodeStateMachine.xml6
-rw-r--r--doc/classes/AnimationNodeStateMachinePlayback.xml4
-rw-r--r--doc/classes/AnimationNodeStateMachineTransition.xml4
-rw-r--r--doc/classes/AnimationNodeSync.xml4
-rw-r--r--doc/classes/AnimationNodeTimeScale.xml6
-rw-r--r--doc/classes/AnimationNodeTimeSeek.xml4
-rw-r--r--doc/classes/AnimationNodeTransition.xml4
-rw-r--r--doc/classes/AnimationPlayer.xml8
-rw-r--r--doc/classes/AnimationRootNode.xml4
-rw-r--r--doc/classes/AnimationTrackEditPlugin.xml9
-rw-r--r--doc/classes/AnimationTree.xml4
-rw-r--r--doc/classes/AudioStreamGenerator.xml26
-rw-r--r--doc/classes/BaseMaterial3D.xml4
-rw-r--r--doc/classes/Bone2D.xml22
-rw-r--r--doc/classes/BoneAttachment3D.xml5
-rw-r--r--doc/classes/BoneMap.xml4
-rw-r--r--doc/classes/Button.xml5
-rw-r--r--doc/classes/CanvasItem.xml13
-rw-r--r--doc/classes/CodeEdit.xml11
-rw-r--r--doc/classes/ColorPicker.xml3
-rw-r--r--doc/classes/Curve.xml2
-rw-r--r--doc/classes/Curve2D.xml2
-rw-r--r--doc/classes/Curve3D.xml2
-rw-r--r--doc/classes/CurveTexture.xml2
-rw-r--r--doc/classes/Decal.xml2
-rw-r--r--doc/classes/DisplayServer.xml12
-rw-r--r--doc/classes/EditorScript.xml4
-rw-r--r--doc/classes/EditorSettings.xml11
-rw-r--r--doc/classes/EditorVCSInterface.xml38
-rw-r--r--doc/classes/Engine.xml2
-rw-r--r--doc/classes/EngineDebugger.xml2
-rw-r--r--doc/classes/Expression.xml1
-rw-r--r--doc/classes/FileAccess.xml5
-rw-r--r--doc/classes/FontFile.xml2
-rw-r--r--doc/classes/GPUParticlesCollisionHeightField3D.xml2
-rw-r--r--doc/classes/GeometryInstance3D.xml7
-rw-r--r--doc/classes/Gradient.xml3
-rw-r--r--doc/classes/HSlider.xml3
-rw-r--r--doc/classes/ImageTexture3D.xml2
-rw-r--r--doc/classes/ImageTextureLayered.xml2
-rw-r--r--doc/classes/ImmediateMesh.xml13
-rw-r--r--doc/classes/ItemList.xml3
-rw-r--r--doc/classes/Light3D.xml2
-rw-r--r--doc/classes/LineEdit.xml6
-rw-r--r--doc/classes/Marker2D.xml2
-rw-r--r--doc/classes/MeshDataTool.xml4
-rw-r--r--doc/classes/NavigationLink2D.xml8
-rw-r--r--doc/classes/NavigationLink3D.xml8
-rw-r--r--doc/classes/NavigationServer2D.xml22
-rw-r--r--doc/classes/NavigationServer3D.xml22
-rw-r--r--doc/classes/Node3D.xml4
-rw-r--r--doc/classes/OS.xml17
-rw-r--r--doc/classes/PackedByteArray.xml2
-rw-r--r--doc/classes/PackedDataContainer.xml29
-rw-r--r--doc/classes/PackedDataContainerRef.xml25
-rw-r--r--doc/classes/ParticleProcessMaterial.xml11
-rw-r--r--doc/classes/PathFollow3D.xml2
-rw-r--r--doc/classes/PhysicalBone2D.xml24
-rw-r--r--doc/classes/PhysicalBone3D.xml3
-rw-r--r--doc/classes/PhysicsServer2D.xml2
-rw-r--r--doc/classes/ProjectSettings.xml64
-rw-r--r--doc/classes/RDAttachmentFormat.xml5
-rw-r--r--doc/classes/RDFramebufferPass.xml6
-rw-r--r--doc/classes/RDPipelineColorBlendState.xml6
-rw-r--r--doc/classes/RDPipelineColorBlendStateAttachment.xml70
-rw-r--r--doc/classes/RDPipelineDepthStencilState.xml3
-rw-r--r--doc/classes/RDPipelineMultisampleState.xml8
-rw-r--r--doc/classes/RDPipelineRasterizationState.xml8
-rw-r--r--doc/classes/RDPipelineSpecializationConstant.xml5
-rw-r--r--doc/classes/RDSamplerState.xml16
-rw-r--r--doc/classes/RDShaderFile.xml7
-rw-r--r--doc/classes/RDShaderSPIRV.xml17
-rw-r--r--doc/classes/RDShaderSource.xml11
-rw-r--r--doc/classes/RDTextureFormat.xml11
-rw-r--r--doc/classes/RDTextureView.xml7
-rw-r--r--doc/classes/RDUniform.xml4
-rw-r--r--doc/classes/RDVertexAttribute.xml2
-rw-r--r--doc/classes/Rect2.xml2
-rw-r--r--doc/classes/Rect2i.xml4
-rw-r--r--doc/classes/ReflectionProbe.xml14
-rw-r--r--doc/classes/RenderingDevice.xml611
-rw-r--r--doc/classes/RenderingServer.xml666
-rw-r--r--doc/classes/RibbonTrailMesh.xml13
-rw-r--r--doc/classes/RichTextLabel.xml2
-rw-r--r--doc/classes/RigidBody2D.xml2
-rw-r--r--doc/classes/RigidBody3D.xml2
-rw-r--r--doc/classes/SceneTree.xml6
-rw-r--r--doc/classes/ScrollContainer.xml6
-rw-r--r--doc/classes/ShaderGlobalsOverride.xml4
-rw-r--r--doc/classes/Skeleton2D.xml6
-rw-r--r--doc/classes/Skeleton3D.xml6
-rw-r--r--doc/classes/SkeletonIK3D.xml6
-rw-r--r--doc/classes/SkeletonModification2D.xml4
-rw-r--r--doc/classes/SkeletonModification2DTwoBoneIK.xml4
-rw-r--r--doc/classes/SkeletonProfile.xml2
-rw-r--r--doc/classes/Sky.xml2
-rw-r--r--doc/classes/SoftBody3D.xml4
-rw-r--r--doc/classes/StreamPeerTLS.xml2
-rw-r--r--doc/classes/String.xml8
-rw-r--r--doc/classes/StringName.xml8
-rw-r--r--doc/classes/SyntaxHighlighter.xml2
-rw-r--r--doc/classes/TextEdit.xml4
-rw-r--r--doc/classes/TextServerDummy.xml14
-rw-r--r--doc/classes/TileMap.xml23
-rw-r--r--doc/classes/TileSet.xml2
-rw-r--r--doc/classes/TileSetScenesCollectionSource.xml2
-rw-r--r--doc/classes/Timer.xml3
-rw-r--r--doc/classes/Tree.xml3
-rw-r--r--doc/classes/TreeItem.xml26
-rw-r--r--doc/classes/TubeTrailMesh.xml11
-rw-r--r--doc/classes/VSlider.xml3
-rw-r--r--doc/classes/VideoStreamPlayback.xml10
-rw-r--r--doc/classes/Viewport.xml5
-rw-r--r--doc/classes/VisualInstance3D.xml2
-rw-r--r--doc/classes/VoxelGI.xml2
-rw-r--r--doc/classes/Window.xml15
-rw-r--r--doc/classes/X509Certificate.xml2
-rwxr-xr-xdoc/tools/make_rst.py49
-rw-r--r--drivers/alsa/audio_driver_alsa.cpp7
-rw-r--r--drivers/alsamidi/midi_driver_alsamidi.cpp4
-rw-r--r--drivers/coreaudio/audio_driver_coreaudio.cpp4
-rw-r--r--drivers/gles3/rasterizer_gles3.cpp7
-rw-r--r--drivers/gles3/shaders/scene.glsl2
-rw-r--r--drivers/gles3/storage/material_storage.cpp3
-rw-r--r--drivers/pulseaudio/audio_driver_pulseaudio.cpp6
-rw-r--r--drivers/vulkan/rendering_device_vulkan.cpp162
-rw-r--r--drivers/vulkan/rendering_device_vulkan.h3
-rw-r--r--drivers/wasapi/audio_driver_wasapi.cpp6
-rw-r--r--drivers/windows/dir_access_windows.cpp15
-rw-r--r--drivers/windows/dir_access_windows.h3
-rw-r--r--drivers/windows/file_access_windows.cpp8
-rw-r--r--drivers/windows/file_access_windows.h1
-rw-r--r--drivers/xaudio2/audio_driver_xaudio2.cpp7
-rw-r--r--editor/animation_track_editor.cpp10
-rw-r--r--editor/code_editor.cpp112
-rw-r--r--editor/code_editor.h3
-rw-r--r--editor/debugger/debug_adapter/debug_adapter_parser.cpp17
-rw-r--r--editor/debugger/debug_adapter/debug_adapter_protocol.cpp6
-rw-r--r--editor/debugger/editor_debugger_node.cpp16
-rw-r--r--editor/directory_create_dialog.cpp172
-rw-r--r--editor/directory_create_dialog.h68
-rw-r--r--editor/doc_tools.cpp10
-rw-r--r--editor/editor_command_palette.cpp10
-rw-r--r--editor/editor_data.cpp12
-rw-r--r--editor/editor_data.h3
-rw-r--r--editor/editor_file_system.cpp4
-rw-r--r--editor/editor_help.cpp163
-rw-r--r--editor/editor_help.h4
-rw-r--r--editor/editor_inspector.cpp34
-rw-r--r--editor/editor_inspector.h4
-rw-r--r--editor/editor_interface.cpp17
-rw-r--r--editor/editor_node.cpp518
-rw-r--r--editor/editor_node.h59
-rw-r--r--editor/editor_plugin.cpp4
-rw-r--r--editor/editor_plugin_settings.cpp1
-rw-r--r--editor/editor_properties_array_dict.cpp13
-rw-r--r--editor/editor_run.cpp2
-rw-r--r--editor/editor_run.h1
-rw-r--r--editor/editor_run_native.cpp7
-rw-r--r--editor/editor_run_native.h6
-rw-r--r--editor/editor_script.cpp (renamed from editor/editor_run_script.cpp)33
-rw-r--r--editor/editor_script.h (renamed from editor/editor_run_script.h)21
-rw-r--r--editor/editor_sectioned_inspector.cpp11
-rw-r--r--editor/editor_sectioned_inspector.h3
-rw-r--r--editor/editor_settings.cpp4
-rw-r--r--editor/editor_settings.h3
-rw-r--r--editor/editor_themes.cpp44
-rw-r--r--editor/export/editor_export_platform.cpp1
-rw-r--r--editor/export/export_template_manager.cpp2
-rw-r--r--editor/export/project_export.cpp13
-rw-r--r--editor/filesystem_dock.cpp64
-rw-r--r--editor/filesystem_dock.h5
-rw-r--r--editor/gui/editor_file_dialog.cpp5
-rw-r--r--editor/gui/editor_run_bar.cpp444
-rw-r--r--editor/gui/editor_run_bar.h115
-rw-r--r--editor/gui/editor_spin_slider.cpp9
-rw-r--r--editor/gui/editor_spin_slider.h1
-rw-r--r--editor/icons/SnapDisable.svg1
-rw-r--r--editor/import/dynamic_font_import_settings.cpp12
-rw-r--r--editor/import/post_import_plugin_skeleton_rest_fixer.cpp2
-rw-r--r--editor/import/resource_importer_scene.cpp32
-rw-r--r--editor/import/scene_import_settings.cpp5
-rw-r--r--editor/import_defaults_editor.cpp6
-rw-r--r--editor/import_dock.cpp2
-rw-r--r--editor/inspector_dock.cpp3
-rw-r--r--editor/plugins/animation_player_editor_plugin.cpp6
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp5
-rw-r--r--editor/plugins/collision_shape_2d_editor_plugin.cpp136
-rw-r--r--editor/plugins/collision_shape_2d_editor_plugin.h12
-rw-r--r--editor/plugins/curve_editor_plugin.cpp23
-rw-r--r--editor/plugins/curve_editor_plugin.h3
-rw-r--r--editor/plugins/material_editor_plugin.cpp13
-rw-r--r--editor/plugins/material_editor_plugin.h2
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp13
-rw-r--r--editor/plugins/script_editor_plugin.cpp44
-rw-r--r--editor/plugins/script_editor_plugin.h7
-rw-r--r--editor/plugins/script_text_editor.cpp45
-rw-r--r--editor/plugins/script_text_editor.h3
-rw-r--r--editor/plugins/shader_editor_plugin.cpp28
-rw-r--r--editor/plugins/shader_editor_plugin.h4
-rw-r--r--editor/plugins/text_editor.cpp14
-rw-r--r--editor/plugins/text_editor.h3
-rw-r--r--editor/plugins/tiles/tile_data_editors.cpp83
-rw-r--r--editor/plugins/tiles/tile_data_editors.h18
-rw-r--r--editor/plugins/tiles/tile_map_editor.cpp14
-rw-r--r--editor/plugins/tiles/tile_set_atlas_source_editor.cpp11
-rw-r--r--editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp11
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp151
-rw-r--r--editor/plugins/visual_shader_editor_plugin.h4
-rw-r--r--editor/project_manager.cpp3
-rw-r--r--editor/project_settings_editor.cpp1
-rw-r--r--editor/register_editor_types.cpp8
-rw-r--r--editor/scene_tree_dock.cpp122
-rw-r--r--editor/scene_tree_dock.h5
-rw-r--r--editor/script_create_dialog.cpp6
-rw-r--r--main/main.cpp34
-rw-r--r--main/main.h2
-rwxr-xr-xmisc/hooks/pre-commit-make-rst2
-rwxr-xr-xmisc/scripts/codespell.sh2
-rw-r--r--modules/csg/csg.cpp107
-rw-r--r--modules/csg/csg.h13
-rw-r--r--modules/csg/csg_shape.cpp2
-rw-r--r--modules/csg/doc_classes/CSGShape3D.xml10
-rw-r--r--modules/enet/doc_classes/ENetConnection.xml10
-rw-r--r--modules/enet/doc_classes/ENetMultiplayerPeer.xml12
-rw-r--r--modules/enet/doc_classes/ENetPacketPeer.xml10
-rw-r--r--modules/etcpak/image_compress_etcpak.cpp2
-rw-r--r--modules/freetype/SCsub18
-rw-r--r--modules/freetype/config.py8
-rw-r--r--modules/gdscript/doc_classes/@GDScript.xml14
-rw-r--r--modules/gdscript/editor/gdscript_docgen.cpp271
-rw-r--r--modules/gdscript/editor/gdscript_docgen.h42
-rw-r--r--modules/gdscript/gdscript.cpp304
-rw-r--r--modules/gdscript/gdscript.h24
-rw-r--r--modules/gdscript/gdscript_analyzer.cpp101
-rw-r--r--modules/gdscript/gdscript_analyzer.h1
-rw-r--r--modules/gdscript/gdscript_byte_codegen.cpp119
-rw-r--r--modules/gdscript/gdscript_byte_codegen.h4
-rw-r--r--modules/gdscript/gdscript_cache.cpp10
-rw-r--r--modules/gdscript/gdscript_cache.h3
-rw-r--r--modules/gdscript/gdscript_codegen.h2
-rw-r--r--modules/gdscript/gdscript_compiler.cpp315
-rw-r--r--modules/gdscript/gdscript_compiler.h3
-rw-r--r--modules/gdscript/gdscript_disassembler.cpp4
-rw-r--r--modules/gdscript/gdscript_editor.cpp23
-rw-r--r--modules/gdscript/gdscript_function.h3
-rw-r--r--modules/gdscript/gdscript_parser.cpp103
-rw-r--r--modules/gdscript/gdscript_parser.h23
-rw-r--r--modules/gdscript/gdscript_vm.cpp21
-rw-r--r--modules/gdscript/gdscript_warning.cpp215
-rw-r--r--modules/gdscript/gdscript_warning.h56
-rw-r--r--modules/gdscript/tests/gdscript_test_runner.cpp26
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/static_constructor_with_return_type.gd5
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/static_constructor_with_return_type.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/static_var_init_non_static_call.gd9
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/static_var_init_non_static_call.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/allow_void_function_to_return_void.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/assert_literal_false.gd6
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/assert_literal_false.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/auto_inferred_type_dont_error.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/warnings/lambda_unused_arg.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/warnings/overriding_native_method.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/warnings/shadowning.out8
-rw-r--r--modules/gdscript/tests/scripts/parser/errors/static_constructor_not_static.gd5
-rw-r--r--modules/gdscript/tests/scripts/parser/errors/static_constructor_not_static.out2
-rw-r--r--modules/gdscript/tests/scripts/parser/errors/static_constructor_returning_something.gd6
-rw-r--r--modules/gdscript/tests/scripts/parser/errors/static_constructor_returning_something.out2
-rw-r--r--modules/gdscript/tests/scripts/parser/features/constants.out16
-rw-r--r--modules/gdscript/tests/scripts/parser/features/match_bind_unused.out2
-rw-r--r--modules/gdscript/tests/scripts/parser/features/static_typing.out10
-rw-r--r--modules/gdscript/tests/scripts/parser/warnings/return_value_discarded.out2
-rw-r--r--modules/gdscript/tests/scripts/parser/warnings/shadowed_constant.out2
-rw-r--r--modules/gdscript/tests/scripts/parser/warnings/shadowed_global_identifier.out4
-rw-r--r--modules/gdscript/tests/scripts/parser/warnings/shadowed_variable_class.out2
-rw-r--r--modules/gdscript/tests/scripts/parser/warnings/shadowed_variable_function.out2
-rw-r--r--modules/gdscript/tests/scripts/parser/warnings/static_called_on_instance.out2
-rw-r--r--modules/gdscript/tests/scripts/parser/warnings/unassigned_variable.out2
-rw-r--r--modules/gdscript/tests/scripts/parser/warnings/unassigned_variable_op_assign.out2
-rw-r--r--modules/gdscript/tests/scripts/parser/warnings/unreachable_code_after_return.out2
-rw-r--r--modules/gdscript/tests/scripts/parser/warnings/unused_argument.out2
-rw-r--r--modules/gdscript/tests/scripts/parser/warnings/unused_variable.out2
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/assign_operator.gd31
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/assign_operator.out6
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/getter_with_freed_object.gd15
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/getter_with_freed_object.out2
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/static_constructor.gd13
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/static_constructor.out4
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/static_variables.gd56
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/static_variables.out16
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/static_variables_load.gd10
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/static_variables_load.out2
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/static_variables_other.gd11
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/static_variables_other.out2
-rw-r--r--modules/gltf/config.py2
-rw-r--r--modules/gltf/doc_classes/GLTFCollider.xml65
-rw-r--r--modules/gltf/doc_classes/GLTFPhysicsBody.xml58
-rw-r--r--modules/gltf/editor/editor_scene_exporter_gltf_plugin.cpp1
-rw-r--r--modules/gltf/extensions/SCsub1
-rw-r--r--modules/gltf/extensions/physics/gltf_collider.cpp308
-rw-r--r--modules/gltf/extensions/physics/gltf_collider.h88
-rw-r--r--modules/gltf/extensions/physics/gltf_document_extension_physics.cpp272
-rw-r--r--modules/gltf/extensions/physics/gltf_document_extension_physics.h53
-rw-r--r--modules/gltf/extensions/physics/gltf_physics_body.cpp237
-rw-r--r--modules/gltf/extensions/physics/gltf_physics_body.h75
-rw-r--r--modules/gltf/gltf_document.cpp20
-rw-r--r--modules/gltf/register_types.cpp4
-rw-r--r--modules/gridmap/doc_classes/GridMap.xml10
-rw-r--r--modules/mono/csharp_script.cpp7
-rw-r--r--modules/mono/editor/editor_internal_calls.cpp5
-rw-r--r--modules/multiplayer/doc_classes/MultiplayerSpawner.xml2
-rw-r--r--modules/multiplayer/doc_classes/MultiplayerSynchronizer.xml10
-rw-r--r--modules/multiplayer/doc_classes/SceneMultiplayer.xml4
-rw-r--r--modules/multiplayer/doc_classes/SceneReplicationConfig.xml16
-rw-r--r--modules/noise/config.py1
-rw-r--r--modules/noise/doc_classes/Noise.xml33
-rw-r--r--modules/noise/doc_classes/NoiseTexture3D.xml49
-rw-r--r--modules/noise/fastnoise_lite.cpp2
-rw-r--r--modules/noise/noise.cpp148
-rw-r--r--modules/noise/noise.h196
-rw-r--r--modules/noise/noise_texture_2d.cpp4
-rw-r--r--modules/noise/noise_texture_3d.cpp352
-rw-r--r--modules/noise/noise_texture_3d.h113
-rw-r--r--modules/noise/register_types.cpp2
-rw-r--r--modules/noise/tests/test_noise_texture_3d.h235
-rw-r--r--modules/openxr/action_map/openxr_action_map.cpp4
-rw-r--r--modules/openxr/extensions/openxr_htc_controller_extension.cpp3
-rw-r--r--modules/openxr/extensions/openxr_opengl_extension.cpp2
-rw-r--r--modules/raycast/raycast_occlusion_cull.cpp4
-rw-r--r--modules/upnp/doc_classes/UPNP.xml18
-rw-r--r--modules/webrtc/doc_classes/WebRTCMultiplayerPeer.xml18
-rw-r--r--modules/webrtc/doc_classes/WebRTCPeerConnection.xml16
-rw-r--r--modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml2
-rw-r--r--modules/websocket/doc_classes/WebSocketPeer.xml2
-rw-r--r--modules/webxr/doc_classes/WebXRInterface.xml12
-rw-r--r--platform/android/doc_classes/EditorExportPlatformAndroid.xml2
-rw-r--r--platform/android/export/export_plugin.cpp4
-rw-r--r--platform/android/java_godot_lib_jni.cpp40
-rw-r--r--platform/android/plugin/godot_plugin_jni.cpp3
-rw-r--r--platform/ios/doc_classes/EditorExportPlatformIOS.xml2
-rw-r--r--platform/ios/export/export_plugin.cpp19
-rw-r--r--platform/ios/os_ios.mm10
-rw-r--r--platform/linuxbsd/export/export_plugin.cpp1
-rw-r--r--platform/macos/doc_classes/EditorExportPlatformMacOS.xml2
-rw-r--r--platform/macos/os_macos.h1
-rw-r--r--platform/macos/os_macos.mm21
-rw-r--r--platform/uwp/export/export.cpp1
-rw-r--r--platform/web/audio_driver_web.cpp2
-rw-r--r--platform/web/export/export.cpp1
-rw-r--r--platform/web/export/export_plugin.cpp5
-rw-r--r--platform/windows/export/export_plugin.cpp1
-rw-r--r--platform/windows/os_windows.cpp53
-rw-r--r--platform/windows/os_windows.h1
-rw-r--r--scene/2d/physics_body_2d.cpp4
-rw-r--r--scene/2d/tile_map.cpp8
-rw-r--r--scene/2d/tile_map.h4
-rw-r--r--scene/3d/collision_object_3d.cpp6
-rw-r--r--scene/3d/collision_polygon_3d.cpp6
-rw-r--r--scene/3d/collision_shape_3d.cpp6
-rw-r--r--scene/3d/light_3d.cpp3
-rw-r--r--scene/3d/navigation_region_3d.cpp8
-rw-r--r--scene/3d/physics_body_3d.cpp4
-rw-r--r--scene/animation/animation_node_state_machine.cpp2
-rw-r--r--scene/animation/animation_player.cpp8
-rw-r--r--scene/animation/animation_tree.cpp50
-rw-r--r--scene/gui/button.cpp69
-rw-r--r--scene/gui/button.h5
-rw-r--r--scene/gui/code_edit.cpp112
-rw-r--r--scene/gui/code_edit.h2
-rw-r--r--scene/gui/color_picker.cpp37
-rw-r--r--scene/gui/color_picker.h2
-rw-r--r--scene/gui/control.cpp13
-rw-r--r--scene/gui/graph_edit.cpp17
-rw-r--r--scene/gui/graph_edit.h4
-rw-r--r--scene/gui/graph_node.cpp13
-rw-r--r--scene/gui/graph_node.h2
-rw-r--r--scene/gui/item_list.cpp14
-rw-r--r--scene/gui/item_list.h4
-rw-r--r--scene/gui/scroll_container.cpp24
-rw-r--r--scene/gui/scroll_container.h6
-rw-r--r--scene/gui/slider.cpp31
-rw-r--r--scene/gui/slider.h3
-rw-r--r--scene/gui/tab_container.cpp8
-rw-r--r--scene/gui/text_edit.cpp31
-rw-r--r--scene/gui/tree.cpp162
-rw-r--r--scene/gui/tree.h29
-rw-r--r--scene/main/canvas_item.cpp9
-rw-r--r--scene/main/http_request.cpp4
-rw-r--r--scene/main/node.cpp16
-rw-r--r--scene/main/viewport.cpp4
-rw-r--r--scene/main/window.cpp4
-rw-r--r--scene/resources/animation.cpp57
-rw-r--r--scene/resources/animation.h12
-rw-r--r--scene/resources/default_theme/default_theme.cpp3
-rw-r--r--scene/resources/material.cpp29
-rw-r--r--scene/resources/packed_scene.cpp19
-rw-r--r--scene/resources/resource_format_text.cpp14
-rw-r--r--scene/resources/surface_tool.cpp18
-rw-r--r--scene/resources/texture.cpp3
-rw-r--r--scene/resources/visual_shader.cpp30
-rw-r--r--scene/resources/visual_shader.h6
-rw-r--r--servers/audio/audio_driver_dummy.cpp6
-rw-r--r--servers/audio/effects/audio_effect_record.cpp4
-rw-r--r--servers/audio_server.cpp14
-rw-r--r--servers/audio_server.h5
-rw-r--r--servers/physics_2d/godot_shape_2d.cpp11
-rw-r--r--servers/physics_2d/godot_shape_2d.h9
-rw-r--r--servers/physics_3d/godot_shape_3d.cpp28
-rw-r--r--servers/rendering/renderer_canvas_cull.cpp24
-rw-r--r--servers/rendering/renderer_rd/environment/fog.cpp63
-rw-r--r--servers/rendering/renderer_rd/environment/fog.h14
-rw-r--r--servers/rendering/renderer_rd/environment/gi.cpp16
-rw-r--r--servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp3
-rw-r--r--servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp3
-rw-r--r--servers/rendering/renderer_rd/shaders/effects/cubemap_downsampler_raster.glsl204
-rw-r--r--servers/rendering/renderer_rd/shaders/environment/gi.glsl8
-rw-r--r--servers/rendering/renderer_rd/storage_rd/light_storage.h10
-rw-r--r--servers/rendering/renderer_viewport.cpp7
-rw-r--r--servers/rendering/renderer_viewport.h1
-rw-r--r--servers/rendering/rendering_device.cpp1
-rw-r--r--servers/rendering/rendering_device.h1
-rw-r--r--servers/rendering/rendering_server_default.cpp4
-rw-r--r--servers/rendering/rendering_server_default.h1
-rw-r--r--servers/rendering/shader_compiler.cpp7
-rw-r--r--servers/rendering/shader_preprocessor.cpp16
-rw-r--r--servers/rendering/shader_preprocessor.h4
-rw-r--r--servers/rendering/shader_types.cpp1
-rw-r--r--servers/rendering_server.cpp2
-rw-r--r--servers/rendering_server.h1
-rw-r--r--tests/core/object/test_object.h42
-rw-r--r--tests/core/string/test_string.h6
-rw-r--r--tests/scene/test_animation.h88
-rw-r--r--tests/scene/test_code_edit.h137
484 files changed, 9360 insertions, 3523 deletions
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
index 0b4abac1af..1050f259a0 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.yml
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -5,9 +5,10 @@ body:
- type: markdown
attributes:
value: |
- - Read our [CONTRIBUTING.md guide](https://github.com/godotengine/godot/blob/master/CONTRIBUTING.md#reporting-bugs) on reporting bugs.
+ - When reporting bugs, you'll make our life simpler (and the fix will come sooner) if you follow the guidelines in this template.
- Write a descriptive issue title above.
- - Search [open](https://github.com/godotengine/godot/issues) and [closed](https://github.com/godotengine/godot/issues?q=is%3Aissue+is%3Aclosed) issues to ensure it has not already been reported.
+ - The golden rule is to **always open *one* issue for *one* bug**. If you notice several bugs and want to report them, make sure to create one new issue for each of them.
+ - Search [open](https://github.com/godotengine/godot/issues) and [closed](https://github.com/godotengine/godot/issues?q=is%3Aissue+is%3Aclosed) issues to ensure it has not already been reported. If you don't find a relevant match or if you're unsure, don't hesitate to **open a new issue**. The bugsquad will handle it from there if it's a duplicate.
- Verify that you are using a [supported Godot version](https://docs.godotengine.org/en/stable/about/release_policy.html).
- type: input
@@ -24,9 +25,11 @@ body:
attributes:
label: System information
description: |
- Specify the OS version, and when relevant hardware information.
- For graphics-related issues, specify the GPU model, driver version, and the rendering backend (GLES2, GLES3, Vulkan).
- placeholder: Windows 10, GLES3, Intel HD Graphics 620 (27.20.100.9616)
+ - Specify the OS version, and when relevant hardware information.
+ - For issues that are likely OS-specific and/or graphics-related, please specify the CPU model and architecture.
+ - For graphics-related issues, specify the GPU model, driver version, and the rendering backend (GLES2, GLES3, Vulkan).
+ - **Bug reports not including the required information may be closed at the maintainers' discretion.** If in doubt, always include all the requested information; it's better to include too much information than not enough information.
+ placeholder: Windows 10, Intel Core i5-7200U, GLES3, Intel HD Graphics 620 (27.20.100.9616)
validations:
required: true
@@ -52,8 +55,10 @@ body:
attributes:
label: Minimal reproduction project
description: |
- A small Godot project which reproduces the issue, with no unnecessary files included. Be sure to not include the `.godot` folder in the archive (but keep `project.godot`).
- Required, unless the reproduction steps are trivial and don't require any project files to be followed. In this case, write "N/A" in the field.
- Drag and drop a ZIP archive to upload it. **Do not select another field until the project is done uploading.**
+ - A small Godot project which reproduces the issue, with no unnecessary files included. Be sure to not include the `.godot` folder in the archive (but keep `project.godot`).
+ - Required, unless the reproduction steps are trivial and don't require any project files to be followed. In this case, write "N/A" in the field.
+ - Drag and drop a ZIP archive to upload it. **Do not select another field until the project is done uploading.**
+ - **Note for C# users:** If your issue is *not* Mono-specific, please upload a minimal reproduction project written in GDScript or VisualScript. This will make it easier for contributors to reproduce the issue locally as not everyone has a Mono setup available.
+ - **If you've been asked by a maintainer to upload a minimal reproduction project, you *must* do so within 7 days.** Otherwise, your bug report will be closed as it'll be considered too difficult to diagnose.
validations:
required: true
diff --git a/.github/workflows/static_checks.yml b/.github/workflows/static_checks.yml
index 0618bee36b..11a9da04b1 100644
--- a/.github/workflows/static_checks.yml
+++ b/.github/workflows/static_checks.yml
@@ -36,6 +36,8 @@ jobs:
fi
echo "$files" >> changed.txt
cat changed.txt
+ files=$(echo "$files" | tr '\n' ' ')
+ echo "CHANGED_FILES=$files" >> $GITHUB_ENV
- name: File formatting checks (file_format.sh)
run: |
@@ -82,7 +84,7 @@ jobs:
- name: Documentation checks
run: |
- doc/tools/make_rst.py --dry-run --color doc/classes modules platforms
+ doc/tools/make_rst.py --dry-run --color doc/classes modules platform
- name: Style checks via clang-format (clang_format.sh)
run: |
@@ -98,9 +100,10 @@ jobs:
fi
- name: Spell checks via codespell
+ if: github.event_name == 'pull_request'
uses: codespell-project/actions-codespell@v1
with:
skip: ./.*,./**/.*,./bin,./thirdparty,*.desktop,*.gen.*,*.po,*.pot,*.rc,./AUTHORS.md,./COPYRIGHT.txt,./DONORS.md,./core/input/gamecontrollerdb.txt,./core/string/locales.h,./editor/project_converter_3_to_4.cpp,./misc/scripts/codespell.sh,./platform/android/java/lib/src/com,./platform/web/node_modules,./platform/web/package-lock.json
check_hidden: false
- ignore_words_list: curvelinear,doubleclick,expct,findn,gird,hel,inout,lod,nd,numer,ot,te
- only_warn: true
+ ignore_words_list: curvelinear,doubleclick,expct,findn,gird,hel,inout,lod,nd,numer,ot,te,vai
+ path: ${{ env.CHANGED_FILES }}
diff --git a/.gitignore b/.gitignore
index 17c9a6c95a..060f5696b8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -63,6 +63,10 @@ tests/data/*.translation
# Binutils tmp linker output of the form "stXXXXXX" where "X" is alphanumeric
st[A-Za-z0-9][A-Za-z0-9][A-Za-z0-9][A-Za-z0-9][A-Za-z0-9][A-Za-z0-9]
+# Python development
+.venv
+venv
+
# Python generated
__pycache__/
*.pyc
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 008aa0db3e..9f795394ad 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -912,7 +912,7 @@ See the [release announcement](https://godotengine.org/article/godot-3-4-is-rele
- Fix reloading `tool` scripts in the editor ([GH-52883](https://github.com/godotengine/godot/pull/52883)).
- Fix C# bindings generator for default value types ([GH-49702](https://github.com/godotengine/godot/pull/49702)).
- Ignore paths with invalid chars in `PathWhich` ([GH-50918](https://github.com/godotengine/godot/pull/50918)).
-- Fix `List<T>` marshalling ([GH-53628](https://github.com/godotengine/godot/pull/53628)).
+- Fix `List<T>` marshaling ([GH-53628](https://github.com/godotengine/godot/pull/53628)).
- Fix `hint_string` for enum arrays ([GH-53638](https://github.com/godotengine/godot/pull/53638)).
- Keep order for C# exported members ([GH-54199](https://github.com/godotengine/godot/pull/54199)).
@@ -1276,7 +1276,7 @@ See the [release announcement](https://godotengine.org/article/godot-3-3-has-arr
#### Mono (C#)
- [Fix targeting .NETFramework with .NET 5](https://github.com/godotengine/godot/pull/44135).
-- [Fix System.Collections.Generic.List marshalling](https://github.com/godotengine/godot/pull/45029).
+- [Fix System.Collections.Generic.List marshaling](https://github.com/godotengine/godot/pull/45029).
- [Fix support for Unicode identifiers](https://github.com/godotengine/godot/pull/45310).
- [Fixes to Mono on WebAssembly](https://github.com/godotengine/godot/pull/44374).
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index aea1c8c5ff..30934dcf9b 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -8,87 +8,10 @@
- [Contributing to Godot's translation](#contributing-to-godots-translation)
- [Communicating with developers](#communicating-with-developers)
-**Please read the first section before reporting a bug!**
-
## Reporting bugs
-The golden rule is to **always open *one* issue for *one* bug**. If you notice
-several bugs and want to report them, make sure to create one new issue for
-each of them.
-
-If you're reporting a new bug, you'll make our life simpler (and the
-fix will come sooner) by following these guidelines:
-
-### Search first in the existing database
-
-Issues are often reported several times by various users. It's good practice to
-**search first in the [issue tracker](https://github.com/godotengine/godot/issues)
-before reporting your issue**. If you don't find a relevant match or if you're
-unsure, don't hesitate to **open a new issue**. The bugsquad will handle it
-from there if it's a duplicate.
-
-### Specify the platform
-
-Godot runs on a large variety of platforms and operating systems and devices.
-**In your bug reports, please always specify:**
-
-- Operating system and version (e.g. Windows 10, macOS 10.15, Ubuntu 19.10)
-- Godot version (e.g. 3.2, 3.1.2, or the Git commit hash if you're using a development branch)
-
-For bugs that are likely OS-specific and/or graphics-related, please also specify:
-
-- Device (CPU model including architecture, e.g. x86_64, arm64, etc.)
-- GPU model (and the driver version in use if you know it)
-
-**Bug reports not including the required information may be closed at the
-maintainers' discretion.** If in doubt, always include all the requested
-information; it's better to include too much information than not enough
-information.
-
-### Specify steps to reproduce
-
-Many bugs can't be reproduced unless specific steps are taken. Please **specify
-the exact steps** that must be taken to reproduce the condition, and try to
-keep them as minimal as possible. If you're describing a procedure to follow
-in the editor, don't hesitate to include screenshots.
-
-Making your bug report easy to reproduce will make it easier for contributors
-to fix the bug.
-
-### Provide a simple example project
-
-Sometimes, unexpected behavior can happen in your project. In such case,
-understand that:
-
-- What happens to you may not happen to other users.
-- We can't take the time to look at your project, understand how it is set up
- and then figure out why it's failing.
-- On the contributors' end, recreating a test project from scratch takes valuable
- time that can be saved by uploading a *minimal* project.
-
-To speed up our work, **please upload a minimal project** that isolates
-and reproduces the issue. This is always the **best way for us to fix it**.
-We recommend attaching a ZIP file with the minimal project directly to the bug report,
-by drag and dropping the file in the GitHub edition field. This ensures the file
-can remain available for a long period of time. Only use third-party file hosts
-if your ZIP file isn't accepted by GitHub because it's too large.
-
-We recommend always attaching a minimal reproduction project, even if the issue
-may seem simple to reproduce manually.
-
-**Note for C# users:** If your issue is *not* .NET-specific, please upload a
-minimal reproduction project written in GDScript.
-This will make it easier for contributors to reproduce the issue
-locally as not everyone has a .NET setup available.
-
-**If you've been asked by a maintainer to upload a minimal reproduction project,
-you *must* do so within 7 days.** Otherwise, your bug report will be closed as
-it'll be considered too difficult to diagnose.
-
-Now that you've read the guidelines, click the link below to create a
-bug report:
-
-- **[Report a bug](https://github.com/godotengine/godot/issues/new?assignees=&labels=&template=bug_report.yml)**
+Report bugs [here](https://github.com/godotengine/godot/issues/new?assignees=&labels=&template=bug_report.yml).
+Please follow the instructions in the template when you do.
## Proposing features or improvements
diff --git a/SConstruct b/SConstruct
index 518dcaa05d..e5421b7887 100644
--- a/SConstruct
+++ b/SConstruct
@@ -191,6 +191,7 @@ opts.Add(BoolVariable("production", "Set defaults to build Godot for use in prod
opts.Add(BoolVariable("deprecated", "Enable compatibility code for deprecated and removed features", True))
opts.Add(EnumVariable("precision", "Set the floating-point precision level", "single", ("single", "double")))
opts.Add(BoolVariable("minizip", "Enable ZIP archive support using minizip", True))
+opts.Add(BoolVariable("brotli", "Enable Brotli for decompresson and WOFF2 fonts support", True))
opts.Add(BoolVariable("xaudio2", "Enable the XAudio2 audio driver", False))
opts.Add(BoolVariable("vulkan", "Enable the vulkan rendering driver", True))
opts.Add(BoolVariable("opengl3", "Enable the OpenGL/GLES3 rendering driver", True))
@@ -830,6 +831,15 @@ if selected_platform in platform_list:
env.module_list = modules_enabled
methods.sort_module_list(env)
+ if env.editor_build:
+ # Add editor-specific dependencies to the dependency graph.
+ env.module_add_dependencies("editor", ["freetype", "svg"])
+
+ # And check if they are met.
+ if not env.module_check_dependencies("editor"):
+ print("Not all modules required by editor builds are enabled.")
+ Exit(255)
+
methods.generate_version_header(env.module_version_string)
env["PROGSUFFIX_WRAP"] = suffix + env.module_version_string + ".console" + env["PROGSUFFIX"]
@@ -850,7 +860,7 @@ if selected_platform in platform_list:
if env["disable_3d"]:
if env.editor_build:
- print("Build option 'disable_3d=yes' cannot be used for editor builds, but only for export templates.")
+ print("Build option 'disable_3d=yes' cannot be used for editor builds, only for export template builds.")
Exit(255)
else:
env.Append(CPPDEFINES=["_3D_DISABLED"])
@@ -858,13 +868,15 @@ if selected_platform in platform_list:
if env.editor_build:
print(
"Build option 'disable_advanced_gui=yes' cannot be used for editor builds, "
- "but only for export templates."
+ "only for export template builds."
)
Exit(255)
else:
env.Append(CPPDEFINES=["ADVANCED_GUI_DISABLED"])
if env["minizip"]:
env.Append(CPPDEFINES=["MINIZIP_ENABLED"])
+ if env["brotli"]:
+ env.Append(CPPDEFINES=["BROTLI_ENABLED"])
if not env["verbose"]:
methods.no_verbose(sys, env)
diff --git a/core/SCsub b/core/SCsub
index 43deff3ad5..a0176f6c33 100644
--- a/core/SCsub
+++ b/core/SCsub
@@ -64,6 +64,31 @@ thirdparty_misc_sources = [
thirdparty_misc_sources = [thirdparty_misc_dir + file for file in thirdparty_misc_sources]
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_misc_sources)
+# Brotli
+if env["brotli"]:
+ thirdparty_brotli_dir = "#thirdparty/brotli/"
+ thirdparty_brotli_sources = [
+ "common/constants.c",
+ "common/context.c",
+ "common/dictionary.c",
+ "common/platform.c",
+ "common/shared_dictionary.c",
+ "common/transform.c",
+ "dec/bit_reader.c",
+ "dec/decode.c",
+ "dec/huffman.c",
+ "dec/state.c",
+ ]
+ thirdparty_brotli_sources = [thirdparty_brotli_dir + file for file in thirdparty_brotli_sources]
+
+ env_thirdparty.Prepend(CPPPATH=[thirdparty_brotli_dir + "include"])
+ env.Prepend(CPPPATH=[thirdparty_brotli_dir + "include"])
+
+ if env.get("use_ubsan") or env.get("use_asan") or env.get("use_tsan") or env.get("use_lsan") or env.get("use_msan"):
+ env_thirdparty.Append(CPPDEFINES=["BROTLI_BUILD_PORTABLE"])
+
+ env_thirdparty.add_source_files(thirdparty_obj, thirdparty_brotli_sources)
+
# Zlib library, can be unbundled
if env["builtin_zlib"]:
thirdparty_zlib_dir = "#thirdparty/zlib/"
diff --git a/core/core_bind.cpp b/core/core_bind.cpp
index 552bd23358..8fa7aad0ac 100644
--- a/core/core_bind.cpp
+++ b/core/core_bind.cpp
@@ -257,6 +257,15 @@ Error OS::shell_open(String p_uri) {
return ::OS::get_singleton()->shell_open(p_uri);
}
+Error OS::shell_show_in_file_manager(String p_path, bool p_open_folder) {
+ if (p_path.begins_with("res://")) {
+ WARN_PRINT("Attempting to explore file path with the \"res://\" protocol. Use `ProjectSettings.globalize_path()` to convert a Godot-specific path to a system path before opening it with `OS.shell_show_in_file_manager()`.");
+ } else if (p_path.begins_with("user://")) {
+ WARN_PRINT("Attempting to explore file path with the \"user://\" protocol. Use `ProjectSettings.globalize_path()` to convert a Godot-specific path to a system path before opening it with `OS.shell_show_in_file_manager()`.");
+ }
+ return ::OS::get_singleton()->shell_show_in_file_manager(p_path, p_open_folder);
+}
+
String OS::read_string_from_stdin() {
return ::OS::get_singleton()->get_stdin_string();
}
@@ -414,7 +423,14 @@ Error OS::set_thread_name(const String &p_name) {
};
bool OS::has_feature(const String &p_feature) const {
- return ::OS::get_singleton()->has_feature(p_feature);
+ const bool *value_ptr = feature_cache.getptr(p_feature);
+ if (value_ptr) {
+ return *value_ptr;
+ } else {
+ const bool has = ::OS::get_singleton()->has_feature(p_feature);
+ feature_cache[p_feature] = has;
+ return has;
+ }
}
uint64_t OS::get_static_memory_usage() const {
@@ -553,6 +569,7 @@ void OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("create_instance", "arguments"), &OS::create_instance);
ClassDB::bind_method(D_METHOD("kill", "pid"), &OS::kill);
ClassDB::bind_method(D_METHOD("shell_open", "uri"), &OS::shell_open);
+ ClassDB::bind_method(D_METHOD("shell_show_in_file_manager", "file_or_dir_path", "open_folder"), &OS::shell_show_in_file_manager, DEFVAL(true));
ClassDB::bind_method(D_METHOD("is_process_running", "pid"), &OS::is_process_running);
ClassDB::bind_method(D_METHOD("get_process_id"), &OS::get_process_id);
diff --git a/core/core_bind.h b/core/core_bind.h
index 04642f464c..be43ae2c9d 100644
--- a/core/core_bind.h
+++ b/core/core_bind.h
@@ -119,6 +119,8 @@ public:
class OS : public Object {
GDCLASS(OS, Object);
+ mutable HashMap<String, bool> feature_cache;
+
protected:
static void _bind_methods();
static OS *singleton;
@@ -152,6 +154,7 @@ public:
int create_instance(const Vector<String> &p_arguments);
Error kill(int p_pid);
Error shell_open(String p_uri);
+ Error shell_show_in_file_manager(String p_path, bool p_open_folder = true);
bool is_process_running(int p_pid) const;
int get_process_id() const;
diff --git a/core/debugger/remote_debugger_peer.cpp b/core/debugger/remote_debugger_peer.cpp
index f82600a9a2..81ee09f515 100644
--- a/core/debugger/remote_debugger_peer.cpp
+++ b/core/debugger/remote_debugger_peer.cpp
@@ -66,7 +66,9 @@ int RemoteDebuggerPeerTCP::get_max_message_size() const {
void RemoteDebuggerPeerTCP::close() {
running = false;
- thread.wait_to_finish();
+ if (thread.is_started()) {
+ thread.wait_to_finish();
+ }
tcp_client->disconnect_from_host();
out_buf.clear();
in_buf.clear();
diff --git a/core/doc_data.h b/core/doc_data.h
index d064818cd5..4e0db89984 100644
--- a/core/doc_data.h
+++ b/core/doc_data.h
@@ -315,61 +315,6 @@ public:
}
};
- struct EnumDoc {
- String name = "@unnamed_enum";
- bool is_bitfield = false;
- String description;
- Vector<DocData::ConstantDoc> values;
- static EnumDoc from_dict(const Dictionary &p_dict) {
- EnumDoc doc;
-
- if (p_dict.has("name")) {
- doc.name = p_dict["name"];
- }
-
- if (p_dict.has("is_bitfield")) {
- doc.is_bitfield = p_dict["is_bitfield"];
- }
-
- if (p_dict.has("description")) {
- doc.description = p_dict["description"];
- }
-
- Array values;
- if (p_dict.has("values")) {
- values = p_dict["values"];
- }
- for (int i = 0; i < values.size(); i++) {
- doc.values.push_back(ConstantDoc::from_dict(values[i]));
- }
-
- return doc;
- }
- static Dictionary to_dict(const EnumDoc &p_doc) {
- Dictionary dict;
-
- if (!p_doc.name.is_empty()) {
- dict["name"] = p_doc.name;
- }
-
- dict["is_bitfield"] = p_doc.is_bitfield;
-
- if (!p_doc.description.is_empty()) {
- dict["description"] = p_doc.description;
- }
-
- if (!p_doc.values.is_empty()) {
- Array values;
- for (int i = 0; i < p_doc.values.size(); i++) {
- values.push_back(ConstantDoc::to_dict(p_doc.values[i]));
- }
- dict["values"] = values;
- }
-
- return dict;
- }
- };
-
struct PropertyDoc {
String name;
String type;
diff --git a/core/input/input.cpp b/core/input/input.cpp
index e74523e059..5aef9a9039 100644
--- a/core/input/input.cpp
+++ b/core/input/input.cpp
@@ -35,6 +35,10 @@
#include "core/input/input_map.h"
#include "core/os/os.h"
+#ifdef DEV_ENABLED
+#include "core/os/thread.h"
+#endif
+
static const char *_joy_buttons[(size_t)JoyButton::SDL_MAX] = {
"a",
"b",
@@ -486,6 +490,10 @@ Vector3 Input::get_gyroscope() const {
}
void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_emulated) {
+ // This function does the final delivery of the input event to user land.
+ // Regardless where the event came from originally, this has to happen on the main thread.
+ DEV_ASSERT(Thread::get_caller_id() == Thread::get_main_id());
+
// Notes on mouse-touch emulation:
// - Emulated mouse events are parsed, that is, re-routed to this method, so they make the same effects
// as true mouse events. The only difference is the situation is flagged as emulated so they are not
@@ -537,7 +545,9 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
touch_event->set_position(mb->get_position());
touch_event->set_double_tap(mb->is_double_click());
touch_event->set_device(InputEvent::DEVICE_ID_EMULATION);
+ _THREAD_SAFE_UNLOCK_
event_dispatch_function(touch_event);
+ _THREAD_SAFE_LOCK_
}
}
@@ -563,7 +573,9 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
drag_event->set_velocity(get_last_mouse_velocity());
drag_event->set_device(InputEvent::DEVICE_ID_EMULATION);
+ _THREAD_SAFE_UNLOCK_
event_dispatch_function(drag_event);
+ _THREAD_SAFE_LOCK_
}
}
@@ -664,7 +676,9 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
if (ge.is_valid()) {
if (event_dispatch_function) {
+ _THREAD_SAFE_UNLOCK_
event_dispatch_function(ge);
+ _THREAD_SAFE_LOCK_
}
}
@@ -687,7 +701,9 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
}
if (event_dispatch_function) {
+ _THREAD_SAFE_UNLOCK_
event_dispatch_function(p_event);
+ _THREAD_SAFE_LOCK_
}
}
@@ -937,8 +953,15 @@ void Input::flush_buffered_events() {
_THREAD_SAFE_METHOD_
while (buffered_events.front()) {
- _parse_input_event_impl(buffered_events.front()->get(), false);
+ // The final delivery of the input event involves releasing the lock.
+ // While the lock is released, another thread may lock it and add new events to the back.
+ // Therefore, we get each event and pop it while we still have the lock,
+ // to ensure the list is in a consistent state.
+ List<Ref<InputEvent>>::Element *E = buffered_events.front();
+ Ref<InputEvent> e = E->get();
buffered_events.pop_front();
+
+ _parse_input_event_impl(e, false);
}
}
diff --git a/core/io/compression.cpp b/core/io/compression.cpp
index a6114e4f63..ac4a637597 100644
--- a/core/io/compression.cpp
+++ b/core/io/compression.cpp
@@ -35,11 +35,18 @@
#include "thirdparty/misc/fastlz.h"
+#ifdef BROTLI_ENABLED
+#include "thirdparty/brotli/include/brotli/decode.h"
+#endif
+
#include <zlib.h>
#include <zstd.h>
int Compression::compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size, Mode p_mode) {
switch (p_mode) {
+ case MODE_BROTLI: {
+ ERR_FAIL_V_MSG(-1, "Only brotli decompression is supported.");
+ } break;
case MODE_FASTLZ: {
if (p_src_size < 16) {
uint8_t src[16];
@@ -95,6 +102,9 @@ int Compression::compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size,
int Compression::get_max_compressed_buffer_size(int p_src_size, Mode p_mode) {
switch (p_mode) {
+ case MODE_BROTLI: {
+ ERR_FAIL_V_MSG(-1, "Only brotli decompression is supported.");
+ } break;
case MODE_FASTLZ: {
int ss = p_src_size + p_src_size * 6 / 100;
if (ss < 66) {
@@ -129,6 +139,16 @@ int Compression::get_max_compressed_buffer_size(int p_src_size, Mode p_mode) {
int Compression::decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *p_src, int p_src_size, Mode p_mode) {
switch (p_mode) {
+ case MODE_BROTLI: {
+#ifdef BROTLI_ENABLED
+ size_t ret_size = p_dst_max_size;
+ BrotliDecoderResult res = BrotliDecoderDecompress(p_src_size, p_src, &ret_size, p_dst);
+ ERR_FAIL_COND_V(res != BROTLI_DECODER_RESULT_SUCCESS, -1);
+ return ret_size;
+#else
+ ERR_FAIL_V_MSG(-1, "Godot was compiled without brotli support.");
+#endif
+ } break;
case MODE_FASTLZ: {
int ret_size = 0;
@@ -186,87 +206,147 @@ int Compression::decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *p
This is much slower however than using Compression::decompress because it may result in multiple full copies of the output buffer.
*/
int Compression::decompress_dynamic(Vector<uint8_t> *p_dst_vect, int p_max_dst_size, const uint8_t *p_src, int p_src_size, Mode p_mode) {
- int ret;
uint8_t *dst = nullptr;
int out_mark = 0;
- z_stream strm;
ERR_FAIL_COND_V(p_src_size <= 0, Z_DATA_ERROR);
- // This function only supports GZip and Deflate
- int window_bits = p_mode == MODE_DEFLATE ? 15 : 15 + 16;
- ERR_FAIL_COND_V(p_mode != MODE_DEFLATE && p_mode != MODE_GZIP, Z_ERRNO);
-
- // Initialize the stream
- strm.zalloc = Z_NULL;
- strm.zfree = Z_NULL;
- strm.opaque = Z_NULL;
- strm.avail_in = 0;
- strm.next_in = Z_NULL;
-
- int err = inflateInit2(&strm, window_bits);
- ERR_FAIL_COND_V(err != Z_OK, -1);
-
- // Setup the stream inputs
- strm.next_in = (Bytef *)p_src;
- strm.avail_in = p_src_size;
-
- // Ensure the destination buffer is empty
- p_dst_vect->clear();
-
- // decompress until deflate stream ends or end of file
- do {
- // Add another chunk size to the output buffer
- // This forces a copy of the whole buffer
- p_dst_vect->resize(p_dst_vect->size() + gzip_chunk);
- // Get pointer to the actual output buffer
- dst = p_dst_vect->ptrw();
-
- // Set the stream to the new output stream
- // Since it was copied, we need to reset the stream to the new buffer
- strm.next_out = &(dst[out_mark]);
- strm.avail_out = gzip_chunk;
-
- // run inflate() on input until output buffer is full and needs to be resized
- // or input runs out
+ if (p_mode == MODE_BROTLI) {
+#ifdef BROTLI_ENABLED
+ BrotliDecoderResult ret;
+ BrotliDecoderState *state = BrotliDecoderCreateInstance(nullptr, nullptr, nullptr);
+ ERR_FAIL_COND_V(state == nullptr, Z_DATA_ERROR);
+
+ // Setup the stream inputs.
+ const uint8_t *next_in = p_src;
+ size_t avail_in = p_src_size;
+ uint8_t *next_out = nullptr;
+ size_t avail_out = 0;
+ size_t total_out = 0;
+
+ // Ensure the destination buffer is empty.
+ p_dst_vect->clear();
+
+ // Decompress until stream ends or end of file.
do {
- ret = inflate(&strm, Z_SYNC_FLUSH);
-
- switch (ret) {
- case Z_NEED_DICT:
- ret = Z_DATA_ERROR;
- [[fallthrough]];
- case Z_DATA_ERROR:
- case Z_MEM_ERROR:
- case Z_STREAM_ERROR:
- case Z_BUF_ERROR:
- if (strm.msg) {
- WARN_PRINT(strm.msg);
- }
- (void)inflateEnd(&strm);
- p_dst_vect->clear();
- return ret;
+ // Add another chunk size to the output buffer.
+ // This forces a copy of the whole buffer.
+ p_dst_vect->resize(p_dst_vect->size() + gzip_chunk);
+ // Get pointer to the actual output buffer.
+ dst = p_dst_vect->ptrw();
+
+ // Set the stream to the new output stream.
+ // Since it was copied, we need to reset the stream to the new buffer.
+ next_out = &(dst[out_mark]);
+ avail_out += gzip_chunk;
+
+ ret = BrotliDecoderDecompressStream(state, &avail_in, &next_in, &avail_out, &next_out, &total_out);
+ if (ret == BROTLI_DECODER_RESULT_ERROR) {
+ WARN_PRINT(BrotliDecoderErrorString(BrotliDecoderGetErrorCode(state)));
+ BrotliDecoderDestroyInstance(state);
+ p_dst_vect->clear();
+ return Z_DATA_ERROR;
}
- } while (strm.avail_out > 0 && strm.avail_in > 0);
- out_mark += gzip_chunk;
+ out_mark += gzip_chunk - avail_out;
- // Enforce max output size
- if (p_max_dst_size > -1 && strm.total_out > (uint64_t)p_max_dst_size) {
- (void)inflateEnd(&strm);
- p_dst_vect->clear();
- return Z_BUF_ERROR;
+ // Enforce max output size.
+ if (p_max_dst_size > -1 && total_out > (uint64_t)p_max_dst_size) {
+ BrotliDecoderDestroyInstance(state);
+ p_dst_vect->clear();
+ return Z_BUF_ERROR;
+ }
+ } while (ret != BROTLI_DECODER_RESULT_SUCCESS);
+
+ // If all done successfully, resize the output if it's larger than the actual output.
+ if ((unsigned long)p_dst_vect->size() > total_out) {
+ p_dst_vect->resize(total_out);
}
- } while (ret != Z_STREAM_END);
- // If all done successfully, resize the output if it's larger than the actual output
- if ((unsigned long)p_dst_vect->size() > strm.total_out) {
- p_dst_vect->resize(strm.total_out);
- }
+ // Clean up and return.
+ BrotliDecoderDestroyInstance(state);
+ return Z_OK;
+#else
+ ERR_FAIL_V_MSG(Z_ERRNO, "Godot was compiled without brotli support.");
+#endif
+ } else {
+ // This function only supports GZip and Deflate.
+ ERR_FAIL_COND_V(p_mode != MODE_DEFLATE && p_mode != MODE_GZIP, Z_ERRNO);
+
+ int ret;
+ z_stream strm;
+ int window_bits = p_mode == MODE_DEFLATE ? 15 : 15 + 16;
+
+ // Initialize the stream.
+ strm.zalloc = Z_NULL;
+ strm.zfree = Z_NULL;
+ strm.opaque = Z_NULL;
+ strm.avail_in = 0;
+ strm.next_in = Z_NULL;
+
+ int err = inflateInit2(&strm, window_bits);
+ ERR_FAIL_COND_V(err != Z_OK, -1);
+
+ // Setup the stream inputs.
+ strm.next_in = (Bytef *)p_src;
+ strm.avail_in = p_src_size;
+
+ // Ensure the destination buffer is empty.
+ p_dst_vect->clear();
+
+ // Decompress until deflate stream ends or end of file.
+ do {
+ // Add another chunk size to the output buffer.
+ // This forces a copy of the whole buffer.
+ p_dst_vect->resize(p_dst_vect->size() + gzip_chunk);
+ // Get pointer to the actual output buffer.
+ dst = p_dst_vect->ptrw();
+
+ // Set the stream to the new output stream.
+ // Since it was copied, we need to reset the stream to the new buffer.
+ strm.next_out = &(dst[out_mark]);
+ strm.avail_out = gzip_chunk;
+
+ // Run inflate() on input until output buffer is full and needs to be resized or input runs out.
+ do {
+ ret = inflate(&strm, Z_SYNC_FLUSH);
+
+ switch (ret) {
+ case Z_NEED_DICT:
+ ret = Z_DATA_ERROR;
+ [[fallthrough]];
+ case Z_DATA_ERROR:
+ case Z_MEM_ERROR:
+ case Z_STREAM_ERROR:
+ case Z_BUF_ERROR:
+ if (strm.msg) {
+ WARN_PRINT(strm.msg);
+ }
+ (void)inflateEnd(&strm);
+ p_dst_vect->clear();
+ return ret;
+ }
+ } while (strm.avail_out > 0 && strm.avail_in > 0);
+
+ out_mark += gzip_chunk;
+
+ // Enforce max output size.
+ if (p_max_dst_size > -1 && strm.total_out > (uint64_t)p_max_dst_size) {
+ (void)inflateEnd(&strm);
+ p_dst_vect->clear();
+ return Z_BUF_ERROR;
+ }
+ } while (ret != Z_STREAM_END);
+
+ // If all done successfully, resize the output if it's larger than the actual output.
+ if ((unsigned long)p_dst_vect->size() > strm.total_out) {
+ p_dst_vect->resize(strm.total_out);
+ }
- // clean up and return
- (void)inflateEnd(&strm);
- return Z_OK;
+ // Clean up and return.
+ (void)inflateEnd(&strm);
+ return Z_OK;
+ }
}
int Compression::zlib_level = Z_DEFAULT_COMPRESSION;
diff --git a/core/io/compression.h b/core/io/compression.h
index 063da6dc7d..a5a2d657da 100644
--- a/core/io/compression.h
+++ b/core/io/compression.h
@@ -47,7 +47,8 @@ public:
MODE_FASTLZ,
MODE_DEFLATE,
MODE_ZSTD,
- MODE_GZIP
+ MODE_GZIP,
+ MODE_BROTLI
};
static int compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size, Mode p_mode = MODE_ZSTD);
diff --git a/core/io/dir_access.h b/core/io/dir_access.h
index 51eb68eaea..52ed688deb 100644
--- a/core/io/dir_access.h
+++ b/core/io/dir_access.h
@@ -68,7 +68,7 @@ protected:
virtual String _get_root_string() const;
AccessType get_access_type() const;
- String fix_path(String p_path) const;
+ virtual String fix_path(String p_path) const;
template <class T>
static Ref<DirAccess> _create_builtin() {
diff --git a/core/io/file_access.cpp b/core/io/file_access.cpp
index 3d10151327..a6a1a224b3 100644
--- a/core/io/file_access.cpp
+++ b/core/io/file_access.cpp
@@ -871,4 +871,5 @@ void FileAccess::_bind_methods() {
BIND_ENUM_CONSTANT(COMPRESSION_DEFLATE);
BIND_ENUM_CONSTANT(COMPRESSION_ZSTD);
BIND_ENUM_CONSTANT(COMPRESSION_GZIP);
+ BIND_ENUM_CONSTANT(COMPRESSION_BROTLI);
}
diff --git a/core/io/file_access.h b/core/io/file_access.h
index 47770cad87..ad1ac665f3 100644
--- a/core/io/file_access.h
+++ b/core/io/file_access.h
@@ -64,7 +64,8 @@ public:
COMPRESSION_FASTLZ = Compression::MODE_FASTLZ,
COMPRESSION_DEFLATE = Compression::MODE_DEFLATE,
COMPRESSION_ZSTD = Compression::MODE_ZSTD,
- COMPRESSION_GZIP = Compression::MODE_GZIP
+ COMPRESSION_GZIP = Compression::MODE_GZIP,
+ COMPRESSION_BROTLI = Compression::MODE_BROTLI,
};
typedef void (*FileCloseFailNotify)(const String &);
@@ -80,7 +81,7 @@ protected:
static void _bind_methods();
AccessType get_access_type() const;
- String fix_path(const String &p_path) const;
+ virtual String fix_path(const String &p_path) const;
virtual Error open_internal(const String &p_path, int p_mode_flags) = 0; ///< open a file
virtual uint64_t _get_modified_time(const String &p_file) = 0;
virtual void _set_access_type(AccessType p_access);
diff --git a/core/io/file_access_compressed.cpp b/core/io/file_access_compressed.cpp
index da59ae8c59..3e5a1217dd 100644
--- a/core/io/file_access_compressed.cpp
+++ b/core/io/file_access_compressed.cpp
@@ -34,13 +34,7 @@
void FileAccessCompressed::configure(const String &p_magic, Compression::Mode p_mode, uint32_t p_block_size) {
magic = p_magic.ascii().get_data();
- if (magic.length() > 4) {
- magic = magic.substr(0, 4);
- } else {
- while (magic.length() < 4) {
- magic += " ";
- }
- }
+ magic = (magic + " ").substr(0, 4);
cmode = p_mode;
block_size = p_block_size;
diff --git a/core/io/json.cpp b/core/io/json.cpp
index 8d0fe53ed4..a6e054a9fe 100644
--- a/core/io/json.cpp
+++ b/core/io/json.cpp
@@ -47,13 +47,7 @@ const char *JSON::tk_name[TK_MAX] = {
};
String JSON::_make_indent(const String &p_indent, int p_size) {
- String indent_text = "";
- if (!p_indent.is_empty()) {
- for (int i = 0; i < p_size; i++) {
- indent_text += p_indent;
- }
- }
- return indent_text;
+ return p_indent.repeat(p_size);
}
String JSON::_stringify(const Variant &p_var, const String &p_indent, int p_cur_indent, bool p_sort_keys, HashSet<const void *> &p_markers, bool p_full_precision) {
diff --git a/core/io/packed_data_container.cpp b/core/io/packed_data_container.cpp
index 6c16401f17..ce4edb18fe 100644
--- a/core/io/packed_data_container.cpp
+++ b/core/io/packed_data_container.cpp
@@ -320,6 +320,8 @@ uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector<uint8_t> &tmpd
}
Error PackedDataContainer::pack(const Variant &p_data) {
+ ERR_FAIL_COND_V_MSG(p_data.get_type() != Variant::ARRAY && p_data.get_type() != Variant::DICTIONARY, ERR_INVALID_DATA, "PackedDataContainer can pack only Array and Dictionary type.");
+
Vector<uint8_t> tmpdata;
HashMap<String, uint32_t> string_cache;
_pack(p_data, tmpdata, string_cache);
@@ -361,7 +363,9 @@ void PackedDataContainer::_bind_methods() {
ClassDB::bind_method(D_METHOD("pack", "value"), &PackedDataContainer::pack);
ClassDB::bind_method(D_METHOD("size"), &PackedDataContainer::size);
- ADD_PROPERTY(PropertyInfo(Variant::PACKED_BYTE_ARRAY, "__data__"), "_set_data", "_get_data");
+ BIND_METHOD_ERR_RETURN_DOC("pack", ERR_INVALID_DATA);
+
+ ADD_PROPERTY(PropertyInfo(Variant::PACKED_BYTE_ARRAY, "__data__", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL), "_set_data", "_get_data");
}
//////////////////
@@ -378,16 +382,11 @@ Variant PackedDataContainerRef::_iter_get(const Variant &p_iter) {
return from->_iter_get_ofs(p_iter, offset);
}
-bool PackedDataContainerRef::_is_dictionary() const {
- return from->_type_at_ofs(offset) == PackedDataContainer::TYPE_DICT;
-}
-
void PackedDataContainerRef::_bind_methods() {
ClassDB::bind_method(D_METHOD("size"), &PackedDataContainerRef::size);
ClassDB::bind_method(D_METHOD("_iter_init"), &PackedDataContainerRef::_iter_init);
ClassDB::bind_method(D_METHOD("_iter_get"), &PackedDataContainerRef::_iter_get);
ClassDB::bind_method(D_METHOD("_iter_next"), &PackedDataContainerRef::_iter_next);
- ClassDB::bind_method(D_METHOD("_is_dictionary"), &PackedDataContainerRef::_is_dictionary);
}
Variant PackedDataContainerRef::getvar(const Variant &p_key, bool *r_valid) const {
diff --git a/core/io/packed_data_container.h b/core/io/packed_data_container.h
index a77970a0bd..cc9996101e 100644
--- a/core/io/packed_data_container.h
+++ b/core/io/packed_data_container.h
@@ -94,7 +94,6 @@ public:
Variant _iter_init(const Array &p_iter);
Variant _iter_next(const Array &p_iter);
Variant _iter_get(const Variant &p_iter);
- bool _is_dictionary() const;
int size() const;
virtual Variant getvar(const Variant &p_key, bool *r_valid = nullptr) const override;
diff --git a/core/math/a_star_grid_2d.cpp b/core/math/a_star_grid_2d.cpp
index 139dc3afb1..63f7c80bdd 100644
--- a/core/math/a_star_grid_2d.cpp
+++ b/core/math/a_star_grid_2d.cpp
@@ -32,6 +32,8 @@
#include "core/variant/typed_array.h"
+#define GET_POINT_UNCHECKED(m_id) points[m_id.y - region.position.y][m_id.x - region.position.x]
+
static real_t heuristic_euclidian(const Vector2i &p_from, const Vector2i &p_to) {
real_t dx = (real_t)ABS(p_to.x - p_from.x);
real_t dy = (real_t)ABS(p_to.y - p_from.y);
@@ -59,16 +61,29 @@ static real_t heuristic_chebyshev(const Vector2i &p_from, const Vector2i &p_to)
static real_t (*heuristics[AStarGrid2D::HEURISTIC_MAX])(const Vector2i &, const Vector2i &) = { heuristic_euclidian, heuristic_manhattan, heuristic_octile, heuristic_chebyshev };
+void AStarGrid2D::set_region(const Rect2i &p_region) {
+ ERR_FAIL_COND(p_region.size.x < 0 || p_region.size.y < 0);
+ if (p_region != region) {
+ region = p_region;
+ dirty = true;
+ }
+}
+
+Rect2i AStarGrid2D::get_region() const {
+ return region;
+}
+
void AStarGrid2D::set_size(const Size2i &p_size) {
+ WARN_DEPRECATED_MSG(R"(The "size" property is deprecated, use "region" instead.)");
ERR_FAIL_COND(p_size.x < 0 || p_size.y < 0);
- if (p_size != size) {
- size = p_size;
+ if (p_size != region.size) {
+ region.size = p_size;
dirty = true;
}
}
Size2i AStarGrid2D::get_size() const {
- return size;
+ return region.size;
}
void AStarGrid2D::set_offset(const Vector2 &p_offset) {
@@ -95,9 +110,11 @@ Size2 AStarGrid2D::get_cell_size() const {
void AStarGrid2D::update() {
points.clear();
- for (int64_t y = 0; y < size.y; y++) {
+ const int64_t end_x = region.position.x + region.size.width;
+ const int64_t end_y = region.position.y + region.size.height;
+ for (int64_t y = region.position.y; y < end_y; y++) {
LocalVector<Point> line;
- for (int64_t x = 0; x < size.x; x++) {
+ for (int64_t x = region.position.x; x < end_x; x++) {
line.push_back(Point(Vector2i(x, y), offset + Vector2(x, y) * cell_size));
}
points.push_back(line);
@@ -106,11 +123,11 @@ void AStarGrid2D::update() {
}
bool AStarGrid2D::is_in_bounds(int p_x, int p_y) const {
- return p_x >= 0 && p_x < size.width && p_y >= 0 && p_y < size.height;
+ return region.has_point(Vector2i(p_x, p_y));
}
bool AStarGrid2D::is_in_boundsv(const Vector2i &p_id) const {
- return p_id.x >= 0 && p_id.x < size.width && p_id.y >= 0 && p_id.y < size.height;
+ return region.has_point(p_id);
}
bool AStarGrid2D::is_dirty() const {
@@ -154,27 +171,27 @@ AStarGrid2D::Heuristic AStarGrid2D::get_default_estimate_heuristic() const {
void AStarGrid2D::set_point_solid(const Vector2i &p_id, bool p_solid) {
ERR_FAIL_COND_MSG(dirty, "Grid is not initialized. Call the update method.");
- ERR_FAIL_COND_MSG(!is_in_boundsv(p_id), vformat("Can't set if point is disabled. Point out of bounds (%s/%s, %s/%s).", p_id.x, size.width, p_id.y, size.height));
- points[p_id.y][p_id.x].solid = p_solid;
+ ERR_FAIL_COND_MSG(!is_in_boundsv(p_id), vformat("Can't set if point is disabled. Point %s out of bounds %s.", p_id, region));
+ GET_POINT_UNCHECKED(p_id).solid = p_solid;
}
bool AStarGrid2D::is_point_solid(const Vector2i &p_id) const {
ERR_FAIL_COND_V_MSG(dirty, false, "Grid is not initialized. Call the update method.");
- ERR_FAIL_COND_V_MSG(!is_in_boundsv(p_id), false, vformat("Can't get if point is disabled. Point out of bounds (%s/%s, %s/%s).", p_id.x, size.width, p_id.y, size.height));
- return points[p_id.y][p_id.x].solid;
+ ERR_FAIL_COND_V_MSG(!is_in_boundsv(p_id), false, vformat("Can't get if point is disabled. Point %s out of bounds %s.", p_id, region));
+ return GET_POINT_UNCHECKED(p_id).solid;
}
void AStarGrid2D::set_point_weight_scale(const Vector2i &p_id, real_t p_weight_scale) {
ERR_FAIL_COND_MSG(dirty, "Grid is not initialized. Call the update method.");
- ERR_FAIL_COND_MSG(!is_in_boundsv(p_id), vformat("Can't set point's weight scale. Point out of bounds (%s/%s, %s/%s).", p_id.x, size.width, p_id.y, size.height));
+ ERR_FAIL_COND_MSG(!is_in_boundsv(p_id), vformat("Can't set point's weight scale. Point %s out of bounds %s.", p_id, region));
ERR_FAIL_COND_MSG(p_weight_scale < 0.0, vformat("Can't set point's weight scale less than 0.0: %f.", p_weight_scale));
- points[p_id.y][p_id.x].weight_scale = p_weight_scale;
+ GET_POINT_UNCHECKED(p_id).weight_scale = p_weight_scale;
}
real_t AStarGrid2D::get_point_weight_scale(const Vector2i &p_id) const {
ERR_FAIL_COND_V_MSG(dirty, 0, "Grid is not initialized. Call the update method.");
- ERR_FAIL_COND_V_MSG(!is_in_boundsv(p_id), 0, vformat("Can't get point's weight scale. Point out of bounds (%s/%s, %s/%s).", p_id.x, size.width, p_id.y, size.height));
- return points[p_id.y][p_id.x].weight_scale;
+ ERR_FAIL_COND_V_MSG(!is_in_boundsv(p_id), 0, vformat("Can't get point's weight scale. Point %s out of bounds %s.", p_id, region));
+ return GET_POINT_UNCHECKED(p_id).weight_scale;
}
AStarGrid2D::Point *AStarGrid2D::_jump(Point *p_from, Point *p_to) {
@@ -285,15 +302,15 @@ void AStarGrid2D::_get_nbors(Point *p_point, LocalVector<Point *> &r_nbors) {
bool has_left = false;
bool has_right = false;
- if (p_point->id.x - 1 >= 0) {
+ if (p_point->id.x - 1 >= region.position.x) {
left = _get_point_unchecked(p_point->id.x - 1, p_point->id.y);
has_left = true;
}
- if (p_point->id.x + 1 < size.width) {
+ if (p_point->id.x + 1 < region.position.x + region.size.width) {
right = _get_point_unchecked(p_point->id.x + 1, p_point->id.y);
has_right = true;
}
- if (p_point->id.y - 1 >= 0) {
+ if (p_point->id.y - 1 >= region.position.y) {
top = _get_point_unchecked(p_point->id.x, p_point->id.y - 1);
if (has_left) {
top_left = _get_point_unchecked(p_point->id.x - 1, p_point->id.y - 1);
@@ -302,7 +319,7 @@ void AStarGrid2D::_get_nbors(Point *p_point, LocalVector<Point *> &r_nbors) {
top_right = _get_point_unchecked(p_point->id.x + 1, p_point->id.y - 1);
}
}
- if (p_point->id.y + 1 < size.height) {
+ if (p_point->id.y + 1 < region.position.y + region.size.height) {
bottom = _get_point_unchecked(p_point->id.x, p_point->id.y + 1);
if (has_left) {
bottom_left = _get_point_unchecked(p_point->id.x - 1, p_point->id.y + 1);
@@ -461,19 +478,19 @@ real_t AStarGrid2D::_compute_cost(const Vector2i &p_from_id, const Vector2i &p_t
void AStarGrid2D::clear() {
points.clear();
- size = Vector2i();
+ region = Rect2i();
}
Vector2 AStarGrid2D::get_point_position(const Vector2i &p_id) const {
ERR_FAIL_COND_V_MSG(dirty, Vector2(), "Grid is not initialized. Call the update method.");
- ERR_FAIL_COND_V_MSG(!is_in_boundsv(p_id), Vector2(), vformat("Can't get point's position. Point out of bounds (%s/%s, %s/%s).", p_id.x, size.width, p_id.y, size.height));
- return points[p_id.y][p_id.x].pos;
+ ERR_FAIL_COND_V_MSG(!is_in_boundsv(p_id), Vector2(), vformat("Can't get point's position. Point %s out of bounds %s.", p_id, region));
+ return GET_POINT_UNCHECKED(p_id).pos;
}
Vector<Vector2> AStarGrid2D::get_point_path(const Vector2i &p_from_id, const Vector2i &p_to_id) {
ERR_FAIL_COND_V_MSG(dirty, Vector<Vector2>(), "Grid is not initialized. Call the update method.");
- ERR_FAIL_COND_V_MSG(!is_in_boundsv(p_from_id), Vector<Vector2>(), vformat("Can't get id path. Point out of bounds (%s/%s, %s/%s)", p_from_id.x, size.width, p_from_id.y, size.height));
- ERR_FAIL_COND_V_MSG(!is_in_boundsv(p_to_id), Vector<Vector2>(), vformat("Can't get id path. Point out of bounds (%s/%s, %s/%s)", p_to_id.x, size.width, p_to_id.y, size.height));
+ ERR_FAIL_COND_V_MSG(!is_in_boundsv(p_from_id), Vector<Vector2>(), vformat("Can't get id path. Point %s out of bounds %s.", p_from_id, region));
+ ERR_FAIL_COND_V_MSG(!is_in_boundsv(p_to_id), Vector<Vector2>(), vformat("Can't get id path. Point %s out of bounds %s.", p_to_id, region));
Point *a = _get_point(p_from_id.x, p_from_id.y);
Point *b = _get_point(p_to_id.x, p_to_id.y);
@@ -520,8 +537,8 @@ Vector<Vector2> AStarGrid2D::get_point_path(const Vector2i &p_from_id, const Vec
TypedArray<Vector2i> AStarGrid2D::get_id_path(const Vector2i &p_from_id, const Vector2i &p_to_id) {
ERR_FAIL_COND_V_MSG(dirty, TypedArray<Vector2i>(), "Grid is not initialized. Call the update method.");
- ERR_FAIL_COND_V_MSG(!is_in_boundsv(p_from_id), TypedArray<Vector2i>(), vformat("Can't get id path. Point out of bounds (%s/%s, %s/%s)", p_from_id.x, size.width, p_from_id.y, size.height));
- ERR_FAIL_COND_V_MSG(!is_in_boundsv(p_to_id), TypedArray<Vector2i>(), vformat("Can't get id path. Point out of bounds (%s/%s, %s/%s)", p_to_id.x, size.width, p_to_id.y, size.height));
+ ERR_FAIL_COND_V_MSG(!is_in_boundsv(p_from_id), TypedArray<Vector2i>(), vformat("Can't get id path. Point %s out of bounds %s.", p_from_id, region));
+ ERR_FAIL_COND_V_MSG(!is_in_boundsv(p_to_id), TypedArray<Vector2i>(), vformat("Can't get id path. Point %s out of bounds %s.", p_to_id, region));
Point *a = _get_point(p_from_id.x, p_from_id.y);
Point *b = _get_point(p_to_id.x, p_to_id.y);
@@ -565,6 +582,8 @@ TypedArray<Vector2i> AStarGrid2D::get_id_path(const Vector2i &p_from_id, const V
}
void AStarGrid2D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_region", "region"), &AStarGrid2D::set_region);
+ ClassDB::bind_method(D_METHOD("get_region"), &AStarGrid2D::get_region);
ClassDB::bind_method(D_METHOD("set_size", "size"), &AStarGrid2D::set_size);
ClassDB::bind_method(D_METHOD("get_size"), &AStarGrid2D::get_size);
ClassDB::bind_method(D_METHOD("set_offset", "offset"), &AStarGrid2D::set_offset);
@@ -596,6 +615,7 @@ void AStarGrid2D::_bind_methods() {
GDVIRTUAL_BIND(_estimate_cost, "from_id", "to_id")
GDVIRTUAL_BIND(_compute_cost, "from_id", "to_id")
+ ADD_PROPERTY(PropertyInfo(Variant::RECT2I, "region"), "set_region", "get_region");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "size"), "set_size", "get_size");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "offset"), "set_offset", "get_offset");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "cell_size"), "set_cell_size", "get_cell_size");
@@ -617,3 +637,5 @@ void AStarGrid2D::_bind_methods() {
BIND_ENUM_CONSTANT(DIAGONAL_MODE_ONLY_IF_NO_OBSTACLES);
BIND_ENUM_CONSTANT(DIAGONAL_MODE_MAX);
}
+
+#undef GET_POINT_UNCHECKED
diff --git a/core/math/a_star_grid_2d.h b/core/math/a_star_grid_2d.h
index e4e62ec360..50df58e0e9 100644
--- a/core/math/a_star_grid_2d.h
+++ b/core/math/a_star_grid_2d.h
@@ -58,7 +58,7 @@ public:
};
private:
- Size2i size;
+ Rect2i region;
Vector2 offset;
Size2 cell_size = Size2(1, 1);
bool dirty = false;
@@ -107,21 +107,21 @@ private:
private: // Internal routines.
_FORCE_INLINE_ bool _is_walkable(int64_t p_x, int64_t p_y) const {
- if (p_x >= 0 && p_y >= 0 && p_x < size.width && p_y < size.height) {
- return !points[p_y][p_x].solid;
+ if (region.has_point(Vector2i(p_x, p_y))) {
+ return !points[p_y - region.position.y][p_x - region.position.x].solid;
}
return false;
}
_FORCE_INLINE_ Point *_get_point(int64_t p_x, int64_t p_y) {
- if (p_x >= 0 && p_y >= 0 && p_x < size.width && p_y < size.height) {
- return &points[p_y][p_x];
+ if (region.has_point(Vector2i(p_x, p_y))) {
+ return &points[p_y - region.position.y][p_x - region.position.x];
}
return nullptr;
}
_FORCE_INLINE_ Point *_get_point_unchecked(int64_t p_x, int64_t p_y) {
- return &points[p_y][p_x];
+ return &points[p_y - region.position.y][p_x - region.position.x];
}
void _get_nbors(Point *p_point, LocalVector<Point *> &r_nbors);
@@ -138,6 +138,9 @@ protected:
GDVIRTUAL2RC(real_t, _compute_cost, Vector2i, Vector2i)
public:
+ void set_region(const Rect2i &p_region);
+ Rect2i get_region() const;
+
void set_size(const Size2i &p_size);
Size2i get_size() const;
diff --git a/core/math/bvh_debug.inc b/core/math/bvh_debug.inc
index 2e519ceb3d..1964f2fa83 100644
--- a/core/math/bvh_debug.inc
+++ b/core/math/bvh_debug.inc
@@ -30,11 +30,7 @@ String _debug_aabb_to_string(const BVHABB_CLASS &aabb) const {
void _debug_recursive_print_tree_node(uint32_t p_node_id, int depth = 0) const {
const TNode &tnode = _nodes[p_node_id];
- String sz = "";
- for (int n = 0; n < depth; n++) {
- sz += "\t";
- }
- sz += itos(p_node_id);
+ String sz = String("\t").repeat(depth) + itos(p_node_id);
if (tnode.is_leaf()) {
sz += " L";
diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp
index a602dc9fb8..760f3bfd0c 100644
--- a/core/object/class_db.cpp
+++ b/core/object/class_db.cpp
@@ -53,8 +53,10 @@ MethodDefinition D_METHODP(const char *p_name, const char *const **p_args, uint3
#endif
ClassDB::APIType ClassDB::current_api = API_CORE;
+HashMap<ClassDB::APIType, uint64_t> ClassDB::api_hashes_cache;
void ClassDB::set_current_api(APIType p_api) {
+ DEV_ASSERT(!api_hashes_cache.has(p_api)); // This API type may not be suitable for caching of hash if it can change later.
current_api = p_api;
}
@@ -165,6 +167,10 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
OBJTYPE_RLOCK;
#ifdef DEBUG_METHODS_ENABLED
+ if (api_hashes_cache.has(p_api)) {
+ return api_hashes_cache[p_api];
+ }
+
uint64_t hash = hash_murmur3_one_64(HashMapHasherDefault::hash(VERSION_FULL_CONFIG));
List<StringName> class_list;
@@ -290,7 +296,14 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
}
}
- return hash_fmix32(hash);
+ hash = hash_fmix32(hash);
+
+ // Extension API changes at runtime; let's just not cache them by now.
+ if (p_api != API_EXTENSION && p_api != API_EDITOR_EXTENSION) {
+ api_hashes_cache[p_api] = hash;
+ }
+
+ return hash;
#else
return 0;
#endif
diff --git a/core/object/class_db.h b/core/object/class_db.h
index 0b62cf40f7..1a5e9235cf 100644
--- a/core/object/class_db.h
+++ b/core/object/class_db.h
@@ -154,6 +154,7 @@ public:
#endif
static APIType current_api;
+ static HashMap<APIType, uint64_t> api_hashes_cache;
static void _add_class2(const StringName &p_class, const StringName &p_inherits);
diff --git a/core/object/message_queue.cpp b/core/object/message_queue.cpp
index 83e0c4aea1..cfd8904af6 100644
--- a/core/object/message_queue.cpp
+++ b/core/object/message_queue.cpp
@@ -62,15 +62,16 @@ Error CallQueue::push_set(Object *p_object, const StringName &p_prop, const Vari
}
Error CallQueue::push_callablep(const Callable &p_callable, const Variant **p_args, int p_argcount, bool p_show_error) {
- mutex.lock();
uint32_t room_needed = sizeof(Message) + sizeof(Variant) * p_argcount;
ERR_FAIL_COND_V_MSG(room_needed > uint32_t(PAGE_SIZE_BYTES), ERR_INVALID_PARAMETER, "Message is too large to fit on a page (" + itos(PAGE_SIZE_BYTES) + " bytes), consider passing less arguments.");
+ mutex.lock();
+
_ensure_first_page();
if ((page_offset + room_needed) > uint32_t(PAGE_SIZE_BYTES)) {
- if (room_needed > uint32_t(PAGE_SIZE_BYTES) || pages_used == max_pages) {
+ if (pages_used == max_pages) {
ERR_PRINT("Failed method: " + p_callable + ". Message queue out of memory. " + error_text);
statistics();
mutex.unlock();
diff --git a/core/object/message_queue.h b/core/object/message_queue.h
index 68969dfd39..2349c6d869 100644
--- a/core/object/message_queue.h
+++ b/core/object/message_queue.h
@@ -61,7 +61,7 @@ private:
};
Mutex mutex;
- typedef PagedAllocator<Page, true> Allocator;
+ typedef PagedAllocator<Page, false> Allocator;
Allocator *allocator = nullptr;
bool allocator_is_custom = false;
diff --git a/core/object/object.cpp b/core/object/object.cpp
index 1775937b38..8ec385c0eb 100644
--- a/core/object/object.cpp
+++ b/core/object/object.cpp
@@ -38,6 +38,7 @@
#include "core/os/os.h"
#include "core/string/print_string.h"
#include "core/string/translation.h"
+#include "core/templates/local_vector.h"
#include "core/variant/typed_array.h"
#ifdef DEBUG_ENABLED
@@ -1013,22 +1014,29 @@ Error Object::emit_signalp(const StringName &p_name, const Variant **p_args, int
return ERR_UNAVAILABLE;
}
- List<_ObjectSignalDisconnectData> disconnect_data;
+ // If this is a ref-counted object, prevent it from being destroyed during signal emission,
+ // which is needed in certain edge cases; e.g., https://github.com/godotengine/godot/issues/73889.
+ Ref<RefCounted> rc = Ref<RefCounted>(Object::cast_to<RefCounted>(this));
- //copy on write will ensure that disconnecting the signal or even deleting the object will not affect the signal calling.
- //this happens automatically and will not change the performance of calling.
- //awesome, isn't it?
- VMap<Callable, SignalData::Slot> slot_map = s->slot_map;
+ List<_ObjectSignalDisconnectData> disconnect_data;
- int ssize = slot_map.size();
+ // Ensure that disconnecting the signal or even deleting the object
+ // will not affect the signal calling.
+ LocalVector<Connection> slot_conns;
+ slot_conns.resize(s->slot_map.size());
+ {
+ uint32_t idx = 0;
+ for (const KeyValue<Callable, SignalData::Slot> &slot_kv : s->slot_map) {
+ slot_conns[idx++] = slot_kv.value.conn;
+ }
+ DEV_ASSERT(idx == s->slot_map.size());
+ }
OBJ_DEBUG_LOCK
Error err = OK;
- for (int i = 0; i < ssize; i++) {
- const Connection &c = slot_map.getv(i).conn;
-
+ for (const Connection &c : slot_conns) {
Object *target = c.callable.get_object();
if (!target) {
// Target might have been deleted during signal callback, this is expected and OK.
@@ -1191,8 +1199,8 @@ void Object::get_all_signal_connections(List<Connection> *p_connections) const {
for (const KeyValue<StringName, SignalData> &E : signal_map) {
const SignalData *s = &E.value;
- for (int i = 0; i < s->slot_map.size(); i++) {
- p_connections->push_back(s->slot_map.getv(i).conn);
+ for (const KeyValue<Callable, SignalData::Slot> &slot_kv : s->slot_map) {
+ p_connections->push_back(slot_kv.value.conn);
}
}
}
@@ -1203,8 +1211,8 @@ void Object::get_signal_connection_list(const StringName &p_signal, List<Connect
return; //nothing
}
- for (int i = 0; i < s->slot_map.size(); i++) {
- p_connections->push_back(s->slot_map.getv(i).conn);
+ for (const KeyValue<Callable, SignalData::Slot> &slot_kv : s->slot_map) {
+ p_connections->push_back(slot_kv.value.conn);
}
}
@@ -1214,8 +1222,8 @@ int Object::get_persistent_signal_connection_count() const {
for (const KeyValue<StringName, SignalData> &E : signal_map) {
const SignalData *s = &E.value;
- for (int i = 0; i < s->slot_map.size(); i++) {
- if (s->slot_map.getv(i).conn.flags & CONNECT_PERSIST) {
+ for (const KeyValue<Callable, SignalData::Slot> &slot_kv : s->slot_map) {
+ if (slot_kv.value.conn.flags & CONNECT_PERSIST) {
count += 1;
}
}
@@ -1315,28 +1323,28 @@ void Object::disconnect(const StringName &p_signal, const Callable &p_callable)
_disconnect(p_signal, p_callable);
}
-void Object::_disconnect(const StringName &p_signal, const Callable &p_callable, bool p_force) {
- ERR_FAIL_COND_MSG(p_callable.is_null(), "Cannot disconnect from '" + p_signal + "': the provided callable is null.");
+bool Object::_disconnect(const StringName &p_signal, const Callable &p_callable, bool p_force) {
+ ERR_FAIL_COND_V_MSG(p_callable.is_null(), false, "Cannot disconnect from '" + p_signal + "': the provided callable is null.");
Object *target_object = p_callable.get_object();
- ERR_FAIL_COND_MSG(!target_object, "Cannot disconnect '" + p_signal + "' from callable '" + p_callable + "': the callable object is null.");
+ ERR_FAIL_COND_V_MSG(!target_object, false, "Cannot disconnect '" + p_signal + "' from callable '" + p_callable + "': the callable object is null.");
SignalData *s = signal_map.getptr(p_signal);
if (!s) {
bool signal_is_valid = ClassDB::has_signal(get_class_name(), p_signal) ||
(!script.is_null() && Ref<Script>(script)->has_script_signal(p_signal));
- ERR_FAIL_COND_MSG(signal_is_valid, "Attempt to disconnect a nonexistent connection from '" + to_string() + "'. Signal: '" + p_signal + "', callable: '" + p_callable + "'.");
+ ERR_FAIL_COND_V_MSG(signal_is_valid, false, "Attempt to disconnect a nonexistent connection from '" + to_string() + "'. Signal: '" + p_signal + "', callable: '" + p_callable + "'.");
}
- ERR_FAIL_COND_MSG(!s, vformat("Disconnecting nonexistent signal '%s' in %s.", p_signal, to_string()));
+ ERR_FAIL_COND_V_MSG(!s, false, vformat("Disconnecting nonexistent signal '%s' in %s.", p_signal, to_string()));
- ERR_FAIL_COND_MSG(!s->slot_map.has(*p_callable.get_base_comparator()), "Disconnecting nonexistent signal '" + p_signal + "', callable: " + p_callable + ".");
+ ERR_FAIL_COND_V_MSG(!s->slot_map.has(*p_callable.get_base_comparator()), false, "Disconnecting nonexistent signal '" + p_signal + "', callable: " + p_callable + ".");
SignalData::Slot *slot = &s->slot_map[*p_callable.get_base_comparator()];
if (!p_force) {
slot->reference_count--; // by default is zero, if it was not referenced it will go below it
if (slot->reference_count > 0) {
- return;
+ return false;
}
}
@@ -1347,6 +1355,8 @@ void Object::_disconnect(const StringName &p_signal, const Callable &p_callable,
//not user signal, delete
signal_map.erase(p_signal);
}
+
+ return true;
}
void Object::_set_bind(const StringName &p_set, const Variant &p_value) {
@@ -1794,26 +1804,30 @@ Object::~Object() {
ERR_PRINT("Object " + to_string() + " was freed or unreferenced while a signal is being emitted from it. Try connecting to the signal using 'CONNECT_DEFERRED' flag, or use queue_free() to free the object (if this object is a Node) to avoid this error and potential crashes.");
}
+ // Drop all connections to the signals of this object.
while (signal_map.size()) {
// Avoid regular iteration so erasing is safe.
KeyValue<StringName, SignalData> &E = *signal_map.begin();
SignalData *s = &E.value;
- //brute force disconnect for performance
- int slot_count = s->slot_map.size();
- const VMap<Callable, SignalData::Slot>::Pair *slot_list = s->slot_map.get_array();
-
- for (int i = 0; i < slot_count; i++) {
- slot_list[i].value.conn.callable.get_object()->connections.erase(slot_list[i].value.cE);
+ for (const KeyValue<Callable, SignalData::Slot> &slot_kv : s->slot_map) {
+ Object *target = slot_kv.value.conn.callable.get_object();
+ if (likely(target)) {
+ target->connections.erase(slot_kv.value.cE);
+ }
}
signal_map.erase(E.key);
}
- //signals from nodes that connect to this node
+ // Disconnect signals that connect to this object.
while (connections.size()) {
Connection c = connections.front()->get();
- c.signal.get_object()->_disconnect(c.signal.get_name(), c.callable, true);
+ bool disconnected = c.signal.get_object()->_disconnect(c.signal.get_name(), c.callable, true);
+ if (unlikely(!disconnected)) {
+ // If the disconnect has failed, abandon the connection to avoid getting trapped in an infinite loop here.
+ connections.pop_front();
+ }
}
if (_instance_id != ObjectID()) {
diff --git a/core/object/object.h b/core/object/object.h
index 99d05a78bb..ed2c625417 100644
--- a/core/object/object.h
+++ b/core/object/object.h
@@ -41,7 +41,6 @@
#include "core/templates/list.h"
#include "core/templates/rb_map.h"
#include "core/templates/safe_refcount.h"
-#include "core/templates/vmap.h"
#include "core/variant/callable_bind.h"
#include "core/variant/variant.h"
@@ -587,7 +586,7 @@ private:
};
MethodInfo user;
- VMap<Callable, Slot> slot_map;
+ HashMap<Callable, Slot, HashableHasher<Callable>> slot_map;
};
HashMap<StringName, SignalData> signal_map;
@@ -725,7 +724,7 @@ protected:
friend class ClassDB;
- void _disconnect(const StringName &p_signal, const Callable &p_callable, bool p_force = false);
+ bool _disconnect(const StringName &p_signal, const Callable &p_callable, bool p_force = false);
public: // Should be protected, but bug in clang++.
static void initialize_class();
diff --git a/core/os/os.cpp b/core/os/os.cpp
index 49b47c6c12..c82f87c731 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -281,6 +281,15 @@ Error OS::shell_open(String p_uri) {
return ERR_UNAVAILABLE;
}
+Error OS::shell_show_in_file_manager(String p_path, bool p_open_folder) {
+ if (!p_path.begins_with("file://")) {
+ p_path = String("file://") + p_path;
+ }
+ if (!p_path.ends_with("/")) {
+ p_path = p_path.get_base_dir();
+ }
+ return shell_open(p_path);
+}
// implement these with the canvas?
uint64_t OS::get_static_memory_usage() const {
diff --git a/core/os/os.h b/core/os/os.h
index 076a9db55c..3248330c74 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -163,6 +163,7 @@ public:
virtual void vibrate_handheld(int p_duration_ms = 500) {}
virtual Error shell_open(String p_uri);
+ virtual Error shell_show_in_file_manager(String p_path, bool p_open_folder = true);
virtual Error set_cwd(const String &p_cwd);
virtual bool has_environment(const String &p_var) const = 0;
diff --git a/core/os/thread.cpp b/core/os/thread.cpp
index 92865576f3..502f82aaef 100644
--- a/core/os/thread.cpp
+++ b/core/os/thread.cpp
@@ -38,13 +38,9 @@
Thread::PlatformFunctions Thread::platform_functions;
-uint64_t Thread::_thread_id_hash(const std::thread::id &p_t) {
- static std::hash<std::thread::id> hasher;
- return hasher(p_t);
-}
+SafeNumeric<uint64_t> Thread::id_counter(1); // The first value after .increment() is 2, hence by default the main thread ID should be 1.
-Thread::ID Thread::main_thread_id = _thread_id_hash(std::this_thread::get_id());
-thread_local Thread::ID Thread::caller_id = 0;
+thread_local Thread::ID Thread::caller_id = Thread::UNASSIGNED_ID;
void Thread::_set_platform_functions(const PlatformFunctions &p_functions) {
platform_functions = p_functions;
@@ -71,31 +67,23 @@ void Thread::callback(ID p_caller_id, const Settings &p_settings, Callback p_cal
}
void Thread::start(Thread::Callback p_callback, void *p_user, const Settings &p_settings) {
- if (id != _thread_id_hash(std::thread::id())) {
-#ifdef DEBUG_ENABLED
- WARN_PRINT("A Thread object has been re-started without wait_to_finish() having been called on it. Please do so to ensure correct cleanup of the thread.");
-#endif
- thread.detach();
- std::thread empty_thread;
- thread.swap(empty_thread);
- }
- std::thread new_thread(&Thread::callback, _thread_id_hash(thread.get_id()), p_settings, p_callback, p_user);
+ ERR_FAIL_COND_MSG(id != UNASSIGNED_ID, "A Thread object has been re-started without wait_to_finish() having been called on it.");
+ id = id_counter.increment();
+ std::thread new_thread(&Thread::callback, id, p_settings, p_callback, p_user);
thread.swap(new_thread);
- id = _thread_id_hash(thread.get_id());
}
bool Thread::is_started() const {
- return id != _thread_id_hash(std::thread::id());
+ return id != UNASSIGNED_ID;
}
void Thread::wait_to_finish() {
- if (id != _thread_id_hash(std::thread::id())) {
- ERR_FAIL_COND_MSG(id == get_caller_id(), "A Thread can't wait for itself to finish.");
- thread.join();
- std::thread empty_thread;
- thread.swap(empty_thread);
- id = _thread_id_hash(std::thread::id());
- }
+ ERR_FAIL_COND_MSG(id == UNASSIGNED_ID, "Attempt of waiting to finish on a thread that was never started.");
+ ERR_FAIL_COND_MSG(id == get_caller_id(), "Threads can't wait to finish on themselves, another thread must wait.");
+ thread.join();
+ std::thread empty_thread;
+ thread.swap(empty_thread);
+ id = UNASSIGNED_ID;
}
Error Thread::set_name(const String &p_name) {
@@ -107,11 +95,10 @@ Error Thread::set_name(const String &p_name) {
}
Thread::Thread() {
- caller_id = _thread_id_hash(std::this_thread::get_id());
}
Thread::~Thread() {
- if (id != _thread_id_hash(std::thread::id())) {
+ if (id != UNASSIGNED_ID) {
#ifdef DEBUG_ENABLED
WARN_PRINT("A Thread object has been destroyed without wait_to_finish() having been called on it. Please do so to ensure correct cleanup of the thread.");
#endif
diff --git a/core/os/thread.h b/core/os/thread.h
index 6eb21fba65..19e1376ca8 100644
--- a/core/os/thread.h
+++ b/core/os/thread.h
@@ -52,6 +52,11 @@ public:
typedef uint64_t ID;
+ enum : ID {
+ UNASSIGNED_ID = 0,
+ MAIN_ID = 1
+ };
+
enum Priority {
PRIORITY_LOW,
PRIORITY_NORMAL,
@@ -74,11 +79,8 @@ public:
private:
friend class Main;
- static ID main_thread_id;
-
- static uint64_t _thread_id_hash(const std::thread::id &p_t);
-
- ID id = _thread_id_hash(std::thread::id());
+ ID id = UNASSIGNED_ID;
+ static SafeNumeric<uint64_t> id_counter;
static thread_local ID caller_id;
std::thread thread;
@@ -86,14 +88,22 @@ private:
static PlatformFunctions platform_functions;
+ static void make_main_thread() { caller_id = MAIN_ID; }
+ static void release_main_thread() { caller_id = UNASSIGNED_ID; }
+
public:
static void _set_platform_functions(const PlatformFunctions &p_functions);
_FORCE_INLINE_ ID get_id() const { return id; }
// get the ID of the caller thread
- _FORCE_INLINE_ static ID get_caller_id() { return caller_id; }
+ _FORCE_INLINE_ static ID get_caller_id() {
+ if (unlikely(caller_id == UNASSIGNED_ID)) {
+ caller_id = id_counter.increment();
+ }
+ return caller_id;
+ }
// get the ID of the main thread
- _FORCE_INLINE_ static ID get_main_id() { return main_thread_id; }
+ _FORCE_INLINE_ static ID get_main_id() { return MAIN_ID; }
static Error set_name(const String &p_name);
diff --git a/core/string/translation.cpp b/core/string/translation.cpp
index 160bad14ab..3ca2e5ccdf 100644
--- a/core/string/translation.cpp
+++ b/core/string/translation.cpp
@@ -941,18 +941,11 @@ String TranslationServer::wrap_with_fakebidi_characters(String &p_message) const
}
String TranslationServer::add_padding(const String &p_message, int p_length) const {
- String res;
- String prefix = pseudolocalization_prefix;
- String suffix;
- for (int i = 0; i < p_length * expansion_ratio / 2; i++) {
- prefix += "_";
- suffix += "_";
- }
- suffix += pseudolocalization_suffix;
- res += prefix;
- res += p_message;
- res += suffix;
- return res;
+ String underscores = String("_").repeat(p_length * expansion_ratio / 2);
+ String prefix = pseudolocalization_prefix + underscores;
+ String suffix = underscores + pseudolocalization_suffix;
+
+ return prefix + p_message + suffix;
}
const char32_t *TranslationServer::get_accented_version(char32_t p_character) const {
diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp
index 49c72a9dcf..92c9e4b70c 100644
--- a/core/string/ustring.cpp
+++ b/core/string/ustring.cpp
@@ -2857,6 +2857,12 @@ String String::insert(int p_at_pos, const String &p_string) const {
return pre + p_string + post;
}
+String String::erase(int p_pos, int p_chars) const {
+ ERR_FAIL_COND_V_MSG(p_pos < 0, "", vformat("Invalid starting position for `String.erase()`: %d. Starting position must be positive or zero.", p_pos));
+ ERR_FAIL_COND_V_MSG(p_chars < 0, "", vformat("Invalid character count for `String.erase()`: %d. Character count must be positive or zero.", p_chars));
+ return left(p_pos) + substr(p_pos + p_chars);
+}
+
String String::substr(int p_from, int p_chars) const {
if (p_chars == -1) {
p_chars = length() - p_from;
@@ -3524,6 +3530,14 @@ String String::replacen(const String &p_key, const String &p_with) const {
String String::repeat(int p_count) const {
ERR_FAIL_COND_V_MSG(p_count < 0, "", "Parameter count should be a positive number.");
+ if (p_count == 0) {
+ return "";
+ }
+
+ if (p_count == 1) {
+ return *this;
+ }
+
int len = length();
String new_string = *this;
new_string.resize(p_count * len + 1);
@@ -4161,13 +4175,11 @@ String String::pad_decimals(int p_digits) const {
}
if (s.length() - (c + 1) > p_digits) {
- s = s.substr(0, c + p_digits + 1);
+ return s.substr(0, c + p_digits + 1);
} else {
- while (s.length() - (c + 1) < p_digits) {
- s += "0";
- }
+ int zeros_to_add = p_digits - s.length() + (c + 1);
+ return s + String("0").repeat(zeros_to_add);
}
- return s;
}
String String::pad_zeros(int p_digits) const {
@@ -4192,12 +4204,8 @@ String String::pad_zeros(int p_digits) const {
return s;
}
- while (end - begin < p_digits) {
- s = s.insert(begin, "0");
- end++;
- }
-
- return s;
+ int zeros_to_add = p_digits - (end - begin);
+ return s.insert(begin, String("0").repeat(zeros_to_add));
}
String String::trim_prefix(const String &p_prefix) const {
@@ -4376,11 +4384,8 @@ String String::path_to(const String &p_path) const {
common_parent--;
- String dir;
-
- for (int i = src_dirs.size() - 1; i > common_parent; i--) {
- dir += "../";
- }
+ int dirs_to_backtrack = (src_dirs.size() - 1) - common_parent;
+ String dir = String("../").repeat(dirs_to_backtrack);
for (int i = common_parent + 1; i < dst_dirs.size(); i++) {
dir += dst_dirs[i] + "/";
@@ -4669,11 +4674,8 @@ String String::rpad(int min_length, const String &character) const {
String s = *this;
int padding = min_length - s.length();
if (padding > 0) {
- for (int i = 0; i < padding; i++) {
- s = s + character;
- }
+ s += character.repeat(padding);
}
-
return s;
}
@@ -4682,11 +4684,8 @@ String String::lpad(int min_length, const String &character) const {
String s = *this;
int padding = min_length - s.length();
if (padding > 0) {
- for (int i = 0; i < padding; i++) {
- s = character + s;
- }
+ s = character.repeat(padding) + s;
}
-
return s;
}
diff --git a/core/string/ustring.h b/core/string/ustring.h
index e1512cfb26..c771dff515 100644
--- a/core/string/ustring.h
+++ b/core/string/ustring.h
@@ -304,6 +304,7 @@ public:
String replacen(const String &p_key, const String &p_with) const;
String repeat(int p_count) const;
String insert(int p_at_pos, const String &p_string) const;
+ String erase(int p_pos, int p_chars = 1) const;
String pad_decimals(int p_digits) const;
String pad_zeros(int p_digits) const;
String trim_prefix(const String &p_prefix) const;
diff --git a/core/templates/hashfuncs.h b/core/templates/hashfuncs.h
index 95e6bad2f2..2a212f3dcb 100644
--- a/core/templates/hashfuncs.h
+++ b/core/templates/hashfuncs.h
@@ -386,6 +386,12 @@ struct HashMapHasherDefault {
}
};
+// TODO: Fold this into HashMapHasherDefault once C++20 concepts are allowed
+template <class T>
+struct HashableHasher {
+ static _FORCE_INLINE_ uint32_t hash(const T &hashable) { return hashable.hash(); }
+};
+
template <typename T>
struct HashMapComparatorDefault {
static bool compare(const T &p_lhs, const T &p_rhs) {
diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp
index e83b6dc183..d77222b166 100644
--- a/core/variant/variant_call.cpp
+++ b/core/variant/variant_call.cpp
@@ -1659,6 +1659,7 @@ static void _register_variant_builtin_methods() {
bind_string_method(replacen, sarray("what", "forwhat"), varray());
bind_string_method(repeat, sarray("count"), varray());
bind_string_method(insert, sarray("position", "what"), varray());
+ bind_string_method(erase, sarray("position", "chars"), varray(1));
bind_string_method(capitalize, sarray(), varray());
bind_string_method(to_camel_case, sarray(), varray());
bind_string_method(to_pascal_case, sarray(), varray());
diff --git a/doc/classes/AStarGrid2D.xml b/doc/classes/AStarGrid2D.xml
index e349f082d3..2a38d34cfb 100644
--- a/doc/classes/AStarGrid2D.xml
+++ b/doc/classes/AStarGrid2D.xml
@@ -5,11 +5,11 @@
</brief_description>
<description>
Compared to [AStar2D] you don't need to manually create points or connect them together. It also supports multiple type of heuristics and modes for diagonal movement. This class also provides a jumping mode which is faster to calculate than without it in the [AStar2D] class.
- In contrast to [AStar2D], you only need set the [member size] of the grid, optionally set the [member cell_size] and then call the [method update] method:
+ In contrast to [AStar2D], you only need set the [member region] of the grid, optionally set the [member cell_size] and then call the [method update] method:
[codeblocks]
[gdscript]
var astar_grid = AStarGrid2D.new()
- astar_grid.size = Vector2i(32, 32)
+ astar_grid.region = Rect2i(0, 0, 32, 32)
astar_grid.cell_size = Vector2(16, 16)
astar_grid.update()
print(astar_grid.get_id_path(Vector2i(0, 0), Vector2i(3, 4))) # prints (0, 0), (1, 1), (2, 2), (3, 3), (3, 4)
@@ -49,7 +49,7 @@
<method name="clear">
<return type="void" />
<description>
- Clears the grid and sets the [member size] to [constant Vector2i.ZERO].
+ Clears the grid and sets the [member region] to [code]Rect2i(0, 0, 0, 0)[/code].
</description>
</method>
<method name="get_id_path">
@@ -132,7 +132,8 @@
<method name="update">
<return type="void" />
<description>
- Updates the internal state of the grid according to the parameters to prepare it to search the path. Needs to be called if parameters like [member size], [member cell_size] or [member offset] are changed. [method is_dirty] will return [code]true[/code] if this is the case and this needs to be called.
+ Updates the internal state of the grid according to the parameters to prepare it to search the path. Needs to be called if parameters like [member region], [member cell_size] or [member offset] are changed. [method is_dirty] will return [code]true[/code] if this is the case and this needs to be called.
+ [b]Note:[/b] All point data (solidity and weight scale) will be cleared.
</description>
</method>
</methods>
@@ -156,8 +157,12 @@
<member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2(0, 0)">
The offset of the grid which will be applied to calculate the resulting point position returned by [method get_point_path]. If changed, [method update] needs to be called before finding the next path.
</member>
+ <member name="region" type="Rect2i" setter="set_region" getter="get_region" default="Rect2i(0, 0, 0, 0)">
+ The region of grid cells available for pathfinding. If changed, [method update] needs to be called before finding the next path.
+ </member>
<member name="size" type="Vector2i" setter="set_size" getter="get_size" default="Vector2i(0, 0)">
The size of the grid (number of cells of size [member cell_size] on each axis). If changed, [method update] needs to be called before finding the next path.
+ [b]Note:[/b] This property is deprecated, use [member region] instead.
</member>
</members>
<constants>
diff --git a/doc/classes/Animation.xml b/doc/classes/Animation.xml
index 6896555b25..3e94f3d0bd 100644
--- a/doc/classes/Animation.xml
+++ b/doc/classes/Animation.xml
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="Animation" inherits="Resource" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
- Contains data used to animate everything in the engine.
+ Holds data that can be used to animate anything in the engine.
</brief_description>
<description>
- An Animation resource contains data used to animate everything in the engine. Animations are divided into tracks, and each track must be linked to a node. The state of that node can be changed through time, by adding timed keys (events) to the track.
+ This resource holds data that can be used to animate anything in the engine. Animations are divided into tracks and each track must be linked to a node. The state of that node can be changed through time, by adding timed keys (events) to the track.
[codeblocks]
[gdscript]
# This creates an animation that makes the node "Enemy" move to the right by
@@ -228,6 +228,14 @@
Inserts a key in a given blend shape track. Returns the key index.
</description>
</method>
+ <method name="blend_shape_track_interpolate" qualifiers="const">
+ <return type="float" />
+ <param index="0" name="track_idx" type="int" />
+ <param index="1" name="time_sec" type="float" />
+ <description>
+ Returns the interpolated blend shape value at the given time (in seconds). The [param track_idx] must be the index of a blend shape track.
+ </description>
+ </method>
<method name="clear">
<return type="void" />
<description>
@@ -291,6 +299,14 @@
Inserts a key in a given 3D position track. Returns the key index.
</description>
</method>
+ <method name="position_track_interpolate" qualifiers="const">
+ <return type="Vector3" />
+ <param index="0" name="track_idx" type="int" />
+ <param index="1" name="time_sec" type="float" />
+ <description>
+ Returns the interpolated position value at the given time (in seconds). The [param track_idx] must be the index of a 3D position track.
+ </description>
+ </method>
<method name="remove_track">
<return type="void" />
<param index="0" name="track_idx" type="int" />
@@ -307,6 +323,14 @@
Inserts a key in a given 3D rotation track. Returns the key index.
</description>
</method>
+ <method name="rotation_track_interpolate" qualifiers="const">
+ <return type="Quaternion" />
+ <param index="0" name="track_idx" type="int" />
+ <param index="1" name="time_sec" type="float" />
+ <description>
+ Returns the interpolated rotation value at the given time (in seconds). The [param track_idx] must be the index of a 3D rotation track.
+ </description>
+ </method>
<method name="scale_track_insert_key">
<return type="int" />
<param index="0" name="track_idx" type="int" />
@@ -316,6 +340,14 @@
Inserts a key in a given 3D scale track. Returns the key index.
</description>
</method>
+ <method name="scale_track_interpolate" qualifiers="const">
+ <return type="Vector3" />
+ <param index="0" name="track_idx" type="int" />
+ <param index="1" name="time_sec" type="float" />
+ <description>
+ Returns the interpolated scale value at the given time (in seconds). The [param track_idx] must be the index of a 3D scale track.
+ </description>
+ </method>
<method name="track_find_key" qualifiers="const">
<return type="int" />
<param index="0" name="track_idx" type="int" />
diff --git a/doc/classes/AnimationNode.xml b/doc/classes/AnimationNode.xml
index 80f9fd0803..cb6a4f30f9 100644
--- a/doc/classes/AnimationNode.xml
+++ b/doc/classes/AnimationNode.xml
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="AnimationNode" inherits="Resource" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
- Base resource for [AnimationTree] nodes.
+ Base class for [AnimationTree] nodes. Not related to scene nodes.
</brief_description>
<description>
Base resource for [AnimationTree] nodes. In general, it's not used directly, but you can create custom ones with custom blending formulas.
Inherit this when creating nodes mainly for use in [AnimationNodeBlendTree], otherwise [AnimationRootNode] should be used instead.
</description>
<tutorials>
- <link title="AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
+ <link title="Using AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
</tutorials>
<methods>
<method name="_get_caption" qualifiers="virtual const">
diff --git a/doc/classes/AnimationNodeAdd2.xml b/doc/classes/AnimationNodeAdd2.xml
index 1320e5de2d..68bbe8090b 100644
--- a/doc/classes/AnimationNodeAdd2.xml
+++ b/doc/classes/AnimationNodeAdd2.xml
@@ -7,6 +7,6 @@
A resource to add to an [AnimationNodeBlendTree]. Blends two animations additively based on an amount value in the [code][0.0, 1.0][/code] range.
</description>
<tutorials>
- <link title="AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
+ <link title="Using AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
</tutorials>
</class>
diff --git a/doc/classes/AnimationNodeAdd3.xml b/doc/classes/AnimationNodeAdd3.xml
index b93f1eadd1..1e51a8a4c5 100644
--- a/doc/classes/AnimationNodeAdd3.xml
+++ b/doc/classes/AnimationNodeAdd3.xml
@@ -11,7 +11,7 @@
- A +add animation to blend with when the blend amount is in the [code][0.0, 1.0][/code] range
</description>
<tutorials>
- <link title="AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
+ <link title="Using AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
<link title="Third Person Shooter Demo">https://godotengine.org/asset-library/asset/678</link>
</tutorials>
</class>
diff --git a/doc/classes/AnimationNodeAnimation.xml b/doc/classes/AnimationNodeAnimation.xml
index 504160516d..ffefa89e35 100644
--- a/doc/classes/AnimationNodeAnimation.xml
+++ b/doc/classes/AnimationNodeAnimation.xml
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="AnimationNodeAnimation" inherits="AnimationRootNode" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
- Input animation to use in an [AnimationNodeBlendTree].
+ An input animation for an [AnimationNodeBlendTree].
</brief_description>
<description>
- A resource to add to an [AnimationNodeBlendTree]. Only features one output set using the [member animation] property. Use it as an input for [AnimationNode] that blend animations together.
+ A resource to add to an [AnimationNodeBlendTree]. Only has one output port using the [member animation] property. Used as an input for [AnimationNode]s that blend animations together.
</description>
<tutorials>
- <link title="AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
+ <link title="Using AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
<link title="3D Platformer Demo">https://godotengine.org/asset-library/asset/125</link>
<link title="Third Person Shooter Demo">https://godotengine.org/asset-library/asset/678</link>
</tutorials>
diff --git a/doc/classes/AnimationNodeBlend2.xml b/doc/classes/AnimationNodeBlend2.xml
index 694beb2780..1460f5f055 100644
--- a/doc/classes/AnimationNodeBlend2.xml
+++ b/doc/classes/AnimationNodeBlend2.xml
@@ -7,7 +7,7 @@
A resource to add to an [AnimationNodeBlendTree]. Blends two animations linearly based on an amount value in the [code][0.0, 1.0][/code] range.
</description>
<tutorials>
- <link title="AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
+ <link title="Using AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
<link title="3D Platformer Demo">https://godotengine.org/asset-library/asset/125</link>
<link title="Third Person Shooter Demo">https://godotengine.org/asset-library/asset/678</link>
</tutorials>
diff --git a/doc/classes/AnimationNodeBlend3.xml b/doc/classes/AnimationNodeBlend3.xml
index 90363a9718..34c4b8566a 100644
--- a/doc/classes/AnimationNodeBlend3.xml
+++ b/doc/classes/AnimationNodeBlend3.xml
@@ -11,6 +11,6 @@
- A +blend animation to blend with when the blend amount is in the [code][0.0, 1.0][/code] range
</description>
<tutorials>
- <link title="AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
+ <link title="Using AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
</tutorials>
</class>
diff --git a/doc/classes/AnimationNodeBlendSpace1D.xml b/doc/classes/AnimationNodeBlendSpace1D.xml
index 3d5b70a69e..aa15ac03d9 100644
--- a/doc/classes/AnimationNodeBlendSpace1D.xml
+++ b/doc/classes/AnimationNodeBlendSpace1D.xml
@@ -1,16 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="AnimationNodeBlendSpace1D" inherits="AnimationRootNode" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
- Blends linearly between two of any number of [AnimationNode] of any type placed on a virtual axis.
+ A set of [AnimationRootNode]s placed on a virtual axis, crossfading between the two adjacent ones. Used by [AnimationTree].
</brief_description>
<description>
- A resource to add to an [AnimationNodeBlendTree].
- This is a virtual axis on which you can add any type of [AnimationNode] using [method add_blend_point].
- Outputs the linear blend of the two [AnimationNode]s closest to the node's current value.
- You can set the extents of the axis using the [member min_space] and [member max_space].
+ A resource used by [AnimationNodeBlendTree].
+ [AnimationNodeBlendSpace1D] represents a virtual axis on which any type of [AnimationRootNode]s can be added using [method add_blend_point]. Outputs the linear blend of the two [AnimationRootNode]s adjacent to the current value.
+ You can set the extents of the axis with [member min_space] and [member max_space].
</description>
<tutorials>
- <link title="AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
+ <link title="Using AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
</tutorials>
<methods>
<method name="add_blend_point">
diff --git a/doc/classes/AnimationNodeBlendSpace2D.xml b/doc/classes/AnimationNodeBlendSpace2D.xml
index 7e9c2eed47..27dff11e88 100644
--- a/doc/classes/AnimationNodeBlendSpace2D.xml
+++ b/doc/classes/AnimationNodeBlendSpace2D.xml
@@ -1,15 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="AnimationNodeBlendSpace2D" inherits="AnimationRootNode" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
- Blends linearly between three [AnimationNode] of any type placed in a 2D space.
+ A set of [AnimationRootNode]s placed on 2D coordinates, crossfading between the three adjacent ones. Used by [AnimationTree].
</brief_description>
<description>
- A resource to add to an [AnimationNodeBlendTree].
- This node allows you to blend linearly between three animations using a [Vector2] weight.
- You can add vertices to the blend space with [method add_blend_point] and automatically triangulate it by setting [member auto_triangles] to [code]true[/code]. Otherwise, use [method add_triangle] and [method remove_triangle] to create up the blend space by hand.
+ A resource used by [AnimationNodeBlendTree].
+ [AnimationNodeBlendSpace1D] represents a virtual 2D space on which [AnimationRootNode]s are placed. Outputs the linear blend of the three adjacent animations using a [Vector2] weight. Adjacent in this context means the three [AnimationRootNode]s making up the triangle that contains the current value.
+ You can add vertices to the blend space with [method add_blend_point] and automatically triangulate it by setting [member auto_triangles] to [code]true[/code]. Otherwise, use [method add_triangle] and [method remove_triangle] to triangulate the blend space by hand.
</description>
<tutorials>
- <link title="AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
+ <link title="Using AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
<link title="Third Person Shooter Demo">https://godotengine.org/asset-library/asset/678</link>
</tutorials>
<methods>
diff --git a/doc/classes/AnimationNodeBlendTree.xml b/doc/classes/AnimationNodeBlendTree.xml
index 4be7f5e7f8..9ae34e8038 100644
--- a/doc/classes/AnimationNodeBlendTree.xml
+++ b/doc/classes/AnimationNodeBlendTree.xml
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="AnimationNodeBlendTree" inherits="AnimationRootNode" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
- [AnimationTree] node resource that contains many blend type nodes.
+ A sub-tree of blend type [AnimationNode]s used for complex animations. Used by [AnimationTree].
</brief_description>
<description>
- This node may contain a sub-tree of any other blend type nodes, such as [AnimationNodeTransition], [AnimationNodeBlend2], [AnimationNodeBlend3], [AnimationNodeOneShot], etc. This is one of the most commonly used roots.
+ This node may contain a sub-tree of any other blend type nodes, such as [AnimationNodeTransition], [AnimationNodeBlend2], [AnimationNodeBlend3], [AnimationNodeOneShot], etc. This is one of the most commonly used animation node roots.
An [AnimationNodeOutput] node named [code]output[/code] is created by default.
</description>
<tutorials>
- <link title="AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
+ <link title="Using AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
</tutorials>
<methods>
<method name="add_node">
diff --git a/doc/classes/AnimationNodeOneShot.xml b/doc/classes/AnimationNodeOneShot.xml
index e95eab993c..11ef27178b 100644
--- a/doc/classes/AnimationNodeOneShot.xml
+++ b/doc/classes/AnimationNodeOneShot.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="AnimationNodeOneShot" inherits="AnimationNodeSync" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
- Plays an animation once in [AnimationNodeBlendTree].
+ Plays an animation once in an [AnimationNodeBlendTree].
</brief_description>
<description>
A resource to add to an [AnimationNodeBlendTree]. This node will execute a sub-animation and return once it finishes. Blend times for fading in and out can be customized, as well as filters.
@@ -36,7 +36,7 @@
[/codeblocks]
</description>
<tutorials>
- <link title="AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
+ <link title="Using AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
<link title="Third Person Shooter Demo">https://godotengine.org/asset-library/asset/678</link>
</tutorials>
<members>
diff --git a/doc/classes/AnimationNodeOutput.xml b/doc/classes/AnimationNodeOutput.xml
index 46b7169bba..0a9210ce37 100644
--- a/doc/classes/AnimationNodeOutput.xml
+++ b/doc/classes/AnimationNodeOutput.xml
@@ -1,12 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="AnimationNodeOutput" inherits="AnimationNode" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
- Generic output node to be added to [AnimationNodeBlendTree].
+ The animation output node of an [AnimationNodeBlendTree].
</brief_description>
<description>
+ A node created automatically in an [AnimationNodeBlendTree] that outputs the final animation.
</description>
<tutorials>
- <link title="AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
+ <link title="Using AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
<link title="3D Platformer Demo">https://godotengine.org/asset-library/asset/125</link>
<link title="Third Person Shooter Demo">https://godotengine.org/asset-library/asset/678</link>
</tutorials>
diff --git a/doc/classes/AnimationNodeStateMachine.xml b/doc/classes/AnimationNodeStateMachine.xml
index 13f88f79ef..9459c31b3b 100644
--- a/doc/classes/AnimationNodeStateMachine.xml
+++ b/doc/classes/AnimationNodeStateMachine.xml
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="AnimationNodeStateMachine" inherits="AnimationRootNode" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
- State machine for control of animations.
+ A state machine with multiple [AnimationRootNode]s, used by [AnimationTree].
</brief_description>
<description>
- Contains multiple nodes representing animation states, connected in a graph. Node transitions can be configured to happen automatically or via code, using a shortest-path algorithm. Retrieve the [AnimationNodeStateMachinePlayback] object from the [AnimationTree] node to control it programmatically.
+ Contains multiple [AnimationRootNode]s representing animation states, connected in a graph. Node transitions can be configured to happen automatically or via code, using a shortest-path algorithm. Retrieve the [AnimationNodeStateMachinePlayback] object from the [AnimationTree] node to control it programmatically.
[b]Example:[/b]
[codeblocks]
[gdscript]
@@ -18,7 +18,7 @@
[/codeblocks]
</description>
<tutorials>
- <link title="AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
+ <link title="Using AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
</tutorials>
<methods>
<method name="add_node">
diff --git a/doc/classes/AnimationNodeStateMachinePlayback.xml b/doc/classes/AnimationNodeStateMachinePlayback.xml
index 7d357a0f83..48d4f154d1 100644
--- a/doc/classes/AnimationNodeStateMachinePlayback.xml
+++ b/doc/classes/AnimationNodeStateMachinePlayback.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="AnimationNodeStateMachinePlayback" inherits="Resource" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
- Playback control for [AnimationNodeStateMachine].
+ Provides playback control for an [AnimationNodeStateMachine].
</brief_description>
<description>
Allows control of [AnimationTree] state machines created with [AnimationNodeStateMachine]. Retrieve with [code]$AnimationTree.get("parameters/playback")[/code].
@@ -18,7 +18,7 @@
[/codeblocks]
</description>
<tutorials>
- <link title="AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
+ <link title="Using AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
</tutorials>
<methods>
<method name="get_current_length" qualifiers="const">
diff --git a/doc/classes/AnimationNodeStateMachineTransition.xml b/doc/classes/AnimationNodeStateMachineTransition.xml
index e23c120cc4..7bb615c148 100644
--- a/doc/classes/AnimationNodeStateMachineTransition.xml
+++ b/doc/classes/AnimationNodeStateMachineTransition.xml
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="AnimationNodeStateMachineTransition" inherits="Resource" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
- A resource to connect each node to make a path for [AnimationNodeStateMachine].
+ A transition within an [AnimationNodeStateMachine] connecting two [AnimationRootNode]s.
</brief_description>
<description>
The path generated when using [method AnimationNodeStateMachinePlayback.travel] is limited to the nodes connected by [AnimationNodeStateMachineTransition].
You can set the timing and conditions of the transition in detail.
</description>
<tutorials>
- <link title="AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
+ <link title="Using AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
</tutorials>
<members>
<member name="advance_condition" type="StringName" setter="set_advance_condition" getter="get_advance_condition" default="&amp;&quot;&quot;">
diff --git a/doc/classes/AnimationNodeSync.xml b/doc/classes/AnimationNodeSync.xml
index e72a0619f4..38f4069c7b 100644
--- a/doc/classes/AnimationNodeSync.xml
+++ b/doc/classes/AnimationNodeSync.xml
@@ -1,11 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="AnimationNodeSync" inherits="AnimationNode" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
- The base class for [AnimationNode] which has more than two input ports and needs to synchronize them.
+ Base class for [AnimationNode]s with more than two input ports that must be synchronized.
</brief_description>
<description>
+ An animation node used to combine, mix, or blend two or more animations together while keeping them synchronized within an [AnimationTree].
</description>
<tutorials>
+ <link title="Using AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
</tutorials>
<members>
<member name="sync" type="bool" setter="set_use_sync" getter="is_using_sync" default="false">
diff --git a/doc/classes/AnimationNodeTimeScale.xml b/doc/classes/AnimationNodeTimeScale.xml
index 5d1b8b109c..65795823b3 100644
--- a/doc/classes/AnimationNodeTimeScale.xml
+++ b/doc/classes/AnimationNodeTimeScale.xml
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="AnimationNodeTimeScale" inherits="AnimationNode" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
- A time-scaling animation node to be used with [AnimationTree].
+ A time-scaling animation node used in [AnimationTree].
</brief_description>
<description>
- Allows scaling the speed of the animation (or reversing it) in any children nodes. Setting it to 0 will pause the animation.
+ Allows to scale the speed of the animation (or reverse it) in any children [AnimationNode]s. Setting it to [code]0.0[/code] will pause the animation.
</description>
<tutorials>
- <link title="AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
+ <link title="Using AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
<link title="3D Platformer Demo">https://godotengine.org/asset-library/asset/125</link>
</tutorials>
</class>
diff --git a/doc/classes/AnimationNodeTimeSeek.xml b/doc/classes/AnimationNodeTimeSeek.xml
index 978cd079c8..3098fa7662 100644
--- a/doc/classes/AnimationNodeTimeSeek.xml
+++ b/doc/classes/AnimationNodeTimeSeek.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="AnimationNodeTimeSeek" inherits="AnimationNode" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
- A time-seeking animation node to be used with [AnimationTree].
+ A time-seeking animation node used in [AnimationTree].
</brief_description>
<description>
This node can be used to cause a seek command to happen to any sub-children of the animation graph. Use this node type to play an [Animation] from the start or a certain playback position inside the [AnimationNodeBlendTree].
@@ -28,6 +28,6 @@
[/codeblocks]
</description>
<tutorials>
- <link title="AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
+ <link title="Using AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
</tutorials>
</class>
diff --git a/doc/classes/AnimationNodeTransition.xml b/doc/classes/AnimationNodeTransition.xml
index ccf14fcb50..481ea9ff59 100644
--- a/doc/classes/AnimationNodeTransition.xml
+++ b/doc/classes/AnimationNodeTransition.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="AnimationNodeTransition" inherits="AnimationNodeSync" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
- A generic animation transition node for [AnimationTree].
+ A transition within an [AnimationTree] connecting two [AnimationNode]s.
</brief_description>
<description>
Simple state machine for cases which don't require a more advanced [AnimationNodeStateMachine]. Animations can be connected to the inputs and transition times can be specified.
@@ -37,7 +37,7 @@
[/codeblocks]
</description>
<tutorials>
- <link title="AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
+ <link title="Using AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
<link title="3D Platformer Demo">https://godotengine.org/asset-library/asset/125</link>
<link title="Third Person Shooter Demo">https://godotengine.org/asset-library/asset/678</link>
</tutorials>
diff --git a/doc/classes/AnimationPlayer.xml b/doc/classes/AnimationPlayer.xml
index 77770a0f7e..94451e7c30 100644
--- a/doc/classes/AnimationPlayer.xml
+++ b/doc/classes/AnimationPlayer.xml
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="AnimationPlayer" inherits="Node" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
- Player of [Animation] resources.
+ A node used for animation playback.
</brief_description>
<description>
- An animation player is used for general-purpose playback of [Animation] resources. It contains a dictionary of [AnimationLibrary] resources and custom blend times between animation transitions.
+ An animation player is used for general-purpose playback of animations. It contains a dictionary of [AnimationLibrary] resources and custom blend times between animation transitions.
Some methods and properties use a single key to reference an animation directly. These keys are formatted as the key for the library, followed by a forward slash, then the key for the animation within the library, for example [code]"movement/run"[/code]. If the library's key is an empty string (known as the default library), the forward slash is omitted, being the same key used by the library.
- [AnimationPlayer] is more suited than [Tween] for animations where you know the final values in advance. For example, fading a screen in and out is more easily done with an [AnimationPlayer] node thanks to the animation tools provided by the editor. That particular example can also be implemented with a [Tween], but it requires doing everything by code.
- Updating the target properties of animations occurs at process time.
+ [AnimationPlayer] is better-suited than [Tween] for more complex animations, for example ones with non-trivial timings. It can also be used over [Tween] if the animation track editor is more convenient than doing it in code.
+ Updating the target properties of animations occurs at the process frame.
</description>
<tutorials>
<link title="2D Sprite animation">$DOCS_URL/tutorials/2d/2d_sprite_animation.html</link>
diff --git a/doc/classes/AnimationRootNode.xml b/doc/classes/AnimationRootNode.xml
index 47c8c8f287..bf5122fe4f 100644
--- a/doc/classes/AnimationRootNode.xml
+++ b/doc/classes/AnimationRootNode.xml
@@ -1,10 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="AnimationRootNode" inherits="AnimationNode" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
- The [AnimationNode] which can be set as the root of an [AnimationTree].
+ Base class for [AnimationNode]s that hold one or multiple composite animations. Usually used for [member AnimationTree.tree_root].
</brief_description>
<description>
+ [AnimationRootNode] is a base class for [AnimationNode]s that hold a complete animation. A complete animation refers to the output of an [AnimationNodeOutput] in an [AnimationNodeBlendTree] or the output of another [AnimationRootNode]. Used for [member AnimationTree.tree_root] or in other [AnimationRootNode]s.
</description>
<tutorials>
+ <link title="Using AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>
</tutorials>
</class>
diff --git a/doc/classes/AnimationTrackEditPlugin.xml b/doc/classes/AnimationTrackEditPlugin.xml
deleted file mode 100644
index 34f18b2989..0000000000
--- a/doc/classes/AnimationTrackEditPlugin.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<class name="AnimationTrackEditPlugin" inherits="RefCounted" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
- <brief_description>
- </brief_description>
- <description>
- </description>
- <tutorials>
- </tutorials>
-</class>
diff --git a/doc/classes/AnimationTree.xml b/doc/classes/AnimationTree.xml
index 4de079c5a3..ef3c1a3f9e 100644
--- a/doc/classes/AnimationTree.xml
+++ b/doc/classes/AnimationTree.xml
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="AnimationTree" inherits="Node" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
- A node to be used for advanced animation transitions in an [AnimationPlayer].
+ A node used for advanced animation transitions in an [AnimationPlayer].
</brief_description>
<description>
- A node to be used for advanced animation transitions in an [AnimationPlayer].
+ A node used for advanced animation transitions in an [AnimationPlayer].
[b]Note:[/b] When linked with an [AnimationPlayer], several properties and methods of the corresponding [AnimationPlayer] will not function as expected. Playback and transitions should be handled using only the [AnimationTree] and its constituent [AnimationNode](s). The [AnimationPlayer] node should be used solely for adding, deleting, and editing animations.
</description>
<tutorials>
diff --git a/doc/classes/AudioStreamGenerator.xml b/doc/classes/AudioStreamGenerator.xml
index fa4b2ae49f..7718cb78ea 100644
--- a/doc/classes/AudioStreamGenerator.xml
+++ b/doc/classes/AudioStreamGenerator.xml
@@ -1,16 +1,36 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="AudioStreamGenerator" inherits="AudioStream" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
- Audio stream that generates sounds procedurally.
+ An audio stream with utilities for procedural sound generation.
</brief_description>
<description>
- This audio stream does not play back sounds, but expects a script to generate audio data for it instead. See also [AudioStreamGeneratorPlayback].
+ [AudioStreamGenerator] is a type of audio stream that does not play back sounds on its own; instead, it expects a script to generate audio data for it. See also [AudioStreamGeneratorPlayback].
+ Here's a sample on how to use it to generate a sine wave:
+ [codeblock]
+ var playback # Will hold the AudioStreamGeneratorPlayback.
+ @onready var sample_hz = $AudioStreamPlayer.stream.mix_rate
+ var pulse_hz = 440.0 # The frequency of the sound wave.
+
+ func _ready():
+ $AudioStreamPlayer.play()
+ playback = $AudioStreamPlayer.get_stream_playback()
+ fill_buffer()
+
+ func fill_buffer():
+ var phase = 0.0
+ var increment = pulse_hz / sample_hz
+ var frames_available = playback.get_frames_available()
+
+ for i in range(frames_available):
+ playback.push_frame(Vector2.ONE * sin(phase * TAU))
+ phase = fmod(phase + increment, 1.0)
+ [/codeblock]
+ In the example above, the "AudioStreamPlayer" node must use an [AudioStreamGenerator] as its stream. The [code]fill_buffer[/code] function provides audio data for approximating a sine wave.
See also [AudioEffectSpectrumAnalyzer] for performing real-time audio spectrum analysis.
[b]Note:[/b] Due to performance constraints, this class is best used from C# or from a compiled language via GDExtension. If you still want to use this class from GDScript, consider using a lower [member mix_rate] such as 11,025 Hz or 22,050 Hz.
</description>
<tutorials>
<link title="Audio Generator Demo">https://godotengine.org/asset-library/asset/526</link>
- <link title="Godot 3.2 will get new audio features">https://godotengine.org/article/godot-32-will-get-new-audio-features</link>
</tutorials>
<members>
<member name="buffer_length" type="float" setter="set_buffer_length" getter="get_buffer_length" default="0.5">
diff --git a/doc/classes/BaseMaterial3D.xml b/doc/classes/BaseMaterial3D.xml
index 989c76d5da..f5e14e29bf 100644
--- a/doc/classes/BaseMaterial3D.xml
+++ b/doc/classes/BaseMaterial3D.xml
@@ -356,13 +356,13 @@
[b]Note:[/b] [member specular_mode] only applies to the specular blob. It does not affect specular reflections from the sky, screen-space reflections, [VoxelGI], SDFGI or [ReflectionProbe]s. To disable reflections from these sources as well, set [member metallic_specular] to [code]0.0[/code] instead.
</member>
<member name="subsurf_scatter_enabled" type="bool" setter="set_feature" getter="get_feature" default="false">
- If [code]true[/code], subsurface scattering is enabled. Emulates light that penetrates an object's surface, is scattered, and then emerges.
+ If [code]true[/code], subsurface scattering is enabled. Emulates light that penetrates an object's surface, is scattered, and then emerges. Subsurface scattering quality is controlled by [member ProjectSettings.rendering/environment/subsurface_scattering/subsurface_scattering_quality].
</member>
<member name="subsurf_scatter_skin_mode" type="bool" setter="set_flag" getter="get_flag" default="false">
If [code]true[/code], subsurface scattering will use a special mode optimized for the color and density of human skin, such as boosting the intensity of the red channel in subsurface scattering.
</member>
<member name="subsurf_scatter_strength" type="float" setter="set_subsurface_scattering_strength" getter="get_subsurface_scattering_strength" default="0.0">
- The strength of the subsurface scattering effect.
+ The strength of the subsurface scattering effect. The depth of the effect is also controlled by [member ProjectSettings.rendering/environment/subsurface_scattering/subsurface_scattering_scale], which is set globally.
</member>
<member name="subsurf_scatter_texture" type="Texture2D" setter="set_texture" getter="get_texture">
Texture used to control the subsurface scattering strength. Stored in the red texture channel. Multiplied by [member subsurf_scatter_strength].
diff --git a/doc/classes/Bone2D.xml b/doc/classes/Bone2D.xml
index 446c9d3702..93bdd9d527 100644
--- a/doc/classes/Bone2D.xml
+++ b/doc/classes/Bone2D.xml
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="Bone2D" inherits="Node2D" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
- Joint used with [Skeleton2D] to control and animate other nodes.
+ A joint used with [Skeleton2D] to control and animate other nodes.
</brief_description>
<description>
- Use a hierarchy of [code]Bone2D[/code] bound to a [Skeleton2D] to control, and animate other [Node2D] nodes.
- You can use [code]Bone2D[/code] and [code]Skeleton2D[/code] nodes to animate 2D meshes created with the Polygon 2D UV editor.
+ A hierarchy of [Bone2D]s can be bound to a [Skeleton2D] to control and animate other [Node2D] nodes.
+ You can use [Bone2D] and [Skeleton2D] nodes to animate 2D meshes created with the [Polygon2D] UV editor.
Each bone has a [member rest] transform that you can reset to with [method apply_rest]. These rest poses are relative to the bone's parent.
If in the editor, you can set the rest pose of an entire skeleton using a menu option, from the code, you need to iterate over the bones to set their individual rest poses.
</description>
@@ -21,14 +21,14 @@
<method name="get_autocalculate_length_and_angle" qualifiers="const">
<return type="bool" />
<description>
- Returns whether this [code]Bone2D[/code] node is going to autocalculate its length and bone angle using its first [code]Bone2D[/code] child node, if one exists. If there are no [code]Bone2D[/code] children, then it cannot autocalculate these values and will print a warning.
+ Returns whether this [Bone2D] is going to autocalculate its length and bone angle using its first [Bone2D] child node, if one exists. If there are no [Bone2D] children, then it cannot autocalculate these values and will print a warning.
</description>
</method>
<method name="get_bone_angle" qualifiers="const">
<return type="float" />
<description>
- Returns the angle of the bone in the [code]Bone2D[/code] node.
- [b]Note:[/b] This is different from the [code]Bone2D[/code]'s rotation. The bone angle is the rotation of the bone shown by the [code]Bone2D[/code] gizmo, and because [code]Bone2D[/code] bones are based on positions, this can vary from the actual rotation of the [code]Bone2D[/code] node.
+ Returns the angle of the bone in the [Bone2D].
+ [b]Note:[/b] This is different from the [Bone2D]'s rotation. The bone's angle is the rotation of the bone shown by the gizmo, which is unaffected by the [Bone2D]'s [member Node2D.transform].
</description>
</method>
<method name="get_index_in_skeleton" qualifiers="const">
@@ -40,7 +40,7 @@
<method name="get_length" qualifiers="const">
<return type="float" />
<description>
- Returns the length of the bone in the [code]Bone2D[/code] node.
+ Returns the length of the bone in the [Bone2D] node.
</description>
</method>
<method name="get_skeleton_rest" qualifiers="const">
@@ -53,22 +53,22 @@
<return type="void" />
<param index="0" name="auto_calculate" type="bool" />
<description>
- When set to [code]true[/code], the [code]Bone2D[/code] node will attempt to automatically calculate the bone angle and length using the first child [code]Bone2D[/code] node, if one exists. If none exist, the [code]Bone2D[/code] cannot automatically calculate these values and will print a warning.
+ When set to [code]true[/code], the [Bone2D] node will attempt to automatically calculate the bone angle and length using the first child [Bone2D] node, if one exists. If none exist, the [Bone2D] cannot automatically calculate these values and will print a warning.
</description>
</method>
<method name="set_bone_angle">
<return type="void" />
<param index="0" name="angle" type="float" />
<description>
- Sets the bone angle for the [code]Bone2D[/code] node. This is typically set to the rotation from the [code]Bone2D[/code] node to a child [code]Bone2D[/code] node.
- [b]Note:[/b] This is different from the [code]Bone2D[/code]'s rotation. The bone angle is the rotation of the bone shown by the [code]Bone2D[/code] gizmo, and because [code]Bone2D[/code] bones are based on positions, this can vary from the actual rotation of the [code]Bone2D[/code] node.
+ Sets the bone angle for the [Bone2D]. This is typically set to the rotation from the [Bone2D] to a child [Bone2D] node.
+ [b]Note:[/b] [b]Note:[/b] This is different from the [Bone2D]'s rotation. The bone's angle is the rotation of the bone shown by the gizmo, which is unaffected by the [Bone2D]'s [member Node2D.transform].
</description>
</method>
<method name="set_length">
<return type="void" />
<param index="0" name="length" type="float" />
<description>
- Sets the length of the bone in the [code]Bone2D[/code] node.
+ Sets the length of the bone in the [Bone2D].
</description>
</method>
</methods>
diff --git a/doc/classes/BoneAttachment3D.xml b/doc/classes/BoneAttachment3D.xml
index bcf7ed42e9..83f70fc331 100644
--- a/doc/classes/BoneAttachment3D.xml
+++ b/doc/classes/BoneAttachment3D.xml
@@ -1,11 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="BoneAttachment3D" inherits="Node3D" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
- A node that will attach to a bone.
+ А node that dynamically copies or overrides the 3D transform of a bone in its parent [Skeleton3D].
</brief_description>
<description>
- This node will allow you to select a bone for this node to attach to. The BoneAttachment3D node can copy the transform of the select bone, or can override the transform of the selected bone.
- The BoneAttachment3D node must either be a child of a [Skeleton3D] node or be given an external [Skeleton3D] to use in order to function properly.
+ This node selects a bone in a [Skeleton3D] and attaches to it. This means that the [BoneAttachment3D] node will either dynamically copy or override the 3D transform of the selected bone.
</description>
<tutorials>
</tutorials>
diff --git a/doc/classes/BoneMap.xml b/doc/classes/BoneMap.xml
index 1fd54a5019..032e2420ca 100644
--- a/doc/classes/BoneMap.xml
+++ b/doc/classes/BoneMap.xml
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="BoneMap" inherits="Resource" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
- Bone map for retargeting.
+ Describes a mapping of bone names for retargeting [Skeleton3D] into common names defined by a [SkeletonProfile].
</brief_description>
<description>
- This class contains a hashmap that uses a list of bone names in [SkeletonProfile] as key names.
+ This class contains a dictionary that uses a list of bone names in [SkeletonProfile] as key names.
By assigning the actual [Skeleton3D] bone name as the key value, it maps the [Skeleton3D] to the [SkeletonProfile].
</description>
<tutorials>
diff --git a/doc/classes/Button.xml b/doc/classes/Button.xml
index ec2447dbbc..1bf5c31818 100644
--- a/doc/classes/Button.xml
+++ b/doc/classes/Button.xml
@@ -58,7 +58,7 @@
To edit margin and spacing of the icon, use [theme_item h_separation] theme property and [code]content_margin_*[/code] properties of the used [StyleBox]es.
</member>
<member name="icon_alignment" type="int" setter="set_icon_alignment" getter="get_icon_alignment" enum="HorizontalAlignment" default="0">
- Specifies if the icon should be aligned to the left, right, or center of a button. Uses the same [enum HorizontalAlignment] constants as the text alignment. If centered, text will draw on top of the icon.
+ Specifies if the icon should be aligned horizontally to the left, right, or center of a button. Uses the same [enum HorizontalAlignment] constants as the text alignment. If centered horizontally and vertically, text will draw on top of the icon.
</member>
<member name="language" type="String" setter="set_language" getter="get_language" default="&quot;&quot;">
Language code used for line-breaking and text shaping algorithms, if left empty current locale is used instead.
@@ -72,6 +72,9 @@
<member name="text_overrun_behavior" type="int" setter="set_text_overrun_behavior" getter="get_text_overrun_behavior" enum="TextServer.OverrunBehavior" default="0">
Sets the clipping behavior when the text exceeds the node's bounding rectangle. See [enum TextServer.OverrunBehavior] for a description of all modes.
</member>
+ <member name="vertical_icon_alignment" type="int" setter="set_vertical_icon_alignment" getter="get_vertical_icon_alignment" enum="VerticalAlignment" default="1">
+ Specifies if the icon should be aligned vertically to the top, bottom, or center of a button. Uses the same [enum VerticalAlignment] constants as the text alignment. If centered horizontally and vertically, text will draw on top of the icon.
+ </member>
</members>
<theme_items>
<theme_item name="font_color" data_type="color" type="Color" default="Color(0.875, 0.875, 0.875, 1)">
diff --git a/doc/classes/CanvasItem.xml b/doc/classes/CanvasItem.xml
index af1f2be76d..bf854e6a5e 100644
--- a/doc/classes/CanvasItem.xml
+++ b/doc/classes/CanvasItem.xml
@@ -237,7 +237,7 @@
<param index="2" name="uvs" type="PackedVector2Array" default="PackedVector2Array()" />
<param index="3" name="texture" type="Texture2D" default="null" />
<description>
- Draws a solid polygon of any number of points, convex or concave. Unlike [method draw_colored_polygon], each point's color can be changed individually. See also [method draw_polyline] and [method draw_polyline_colors].
+ Draws a solid polygon of any number of points, convex or concave. Unlike [method draw_colored_polygon], each point's color can be changed individually. See also [method draw_polyline] and [method draw_polyline_colors]. If you need more flexibility (such as being able to use bones), use [method RenderingServer.canvas_item_add_triangle_array] instead.
</description>
</method>
<method name="draw_polyline">
@@ -279,7 +279,7 @@
<param index="2" name="filled" type="bool" default="true" />
<param index="3" name="width" type="float" default="-1.0" />
<description>
- Draws a rectangle. If [param filled] is [code]true[/code], the rectangle will be filled with the [param color] specified. If [param filled] is [code]false[/code], the rectangle will be drawn as a stroke with the [param color] and [param width] specified.
+ Draws a rectangle. If [param filled] is [code]true[/code], the rectangle will be filled with the [param color] specified. If [param filled] is [code]false[/code], the rectangle will be drawn as a stroke with the [param color] and [param width] specified. See also [method draw_texture_rect].
If [param width] is negative, then two-point primitives will be drawn instead of a four-point ones. This means that when the CanvasItem is scaled, the lines will remain thin. If this behavior is not desired, then pass a positive [param width] like [code]1.0[/code].
[b]Note:[/b] [param width] is only effective if [param filled] is [code]false[/code].
[b]Note:[/b] Unfilled rectangles drawn with a negative [param width] may not display perfectly. For example, corners may be missing or brighter due to overlapping lines (for a translucent [param color]).
@@ -380,7 +380,7 @@
<param index="3" name="modulate" type="Color" default="Color(1, 1, 1, 1)" />
<param index="4" name="transpose" type="bool" default="false" />
<description>
- Draws a textured rectangle at a given position, optionally modulated by a color. If [param transpose] is [code]true[/code], the texture will have its X and Y coordinates swapped.
+ Draws a textured rectangle at a given position, optionally modulated by a color. If [param transpose] is [code]true[/code], the texture will have its X and Y coordinates swapped. See also [method draw_rect] and [method draw_texture_rect_region].
</description>
</method>
<method name="draw_texture_rect_region">
@@ -392,7 +392,7 @@
<param index="4" name="transpose" type="bool" default="false" />
<param index="5" name="clip_uv" type="bool" default="true" />
<description>
- Draws a textured rectangle region at a given position, optionally modulated by a color. If [param transpose] is [code]true[/code], the texture will have its X and Y coordinates swapped.
+ Draws a textured rectangle from a texture's region (specified by [param src_rect]) at a given position, optionally modulated by a color. If [param transpose] is [code]true[/code], the texture will have its X and Y coordinates swapped. See also [method draw_texture_rect].
</description>
</method>
<method name="force_update_transform">
@@ -423,6 +423,7 @@
<return type="Vector2" />
<description>
Returns the mouse's position in the [CanvasLayer] that this [CanvasItem] is in using the coordinate system of the [CanvasLayer].
+ [b]Note:[/b] For screen-space coordinates (e.g. when using a non-embedded [Popup]), you can use [method DisplayServer.mouse_get_position].
</description>
</method>
<method name="get_global_transform" qualifiers="const">
@@ -502,7 +503,7 @@
<method name="is_visible_in_tree" qualifiers="const">
<return type="bool" />
<description>
- Returns [code]true[/code] if the node is present in the [SceneTree], its [member visible] property is [code]true[/code] and all its antecedents are also visible. If any antecedent is hidden, this node will not be visible in the scene tree, and is consequently not drawn (see [method _draw]).
+ Returns [code]true[/code] if the node is present in the [SceneTree], its [member visible] property is [code]true[/code] and all its ancestors are also visible. If any ancestor is hidden, this node will not be visible in the scene tree, and is consequently not drawn (see [method _draw]).
</description>
</method>
<method name="make_canvas_position_local" qualifiers="const">
@@ -597,7 +598,7 @@
The rendering layer in which this [CanvasItem] is rendered by [Viewport] nodes. A [Viewport] will render a [CanvasItem] if it and all its parents share a layer with the [Viewport]'s canvas cull mask.
</member>
<member name="visible" type="bool" setter="set_visible" getter="is_visible" default="true">
- If [code]true[/code], this [CanvasItem] is drawn. The node is only visible if all of its antecedents are visible as well (in other words, [method is_visible_in_tree] must return [code]true[/code]).
+ If [code]true[/code], this [CanvasItem] is drawn. The node is only visible if all of its ancestors are visible as well (in other words, [method is_visible_in_tree] must return [code]true[/code]).
[b]Note:[/b] For controls that inherit [Popup], the correct way to make them visible is to call one of the multiple [code]popup*()[/code] functions instead.
</member>
<member name="y_sort_enabled" type="bool" setter="set_y_sort_enabled" getter="is_y_sort_enabled" default="false">
diff --git a/doc/classes/CodeEdit.xml b/doc/classes/CodeEdit.xml
index 8642fcc0d0..84e1c80900 100644
--- a/doc/classes/CodeEdit.xml
+++ b/doc/classes/CodeEdit.xml
@@ -126,6 +126,15 @@
Inserts the selected entry into the text. If [param replace] is true, any existing text is replaced rather then merged.
</description>
</method>
+ <method name="convert_indent">
+ <return type="void" />
+ <param index="0" name="from_line" type="int" default="-1" />
+ <param index="1" name="to_line" type="int" default="-1" />
+ <description>
+ Converts the indents of lines between [param from_line] and [param to_line] to tabs or spaces as set by [member indent_use_spaces].
+ Values of [code]-1[/code] convert the entire text.
+ </description>
+ </method>
<method name="do_indent">
<return type="void" />
<description>
@@ -537,7 +546,7 @@
Marks the option as a member.
</constant>
<constant name="KIND_ENUM" value="5" enum="CodeCompletionKind">
- Marks the option as a enum entry.
+ Marks the option as an enum entry.
</constant>
<constant name="KIND_CONSTANT" value="6" enum="CodeCompletionKind">
Marks the option as a constant.
diff --git a/doc/classes/ColorPicker.xml b/doc/classes/ColorPicker.xml
index 14656c649e..61a0606f79 100644
--- a/doc/classes/ColorPicker.xml
+++ b/doc/classes/ColorPicker.xml
@@ -141,6 +141,9 @@
</constant>
</constants>
<theme_items>
+ <theme_item name="center_slider_grabbers" data_type="constant" type="int" default="1">
+ Overrides the [theme_item HSlider.center_grabber] theme property of the sliders.
+ </theme_item>
<theme_item name="h_width" data_type="constant" type="int" default="30">
The width of the hue selection slider.
</theme_item>
diff --git a/doc/classes/Curve.xml b/doc/classes/Curve.xml
index 317a578559..52f79ecc9d 100644
--- a/doc/classes/Curve.xml
+++ b/doc/classes/Curve.xml
@@ -78,7 +78,7 @@
<return type="void" />
<param index="0" name="index" type="int" />
<description>
- Removes the point at [code]index[/code] from the curve.
+ Removes the point at [param index] from the curve.
</description>
</method>
<method name="sample" qualifiers="const">
diff --git a/doc/classes/Curve2D.xml b/doc/classes/Curve2D.xml
index d545c144ab..abf71c5754 100644
--- a/doc/classes/Curve2D.xml
+++ b/doc/classes/Curve2D.xml
@@ -80,7 +80,7 @@
<return type="void" />
<param index="0" name="idx" type="int" />
<description>
- Deletes the point [code]idx[/code] from the curve. Sends an error to the console if [code]idx[/code] is out of bounds.
+ Deletes the point [param idx] from the curve. Sends an error to the console if [param idx] is out of bounds.
</description>
</method>
<method name="sample" qualifiers="const">
diff --git a/doc/classes/Curve3D.xml b/doc/classes/Curve3D.xml
index 4134df25dd..4d1f5a7180 100644
--- a/doc/classes/Curve3D.xml
+++ b/doc/classes/Curve3D.xml
@@ -100,7 +100,7 @@
<return type="void" />
<param index="0" name="idx" type="int" />
<description>
- Deletes the point [code]idx[/code] from the curve. Sends an error to the console if [code]idx[/code] is out of bounds.
+ Deletes the point [param idx] from the curve. Sends an error to the console if [param idx] is out of bounds.
</description>
</method>
<method name="sample" qualifiers="const">
diff --git a/doc/classes/CurveTexture.xml b/doc/classes/CurveTexture.xml
index 4dcdd9560a..7d530e45cf 100644
--- a/doc/classes/CurveTexture.xml
+++ b/doc/classes/CurveTexture.xml
@@ -15,7 +15,7 @@
</member>
<member name="resource_local_to_scene" type="bool" setter="set_local_to_scene" getter="is_local_to_scene" overrides="Resource" default="false" />
<member name="texture_mode" type="int" setter="set_texture_mode" getter="get_texture_mode" enum="CurveTexture.TextureMode" default="0">
- The format the texture should be generated with. When passing a CurveTexture as a input to a [Shader], this may need to be adjusted.
+ The format the texture should be generated with. When passing a CurveTexture as an input to a [Shader], this may need to be adjusted.
</member>
<member name="width" type="int" setter="set_width" getter="get_width" default="256">
The width of the texture (in pixels). Higher values make it possible to represent high-frequency data better (such as sudden direction changes), at the cost of increased generation time and memory usage.
diff --git a/doc/classes/Decal.xml b/doc/classes/Decal.xml
index b1ce4cef1a..ace1d026d4 100644
--- a/doc/classes/Decal.xml
+++ b/doc/classes/Decal.xml
@@ -107,7 +107,7 @@
<member name="texture_orm" type="Texture2D" setter="set_texture" getter="get_texture">
[Texture2D] storing ambient occlusion, roughness, and metallic for the decal. Use this to add extra detail to decals.
[b]Note:[/b] Unlike [BaseMaterial3D] whose filter mode can be adjusted on a per-material basis, the filter mode for [Decal] textures is set globally with [member ProjectSettings.rendering/textures/decals/filter].
- [b]Note:[/b] Setting this texture alone will not result in a visible decal, as [member texture_albedo] must also be set. To create a ORM-only decal, load an albedo texture into [member texture_albedo] and set [member albedo_mix] to [code]0.0[/code]. The albedo texture's alpha channel will be used to determine where the underlying surface's ORM map should be overridden (and its intensity).
+ [b]Note:[/b] Setting this texture alone will not result in a visible decal, as [member texture_albedo] must also be set. To create an ORM-only decal, load an albedo texture into [member texture_albedo] and set [member albedo_mix] to [code]0.0[/code]. The albedo texture's alpha channel will be used to determine where the underlying surface's ORM map should be overridden (and its intensity).
</member>
<member name="upper_fade" type="float" setter="set_upper_fade" getter="get_upper_fade" default="0.3">
Sets the curve over which the decal will fade as the surface gets further from the center of the [AABB]. Only positive values are valid (negative values will be clamped to [code]0.0[/code]). See also [member lower_fade].
diff --git a/doc/classes/DisplayServer.xml b/doc/classes/DisplayServer.xml
index 924e1d5d2f..513414e695 100644
--- a/doc/classes/DisplayServer.xml
+++ b/doc/classes/DisplayServer.xml
@@ -468,7 +468,7 @@
<param index="0" name="menu_root" type="String" />
<param index="1" name="idx" type="int" />
<description>
- Returns number of states of an multistate item. See [method global_menu_add_multistate_item] for details.
+ Returns number of states of a multistate item. See [method global_menu_add_multistate_item] for details.
[b]Note:[/b] This method is implemented on macOS.
</description>
</method>
@@ -477,7 +477,7 @@
<param index="0" name="menu_root" type="String" />
<param index="1" name="idx" type="int" />
<description>
- Returns the state of an multistate item. See [method global_menu_add_multistate_item] for details.
+ Returns the state of a multistate item. See [method global_menu_add_multistate_item] for details.
[b]Note:[/b] This method is implemented on macOS.
</description>
</method>
@@ -654,7 +654,7 @@
<param index="1" name="idx" type="int" />
<param index="2" name="max_states" type="int" />
<description>
- Sets number of state of an multistate item. See [method global_menu_add_multistate_item] for details.
+ Sets number of state of a multistate item. See [method global_menu_add_multistate_item] for details.
[b]Note:[/b] This method is implemented on macOS.
</description>
</method>
@@ -675,7 +675,7 @@
<param index="1" name="idx" type="int" />
<param index="2" name="state" type="int" />
<description>
- Sets the state of an multistate item. See [method global_menu_add_multistate_item] for details.
+ Sets the state of a multistate item. See [method global_menu_add_multistate_item] for details.
[b]Note:[/b] This method is implemented on macOS.
</description>
</method>
@@ -821,7 +821,7 @@
<method name="mouse_get_position" qualifiers="const">
<return type="Vector2i" />
<description>
- Returns the mouse cursor's current position.
+ Returns the mouse cursor's current position in screen coordinates.
</description>
</method>
<method name="mouse_set_mode">
@@ -1718,7 +1718,7 @@
[b]Note:[/b] Regardless of the platform, enabling full screen will change the window size to match the monitor's size. Therefore, make sure your project supports [url=$DOCS_URL/tutorials/rendering/multiple_resolutions.html]multiple resolutions[/url] when enabling full screen mode.
</constant>
<constant name="WINDOW_FLAG_RESIZE_DISABLED" value="0" enum="WindowFlags">
- The window can't be resizing by dragging its resize grip. It's still possible to resize the window using [method window_set_size]. This flag is ignored for full screen windows.
+ The window can't be resized by dragging its resize grip. It's still possible to resize the window using [method window_set_size]. This flag is ignored for full screen windows.
</constant>
<constant name="WINDOW_FLAG_BORDERLESS" value="1" enum="WindowFlags">
The window do not have native title bar and other decorations. This flag is ignored for full-screen windows.
diff --git a/doc/classes/EditorScript.xml b/doc/classes/EditorScript.xml
index ecaa21efb3..d77d11857b 100644
--- a/doc/classes/EditorScript.xml
+++ b/doc/classes/EditorScript.xml
@@ -48,13 +48,13 @@
[b]Warning:[/b] The implementation of this method is currently disabled.
</description>
</method>
- <method name="get_editor_interface">
+ <method name="get_editor_interface" qualifiers="const">
<return type="EditorInterface" />
<description>
Returns the [EditorInterface] singleton instance.
</description>
</method>
- <method name="get_scene">
+ <method name="get_scene" qualifiers="const">
<return type="Node" />
<description>
Returns the Editor's currently active scene.
diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml
index 14ef879f95..8c27c1bc06 100644
--- a/doc/classes/EditorSettings.xml
+++ b/doc/classes/EditorSettings.xml
@@ -295,7 +295,7 @@
If [code]true[/code], render the grid on an XZ plane.
</member>
<member name="editors/3d/grid_yz_plane" type="bool" setter="" getter="">
- If [code]true[/code], render the grid on an YZ plane. This can be useful for 3D side-scrolling games.
+ If [code]true[/code], render the grid on a YZ plane. This can be useful for 3D side-scrolling games.
</member>
<member name="editors/3d/navigation/emulate_3_button_mouse" type="bool" setter="" getter="">
If [code]true[/code], enables 3-button mouse emulation mode. This is useful on laptops when using a trackpad.
@@ -571,6 +571,9 @@
If [code]true[/code], editor main menu is using embedded [MenuBar] instead of system global menu.
Specific to the macOS platform.
</member>
+ <member name="interface/inspector/float_drag_speed" type="float" setter="" getter="">
+ Base speed for increasing/decreasing float values by dragging them in the inspector.
+ </member>
<member name="interface/inspector/max_array_dictionary_items_per_page" type="int" setter="" getter="">
The number of [Array] or [Dictionary] items to display on each "page" in the inspector. Higher values allow viewing more values per page, but take more time to load. This increased load time is noticeable when selecting nodes that have array or dictionary properties in the editor.
</member>
@@ -641,6 +644,10 @@
If [code]true[/code], increases the scrollbar touch area to improve usability on touchscreen devices.
[b]Note:[/b] Defaults to [code]true[/code] on touchscreen devices.
</member>
+ <member name="interface/touchscreen/scale_gizmo_handles" type="float" setter="" getter="">
+ Specify the multiplier to apply to the scale for the editor gizmo handles to improve usability on touchscreen devices.
+ [b]Note:[/b] Defaults to [code]1[/code] on non-touchscreen devices.
+ </member>
<member name="network/debug/remote_host" type="String" setter="" getter="">
The address to listen to when starting the remote debugger. This can be set to [code]0.0.0.0[/code] to allow external clients to connect to the remote debugger (instead of restricting the remote debugger to connections from [code]localhost[/code]).
</member>
@@ -701,7 +708,7 @@
If [code]true[/code], colors the background of the line the caret is currently on with [member text_editor/theme/highlighting/current_line_color].
</member>
<member name="text_editor/appearance/caret/type" type="int" setter="" getter="">
- The shape of the caret to use in the script editor. [b]Line[/b] displays a vertical line to the left of the current character, whereas [b]Block[/b] displays a outline over the current character.
+ The shape of the caret to use in the script editor. [b]Line[/b] displays a vertical line to the left of the current character, whereas [b]Block[/b] displays an outline over the current character.
</member>
<member name="text_editor/appearance/guidelines/line_length_guideline_hard_column" type="int" setter="" getter="">
The column at which to display a subtle line as a line length guideline for scripts. This should generally be greater than [member text_editor/appearance/guidelines/line_length_guideline_soft_column].
diff --git a/doc/classes/EditorVCSInterface.xml b/doc/classes/EditorVCSInterface.xml
index d5dc6abe81..031d2a50c3 100644
--- a/doc/classes/EditorVCSInterface.xml
+++ b/doc/classes/EditorVCSInterface.xml
@@ -13,21 +13,21 @@
<return type="bool" />
<param index="0" name="branch_name" type="String" />
<description>
- Checks out a [code]branch_name[/code] in the VCS.
+ Checks out a [param branch_name] in the VCS.
</description>
</method>
<method name="_commit" qualifiers="virtual">
<return type="void" />
<param index="0" name="msg" type="String" />
<description>
- Commits the currently staged changes and applies the commit [code]msg[/code] to the resulting commit.
+ Commits the currently staged changes and applies the commit [param msg] to the resulting commit.
</description>
</method>
<method name="_create_branch" qualifiers="virtual">
<return type="void" />
<param index="0" name="branch_name" type="String" />
<description>
- Creates a new branch named [code]branch_name[/code] in the VCS.
+ Creates a new branch named [param branch_name] in the VCS.
</description>
</method>
<method name="_create_remote" qualifiers="virtual">
@@ -35,21 +35,21 @@
<param index="0" name="remote_name" type="String" />
<param index="1" name="remote_url" type="String" />
<description>
- Creates a new remote destination with name [code]remote_name[/code] and points it to [code]remote_url[/code]. This can be an HTTPS remote or an SSH remote.
+ Creates a new remote destination with name [param remote_name] and points it to [param remote_url]. This can be an HTTPS remote or an SSH remote.
</description>
</method>
<method name="_discard_file" qualifiers="virtual">
<return type="void" />
<param index="0" name="file_path" type="String" />
<description>
- Discards the changes made in a file present at [code]file_path[/code].
+ Discards the changes made in a file present at [param file_path].
</description>
</method>
<method name="_fetch" qualifiers="virtual">
<return type="void" />
<param index="0" name="remote" type="String" />
<description>
- Fetches new changes from the remote, but doesn't write changes to the current working directory. Equivalent to [code]git fetch[/code].
+ Fetches new changes from the [param remote], but doesn't write changes to the current working directory. Equivalent to [code]git fetch[/code].
</description>
</method>
<method name="_get_branch_list" qualifiers="virtual">
@@ -69,7 +69,7 @@
<param index="0" name="identifier" type="String" />
<param index="1" name="area" type="int" />
<description>
- Returns an array of [Dictionary] items (see [method create_diff_file], [method create_diff_hunk], [method create_diff_line], [method add_line_diffs_into_diff_hunk] and [method add_diff_hunks_into_diff_file]), each containing information about a diff. If [code]identifier[/code] is a file path, returns a file diff, and if it is a commit identifier, then returns a commit diff.
+ Returns an array of [Dictionary] items (see [method create_diff_file], [method create_diff_hunk], [method create_diff_line], [method add_line_diffs_into_diff_hunk] and [method add_diff_hunks_into_diff_file]), each containing information about a diff. If [param identifier] is a file path, returns a file diff, and if it is a commit identifier, then returns a commit diff.
</description>
</method>
<method name="_get_line_diff" qualifiers="virtual">
@@ -77,7 +77,7 @@
<param index="0" name="file_path" type="String" />
<param index="1" name="text" type="String" />
<description>
- Returns an [Array] of [Dictionary] items (see [method create_diff_hunk]), each containing a line diff between a file at [code]file_path[/code] and the [code]text[/code] which is passed in.
+ Returns an [Array] of [Dictionary] items (see [method create_diff_hunk]), each containing a line diff between a file at [param file_path] and the [param text] which is passed in.
</description>
</method>
<method name="_get_modified_files_data" qualifiers="virtual">
@@ -109,7 +109,7 @@
<return type="bool" />
<param index="0" name="project_path" type="String" />
<description>
- Initializes the VCS plugin when called from the editor. Returns whether or not the plugin was successfully initialized. A VCS project is initialized at [code]project_path[/code].
+ Initializes the VCS plugin when called from the editor. Returns whether or not the plugin was successfully initialized. A VCS project is initialized at [param project_path].
</description>
</method>
<method name="_pull" qualifiers="virtual">
@@ -149,7 +149,7 @@
<param index="3" name="ssh_private_key_path" type="String" />
<param index="4" name="ssh_passphrase" type="String" />
<description>
- Set user credentials in the underlying VCS. [code]username[/code] and [code]password[/code] are used only during HTTPS authentication unless not already mentioned in the remote URL. [code]ssh_public_key_path[/code], [code]ssh_private_key_path[/code], and [code]ssh_passphrase[/code] are only used during SSH authentication.
+ Set user credentials in the underlying VCS. [param username] and [param password] are used only during HTTPS authentication unless not already mentioned in the remote URL. [param ssh_public_key_path], [param ssh_private_key_path], and [param ssh_passphrase] are only used during SSH authentication.
</description>
</method>
<method name="_shut_down" qualifiers="virtual">
@@ -162,14 +162,14 @@
<return type="void" />
<param index="0" name="file_path" type="String" />
<description>
- Stages the file present at [code]file_path[/code] to the staged area.
+ Stages the file present at [param file_path] to the staged area.
</description>
</method>
<method name="_unstage_file" qualifiers="virtual">
<return type="void" />
<param index="0" name="file_path" type="String" />
<description>
- Unstages the file present at [code]file_path[/code] from the staged area to the unstaged area.
+ Unstages the file present at [param file_path] from the staged area to the unstaged area.
</description>
</method>
<method name="add_diff_hunks_into_diff_file">
@@ -177,7 +177,7 @@
<param index="0" name="diff_file" type="Dictionary" />
<param index="1" name="diff_hunks" type="Dictionary[]" />
<description>
- Helper function to add an array of [code]diff_hunks[/code] into a [code]diff_file[/code].
+ Helper function to add an array of [param diff_hunks] into a [param diff_file].
</description>
</method>
<method name="add_line_diffs_into_diff_hunk">
@@ -185,7 +185,7 @@
<param index="0" name="diff_hunk" type="Dictionary" />
<param index="1" name="line_diffs" type="Dictionary[]" />
<description>
- Helper function to add an array of [code]line_diffs[/code] into a [code]diff_hunk[/code].
+ Helper function to add an array of [param line_diffs] into a [param diff_hunk].
</description>
</method>
<method name="create_commit">
@@ -196,7 +196,7 @@
<param index="3" name="unix_timestamp" type="int" />
<param index="4" name="offset_minutes" type="int" />
<description>
- Helper function to create a commit [Dictionary] item. [code]msg[/code] is the commit message of the commit. [code]author[/code] is a single human-readable string containing all the author's details, e.g. the email and name configured in the VCS. [code]id[/code] is the identifier of the commit, in whichever format your VCS may provide an identifier to commits. [code]unix_timestamp[/code] is the UTC Unix timestamp of when the commit was created. [code]offset_minutes[/code] is the timezone offset in minutes, recorded from the system timezone where the commit was created.
+ Helper function to create a commit [Dictionary] item. [param msg] is the commit message of the commit. [param author] is a single human-readable string containing all the author's details, e.g. the email and name configured in the VCS. [param id] is the identifier of the commit, in whichever format your VCS may provide an identifier to commits. [param unix_timestamp] is the UTC Unix timestamp of when the commit was created. [param offset_minutes] is the timezone offset in minutes, recorded from the system timezone where the commit was created.
</description>
</method>
<method name="create_diff_file">
@@ -204,7 +204,7 @@
<param index="0" name="new_file" type="String" />
<param index="1" name="old_file" type="String" />
<description>
- Helper function to create a [code]Dictionary[/code] for storing old and new diff file paths.
+ Helper function to create a [Dictionary] for storing old and new diff file paths.
</description>
</method>
<method name="create_diff_hunk">
@@ -214,7 +214,7 @@
<param index="2" name="old_lines" type="int" />
<param index="3" name="new_lines" type="int" />
<description>
- Helper function to create a [code]Dictionary[/code] for storing diff hunk data. [code]old_start[/code] is the starting line number in old file. [code]new_start[/code] is the starting line number in new file. [code]old_lines[/code] is the number of lines in the old file. [code]new_lines[/code] is the number of lines in the new file.
+ Helper function to create a [Dictionary] for storing diff hunk data. [param old_start] is the starting line number in old file. [param new_start] is the starting line number in new file. [param old_lines] is the number of lines in the old file. [param new_lines] is the number of lines in the new file.
</description>
</method>
<method name="create_diff_line">
@@ -224,7 +224,7 @@
<param index="2" name="content" type="String" />
<param index="3" name="status" type="String" />
<description>
- Helper function to create a [code]Dictionary[/code] for storing a line diff. [code]new_line_no[/code] is the line number in the new file (can be [code]-1[/code] if the line is deleted). [code]old_line_no[/code] is the line number in the old file (can be [code]-1[/code] if the line is added). [code]content[/code] is the diff text. [code]status[/code] is a single character string which stores the line origin.
+ Helper function to create a [Dictionary] for storing a line diff. [param new_line_no] is the line number in the new file (can be [code]-1[/code] if the line is deleted). [param old_line_no] is the line number in the old file (can be [code]-1[/code] if the line is added). [param content] is the diff text. [param status] is a single character string which stores the line origin.
</description>
</method>
<method name="create_status_file">
@@ -233,7 +233,7 @@
<param index="1" name="change_type" type="int" enum="EditorVCSInterface.ChangeType" />
<param index="2" name="area" type="int" enum="EditorVCSInterface.TreeArea" />
<description>
- Helper function to create a [code]Dictionary[/code] used by editor to read the status of a file.
+ Helper function to create a [Dictionary] used by editor to read the status of a file.
</description>
</method>
<method name="popup_error">
diff --git a/doc/classes/Engine.xml b/doc/classes/Engine.xml
index 9ea59010cc..aa15f88afa 100644
--- a/doc/classes/Engine.xml
+++ b/doc/classes/Engine.xml
@@ -306,7 +306,7 @@
[b]Note:[/b] This property does not impact the editor's Errors tab when running a project from the editor.
</member>
<member name="time_scale" type="float" setter="set_time_scale" getter="get_time_scale" default="1.0">
- Controls how fast or slow the in-game clock ticks versus the real life one. It defaults to 1.0. A value of 2.0 means the game moves twice as fast as real life, whilst a value of 0.5 means the game moves at half the regular speed.
+ Controls how fast or slow the in-game clock ticks versus the real life one. It defaults to 1.0. A value of 2.0 means the game moves twice as fast as real life, whilst a value of 0.5 means the game moves at half the regular speed. This also affects [Timer] and [SceneTreeTimer] (see [method SceneTree.create_timer] for how to control this).
</member>
</members>
</class>
diff --git a/doc/classes/EngineDebugger.xml b/doc/classes/EngineDebugger.xml
index f8ca5326a0..45317be394 100644
--- a/doc/classes/EngineDebugger.xml
+++ b/doc/classes/EngineDebugger.xml
@@ -50,7 +50,7 @@
<param index="1" name="enable" type="bool" />
<param index="2" name="arguments" type="Array" default="[]" />
<description>
- Calls the [code]toggle[/code] callable of the profiler with given [param name] and [param arguments]. Enables/Disables the same profiler depending on [code]enable[/code] argument.
+ Calls the [code]toggle[/code] callable of the profiler with given [param name] and [param arguments]. Enables/Disables the same profiler depending on [param enable] argument.
</description>
</method>
<method name="register_message_capture">
diff --git a/doc/classes/Expression.xml b/doc/classes/Expression.xml
index 0796e837b2..ff04440a04 100644
--- a/doc/classes/Expression.xml
+++ b/doc/classes/Expression.xml
@@ -49,6 +49,7 @@
[/codeblocks]
</description>
<tutorials>
+ <link title="Evaluating Expressions">$DOCS_URL/tutorials/scripting/evaluating_expressions.html</link>
</tutorials>
<methods>
<method name="execute">
diff --git a/doc/classes/FileAccess.xml b/doc/classes/FileAccess.xml
index fb84943eb4..d1ee90142e 100644
--- a/doc/classes/FileAccess.xml
+++ b/doc/classes/FileAccess.xml
@@ -204,7 +204,7 @@
<return type="int" />
<param index="0" name="file" type="String" />
<description>
- Returns the last time the [param file] was modified in Unix timestamp format or returns a [String] "ERROR IN [code]file[/code]". This Unix timestamp can be converted to another format using the [Time] singleton.
+ Returns the last time the [param file] was modified in Unix timestamp format or returns a [String] "ERROR IN [param file]". This Unix timestamp can be converted to another format using the [Time] singleton.
</description>
</method>
<method name="get_open_error" qualifiers="static">
@@ -492,5 +492,8 @@
<constant name="COMPRESSION_GZIP" value="3" enum="CompressionMode">
Uses the [url=https://www.gzip.org/]gzip[/url] compression method.
</constant>
+ <constant name="COMPRESSION_BROTLI" value="4" enum="CompressionMode">
+ Uses the [url=https://github.com/google/brotli]brotli[/url] compression method (only decompression is supported).
+ </constant>
</constants>
</class>
diff --git a/doc/classes/FontFile.xml b/doc/classes/FontFile.xml
index ed9906186c..4993d0dc42 100644
--- a/doc/classes/FontFile.xml
+++ b/doc/classes/FontFile.xml
@@ -12,7 +12,7 @@
- Bitmap font importer: AngelCode BMFont (.fnt, .font), text and binary (version 3) format variants.
- Monospace image font importer: All supported image formats.
[b]Note:[/b] A character is a symbol that represents an item (letter, digit etc.) in an abstract way.
- [b]Note:[/b] A glyph is a bitmap or shape used to draw a one or more characters in a context-dependent manner. Glyph indices are bound to the specific font data source.
+ [b]Note:[/b] A glyph is a bitmap or shape used to draw one or more characters in a context-dependent manner. Glyph indices are bound to the specific font data source.
[b]Note:[/b] If a none of the font data sources contain glyphs for a character used in a string, the character in question will be replaced with a box displaying its hexadecimal code.
[codeblocks]
[gdscript]
diff --git a/doc/classes/GPUParticlesCollisionHeightField3D.xml b/doc/classes/GPUParticlesCollisionHeightField3D.xml
index 99ed5e7062..4c55aa225c 100644
--- a/doc/classes/GPUParticlesCollisionHeightField3D.xml
+++ b/doc/classes/GPUParticlesCollisionHeightField3D.xml
@@ -50,7 +50,7 @@
Represents the size of the [enum Resolution] enum.
</constant>
<constant name="UPDATE_MODE_WHEN_MOVED" value="0" enum="UpdateMode">
- Only update the heightmap when the [GPUParticlesCollisionHeightField3D] node is moved, or when the camera moves if [member follow_camera_enabled] is [code]true[/code]. An update can be forced by slightly moving the [GPUParticlesCollisionHeightField3D] in any direction.
+ Only update the heightmap when the [GPUParticlesCollisionHeightField3D] node is moved, or when the camera moves if [member follow_camera_enabled] is [code]true[/code]. An update can be forced by slightly moving the [GPUParticlesCollisionHeightField3D] in any direction, or by calling [method RenderingServer.particles_collision_height_field_update].
</constant>
<constant name="UPDATE_MODE_ALWAYS" value="1" enum="UpdateMode">
Update the heightmap every frame. This has a significant performance cost. This update should only be used when geometry that particles can collide with changes significantly during gameplay.
diff --git a/doc/classes/GeometryInstance3D.xml b/doc/classes/GeometryInstance3D.xml
index 14945922c6..edf2f9e18a 100644
--- a/doc/classes/GeometryInstance3D.xml
+++ b/doc/classes/GeometryInstance3D.xml
@@ -33,7 +33,7 @@
The selected shadow casting flag. See [enum ShadowCastingSetting] for possible values.
</member>
<member name="custom_aabb" type="AABB" setter="set_custom_aabb" getter="get_custom_aabb" default="AABB(0, 0, 0, 0, 0, 0)">
- Overrides the bounding box of this node with a custom one. This can be used to avoid the expensive [AABB] recalculation that happens when a skeleton is used with a [MeshInstance3D] or to have fine control over the [MeshInstance3D]'s bounding box. To remove this, set value to an [AABB] with all fields set to zero.
+ Overrides the bounding box of this node with a custom one. This can be used to avoid the expensive [AABB] recalculation that happens when a skeleton is used with a [MeshInstance3D] or to have fine control over the [MeshInstance3D]'s bounding box. To use the default AABB, set value to an [AABB] with all fields set to [code]0.0[/code]. To avoid frustum culling, set [member custom_aabb] to a very large AABB that covers your entire game world such as [code]AABB(-10000, -10000, -10000, 20000, 20000, 20000)[/code]. To disable all forms of culling (including occlusion culling), call [method RenderingServer.instance_set_ignore_culling] on the [GeometryInstance3D]'s [RID].
</member>
<member name="extra_cull_margin" type="float" setter="set_extra_cull_margin" getter="get_extra_cull_margin" default="0.0">
The extra distance added to the GeometryInstance3D's bounding box ([AABB]) to increase its cull box.
@@ -47,6 +47,7 @@
</member>
<member name="ignore_occlusion_culling" type="bool" setter="set_ignore_occlusion_culling" getter="is_ignoring_occlusion_culling" default="false">
If [code]true[/code], disables occlusion culling for this instance. Useful for gizmos that must be rendered even when occlusion culling is in use.
+ [b]Note:[/b] [member ignore_occlusion_culling] does not affect frustum culling (which is what happens when an object is not visible given the camera's angle). To avoid frustum culling, set [member custom_aabb] to a very large AABB that covers your entire game world such as [code]AABB(-10000, -10000, -10000, 20000, 20000, 20000)[/code].
</member>
<member name="lod_bias" type="float" setter="set_lod_bias" getter="get_lod_bias" default="1.0">
Changes how quickly the mesh transitions to a lower level of detail. A value of 0 will force the mesh to its lowest level of detail, a value of 1 will use the default settings, and larger values will keep the mesh in a higher level of detail at farther distances.
@@ -70,14 +71,14 @@
</member>
<member name="visibility_range_begin_margin" type="float" setter="set_visibility_range_begin_margin" getter="get_visibility_range_begin_margin" default="0.0">
Margin for the [member visibility_range_begin] threshold. The GeometryInstance3D will only change its visibility state when it goes over or under the [member visibility_range_begin] threshold by this amount.
- If [member visibility_range_fade_mode] is [constant VISIBILITY_RANGE_FADE_DISABLED], this acts as an hysteresis distance. If [member visibility_range_fade_mode] is [constant VISIBILITY_RANGE_FADE_SELF] or [constant VISIBILITY_RANGE_FADE_DEPENDENCIES], this acts as a fade transition distance and must be set to a value greater than [code]0.0[/code] for the effect to be noticeable.
+ If [member visibility_range_fade_mode] is [constant VISIBILITY_RANGE_FADE_DISABLED], this acts as a hysteresis distance. If [member visibility_range_fade_mode] is [constant VISIBILITY_RANGE_FADE_SELF] or [constant VISIBILITY_RANGE_FADE_DEPENDENCIES], this acts as a fade transition distance and must be set to a value greater than [code]0.0[/code] for the effect to be noticeable.
</member>
<member name="visibility_range_end" type="float" setter="set_visibility_range_end" getter="get_visibility_range_end" default="0.0">
Distance from which the GeometryInstance3D will be hidden, taking [member visibility_range_end_margin] into account as well. The default value of 0 is used to disable the range check.
</member>
<member name="visibility_range_end_margin" type="float" setter="set_visibility_range_end_margin" getter="get_visibility_range_end_margin" default="0.0">
Margin for the [member visibility_range_end] threshold. The GeometryInstance3D will only change its visibility state when it goes over or under the [member visibility_range_end] threshold by this amount.
- If [member visibility_range_fade_mode] is [constant VISIBILITY_RANGE_FADE_DISABLED], this acts as an hysteresis distance. If [member visibility_range_fade_mode] is [constant VISIBILITY_RANGE_FADE_SELF] or [constant VISIBILITY_RANGE_FADE_DEPENDENCIES], this acts as a fade transition distance and must be set to a value greater than [code]0.0[/code] for the effect to be noticeable.
+ If [member visibility_range_fade_mode] is [constant VISIBILITY_RANGE_FADE_DISABLED], this acts as a hysteresis distance. If [member visibility_range_fade_mode] is [constant VISIBILITY_RANGE_FADE_SELF] or [constant VISIBILITY_RANGE_FADE_DEPENDENCIES], this acts as a fade transition distance and must be set to a value greater than [code]0.0[/code] for the effect to be noticeable.
</member>
<member name="visibility_range_fade_mode" type="int" setter="set_visibility_range_fade_mode" getter="get_visibility_range_fade_mode" enum="GeometryInstance3D.VisibilityRangeFadeMode" default="0">
Controls which instances will be faded when approaching the limits of the visibility range. See [enum VisibilityRangeFadeMode] for possible values.
diff --git a/doc/classes/Gradient.xml b/doc/classes/Gradient.xml
index 6026467b06..aa941f9fd3 100644
--- a/doc/classes/Gradient.xml
+++ b/doc/classes/Gradient.xml
@@ -49,13 +49,14 @@
<return type="void" />
<description>
Reverses/mirrors the gradient.
+ [b]Note:[/b] This method mirrors all points around the middle of the gradient, which may produce unexpected results when [member interpolation_mode] is set to [constant GRADIENT_INTERPOLATE_CONSTANT].
</description>
</method>
<method name="sample">
<return type="Color" />
<param index="0" name="offset" type="float" />
<description>
- Returns the interpolated color specified by [code]offset[/code].
+ Returns the interpolated color specified by [param offset].
</description>
</method>
<method name="set_color">
diff --git a/doc/classes/HSlider.xml b/doc/classes/HSlider.xml
index 5e11c1c3ab..2ab66a2e75 100644
--- a/doc/classes/HSlider.xml
+++ b/doc/classes/HSlider.xml
@@ -10,6 +10,9 @@
<tutorials>
</tutorials>
<theme_items>
+ <theme_item name="center_grabber" data_type="constant" type="int" default="0">
+ Boolean constant. If [code]1[/code], the grabber texture size will be ignored and it will fit within slider's bounds based only on its center position.
+ </theme_item>
<theme_item name="grabber_offset" data_type="constant" type="int" default="0">
Vertical offset of the grabber.
</theme_item>
diff --git a/doc/classes/ImageTexture3D.xml b/doc/classes/ImageTexture3D.xml
index ebfd38c3f4..4396039ab2 100644
--- a/doc/classes/ImageTexture3D.xml
+++ b/doc/classes/ImageTexture3D.xml
@@ -26,7 +26,7 @@
<return type="void" />
<param index="0" name="data" type="Image[]" />
<description>
- Replaces the texture's existing data with the layers specified in [code]data[/code]. The size of [code]data[/code] must match the parameters that were used for [method create]. In other words, the texture cannot be resized or have its format changed by calling [method update].
+ Replaces the texture's existing data with the layers specified in [param data]. The size of [param data] must match the parameters that were used for [method create]. In other words, the texture cannot be resized or have its format changed by calling [method update].
</description>
</method>
</methods>
diff --git a/doc/classes/ImageTextureLayered.xml b/doc/classes/ImageTextureLayered.xml
index 7f17c8e897..215ff6ac5d 100644
--- a/doc/classes/ImageTextureLayered.xml
+++ b/doc/classes/ImageTextureLayered.xml
@@ -22,7 +22,7 @@
<param index="0" name="image" type="Image" />
<param index="1" name="layer" type="int" />
<description>
- Replaces the existing [Image] data at the given [code]layer[/code] with this new image.
+ Replaces the existing [Image] data at the given [param layer] with this new image.
The given [Image] must have the same width, height, image format and mipmapping setting (a [code]bool[/code] value) as the rest of the referenced images.
If the image format is unsupported, it will be decompressed and converted to a similar and supported [enum Image.Format].
The update is immediate: it's synchronized with drawing.
diff --git a/doc/classes/ImmediateMesh.xml b/doc/classes/ImmediateMesh.xml
index 504076e3fe..cd6cb32d3e 100644
--- a/doc/classes/ImmediateMesh.xml
+++ b/doc/classes/ImmediateMesh.xml
@@ -4,9 +4,20 @@
Mesh optimized for creating geometry manually.
</brief_description>
<description>
- Mesh optimized for creating geometry manually, similar to OpenGL1.x immediate mode.
+ A mesh type optimized for creating geometry manually, similar to OpenGL 1.x immediate mode.
+ Here's a sample on how to generate a triangular face:
+ [codeblocks]
+ var mesh = ImmediateMesh.new()
+ mesh.surface_begin(Mesh.PRIMITIVE_TRIANGLES)
+ mesh.surface_add_vertex(Vector3.LEFT)
+ mesh.surface_add_vertex(Vector3.FORWARD)
+ mesh.surface_add_vertex(Vector3.ZERO)
+ mesh.surface_end()
+ [/codeblocks]
+ [b]Note:[/b] Generating complex geometries with [ImmediateMesh] is highly inefficient. Instead, it is designed to generate simple geometry that changes often.
</description>
<tutorials>
+ <link title="Using ImmediateMesh">$DOCS_URL/tutorials/3d/procedural_geometry/immediatemesh.html</link>
</tutorials>
<methods>
<method name="clear_surfaces">
diff --git a/doc/classes/ItemList.xml b/doc/classes/ItemList.xml
index f5da4553d0..2da5ad3cac 100644
--- a/doc/classes/ItemList.xml
+++ b/doc/classes/ItemList.xml
@@ -341,6 +341,9 @@
<member name="allow_rmb_select" type="bool" setter="set_allow_rmb_select" getter="get_allow_rmb_select" default="false">
If [code]true[/code], right mouse button click can select items.
</member>
+ <member name="allow_search" type="bool" setter="set_allow_search" getter="get_allow_search" default="true">
+ If [code]true[/code], allows navigating the [ItemList] with letter keys through incremental search.
+ </member>
<member name="auto_height" type="bool" setter="set_auto_height" getter="has_auto_height" default="false">
If [code]true[/code], the control will automatically resize the height to fit its content.
</member>
diff --git a/doc/classes/Light3D.xml b/doc/classes/Light3D.xml
index 59549cecb8..26b97edc25 100644
--- a/doc/classes/Light3D.xml
+++ b/doc/classes/Light3D.xml
@@ -204,7 +204,7 @@
Light is taken into account in static baking ([VoxelGI], [LightmapGI], SDFGI ([member Environment.sdfgi_enabled])). The light can be moved around or modified, but its global illumination will not update in real-time. This is suitable for subtle changes (such as flickering torches), but generally not large changes such as toggling a light on and off.
</constant>
<constant name="BAKE_DYNAMIC" value="2" enum="BakeMode">
- Light is taken into account in dynamic baking ([VoxelGI] and SDFGI ([member Environment.sdfgi_enabled]) only). The light can be moved around or modified with global illumination updating in real-time. The light's global illumination appearance will be slightly different compared to [constant BAKE_STATIC]. This has a greater performance cost compared to [constant BAKE_STATIC].
+ Light is taken into account in dynamic baking ([VoxelGI] and SDFGI ([member Environment.sdfgi_enabled]) only). The light can be moved around or modified with global illumination updating in real-time. The light's global illumination appearance will be slightly different compared to [constant BAKE_STATIC]. This has a greater performance cost compared to [constant BAKE_STATIC]. When using SDFGI, the update speed of dynamic lights is affected by [member ProjectSettings.rendering/global_illumination/sdfgi/frames_to_update_lights].
</constant>
</constants>
</class>
diff --git a/doc/classes/LineEdit.xml b/doc/classes/LineEdit.xml
index f63243e8d4..d040c51bb0 100644
--- a/doc/classes/LineEdit.xml
+++ b/doc/classes/LineEdit.xml
@@ -203,7 +203,7 @@
[b]Note:[/b] [kbd]Backspace[/kbd] is always removing individual composite character components.
</member>
<member name="clear_button_enabled" type="bool" setter="set_clear_button_enabled" getter="is_clear_button_enabled" default="false">
- If [code]true[/code], the [LineEdit] will show a clear button if [code]text[/code] is not empty, which can be used to clear the text quickly.
+ If [code]true[/code], the [LineEdit] will show a clear button if [member text] is not empty, which can be used to clear the text quickly.
</member>
<member name="context_menu_enabled" type="bool" setter="set_context_menu_enabled" getter="is_context_menu_enabled" default="true">
If [code]true[/code], the context menu will appear when right-clicked.
@@ -302,7 +302,7 @@
<signal name="text_change_rejected">
<param index="0" name="rejected_substring" type="String" />
<description>
- Emitted when appending text that overflows the [member max_length]. The appended text is truncated to fit [member max_length], and the part that couldn't fit is passed as the [code]rejected_substring[/code] argument.
+ Emitted when appending text that overflows the [member max_length]. The appended text is truncated to fit [member max_length], and the part that couldn't fit is passed as the [param rejected_substring] argument.
</description>
</signal>
<signal name="text_changed">
@@ -487,7 +487,7 @@
Texture for the clear button. See [member clear_button_enabled].
</theme_item>
<theme_item name="focus" data_type="style" type="StyleBox">
- Background used when [LineEdit] has GUI focus. The [code]focus[/code] [StyleBox] is displayed [i]over[/i] the base [StyleBox], so a partially transparent [StyleBox] should be used to ensure the base [StyleBox] remains visible. A [StyleBox] that represents an outline or an underline works well for this purpose. To disable the focus visual effect, assign a [StyleBoxEmpty] resource. Note that disabling the focus visual effect will harm keyboard/controller navigation usability, so this is not recommended for accessibility reasons.
+ Background used when [LineEdit] has GUI focus. The [theme_item focus] [StyleBox] is displayed [i]over[/i] the base [StyleBox], so a partially transparent [StyleBox] should be used to ensure the base [StyleBox] remains visible. A [StyleBox] that represents an outline or an underline works well for this purpose. To disable the focus visual effect, assign a [StyleBoxEmpty] resource. Note that disabling the focus visual effect will harm keyboard/controller navigation usability, so this is not recommended for accessibility reasons.
</theme_item>
<theme_item name="normal" data_type="style" type="StyleBox">
Default background for the [LineEdit].
diff --git a/doc/classes/Marker2D.xml b/doc/classes/Marker2D.xml
index e4498663fb..16342669c8 100644
--- a/doc/classes/Marker2D.xml
+++ b/doc/classes/Marker2D.xml
@@ -4,7 +4,7 @@
Generic 2D position hint for editing.
</brief_description>
<description>
- Generic 2D position hint for editing. It's just like a plain [Node2D], but it displays as a cross in the 2D editor at all times. You can set cross' visual size by using the gizmo in the 2D editor while the node is selected.
+ Generic 2D position hint for editing. It's just like a plain [Node2D], but it displays as a cross in the 2D editor at all times. You can set the cross' visual size by using the gizmo in the 2D editor while the node is selected.
</description>
<tutorials>
</tutorials>
diff --git a/doc/classes/MeshDataTool.xml b/doc/classes/MeshDataTool.xml
index 1362949a44..3b208f1fb7 100644
--- a/doc/classes/MeshDataTool.xml
+++ b/doc/classes/MeshDataTool.xml
@@ -19,7 +19,7 @@
vertex += mdt.get_vertex_normal(i)
# Save your change.
mdt.set_vertex(i, vertex)
- mesh.surface_remove(0)
+ mesh.clear_surfaces()
mdt.commit_to_surface(mesh)
var mi = MeshInstance.new()
mi.mesh = mesh
@@ -38,7 +38,7 @@
// Save your change.
mdt.SetVertex(i, vertex);
}
- mesh.SurfaceRemove(0);
+ mesh.ClearSurfaces();
mdt.CommitToSurface(mesh);
var mi = new MeshInstance();
mi.Mesh = mesh;
diff --git a/doc/classes/NavigationLink2D.xml b/doc/classes/NavigationLink2D.xml
index 39509e10b7..a08f65da3c 100644
--- a/doc/classes/NavigationLink2D.xml
+++ b/doc/classes/NavigationLink2D.xml
@@ -26,7 +26,7 @@
<return type="bool" />
<param index="0" name="layer_number" type="int" />
<description>
- Returns whether or not the specified layer of the [member navigation_layers] bitmask is enabled, given a [code]layer_number[/code] between 1 and 32.
+ Returns whether or not the specified layer of the [member navigation_layers] bitmask is enabled, given a [param layer_number] between 1 and 32.
</description>
</method>
<method name="set_global_end_position">
@@ -48,7 +48,7 @@
<param index="0" name="layer_number" type="int" />
<param index="1" name="value" type="bool" />
<description>
- Based on [code]value[/code], enables or disables the specified layer in the [member navigation_layers] bitmask, given a [code]layer_number[/code] between 1 and 32.
+ Based on [param value], enables or disables the specified layer in the [member navigation_layers] bitmask, given a [param layer_number] between 1 and 32.
</description>
</method>
</methods>
@@ -65,7 +65,7 @@
The distance the link will search is controlled by [method NavigationServer2D.map_set_link_connection_radius].
</member>
<member name="enter_cost" type="float" setter="set_enter_cost" getter="get_enter_cost" default="0.0">
- When pathfinding enters this link from another regions navigation mesh the [code]enter_cost[/code] value is added to the path distance for determining the shortest path.
+ When pathfinding enters this link from another regions navigation mesh the [member enter_cost] value is added to the path distance for determining the shortest path.
</member>
<member name="navigation_layers" type="int" setter="set_navigation_layers" getter="get_navigation_layers" default="1">
A bitfield determining all navigation layers the link belongs to. These navigation layers will be checked when requesting a path with [method NavigationServer2D.map_get_path].
@@ -76,7 +76,7 @@
The distance the link will search is controlled by [method NavigationServer2D.map_set_link_connection_radius].
</member>
<member name="travel_cost" type="float" setter="set_travel_cost" getter="get_travel_cost" default="1.0">
- When pathfinding moves along the link the traveled distance is multiplied with [code]travel_cost[/code] for determining the shortest path.
+ When pathfinding moves along the link the traveled distance is multiplied with [member travel_cost] for determining the shortest path.
</member>
</members>
</class>
diff --git a/doc/classes/NavigationLink3D.xml b/doc/classes/NavigationLink3D.xml
index 49fdc774cd..70dfee9c10 100644
--- a/doc/classes/NavigationLink3D.xml
+++ b/doc/classes/NavigationLink3D.xml
@@ -26,7 +26,7 @@
<return type="bool" />
<param index="0" name="layer_number" type="int" />
<description>
- Returns whether or not the specified layer of the [member navigation_layers] bitmask is enabled, given a [code]layer_number[/code] between 1 and 32.
+ Returns whether or not the specified layer of the [member navigation_layers] bitmask is enabled, given a [param layer_number] between 1 and 32.
</description>
</method>
<method name="set_global_end_position">
@@ -48,7 +48,7 @@
<param index="0" name="layer_number" type="int" />
<param index="1" name="value" type="bool" />
<description>
- Based on [code]value[/code], enables or disables the specified layer in the [member navigation_layers] bitmask, given a [code]layer_number[/code] between 1 and 32.
+ Based on [param value], enables or disables the specified layer in the [member navigation_layers] bitmask, given a [param layer_number] between 1 and 32.
</description>
</method>
</methods>
@@ -65,7 +65,7 @@
The distance the link will search is controlled by [method NavigationServer3D.map_set_link_connection_radius].
</member>
<member name="enter_cost" type="float" setter="set_enter_cost" getter="get_enter_cost" default="0.0">
- When pathfinding enters this link from another regions navigation mesh the [code]enter_cost[/code] value is added to the path distance for determining the shortest path.
+ When pathfinding enters this link from another regions navigation mesh the [member enter_cost] value is added to the path distance for determining the shortest path.
</member>
<member name="navigation_layers" type="int" setter="set_navigation_layers" getter="get_navigation_layers" default="1">
A bitfield determining all navigation layers the link belongs to. These navigation layers will be checked when requesting a path with [method NavigationServer3D.map_get_path].
@@ -76,7 +76,7 @@
The distance the link will search is controlled by [method NavigationServer3D.map_set_link_connection_radius].
</member>
<member name="travel_cost" type="float" setter="set_travel_cost" getter="get_travel_cost" default="1.0">
- When pathfinding moves along the link the traveled distance is multiplied with [code]travel_cost[/code] for determining the shortest path.
+ When pathfinding moves along the link the traveled distance is multiplied with [member travel_cost] for determining the shortest path.
</member>
</members>
</class>
diff --git a/doc/classes/NavigationServer2D.xml b/doc/classes/NavigationServer2D.xml
index 75d648c540..e96f3dc7e4 100644
--- a/doc/classes/NavigationServer2D.xml
+++ b/doc/classes/NavigationServer2D.xml
@@ -148,7 +148,7 @@
<return type="Vector2" />
<param index="0" name="link" type="RID" />
<description>
- Returns the ending position of this [code]link[/code].
+ Returns the ending position of this [param link].
</description>
</method>
<method name="link_get_enter_cost" qualifiers="const">
@@ -162,14 +162,14 @@
<return type="RID" />
<param index="0" name="link" type="RID" />
<description>
- Returns the navigation map [RID] the requested [code]link[/code] is currently assigned to.
+ Returns the navigation map [RID] the requested [param link] is currently assigned to.
</description>
</method>
<method name="link_get_navigation_layers" qualifiers="const">
<return type="int" />
<param index="0" name="link" type="RID" />
<description>
- Returns the navigation layers for this [code]link[/code].
+ Returns the navigation layers for this [param link].
</description>
</method>
<method name="link_get_owner_id" qualifiers="const">
@@ -183,7 +183,7 @@
<return type="Vector2" />
<param index="0" name="link" type="RID" />
<description>
- Returns the starting position of this [code]link[/code].
+ Returns the starting position of this [param link].
</description>
</method>
<method name="link_get_travel_cost" qualifiers="const">
@@ -197,7 +197,7 @@
<return type="bool" />
<param index="0" name="link" type="RID" />
<description>
- Returns whether this [code]link[/code] can be travelled in both directions.
+ Returns whether this [param link] can be travelled in both directions.
</description>
</method>
<method name="link_set_bidirectional">
@@ -205,7 +205,7 @@
<param index="0" name="link" type="RID" />
<param index="1" name="bidirectional" type="bool" />
<description>
- Sets whether this [code]link[/code] can be travelled in both directions.
+ Sets whether this [param link] can be travelled in both directions.
</description>
</method>
<method name="link_set_end_position">
@@ -213,7 +213,7 @@
<param index="0" name="link" type="RID" />
<param index="1" name="position" type="Vector2" />
<description>
- Sets the exit position for the [code]link[/code].
+ Sets the exit position for the [param link].
</description>
</method>
<method name="link_set_enter_cost">
@@ -221,7 +221,7 @@
<param index="0" name="link" type="RID" />
<param index="1" name="enter_cost" type="float" />
<description>
- Sets the [code]enter_cost[/code] for this [code]link[/code].
+ Sets the [param enter_cost] for this [param link].
</description>
</method>
<method name="link_set_map">
@@ -253,7 +253,7 @@
<param index="0" name="link" type="RID" />
<param index="1" name="position" type="Vector2" />
<description>
- Sets the entry position for this [code]link[/code].
+ Sets the entry position for this [param link].
</description>
</method>
<method name="link_set_travel_cost">
@@ -261,7 +261,7 @@
<param index="0" name="link" type="RID" />
<param index="1" name="travel_cost" type="float" />
<description>
- Sets the [code]travel_cost[/code] for this [code]link[/code].
+ Sets the [param travel_cost] for this [param link].
</description>
</method>
<method name="map_create">
@@ -328,7 +328,7 @@
<return type="RID[]" />
<param index="0" name="map" type="RID" />
<description>
- Returns all navigation link [RID]s that are currently assigned to the requested navigation [code]map[/code].
+ Returns all navigation link [RID]s that are currently assigned to the requested navigation [param map].
</description>
</method>
<method name="map_get_path" qualifiers="const">
diff --git a/doc/classes/NavigationServer3D.xml b/doc/classes/NavigationServer3D.xml
index e6eed172f2..5b79355b61 100644
--- a/doc/classes/NavigationServer3D.xml
+++ b/doc/classes/NavigationServer3D.xml
@@ -155,7 +155,7 @@
<return type="Vector3" />
<param index="0" name="link" type="RID" />
<description>
- Returns the ending position of this [code]link[/code].
+ Returns the ending position of this [param link].
</description>
</method>
<method name="link_get_enter_cost" qualifiers="const">
@@ -169,14 +169,14 @@
<return type="RID" />
<param index="0" name="link" type="RID" />
<description>
- Returns the navigation map [RID] the requested [code]link[/code] is currently assigned to.
+ Returns the navigation map [RID] the requested [param link] is currently assigned to.
</description>
</method>
<method name="link_get_navigation_layers" qualifiers="const">
<return type="int" />
<param index="0" name="link" type="RID" />
<description>
- Returns the navigation layers for this [code]link[/code].
+ Returns the navigation layers for this [param link].
</description>
</method>
<method name="link_get_owner_id" qualifiers="const">
@@ -190,7 +190,7 @@
<return type="Vector3" />
<param index="0" name="link" type="RID" />
<description>
- Returns the starting position of this [code]link[/code].
+ Returns the starting position of this [param link].
</description>
</method>
<method name="link_get_travel_cost" qualifiers="const">
@@ -204,7 +204,7 @@
<return type="bool" />
<param index="0" name="link" type="RID" />
<description>
- Returns whether this [code]link[/code] can be travelled in both directions.
+ Returns whether this [param link] can be travelled in both directions.
</description>
</method>
<method name="link_set_bidirectional">
@@ -212,7 +212,7 @@
<param index="0" name="link" type="RID" />
<param index="1" name="bidirectional" type="bool" />
<description>
- Sets whether this [code]link[/code] can be travelled in both directions.
+ Sets whether this [param link] can be travelled in both directions.
</description>
</method>
<method name="link_set_end_position">
@@ -220,7 +220,7 @@
<param index="0" name="link" type="RID" />
<param index="1" name="position" type="Vector3" />
<description>
- Sets the exit position for the [code]link[/code].
+ Sets the exit position for the [param link].
</description>
</method>
<method name="link_set_enter_cost">
@@ -228,7 +228,7 @@
<param index="0" name="link" type="RID" />
<param index="1" name="enter_cost" type="float" />
<description>
- Sets the [code]enter_cost[/code] for this [code]link[/code].
+ Sets the [param enter_cost] for this [param link].
</description>
</method>
<method name="link_set_map">
@@ -260,7 +260,7 @@
<param index="0" name="link" type="RID" />
<param index="1" name="position" type="Vector3" />
<description>
- Sets the entry position for this [code]link[/code].
+ Sets the entry position for this [param link].
</description>
</method>
<method name="link_set_travel_cost">
@@ -268,7 +268,7 @@
<param index="0" name="link" type="RID" />
<param index="1" name="travel_cost" type="float" />
<description>
- Sets the [code]travel_cost[/code] for this [code]link[/code].
+ Sets the [param travel_cost] for this [param link].
</description>
</method>
<method name="map_create">
@@ -353,7 +353,7 @@
<return type="RID[]" />
<param index="0" name="map" type="RID" />
<description>
- Returns all navigation link [RID]s that are currently assigned to the requested navigation [code]map[/code].
+ Returns all navigation link [RID]s that are currently assigned to the requested navigation [param map].
</description>
</method>
<method name="map_get_path" qualifiers="const">
diff --git a/doc/classes/Node3D.xml b/doc/classes/Node3D.xml
index da898a5567..27cb3915ee 100644
--- a/doc/classes/Node3D.xml
+++ b/doc/classes/Node3D.xml
@@ -105,7 +105,7 @@
<method name="is_visible_in_tree" qualifiers="const">
<return type="bool" />
<description>
- Returns [code]true[/code] if the node is present in the [SceneTree], its [member visible] property is [code]true[/code] and all its antecedents are also visible. If any antecedent is hidden, this node will not be visible in the scene tree.
+ Returns [code]true[/code] if the node is present in the [SceneTree], its [member visible] property is [code]true[/code] and all its ancestors are also visible. If any ancestor is hidden, this node will not be visible in the scene tree.
</description>
</method>
<method name="look_at">
@@ -315,7 +315,7 @@
Defines the visibility range parent for this node and its subtree. The visibility parent must be a GeometryInstance3D. Any visual instance will only be visible if the visibility parent (and all of its visibility ancestors) is hidden by being closer to the camera than its own [member GeometryInstance3D.visibility_range_begin]. Nodes hidden via the [member Node3D.visible] property are essentially removed from the visibility dependency tree, so dependent instances will not take the hidden node or its ancestors into account.
</member>
<member name="visible" type="bool" setter="set_visible" getter="is_visible" default="true">
- If [code]true[/code], this node is drawn. The node is only visible if all of its antecedents are visible as well (in other words, [method is_visible_in_tree] must return [code]true[/code]).
+ If [code]true[/code], this node is drawn. The node is only visible if all of its ancestors are visible as well (in other words, [method is_visible_in_tree] must return [code]true[/code]).
</member>
</members>
<signals>
diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml
index 12c3e573e3..3bf4177549 100644
--- a/doc/classes/OS.xml
+++ b/doc/classes/OS.xml
@@ -91,7 +91,7 @@
<param index="3" name="read_stderr" type="bool" default="false" />
<param index="4" name="open_console" type="bool" default="false" />
<description>
- Executes a command. The file specified in [param path] must exist and be executable. Platform path resolution will be used. The [param arguments] are used in the given order and separated by a space. If an [param output] [Array] is provided, the complete shell output of the process will be appended as a single [String] element in [param output]. If [param read_stderr] is [code]true[/code], the output to the standard error stream will be included too.
+ Executes a command. The file specified in [param path] must exist and be executable. Platform path resolution will be used. The [param arguments] are used in the given order, separated by spaces, and wrapped in quotes. If an [param output] [Array] is provided, the complete shell output of the process will be appended as a single [String] element in [param output]. If [param read_stderr] is [code]true[/code], the output to the standard error stream will be included too.
On Windows, if [param open_console] is [code]true[/code] and the process is a console app, a new terminal window will be opened. This is ignored on other platforms.
If the command is successfully executed, the method will return the exit code of the command, or [code]-1[/code] if it fails.
[b]Note:[/b] The Godot thread will pause its execution until the executed command terminates. Use [Thread] to create a separate thread that will not pause the Godot thread, or use [method create_process] to create a completely independent process.
@@ -426,7 +426,7 @@
<description>
Returns an array of the system substitute font file paths, which are similar to the font with [param font_name] and style for the specified text, locale and script. Returns empty array if no matching fonts found.
The following aliases can be used to request default fonts: "sans-serif", "serif", "monospace", "cursive", and "fantasy".
- [b]Note:[/b] Depending on OS, it's not guaranteed that any of the returned fonts is suitable for rendering specified text. Fonts should be loaded and checked in the order they are returned, and the first suitable one used.
+ [b]Note:[/b] Depending on OS, it's not guaranteed that any of the returned fonts will be suitable for rendering specified text. Fonts should be loaded and checked in the order they are returned, and the first suitable one used.
[b]Note:[/b] Returned fonts might have different style if the requested style is not available or belong to a different font family.
[b]Note:[/b] This method is implemented on Android, iOS, Linux, macOS and Windows.
</description>
@@ -481,7 +481,7 @@
<method name="get_video_adapter_driver_info" qualifiers="const">
<return type="PackedStringArray" />
<description>
- Returns the video adapter driver name and version for the user's currently active graphics card.
+ Returns the video adapter driver name and version for the user's currently active graphics card. See also [method RenderingServer.get_video_adapter_api_version].
The first element holds the driver name, such as [code]nvidia[/code], [code]amdgpu[/code], etc.
The second element holds the driver version. For e.g. the [code]nvidia[/code] driver on a Linux/BSD platform, the version is in the format [code]510.85.02[/code]. For Windows, the driver's format is [code]31.0.15.1659[/code].
[b]Note:[/b] This method is only supported on the platforms Linux/BSD and Windows when not running in headless mode. It returns an empty array on other platforms.
@@ -649,6 +649,17 @@
[b]Note:[/b] This method is implemented on Android, iOS, Web, Linux, macOS and Windows.
</description>
</method>
+ <method name="shell_show_in_file_manager">
+ <return type="int" enum="Error" />
+ <param index="0" name="file_or_dir_path" type="String" />
+ <param index="1" name="open_folder" type="bool" default="true" />
+ <description>
+ Requests the OS to open the file manager, then navigate to the given [param file_or_dir_path] and select the target file or folder.
+ If [param file_or_dir_path] is a valid directory path, and [param open_folder] is [code]true[/code], the method will open the file manager and enter the target folder without selecting anything.
+ Use [method ProjectSettings.globalize_path] to convert a [code]res://[/code] or [code]user://[/code] path into a system path for use with this method.
+ [b]Note:[/b] Currently this method is only implemented on Windows. On other platforms, it will fallback to [method shell_open] with a directory path for [param file_or_dir_path].
+ </description>
+ </method>
<method name="unset_environment" qualifiers="const">
<return type="void" />
<param index="0" name="variable" type="String" />
diff --git a/doc/classes/PackedByteArray.xml b/doc/classes/PackedByteArray.xml
index a3f23fa7ae..431ccf634c 100644
--- a/doc/classes/PackedByteArray.xml
+++ b/doc/classes/PackedByteArray.xml
@@ -181,7 +181,7 @@
<param index="0" name="max_output_size" type="int" />
<param index="1" name="compression_mode" type="int" default="0" />
<description>
- Returns a new [PackedByteArray] with the data decompressed. Set the compression mode using one of [enum FileAccess.CompressionMode]'s constants. [b]This method only accepts gzip and deflate compression modes.[/b]
+ Returns a new [PackedByteArray] with the data decompressed. Set the compression mode using one of [enum FileAccess.CompressionMode]'s constants. [b]This method only accepts brotli, gzip, and deflate compression modes.[/b]
This method is potentially slower than [code]decompress[/code], as it may have to re-allocate its output buffer multiple times while decompressing, whereas [code]decompress[/code] knows it's output buffer size from the beginning.
GZIP has a maximal compression ratio of 1032:1, meaning it's very possible for a small compressed payload to decompress to a potentially very large output. To guard against this, you may provide a maximum size this function is allowed to allocate in bytes via [param max_output_size]. Passing -1 will allow for unbounded output. If any positive value is passed, and the decompression exceeds that amount in bytes, then an error will be returned.
</description>
diff --git a/doc/classes/PackedDataContainer.xml b/doc/classes/PackedDataContainer.xml
index addfdbed6b..8b500b41bd 100644
--- a/doc/classes/PackedDataContainer.xml
+++ b/doc/classes/PackedDataContainer.xml
@@ -1,26 +1,47 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PackedDataContainer" inherits="Resource" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
+ Efficiently packs and serializes [Array] or [Dictionary].
</brief_description>
<description>
+ [PackedDataContainer] can be used to efficiently store data from untyped containers. The data is packed into raw bytes and can be saved to file. Only [Array] and [Dictionary] can be stored this way.
+ You can retrieve the data by iterating on the container, which will work as if iterating on the packed data itself. If the packed container is a [Dictionary], the data can be retrieved by key names ([String]/[StringName] only).
+ [codeblock]
+ var data = { "key": "value", "another_key": 123, "lock": Vector2() }
+ var packed = PackedDataContainer.new()
+ packed.pack(data)
+ ResourceSaver.save(packed, "packed_data.res")
+ [/codeblock]
+ [codeblock]
+ var container = load("packed_data.res")
+ for key in container:
+ prints(key, container[key])
+
+ # Prints:
+ # key value
+ # lock (0, 0)
+ # another_key 123
+ [/codeblock]
+ Nested containers will be packed recursively. While iterating, they will be returned as [PackedDataContainerRef].
</description>
<tutorials>
</tutorials>
<methods>
<method name="pack">
<return type="int" enum="Error" />
+ <returns_error number="0"/>
+ <returns_error number="30"/>
<param index="0" name="value" type="Variant" />
<description>
+ Packs the given container into a binary representation. The [param value] must be either [Array] or [Dictionary], any other type will result in invalid data error.
+ [b]Note:[/b] Subsequent calls to this method will overwrite the existing data.
</description>
</method>
<method name="size" qualifiers="const">
<return type="int" />
<description>
+ Returns the size of the packed container (see [method Array.size] and [method Dictionary.size]).
</description>
</method>
</methods>
- <members>
- <member name="__data__" type="PackedByteArray" setter="_set_data" getter="_get_data" default="PackedByteArray()">
- </member>
- </members>
</class>
diff --git a/doc/classes/PackedDataContainerRef.xml b/doc/classes/PackedDataContainerRef.xml
index 47285fa8d6..440673d9b0 100644
--- a/doc/classes/PackedDataContainerRef.xml
+++ b/doc/classes/PackedDataContainerRef.xml
@@ -1,9 +1,31 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PackedDataContainerRef" inherits="RefCounted" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
- Reference-counted version of [PackedDataContainer].
+ Internal class used by [PackedDataContainer].
</brief_description>
<description>
+ When packing nested containers using [PackedDataContainer], they are recursively packed into [PackedDataContainerRef] (only applies to [Array] and [Dictionary]). Their data can be retrieved the same way as from [PackedDataContainer].
+ [codeblock]
+ var packed = PackedDataContainer.new()
+ packed.pack([1, 2, 3, ["abc", "def"], 4, 5, 6])
+
+ for element in packed:
+ if element is PackedDataContainerRef:
+ for subelement in element:
+ print("::", subelement)
+ else:
+ print(element)
+
+ # Prints:
+ # 1
+ # 2
+ # 3
+ # ::abc
+ # ::def
+ # 4
+ # 5
+ # 6
+ [/codeblock]
</description>
<tutorials>
</tutorials>
@@ -11,6 +33,7 @@
<method name="size" qualifiers="const">
<return type="int" />
<description>
+ Returns the size of the packed container (see [method Array.size] and [method Dictionary.size]).
</description>
</method>
</methods>
diff --git a/doc/classes/ParticleProcessMaterial.xml b/doc/classes/ParticleProcessMaterial.xml
index 6d549e1b67..5497effc75 100644
--- a/doc/classes/ParticleProcessMaterial.xml
+++ b/doc/classes/ParticleProcessMaterial.xml
@@ -282,7 +282,8 @@
Minimum equivalent of [member tangential_accel_max].
</member>
<member name="turbulence_enabled" type="bool" setter="set_turbulence_enabled" getter="get_turbulence_enabled" default="false">
- Enables and disables Turbulence for the particle system.
+ If [code]true[/code], enables turbulence for the particle system. Turbulence can be used to vary particle movement according to its position (based on a 3D noise pattern). In 3D, [GPUParticlesAttractorVectorField3D] with [NoiseTexture3D] can be used as an alternative to turbulence that works in world space and with multiple particle systems reacting in the same way.
+ [b]Note:[/b] Enabling turbulence has a high performance cost on the GPU. Only enable turbulence on a few particle systems at once at most, and consider disabling it when targeting mobile/web platforms.
</member>
<member name="turbulence_influence_max" type="float" setter="set_param_max" getter="get_param_max" default="0.1">
Maximum turbulence influence on each particle.
@@ -296,11 +297,11 @@
Each particle's amount of turbulence will be influenced along this [CurveTexture] over its life time.
</member>
<member name="turbulence_initial_displacement_max" type="float" setter="set_param_max" getter="get_param_max" default="0.0">
- Maximum displacement of each particles spawn position by the turbulence.
+ Maximum displacement of each particle's spawn position by the turbulence.
The actual amount of displacement will be a factor of the underlying turbulence multiplied by a random value between [member turbulence_initial_displacement_min] and [member turbulence_initial_displacement_max].
</member>
<member name="turbulence_initial_displacement_min" type="float" setter="set_param_min" getter="get_param_min" default="0.0">
- Minimum displacement of each particles spawn position by the turbulence.
+ Minimum displacement of each particle's spawn position by the turbulence.
The actual amount of displacement will be a factor of the underlying turbulence multiplied by a random value between [member turbulence_initial_displacement_min] and [member turbulence_initial_displacement_max].
</member>
<member name="turbulence_noise_scale" type="float" setter="set_turbulence_noise_scale" getter="get_turbulence_noise_scale" default="9.0">
@@ -312,10 +313,10 @@
A value of [code]Vector3(0.0, 0.0, 0.0)[/code] will freeze the turbulence pattern in place.
</member>
<member name="turbulence_noise_speed_random" type="float" setter="set_turbulence_noise_speed_random" getter="get_turbulence_noise_speed_random" default="0.0">
- Use to influence the noise speed in a random pattern. This helps to break up visible movement patterns.
+ Use to influence the noise speed in a random pattern. This helps break up visible movement patterns.
</member>
<member name="turbulence_noise_strength" type="float" setter="set_turbulence_noise_strength" getter="get_turbulence_noise_strength" default="1.0">
- The turbulence noise strength. Increasing this will result in a stronger, more contrasting, noise pattern.
+ The turbulence noise strength. Increasing this will result in a stronger, more contrasting noise pattern.
</member>
</members>
<constants>
diff --git a/doc/classes/PathFollow3D.xml b/doc/classes/PathFollow3D.xml
index bf8194a7cf..41727a7bd8 100644
--- a/doc/classes/PathFollow3D.xml
+++ b/doc/classes/PathFollow3D.xml
@@ -15,7 +15,7 @@
<param index="0" name="transform" type="Transform3D" />
<param index="1" name="rotation_mode" type="int" enum="PathFollow3D.RotationMode" />
<description>
- Correct the [code]transform[/code]. [code]rotation_mode[/code] implicitly specifies how posture (forward, up and sideway direction) is calculated.
+ Correct the [param transform]. [param rotation_mode] implicitly specifies how posture (forward, up and sideway direction) is calculated.
</description>
</method>
</methods>
diff --git a/doc/classes/PhysicalBone2D.xml b/doc/classes/PhysicalBone2D.xml
index d0bfbbd998..f201016f9c 100644
--- a/doc/classes/PhysicalBone2D.xml
+++ b/doc/classes/PhysicalBone2D.xml
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PhysicalBone2D" inherits="RigidBody2D" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
- A 2D node that can be used for physically aware bones in 2D.
+ A [RigidBody2D]-derived node used to make [Bone2D]s in a [Skeleton2D] react to physics.
</brief_description>
<description>
- The [code]PhysicalBone2D[/code] node is a [RigidBody2D]-based node that can be used to make [Bone2D] nodes in a [Skeleton2D] react to physics. This node is very similar to the [PhysicalBone3D] node, just for 2D instead of 3D.
- [b]Note:[/b] To have the Bone2D nodes visually follow the [code]PhysicalBone2D[/code] node, use a [SkeletonModification2DPhysicalBones] modification on the [Skeleton2D] node with the [Bone2D] nodes.
- [b]Note:[/b] The PhysicalBone2D node does not automatically create a [Joint2D] node to keep [code]PhysicalBone2D[/code] nodes together. You will need to create these manually. For most cases, you want to use a [PinJoint2D] node. The [code]PhysicalBone2D[/code] node can automatically configure the [Joint2D] node once it's been created as a child node.
+ The [PhysicalBone2D] node is a [RigidBody2D]-based node that can be used to make [Bone2D]s in a [Skeleton2D] react to physics.
+ [b]Note:[/b] To make the [Bone2D]s visually follow the [PhysicalBone2D] node, use a [SkeletonModification2DPhysicalBones] modification on the [Skeleton2D] parent.
+ [b]Note:[/b] The [PhysicalBone2D] node does not automatically create a [Joint2D] node to keep [PhysicalBone2D] nodes together. They must be created manually. For most cases, you want to use a [PinJoint2D] node. The [PhysicalBone2D] node will automatically configure the [Joint2D] node once it's been added as a child node.
</description>
<tutorials>
</tutorials>
@@ -14,32 +14,32 @@
<method name="get_joint" qualifiers="const">
<return type="Joint2D" />
<description>
- Returns the first [Joint2D] child node, if one exists. This is mainly a helper function to make it easier to get the [Joint2D] that the [code]PhysicalBone2D[/code] is autoconfiguring.
+ Returns the first [Joint2D] child node, if one exists. This is mainly a helper function to make it easier to get the [Joint2D] that the [PhysicalBone2D] is autoconfiguring.
</description>
</method>
<method name="is_simulating_physics" qualifiers="const">
<return type="bool" />
<description>
- Returns a boolean that indicates whether the [code]PhysicalBone2D[/code] node is running and simulating using the Godot 2D physics engine. When [code]true[/code], the PhysicalBone2D node is using physics.
+ Returns a boolean that indicates whether the [PhysicalBone2D] is running and simulating using the Godot 2D physics engine. When [code]true[/code], the PhysicalBone2D node is using physics.
</description>
</method>
</methods>
<members>
<member name="auto_configure_joint" type="bool" setter="set_auto_configure_joint" getter="get_auto_configure_joint" default="true">
- If [code]true[/code], the [code]PhysicalBone2D[/code] node will automatically configure the first [Joint2D] child node. The automatic configuration is limited to setting up the node properties and positioning the [Joint2D].
+ If [code]true[/code], the [PhysicalBone2D] will automatically configure the first [Joint2D] child node. The automatic configuration is limited to setting up the node properties and positioning the [Joint2D].
</member>
<member name="bone2d_index" type="int" setter="set_bone2d_index" getter="get_bone2d_index" default="-1">
- The index of the [Bone2D] node that this [code]PhysicalBone2D[/code] node is supposed to be simulating.
+ The index of the [Bone2D] that this [PhysicalBone2D] should simulate.
</member>
<member name="bone2d_nodepath" type="NodePath" setter="set_bone2d_nodepath" getter="get_bone2d_nodepath" default="NodePath(&quot;&quot;)">
- The [NodePath] to the [Bone2D] node that this [code]PhysicalBone2D[/code] node is supposed to be simulating.
+ The [NodePath] to the [Bone2D] that this [PhysicalBone2D] isshould simulate.
</member>
<member name="follow_bone_when_simulating" type="bool" setter="set_follow_bone_when_simulating" getter="get_follow_bone_when_simulating" default="false">
- If [code]true[/code], the [code]PhysicalBone2D[/code] will keep the transform of the bone it is bound to when simulating physics.
+ If [code]true[/code], the [PhysicalBone2D] will keep the transform of the bone it is bound to when simulating physics.
</member>
<member name="simulate_physics" type="bool" setter="set_simulate_physics" getter="get_simulate_physics" default="false">
- If [code]true[/code], the [code]PhysicalBone2D[/code] will start simulating using physics. If [code]false[/code], the [code]PhysicalBone2D[/code] will follow the transform of the [Bone2D] node.
- [b]Note:[/b] To have the Bone2D nodes visually follow the [code]PhysicalBone2D[/code] node, use a [SkeletonModification2DPhysicalBones] modification on the [Skeleton2D] node with the [Bone2D] nodes.
+ If [code]true[/code], the [PhysicalBone2D] will start simulating using physics. If [code]false[/code], the [PhysicalBone2D] will follow the transform of the [Bone2D] node.
+ [b]Note:[/b] To have the [Bone2D]s visually follow the [PhysicalBone2D], use a [SkeletonModification2DPhysicalBones] modification on the [Skeleton2D] node with the [Bone2D] nodes.
</member>
</members>
</class>
diff --git a/doc/classes/PhysicalBone3D.xml b/doc/classes/PhysicalBone3D.xml
index 7d5d0f1691..06941c0a50 100644
--- a/doc/classes/PhysicalBone3D.xml
+++ b/doc/classes/PhysicalBone3D.xml
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PhysicalBone3D" inherits="PhysicsBody3D" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
+ A physics body used to make bones in a [Skeleton3D] react to physics.
</brief_description>
<description>
- [b]Warning:[/b] With a non-uniform scale this node will probably not function as expected. Please make sure to keep its scale uniform (i.e. the same on all axes), and change the size(s) of its collision shape(s) instead.
+ The [PhysicalBone3D] node is a physics body that can be used to make bones in a [Skeleton3D] react to physics.
</description>
<tutorials>
</tutorials>
diff --git a/doc/classes/PhysicsServer2D.xml b/doc/classes/PhysicsServer2D.xml
index 010a73a8e5..4ed65e7bfb 100644
--- a/doc/classes/PhysicsServer2D.xml
+++ b/doc/classes/PhysicsServer2D.xml
@@ -595,7 +595,7 @@
Sets the function used to calculate physics for the body, if that body allows it (see [method body_set_omit_force_integration]).
The force integration function takes the following two parameters:
1. a [PhysicsDirectBodyState2D] [code]state[/code]: used to retrieve and modify the body's state,
- 2. a [Variant] [code]userdata[/code]: optional user data.
+ 2. a [Variant] [param userdata]: optional user data.
[b]Note:[/b] This callback is currently not called in Godot Physics.
</description>
</method>
diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml
index 6eed8434ac..f06e6e5da1 100644
--- a/doc/classes/ProjectSettings.xml
+++ b/doc/classes/ProjectSettings.xml
@@ -20,9 +20,9 @@
<param index="0" name="hint" type="Dictionary" />
<description>
Adds a custom property info to a property. The dictionary must contain:
- - [code]name[/code]: [String] (the property's name)
- - [code]type[/code]: [int] (see [enum Variant.Type])
- - optionally [code]hint[/code]: [int] (see [enum PropertyHint]) and [code]hint_string[/code]: [String]
+ - [code]"name"[/code]: [String] (the property's name)
+ - [code]"type"[/code]: [int] (see [enum Variant.Type])
+ - optionally [code]"hint"[/code]: [int] (see [enum PropertyHint]) and [code]"hint_string"[/code]: [String]
[b]Example:[/b]
[codeblocks]
[gdscript]
@@ -456,6 +456,9 @@
<member name="debug/gdscript/warnings/redundant_await" type="int" setter="" getter="" default="1">
When set to [code]warn[/code] or [code]error[/code], produces a warning or an error respectively when a function that is not a coroutine is called with await.
</member>
+ <member name="debug/gdscript/warnings/redundant_static_unload" type="int" setter="" getter="" default="1">
+ When set to [code]warn[/code] or [code]error[/code], produces a warning or an error respectively when the [code]@static_unload[/code] annotation is used in a script without any static variables.
+ </member>
<member name="debug/gdscript/warnings/renamed_in_godot_4_hint" type="bool" setter="" getter="" default="1">
When enabled, using a property, enum, or function that was renamed since Godot 3 will produce a hint if an error occurs.
</member>
@@ -821,6 +824,7 @@
Default value for [member ScrollContainer.scroll_deadzone], which will be used for all [ScrollContainer]s unless overridden.
</member>
<member name="gui/common/snap_controls_to_pixels" type="bool" setter="" getter="" default="true">
+ If [code]true[/code], snaps [Control] node vertices to the nearest pixel to ensure they remain crisp even when the camera moves or zooms.
</member>
<member name="gui/common/swap_cancel_ok" type="bool" setter="" getter="">
If [code]true[/code], swaps [b]Cancel[/b] and [b]OK[/b] buttons in dialogs on Windows and UWP to follow interface conventions. [method DisplayServer.get_swap_cancel_ok] can be used to query whether buttons are swapped at run-time.
@@ -1952,23 +1956,34 @@
[b]Note:[/b] Only [member physics/common/max_physics_steps_per_frame] physics ticks may be simulated per rendered frame at most. If more physics ticks have to be simulated per rendered frame to keep up with rendering, the project will appear to slow down (even if [code]delta[/code] is used consistently in physics calculations). Therefore, it is recommended to also increase [member physics/common/max_physics_steps_per_frame] if increasing [member physics/common/physics_ticks_per_second] significantly above its default value.
</member>
<member name="rendering/2d/sdf/oversize" type="int" setter="" getter="" default="1">
+ Controls how much of the original viewport size should be covered by the 2D signed distance field. This SDF can be sampled in [CanvasItem] shaders and is used for [GPUParticles2D] collision. Higher values allow portions of occluders located outside the viewport to still be taken into account in the generated signed distance field, at the cost of performance. If you notice particles falling through [LightOccluder2D]s as the occluders leave the viewport, increase this setting.
+ The percentage specified is added on each axis and on both sides. For example, with the default setting of 120%, the signed distance field will cover 20% of the viewport's size outside the viewport on each side (top, right, bottom, left).
+ [b]Note:[/b] This property is only read when the project starts. To change the 2D SDF oversizing percentage at runtime, use [method RenderingServer.viewport_set_sdf_oversize_and_scale] instead.
</member>
<member name="rendering/2d/sdf/scale" type="int" setter="" getter="" default="1">
+ The resolution scale to use for the 2D signed distance field. Higher values lead to a more precise and more stable signed distance field as the camera moves, at the cost of performance. The default value (50%) renders at half the resolution of the viewport size on each axis, which means the SDF is generated with 25% of the viewport's pixel count.
+ [b]Note:[/b] This property is only read when the project starts. To change the 2D SDF resolution scale at runtime, use [method RenderingServer.viewport_set_sdf_oversize_and_scale] instead.
</member>
<member name="rendering/2d/shadow_atlas/size" type="int" setter="" getter="" default="2048">
+ The size of the 2D shadow atlas in pixels. Higher values result in more precise [Light2D] shadows, at the cost of performance and video memory usage. The specified value is rounded up to the nearest power of 2.
+ [b]Note:[/b] This property is only read when the project starts. To change the 2D shadow atlas size at runtime, use [method RenderingServer.canvas_set_shadow_texture_size] instead.
</member>
<member name="rendering/2d/snap/snap_2d_transforms_to_pixel" type="bool" setter="" getter="" default="false">
- If [code]true[/code], [CanvasItem] nodes will internally snap to full pixels. Their position can still be sub-pixel, but the decimals will not have effect.
+ If [code]true[/code], [CanvasItem] nodes will internally snap to full pixels. Their position can still be sub-pixel, but the decimals will not have effect. This can lead to a crisper appearance at the cost of less smooth movement, especially when [Camera2D] smoothing is enabled.
+ [b]Note:[/b] This property is only read when the project starts. To toggle 2D transform snapping at runtime, use [method RenderingServer.viewport_set_snap_2d_transforms_to_pixel] on the root [Viewport] instead.
+ [b]Note:[/b] [Control] nodes are snapped to the nearest pixel by default. This is controlled by [member gui/common/snap_controls_to_pixels].
</member>
<member name="rendering/2d/snap/snap_2d_vertices_to_pixel" type="bool" setter="" getter="" default="false">
- If [code]true[/code], vertices of [CanvasItem] nodes will snap to full pixels. Only affects the final vertex positions, not the transforms.
+ If [code]true[/code], vertices of [CanvasItem] nodes will snap to full pixels. Only affects the final vertex positions, not the transforms. This can lead to a crisper appearance at the cost of less smooth movement, especially when [Camera2D] smoothing is enabled.
+ [b]Note:[/b] This property is only read when the project starts. To toggle 2D vertex snapping at runtime, use [method RenderingServer.viewport_set_snap_2d_vertices_to_pixel] on the root [Viewport] instead.
+ [b]Note:[/b] [Control] nodes are snapped to the nearest pixel by default. This is controlled by [member gui/common/snap_controls_to_pixels].
</member>
<member name="rendering/anti_aliasing/quality/msaa_2d" type="int" setter="" getter="" default="0">
- Sets the number of MSAA samples to use for 2D/Canvas rendering (as a power of two). MSAA is used to reduce aliasing around the edges of polygons. A higher MSAA value results in smoother edges but can be significantly slower on some hardware. This has no effect on shader-induced aliasing or texture aliasing.
+ Sets the number of MSAA samples to use for 2D/Canvas rendering (as a power of two). MSAA is used to reduce aliasing around the edges of polygons. A higher MSAA value results in smoother edges but can be significantly slower on some hardware, especially integrated graphics due to their limited memory bandwidth. This has no effect on shader-induced aliasing or texture aliasing.
[b]Note:[/b] MSAA is only supported in the Forward+ and Mobile rendering methods, not Compatibility.
</member>
<member name="rendering/anti_aliasing/quality/msaa_3d" type="int" setter="" getter="" default="0">
- Sets the number of MSAA samples to use for 3D rendering (as a power of two). MSAA is used to reduce aliasing around the edges of polygons. A higher MSAA value results in smoother edges but can be significantly slower on some hardware. See also bilinear scaling 3d [member rendering/scaling_3d/mode] for supersampling, which provides higher quality but is much more expensive. This has no effect on shader-induced aliasing or texture aliasing.
+ Sets the number of MSAA samples to use for 3D rendering (as a power of two). MSAA is used to reduce aliasing around the edges of polygons. A higher MSAA value results in smoother edges but can be significantly slower on some hardware, especially integrated graphics due to their limited memory bandwidth. See also [member rendering/scaling_3d/mode] for supersampling, which provides higher quality but is much more expensive. This has no effect on shader-induced aliasing or texture aliasing.
[b]Note:[/b] MSAA is only supported in the Forward+ and Mobile rendering methods, not Compatibility.
</member>
<member name="rendering/anti_aliasing/quality/screen_space_aa" type="int" setter="" getter="" default="0">
@@ -1987,12 +2002,15 @@
[b]Note:[/b] TAA is only supported in the Forward+ rendering method, not Mobile or Compatibility.
</member>
<member name="rendering/anti_aliasing/screen_space_roughness_limiter/amount" type="float" setter="" getter="" default="0.25">
+ [b]Note:[/b] This property is only read when the project starts. To control the screen-space roughness limiter at runtime, call [method RenderingServer.screen_space_roughness_limiter_set_active] instead.
</member>
<member name="rendering/anti_aliasing/screen_space_roughness_limiter/enabled" type="bool" setter="" getter="" default="true">
If [code]true[/code], enables a spatial filter to limit roughness in areas with high-frequency detail. This can help reduce specular aliasing to an extent, though not as much as enabling [member rendering/anti_aliasing/quality/use_taa]. This filter has a small performance cost, so consider disabling it if it doesn't benefit your scene noticeably.
- [b]Note:[/b] TAA is only supported in the Forward+ and Mobile rendering methods, not Compatibility.
+ [b]Note:[/b] The screen-space roughness limiter is only supported in the Forward+ and Mobile rendering methods, not Compatibility.
+ [b]Note:[/b] This property is only read when the project starts. To control the screen-space roughness limiter at runtime, call [method RenderingServer.screen_space_roughness_limiter_set_active] instead.
</member>
<member name="rendering/anti_aliasing/screen_space_roughness_limiter/limit" type="float" setter="" getter="" default="0.18">
+ [b]Note:[/b] This property is only read when the project starts. To control the screen-space roughness limiter at runtime, call [method RenderingServer.screen_space_roughness_limiter_set_active] instead.
</member>
<member name="rendering/camera/depth_of_field/depth_of_field_bokeh_quality" type="int" setter="" getter="" default="1">
Sets the quality of the depth of field effect. Higher quality takes more samples, which is slower but looks smoother.
@@ -2065,13 +2083,16 @@
Sets the quality of the screen-space indirect lighting effect. Higher values take more samples and so will result in better quality, at the cost of performance. Setting to [code]Ultra[/code] will use the [member rendering/environment/ssil/adaptive_target] setting.
</member>
<member name="rendering/environment/subsurface_scattering/subsurface_scattering_depth_scale" type="float" setter="" getter="" default="0.01">
- Scales the depth over which the subsurface scattering effect is applied. A high value may allow light to scatter into a part of the mesh or another mesh that is close in screen space but far in depth.
+ Scales the depth over which the subsurface scattering effect is applied. A high value may allow light to scatter into a part of the mesh or another mesh that is close in screen space but far in depth. See also [member rendering/environment/subsurface_scattering/subsurface_scattering_scale].
+ [b]Note:[/b] This property is only read when the project starts. To set the subsurface scattering depth scale at runtime, call [method RenderingServer.sub_surface_scattering_set_scale] instead.
</member>
<member name="rendering/environment/subsurface_scattering/subsurface_scattering_quality" type="int" setter="" getter="" default="1">
- Sets the quality of the subsurface scattering effect. Higher values are slower but look nicer.
+ Sets the quality of the subsurface scattering effect. Higher values are slower but look nicer. This affects the rendering of materials that have [member BaseMaterial3D.subsurf_scatter_enabled] set to [code]true[/code], along with [ShaderMaterial]s that set [code]SSS_STRENGTH[/code].
+ [b]Note:[/b] This property is only read when the project starts. To set the subsurface scattering quality at runtime, call [method RenderingServer.sub_surface_scattering_set_quality] instead.
</member>
<member name="rendering/environment/subsurface_scattering/subsurface_scattering_scale" type="float" setter="" getter="" default="0.05">
- Scales the distance over which samples are taken for subsurface scattering effect. Changing this does not impact performance, but higher values will result in significant artifacts as the samples will become obviously spread out. A lower value results in a smaller spread of scattered light.
+ Scales the distance over which samples are taken for subsurface scattering effect. Changing this does not impact performance, but higher values will result in significant artifacts as the samples will become obviously spread out. A lower value results in a smaller spread of scattered light. See also [member rendering/environment/subsurface_scattering/subsurface_scattering_depth_scale].
+ [b]Note:[/b] This property is only read when the project starts. To set the subsurface scattering scale at runtime, call [method RenderingServer.sub_surface_scattering_set_scale] instead.
</member>
<member name="rendering/environment/volumetric_fog/use_filter" type="int" setter="" getter="" default="1">
Enables filtering of the volumetric fog effect prior to integration. This substantially blurs the fog which reduces fine details but also smooths out harsh edges and aliasing artifacts. Disable when more detail is required.
@@ -2111,12 +2132,21 @@
[b]Note:[/b] This property is only read when the project starts. To set half-resolution GI at run-time, call [method RenderingServer.gi_set_use_half_resolution] instead.
</member>
<member name="rendering/global_illumination/sdfgi/frames_to_converge" type="int" setter="" getter="" default="5">
+ The number of frames to use for converging signed distance field global illumination. Higher values lead to a less noisy result, at the cost of taking a longer time to fully converge. This means the scene's global illumination will be too dark for a longer period of time, especially when the camera moves fast. The actual convergence speed depends on rendered framerate. For example, with the default setting of 30 frames, rendering at 60 FPS will make SDFGI fully converge after 0.5 seconds. See also [member rendering/global_illumination/sdfgi/frames_to_update_lights] and [member rendering/global_illumination/sdfgi/probe_ray_count].
+ [b]Note:[/b] This property is only read when the project starts. To control SDFGI convergence speed at runtime, call [method RenderingServer.environment_set_sdfgi_frames_to_converge] instead.
</member>
<member name="rendering/global_illumination/sdfgi/frames_to_update_lights" type="int" setter="" getter="" default="2">
+ The number of frames over which dynamic lights should be updated in signed distance field global illumination. Higher values take more time to update indirect lighting coming from dynamic lights, but result in better performance when many dynamic lights are present. See also [member rendering/global_illumination/sdfgi/frames_to_converge] and [member rendering/global_illumination/sdfgi/probe_ray_count].
+ [b]Note:[/b] This only affects [Light3D] nodes whose [member Light3D.light_bake_mode] is [constant Light3D.BAKE_DYNAMIC] (which is the default). Consider making non-moving lights use the [constant Light3D.BAKE_STATIC] bake mode to improve performance.
+ [b]Note:[/b] This property is only read when the project starts. To control SDFGI light update speed at runtime, call [method RenderingServer.environment_set_sdfgi_frames_to_update_light] instead.
</member>
<member name="rendering/global_illumination/sdfgi/probe_ray_count" type="int" setter="" getter="" default="1">
+ The number of rays to throw per frame when computing signed distance field global illumination. Higher values lead to a less noisy result, at the cost of performance. See also [member rendering/global_illumination/sdfgi/frames_to_converge] and [member rendering/global_illumination/sdfgi/frames_to_update_lights].
+ [b]Note:[/b] This property is only read when the project starts. To control SDFGI quality at runtime, call [method RenderingServer.environment_set_sdfgi_ray_count] instead.
</member>
<member name="rendering/global_illumination/voxel_gi/quality" type="int" setter="" getter="" default="0">
+ The VoxelGI quality to use. High quality leads to more precise lighting and better reflections, but is slower to render. This setting does not affect the baked data and doesn't require baking the [VoxelGI] again to apply.
+ [b]Note:[/b] This property is only read when the project starts. To control VoxelGI quality at runtime, call [method RenderingServer.voxel_gi_set_quality] instead.
</member>
<member name="rendering/lightmapping/bake_performance/max_rays_per_pass" type="int" setter="" getter="" default="32">
The maximum number of rays that can be thrown per pass when baking lightmaps with [LightmapGI]. Depending on the scene, adjusting this value may result in higher GPU utilization when baking lightmaps, leading to faster bake times.
@@ -2158,10 +2188,10 @@
The framerate-independent update speed when representing dynamic object lighting from [LightmapProbe]s. Higher values make dynamic object lighting update faster. Higher values can prevent fast-moving objects from having "outdated" indirect lighting displayed on them, at the cost of possible flickering when an object moves from a bright area to a shaded area.
</member>
<member name="rendering/lights_and_shadows/directional_shadow/16_bits" type="bool" setter="" getter="" default="true">
- Use 16 bits for shadow depth map. Enabling this results in shadows having less precision and may result in shadow acne, but can lead to performance improvements on some devices.
+ Use 16 bits for the directional shadow depth map. Enabling this results in shadows having less precision and may result in shadow acne, but can lead to performance improvements on some devices.
</member>
<member name="rendering/lights_and_shadows/directional_shadow/size" type="int" setter="" getter="" default="4096">
- The directional shadow's size in pixels. Higher values will result in sharper shadows, at the cost of performance. The value will be rounded up to the nearest power of 2.
+ The directional shadow's size in pixels. Higher values will result in sharper shadows, at the cost of performance. The value is rounded up to the nearest power of 2.
</member>
<member name="rendering/lights_and_shadows/directional_shadow/size.mobile" type="int" setter="" getter="" default="2048">
Lower-end override for [member rendering/lights_and_shadows/directional_shadow/size] on mobile devices, due to performance concerns or driver support.
@@ -2175,7 +2205,7 @@
Lower-end override for [member rendering/lights_and_shadows/directional_shadow/soft_shadow_filter_quality] on mobile devices, due to performance concerns or driver support.
</member>
<member name="rendering/lights_and_shadows/positional_shadow/atlas_16_bits" type="bool" setter="" getter="" default="true">
- Use 16 bits for shadow depth map. Enabling this results in shadows having less precision and may result in shadow acne, but can lead to performance improvements on some devices.
+ Use 16 bits for the omni/spot shadow depth map. Enabling this results in shadows having less precision and may result in shadow acne, but can lead to performance improvements on some devices.
</member>
<member name="rendering/lights_and_shadows/positional_shadow/atlas_quadrant_0_subdiv" type="int" setter="" getter="" default="2">
Subdivision quadrant size for shadow mapping. See shadow mapping documentation.
@@ -2239,10 +2269,12 @@
[b]Note:[/b] This property is only read when the project starts. To adjust the automatic LOD threshold at runtime, set [member Viewport.mesh_lod_threshold] on the root [Viewport].
</member>
<member name="rendering/occlusion_culling/bvh_build_quality" type="int" setter="" getter="" default="2">
- The [url=https://en.wikipedia.org/wiki/Bounding_volume_hierarchy]BVH[/url] quality to use when rendering the occlusion culling buffer. Higher values will result in more accurate occlusion culling, at the cost of higher CPU usage.
+ The [url=https://en.wikipedia.org/wiki/Bounding_volume_hierarchy]Bounding Volume Hierarchy[/url] quality to use when rendering the occlusion culling buffer. Higher values will result in more accurate occlusion culling, at the cost of higher CPU usage. See also [member rendering/occlusion_culling/occlusion_rays_per_thread].
+ [b]Note:[/b] This property is only read when the project starts. To adjust the BVH build quality at runtime, use [method RenderingServer.viewport_set_occlusion_culling_build_quality].
</member>
<member name="rendering/occlusion_culling/occlusion_rays_per_thread" type="int" setter="" getter="" default="512">
- Higher values will result in more accurate occlusion culling, at the cost of higher CPU usage. The occlusion culling buffer's pixel count is roughly equal to [code]occlusion_rays_per_thread * number_of_logical_cpu_cores[/code], so it will depend on the system's CPU. Therefore, CPUs with fewer cores will use a lower resolution to attempt keeping performance costs even across devices.
+ The number of occlusion rays traced per CPU thread. Higher values will result in more accurate occlusion culling, at the cost of higher CPU usage. The occlusion culling buffer's pixel count is roughly equal to [code]occlusion_rays_per_thread * number_of_logical_cpu_cores[/code], so it will depend on the system's CPU. Therefore, CPUs with fewer cores will use a lower resolution to attempt keeping performance costs even across devices. See also [member rendering/occlusion_culling/bvh_build_quality].
+ [b]Note:[/b] This property is only read when the project starts. To adjust the number of occlusion rays traced per thread at runtime, use [method RenderingServer.viewport_set_occlusion_rays_per_thread].
</member>
<member name="rendering/occlusion_culling/use_occlusion_culling" type="bool" setter="" getter="" default="false">
If [code]true[/code], [OccluderInstance3D] nodes will be usable for occlusion culling in 3D in the root viewport. In custom viewports, [member Viewport.use_occlusion_culling] must be set to [code]true[/code] instead.
diff --git a/doc/classes/RDAttachmentFormat.xml b/doc/classes/RDAttachmentFormat.xml
index 4d912da1ef..1c32041f4b 100644
--- a/doc/classes/RDAttachmentFormat.xml
+++ b/doc/classes/RDAttachmentFormat.xml
@@ -1,17 +1,22 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="RDAttachmentFormat" inherits="RefCounted" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
+ Attachment format (used by [RenderingDevice]).
</brief_description>
<description>
+ This object is used by [RenderingDevice].
</description>
<tutorials>
</tutorials>
<members>
<member name="format" type="int" setter="set_format" getter="get_format" enum="RenderingDevice.DataFormat" default="36">
+ The attachment's data format.
</member>
<member name="samples" type="int" setter="set_samples" getter="get_samples" enum="RenderingDevice.TextureSamples" default="0">
+ The number of samples used when sampling the attachment.
</member>
<member name="usage_flags" type="int" setter="set_usage_flags" getter="get_usage_flags" default="0">
+ The attachment's usage flags, which determine what can be done with it.
</member>
</members>
</class>
diff --git a/doc/classes/RDFramebufferPass.xml b/doc/classes/RDFramebufferPass.xml
index b78658d559..5a296da19c 100644
--- a/doc/classes/RDFramebufferPass.xml
+++ b/doc/classes/RDFramebufferPass.xml
@@ -1,11 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="RDFramebufferPass" inherits="RefCounted" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
- Framebuffer pass attachment description.
+ Framebuffer pass attachment description (used by [RenderingDevice]).
</brief_description>
<description>
This class contains the list of attachment descriptions for a framebuffer pass. Each points with an index to a previously supplied list of texture attachments.
- Multipass framebuffers can optimize some configurations in mobile, on desktop they provide little to no advantage.
+ Multipass framebuffers can optimize some configurations in mobile. On desktop, they provide little to no advantage.
+ This object is used by [RenderingDevice].
</description>
<tutorials>
</tutorials>
@@ -28,6 +29,7 @@
</members>
<constants>
<constant name="ATTACHMENT_UNUSED" value="-1">
+ Attachment is unused.
</constant>
</constants>
</class>
diff --git a/doc/classes/RDPipelineColorBlendState.xml b/doc/classes/RDPipelineColorBlendState.xml
index 7ce5157cc5..363349927e 100644
--- a/doc/classes/RDPipelineColorBlendState.xml
+++ b/doc/classes/RDPipelineColorBlendState.xml
@@ -1,19 +1,25 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="RDPipelineColorBlendState" inherits="RefCounted" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
+ Pipeline color blend state (used by [RenderingDevice]).
</brief_description>
<description>
+ This object is used by [RenderingDevice].
</description>
<tutorials>
</tutorials>
<members>
<member name="attachments" type="RDPipelineColorBlendStateAttachment[]" setter="set_attachments" getter="get_attachments" default="[]">
+ The attachments that are blended together.
</member>
<member name="blend_constant" type="Color" setter="set_blend_constant" getter="get_blend_constant" default="Color(0, 0, 0, 1)">
+ The constant color to blend with. See also [method RenderingDevice.draw_list_set_blend_constants].
</member>
<member name="enable_logic_op" type="bool" setter="set_enable_logic_op" getter="get_enable_logic_op" default="false">
+ If [code]true[/code], performs the logic operation defined in [member logic_op].
</member>
<member name="logic_op" type="int" setter="set_logic_op" getter="get_logic_op" enum="RenderingDevice.LogicOperation" default="0">
+ The logic operation to perform for blending. Only effective if [member enable_logic_op] is [code]true[/code].
</member>
</members>
</class>
diff --git a/doc/classes/RDPipelineColorBlendStateAttachment.xml b/doc/classes/RDPipelineColorBlendStateAttachment.xml
index ff52be9b23..4892536814 100644
--- a/doc/classes/RDPipelineColorBlendStateAttachment.xml
+++ b/doc/classes/RDPipelineColorBlendStateAttachment.xml
@@ -1,8 +1,66 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="RDPipelineColorBlendStateAttachment" inherits="RefCounted" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
+ Pipeline color blend state attachment (used by [RenderingDevice]).
</brief_description>
<description>
+ Controls how blending between source and destination fragments is performed when using [RenderingDevice].
+ For reference, this is how common user-facing blend modes are implemented in Godot's 2D renderer:
+ [b]Mix:[/b]
+ [codeblock]
+ var attachment = RDPipelineColorBlendStateAttachment.new()
+ attachment.enable_blend = true
+ attachment.color_blend_op = RenderingDevice.BLEND_OP_ADD
+ attachment.src_color_blend_factor = RenderingDevice.BLEND_FACTOR_SRC_ALPHA
+ attachment.dst_color_blend_factor = RenderingDevice.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA
+ attachment.alpha_blend_op = RenderingDevice.BLEND_OP_ADD
+ attachment.src_alpha_blend_factor = RenderingDevice.BLEND_FACTOR_ONE
+ attachment.dst_alpha_blend_factor = RenderingDevice.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA
+ [/codeblock]
+ [b]Add:[/b]
+ [codeblock]
+ var attachment = RDPipelineColorBlendStateAttachment.new()
+ attachment.enable_blend = true
+ attachment.alpha_blend_op = RenderingDevice.BLEND_OP_ADD
+ attachment.color_blend_op = RenderingDevice.BLEND_OP_ADD
+ attachment.src_color_blend_factor = RenderingDevice.BLEND_FACTOR_SRC_ALPHA
+ attachment.dst_color_blend_factor = RenderingDevice.BLEND_FACTOR_ONE
+ attachment.src_alpha_blend_factor = RenderingDevice.BLEND_FACTOR_SRC_ALPHA
+ attachment.dst_alpha_blend_factor = RenderingDevice.BLEND_FACTOR_ONE
+ [/codeblock]
+ [b]Subtract:[/b]
+ [codeblock]
+ var attachment = RDPipelineColorBlendStateAttachment.new()
+ attachment.enable_blend = true
+ attachment.alpha_blend_op = RenderingDevice.BLEND_OP_SUBTRACT
+ attachment.color_blend_op = RenderingDevice.BLEND_OP_SUBTRACT
+ attachment.src_color_blend_factor = RenderingDevice.BLEND_FACTOR_SRC_ALPHA
+ attachment.dst_color_blend_factor = RenderingDevice.BLEND_FACTOR_ONE
+ attachment.src_alpha_blend_factor = RenderingDevice.BLEND_FACTOR_SRC_ALPHA
+ attachment.dst_alpha_blend_factor = RenderingDevice.BLEND_FACTOR_ONE
+ [/codeblock]
+ [b]Multiply:[/b]
+ [codeblock]
+ var attachment = RDPipelineColorBlendStateAttachment.new()
+ attachment.enable_blend = true
+ attachment.alpha_blend_op = RenderingDevice.BLEND_OP_ADD
+ attachment.color_blend_op = RenderingDevice.BLEND_OP_ADD
+ attachment.src_color_blend_factor = RenderingDevice.BLEND_FACTOR_DST_COLOR
+ attachment.dst_color_blend_factor = RenderingDevice.BLEND_FACTOR_ZERO
+ attachment.src_alpha_blend_factor = RenderingDevice.BLEND_FACTOR_DST_ALPHA
+ attachment.dst_alpha_blend_factor = RenderingDevice.BLEND_FACTOR_ZERO
+ [/codeblock]
+ [b]Pre-multiplied alpha:[/b]
+ [codeblock]
+ var attachment = RDPipelineColorBlendStateAttachment.new()
+ attachment.enable_blend = true
+ attachment.alpha_blend_op = RenderingDevice.BLEND_OP_ADD
+ attachment.color_blend_op = RenderingDevice.BLEND_OP_ADD
+ attachment.src_color_blend_factor = RenderingDevice.BLEND_FACTOR_ONE
+ attachment.dst_color_blend_factor = RenderingDevice.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA
+ attachment.src_alpha_blend_factor = RenderingDevice.BLEND_FACTOR_ONE
+ attachment.dst_alpha_blend_factor = RenderingDevice.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA
+ [/codeblock]
</description>
<tutorials>
</tutorials>
@@ -10,31 +68,43 @@
<method name="set_as_mix">
<return type="void" />
<description>
+ Convenience method to perform standard mix blending with straight (non-premultiplied) alpha. This sets [member enable_blend] to [code]true[/code], [member src_color_blend_factor] to [constant RenderingDevice.BLEND_FACTOR_SRC_ALPHA], [member dst_color_blend_factor] to [constant RenderingDevice.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA], [member src_alpha_blend_factor] to [constant RenderingDevice.BLEND_FACTOR_SRC_ALPHA] and [member dst_alpha_blend_factor] to [constant RenderingDevice.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA].
</description>
</method>
</methods>
<members>
<member name="alpha_blend_op" type="int" setter="set_alpha_blend_op" getter="get_alpha_blend_op" enum="RenderingDevice.BlendOperation" default="0">
+ The blend mode to use for the alpha channel.
</member>
<member name="color_blend_op" type="int" setter="set_color_blend_op" getter="get_color_blend_op" enum="RenderingDevice.BlendOperation" default="0">
+ The blend mode to use for the red/green/blue color channels.
</member>
<member name="dst_alpha_blend_factor" type="int" setter="set_dst_alpha_blend_factor" getter="get_dst_alpha_blend_factor" enum="RenderingDevice.BlendFactor" default="0">
+ Controls how the blend factor for the alpha channel is determined based on the destination's fragments.
</member>
<member name="dst_color_blend_factor" type="int" setter="set_dst_color_blend_factor" getter="get_dst_color_blend_factor" enum="RenderingDevice.BlendFactor" default="0">
+ Controls how the blend factor for the color channels is determined based on the destination's fragments.
</member>
<member name="enable_blend" type="bool" setter="set_enable_blend" getter="get_enable_blend" default="false">
+ If [code]true[/code], performs blending between the source and destination according to the factors defined in [member src_color_blend_factor], [member dst_color_blend_factor], [member src_alpha_blend_factor] and [member dst_alpha_blend_factor]. The blend modes [member color_blend_op] and [member alpha_blend_op] are also taken into account, with [member write_r], [member write_g], [member write_b] and [member write_a] controlling the output.
</member>
<member name="src_alpha_blend_factor" type="int" setter="set_src_alpha_blend_factor" getter="get_src_alpha_blend_factor" enum="RenderingDevice.BlendFactor" default="0">
+ Controls how the blend factor for the alpha channel is determined based on the source's fragments.
</member>
<member name="src_color_blend_factor" type="int" setter="set_src_color_blend_factor" getter="get_src_color_blend_factor" enum="RenderingDevice.BlendFactor" default="0">
+ Controls how the blend factor for the color channels is determined based on the source's fragments.
</member>
<member name="write_a" type="bool" setter="set_write_a" getter="get_write_a" default="true">
+ If [code]true[/code], writes the new alpha channel to the final result.
</member>
<member name="write_b" type="bool" setter="set_write_b" getter="get_write_b" default="true">
+ If [code]true[/code], writes the new blue color channel to the final result.
</member>
<member name="write_g" type="bool" setter="set_write_g" getter="get_write_g" default="true">
+ If [code]true[/code], writes the new green color channel to the final result.
</member>
<member name="write_r" type="bool" setter="set_write_r" getter="get_write_r" default="true">
+ If [code]true[/code], writes the new red color channel to the final result.
</member>
</members>
</class>
diff --git a/doc/classes/RDPipelineDepthStencilState.xml b/doc/classes/RDPipelineDepthStencilState.xml
index 65a83a962a..3893e0188d 100644
--- a/doc/classes/RDPipelineDepthStencilState.xml
+++ b/doc/classes/RDPipelineDepthStencilState.xml
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="RDPipelineDepthStencilState" inherits="RefCounted" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
+ Pipeline depth/stencil state (used by [RenderingDevice]).
</brief_description>
<description>
+ [RDPipelineDepthStencilState] controls the way depth and stencil comparisons are performed when sampling those values using [RenderingDevice].
</description>
<tutorials>
</tutorials>
@@ -30,6 +32,7 @@
<member name="enable_depth_range" type="bool" setter="set_enable_depth_range" getter="get_enable_depth_range" default="false">
</member>
<member name="enable_depth_test" type="bool" setter="set_enable_depth_test" getter="get_enable_depth_test" default="false">
+ If [code]true[/code], enables depth testing which allows objects to be automatically occluded by other objects based on their depth. This also allows objects to be partially occluded by other objects. If [code]false[/code], objects will appear in the order they were drawn (like in Godot's 2D renderer).
</member>
<member name="enable_depth_write" type="bool" setter="set_enable_depth_write" getter="get_enable_depth_write" default="false">
</member>
diff --git a/doc/classes/RDPipelineMultisampleState.xml b/doc/classes/RDPipelineMultisampleState.xml
index 2e72ca2bae..635a2480de 100644
--- a/doc/classes/RDPipelineMultisampleState.xml
+++ b/doc/classes/RDPipelineMultisampleState.xml
@@ -1,23 +1,31 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="RDPipelineMultisampleState" inherits="RefCounted" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
+ Pipeline multisample state (used by [RenderingDevice]).
</brief_description>
<description>
+ [RDPipelineMultisampleState] is used to control how multisample or supersample antialiasing is being performed when rendering using [RenderingDevice].
</description>
<tutorials>
</tutorials>
<members>
<member name="enable_alpha_to_coverage" type="bool" setter="set_enable_alpha_to_coverage" getter="get_enable_alpha_to_coverage" default="false">
+ If [code]true[/code], alpha to coverage is enabled. This generates a temporary coverage value based on the alpha component of the fragment's first color output. This allows alpha transparency to make use of multisample antialiasing.
</member>
<member name="enable_alpha_to_one" type="bool" setter="set_enable_alpha_to_one" getter="get_enable_alpha_to_one" default="false">
+ If [code]true[/code], alpha is forced to either [code]0.0[/code] or [code]1.0[/code]. This allows hardening the edges of antialiased alpha transparencies. Only relevant if [member enable_alpha_to_coverage] is [code]true[/code].
</member>
<member name="enable_sample_shading" type="bool" setter="set_enable_sample_shading" getter="get_enable_sample_shading" default="false">
+ If [code]true[/code], enables per-sample shading which replaces MSAA by SSAA. This provides higher quality antialiasing that works with transparent (alpha scissor) edges. This has a very high performance cost. See also [member min_sample_shading]. See the [url=https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#primsrast-sampleshading]per-sample shading Vulkan documentation[/url] for more details.
</member>
<member name="min_sample_shading" type="float" setter="set_min_sample_shading" getter="get_min_sample_shading" default="0.0">
+ The multiplier of [member sample_count] that determines how many samples are performed for each fragment. Must be between [code]0.0[/code] and [code]1.0[/code] (inclusive). Only effective if [member enable_sample_shading] is [code]true[/code]. If [member min_sample_shading] is [code]1.0[/code], fragment invocation must only read from the coverage index sample. Tile image access must not be used if [member enable_sample_shading] is [i]not[/i] [code]1.0[/code].
</member>
<member name="sample_count" type="int" setter="set_sample_count" getter="get_sample_count" enum="RenderingDevice.TextureSamples" default="0">
+ The number of MSAA samples (or SSAA samples if [member enable_sample_shading] is [code]true[/code]) to perform. Higher values result in better antialiasing, at the cost of performance.
</member>
<member name="sample_masks" type="int[]" setter="set_sample_masks" getter="get_sample_masks" default="[]">
+ The sampleSee the [url=https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#fragops-samplemask]sample mask Vulkan documentation[/url] for more details.
</member>
</members>
</class>
diff --git a/doc/classes/RDPipelineRasterizationState.xml b/doc/classes/RDPipelineRasterizationState.xml
index 80aef26d2b..79d0eeef48 100644
--- a/doc/classes/RDPipelineRasterizationState.xml
+++ b/doc/classes/RDPipelineRasterizationState.xml
@@ -1,13 +1,16 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="RDPipelineRasterizationState" inherits="RefCounted" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
+ Pipeline rasterization state (used by [RenderingDevice]).
</brief_description>
<description>
+ This object is used by [RenderingDevice].
</description>
<tutorials>
</tutorials>
<members>
<member name="cull_mode" type="int" setter="set_cull_mode" getter="get_cull_mode" enum="RenderingDevice.PolygonCullMode" default="0">
+ The cull mode to use when drawing polygons, which determines whether front faces or backfaces are hidden.
</member>
<member name="depth_bias_clamp" type="float" setter="set_depth_bias_clamp" getter="get_depth_bias_clamp" default="0.0">
</member>
@@ -18,16 +21,21 @@
<member name="depth_bias_slope_factor" type="float" setter="set_depth_bias_slope_factor" getter="get_depth_bias_slope_factor" default="0.0">
</member>
<member name="discard_primitives" type="bool" setter="set_discard_primitives" getter="get_discard_primitives" default="false">
+ If [code]true[/code], primitives are discarded immediately before the rasterization stage.
</member>
<member name="enable_depth_clamp" type="bool" setter="set_enable_depth_clamp" getter="get_enable_depth_clamp" default="false">
</member>
<member name="front_face" type="int" setter="set_front_face" getter="get_front_face" enum="RenderingDevice.PolygonFrontFace" default="0">
+ The winding order to use to determine which face of a triangle is considered its front face.
</member>
<member name="line_width" type="float" setter="set_line_width" getter="get_line_width" default="1.0">
+ THe line width to use when drawing lines (in pixels). Thick lines may not be supported on all hardware.
</member>
<member name="patch_control_points" type="int" setter="set_patch_control_points" getter="get_patch_control_points" default="1">
+ The number of control points to use when drawing a patch with tessellation enabled. Higher values result in higher quality at the cost of performance.
</member>
<member name="wireframe" type="bool" setter="set_wireframe" getter="get_wireframe" default="false">
+ If [code]true[/code], performs wireframe rendering for triangles instead of flat or textured rendering.
</member>
</members>
</class>
diff --git a/doc/classes/RDPipelineSpecializationConstant.xml b/doc/classes/RDPipelineSpecializationConstant.xml
index 3c1c8b3a76..9b1ca98708 100644
--- a/doc/classes/RDPipelineSpecializationConstant.xml
+++ b/doc/classes/RDPipelineSpecializationConstant.xml
@@ -1,15 +1,20 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="RDPipelineSpecializationConstant" inherits="RefCounted" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
+ Pipeline specialization constant (used by [RenderingDevice]).
</brief_description>
<description>
+ A [i]specialization constant[/i] is a way to create additional variants of shaders without actually increasing the number of shader versions that are compiled. This allows improving performance by reducing the number of shader versions and reducing [code]if[/code] branching, while still allowing shaders to be flexible for different use cases.
+ This object is used by [RenderingDevice].
</description>
<tutorials>
</tutorials>
<members>
<member name="constant_id" type="int" setter="set_constant_id" getter="get_constant_id" default="0">
+ The identifier of the specialization constant. This is a value starting from [code]0[/code] and that increments for every different specialization constant for a given shader.
</member>
<member name="value" type="Variant" setter="set_value" getter="get_value">
+ The specialization constant's value. Only [bool], [int] and [float] types are valid for specialization constants.
</member>
</members>
</class>
diff --git a/doc/classes/RDSamplerState.xml b/doc/classes/RDSamplerState.xml
index 3ddc73a05e..464fe61543 100644
--- a/doc/classes/RDSamplerState.xml
+++ b/doc/classes/RDSamplerState.xml
@@ -1,41 +1,57 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="RDSamplerState" inherits="RefCounted" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
+ Sampler state (used by [RenderingDevice]).
</brief_description>
<description>
+ This object is used by [RenderingDevice].
</description>
<tutorials>
</tutorials>
<members>
<member name="anisotropy_max" type="float" setter="set_anisotropy_max" getter="get_anisotropy_max" default="1.0">
+ Maximum anisotropy that can be used when sampling. Only effective if [member use_anisotropy] is [code]true[/code]. Higher values result in a sharper sampler at oblique angles, at the cost of performance (due to memory bandwidth). This value may be limited by the graphics hardware in use. Most graphics hardware only supports values up to [code]16.0[/code].
+ If [member anisotropy_max] is [code]1.0[/code], forcibly disables anisotropy even if [member use_anisotropy] is [code]true[/code].
</member>
<member name="border_color" type="int" setter="set_border_color" getter="get_border_color" enum="RenderingDevice.SamplerBorderColor" default="2">
+ The border color that will be returned when sampling outside the sampler's bounds and the [member repeat_u], [member repeat_v] or [member repeat_w] modes have repeating disabled.
</member>
<member name="compare_op" type="int" setter="set_compare_op" getter="get_compare_op" enum="RenderingDevice.CompareOperator" default="7">
+ The compare operation to use. Only effective if [member enable_compare] is [code]true[/code].
</member>
<member name="enable_compare" type="bool" setter="set_enable_compare" getter="get_enable_compare" default="false">
+ If [code]true[/code], returned values will be based on the comparison operation defined in [member compare_op]. This is a hardware-based approach and is therefore faster than performing this manually in a shader. For example, compare operations are used for shadow map rendering by comparing depth values from a shadow sampler.
</member>
<member name="lod_bias" type="float" setter="set_lod_bias" getter="get_lod_bias" default="0.0">
+ The mipmap LOD bias to use. Positive values will make the sampler blurrier at a given distance, while negative values will make the sampler sharper at a given distance (at the risk of looking grainy). Recommended values are between [code]-0.5[/code] and [code]0.0[/code]. Only effective if the sampler has mipmaps available.
</member>
<member name="mag_filter" type="int" setter="set_mag_filter" getter="get_mag_filter" enum="RenderingDevice.SamplerFilter" default="0">
+ The sampler's magnification filter.
</member>
<member name="max_lod" type="float" setter="set_max_lod" getter="get_max_lod" default="1e+20">
+ The maximum mipmap LOD bias to display (lowest resolution). Only effective if the sampler has mipmaps available.
</member>
<member name="min_filter" type="int" setter="set_min_filter" getter="get_min_filter" enum="RenderingDevice.SamplerFilter" default="0">
</member>
<member name="min_lod" type="float" setter="set_min_lod" getter="get_min_lod" default="0.0">
+ The minimum mipmap LOD bias to display (highest resolution). Only effective if the sampler has mipmaps available.
</member>
<member name="mip_filter" type="int" setter="set_mip_filter" getter="get_mip_filter" enum="RenderingDevice.SamplerFilter" default="0">
+ The filtering method to use for mipmaps.
</member>
<member name="repeat_u" type="int" setter="set_repeat_u" getter="get_repeat_u" enum="RenderingDevice.SamplerRepeatMode" default="2">
+ The repeat mode to use along the U axis of UV coordinates. This affects the returned values if sampling outside the UV bounds.
</member>
<member name="repeat_v" type="int" setter="set_repeat_v" getter="get_repeat_v" enum="RenderingDevice.SamplerRepeatMode" default="2">
+ The repeat mode to use along the V axis of UV coordinates. This affects the returned values if sampling outside the UV bounds.
</member>
<member name="repeat_w" type="int" setter="set_repeat_w" getter="get_repeat_w" enum="RenderingDevice.SamplerRepeatMode" default="2">
+ The repeat mode to use along the W axis of UV coordinates. This affects the returned values if sampling outside the UV bounds. Only effective for 3D samplers.
</member>
<member name="unnormalized_uvw" type="bool" setter="set_unnormalized_uvw" getter="get_unnormalized_uvw" default="false">
</member>
<member name="use_anisotropy" type="bool" setter="set_use_anisotropy" getter="get_use_anisotropy" default="false">
+ If [code]true[/code], perform anisotropic sampling. See [member anisotropy_max].
</member>
</members>
</class>
diff --git a/doc/classes/RDShaderFile.xml b/doc/classes/RDShaderFile.xml
index 0a15e1048f..98c719e6c8 100644
--- a/doc/classes/RDShaderFile.xml
+++ b/doc/classes/RDShaderFile.xml
@@ -1,8 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="RDShaderFile" inherits="Resource" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
+ Compiled shader file in SPIR-V form (used by [RenderingDevice]). Not to be confused with Godot's own [Shader].
</brief_description>
<description>
+ Compiled shader file in SPIR-V form.
+ See also [RDShaderSource]. [RDShaderFile] is only meant to be used with the [RenderingDevice] API. It should not be confused with Godot's own [Shader] resource, which is what Godot's various nodes use for high-level shader programming.
</description>
<tutorials>
</tutorials>
@@ -11,11 +14,13 @@
<return type="RDShaderSPIRV" />
<param index="0" name="version" type="StringName" default="&amp;&quot;&quot;" />
<description>
+ Returns the SPIR-V intermediate representation for the specified shader [param version].
</description>
</method>
<method name="get_version_list" qualifiers="const">
<return type="StringName[]" />
<description>
+ Returns the list of compiled versions for this shader.
</description>
</method>
<method name="set_bytecode">
@@ -23,11 +28,13 @@
<param index="0" name="bytecode" type="RDShaderSPIRV" />
<param index="1" name="version" type="StringName" default="&amp;&quot;&quot;" />
<description>
+ Sets the SPIR-V [param bytecode] that will be compiled for the specified [param version].
</description>
</method>
</methods>
<members>
<member name="base_error" type="String" setter="set_base_error" getter="get_base_error" default="&quot;&quot;">
+ The base compilation error message, which indicates errors not related to a specific shader stage if non-empty. If empty, shader compilation is not necessarily successful (check [RDShaderSPIRV]'s error message members).
</member>
</members>
</class>
diff --git a/doc/classes/RDShaderSPIRV.xml b/doc/classes/RDShaderSPIRV.xml
index c17699882b..3fc69431d2 100644
--- a/doc/classes/RDShaderSPIRV.xml
+++ b/doc/classes/RDShaderSPIRV.xml
@@ -1,8 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="RDShaderSPIRV" inherits="Resource" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
+ SPIR-V intermediate representation as part of a [RDShaderFile] (used by [RenderingDevice]).
</brief_description>
<description>
+ [RDShaderSPIRV] represents a [RDShaderFile]'s [url=https://www.khronos.org/spir/]SPIR-V[/url] code for various shader stages, as well as possible compilation error messages. SPIR-V a low-level intermediate shader representation. This intermediate representation is not used directly by GPUs for rendering, but it can be compiled into binary shaders that GPUs can understand. Unlike compiled shaders, SPIR-V is portable across GPU models and driver versions.
+ This object is used by [RenderingDevice].
</description>
<tutorials>
</tutorials>
@@ -11,12 +14,14 @@
<return type="PackedByteArray" />
<param index="0" name="stage" type="int" enum="RenderingDevice.ShaderStage" />
<description>
+ Equivalent to getting one of [member bytecode_compute], [member bytecode_fragment], [member bytecode_tesselation_control], [member bytecode_tesselation_evaluation], [member bytecode_vertex].
</description>
</method>
<method name="get_stage_compile_error" qualifiers="const">
<return type="String" />
<param index="0" name="stage" type="int" enum="RenderingDevice.ShaderStage" />
<description>
+ Returns the compilation error message for the given shader [param stage]. Equivalent to getting one of [member compile_error_compute], [member compile_error_fragment], [member compile_error_tesselation_control], [member compile_error_tesselation_evaluation], [member compile_error_vertex].
</description>
</method>
<method name="set_stage_bytecode">
@@ -24,6 +29,7 @@
<param index="0" name="stage" type="int" enum="RenderingDevice.ShaderStage" />
<param index="1" name="bytecode" type="PackedByteArray" />
<description>
+ Sets the SPIR-V [param bytecode] for the given shader [param stage]. Equivalent to setting one of [member bytecode_compute], [member bytecode_fragment], [member bytecode_tesselation_control], [member bytecode_tesselation_evaluation], [member bytecode_vertex].
</description>
</method>
<method name="set_stage_compile_error">
@@ -31,29 +37,40 @@
<param index="0" name="stage" type="int" enum="RenderingDevice.ShaderStage" />
<param index="1" name="compile_error" type="String" />
<description>
+ Sets the compilation error message for the given shader [param stage] to [param compile_error]. Equivalent to setting one of [member compile_error_compute], [member compile_error_fragment], [member compile_error_tesselation_control], [member compile_error_tesselation_evaluation], [member compile_error_vertex].
</description>
</method>
</methods>
<members>
<member name="bytecode_compute" type="PackedByteArray" setter="set_stage_bytecode" getter="get_stage_bytecode" default="PackedByteArray()">
+ The SPIR-V bytecode for the compute shader stage.
</member>
<member name="bytecode_fragment" type="PackedByteArray" setter="set_stage_bytecode" getter="get_stage_bytecode" default="PackedByteArray()">
+ The SPIR-V bytecode for the fragment shader stage.
</member>
<member name="bytecode_tesselation_control" type="PackedByteArray" setter="set_stage_bytecode" getter="get_stage_bytecode" default="PackedByteArray()">
+ The SPIR-V bytecode for the tessellation control shader stage.
</member>
<member name="bytecode_tesselation_evaluation" type="PackedByteArray" setter="set_stage_bytecode" getter="get_stage_bytecode" default="PackedByteArray()">
+ The SPIR-V bytecode for the tessellation evaluation shader stage.
</member>
<member name="bytecode_vertex" type="PackedByteArray" setter="set_stage_bytecode" getter="get_stage_bytecode" default="PackedByteArray()">
+ The SPIR-V bytecode for the vertex shader stage.
</member>
<member name="compile_error_compute" type="String" setter="set_stage_compile_error" getter="get_stage_compile_error" default="&quot;&quot;">
+ The compilation error message for the compute shader stage (set by the SPIR-V compiler and Godot). If empty, shader compilation was successful.
</member>
<member name="compile_error_fragment" type="String" setter="set_stage_compile_error" getter="get_stage_compile_error" default="&quot;&quot;">
+ The compilation error message for the fragment shader stage (set by the SPIR-V compiler and Godot). If empty, shader compilation was successful.
</member>
<member name="compile_error_tesselation_control" type="String" setter="set_stage_compile_error" getter="get_stage_compile_error" default="&quot;&quot;">
+ The compilation error message for the tessellation control shader stage (set by the SPIR-V compiler and Godot). If empty, shader compilation was successful.
</member>
<member name="compile_error_tesselation_evaluation" type="String" setter="set_stage_compile_error" getter="get_stage_compile_error" default="&quot;&quot;">
+ The compilation error message for the tessellation evaluation shader stage (set by the SPIR-V compiler and Godot). If empty, shader compilation was successful.
</member>
<member name="compile_error_vertex" type="String" setter="set_stage_compile_error" getter="get_stage_compile_error" default="&quot;&quot;">
+ The compilation error message for the vertex shader stage (set by the SPIR-V compiler and Godot). If empty, shader compilation was successful.
</member>
</members>
</class>
diff --git a/doc/classes/RDShaderSource.xml b/doc/classes/RDShaderSource.xml
index d7fbb6a1ee..054e882b91 100644
--- a/doc/classes/RDShaderSource.xml
+++ b/doc/classes/RDShaderSource.xml
@@ -1,8 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="RDShaderSource" inherits="RefCounted" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
+ Shader source code (used by [RenderingDevice]).
</brief_description>
<description>
+ Shader source code in text form.
+ See also [RDShaderFile]. [RDShaderSource] is only meant to be used with the [RenderingDevice] API. It should not be confused with Godot's own [Shader] resource, which is what Godot's various nodes use for high-level shader programming.
</description>
<tutorials>
</tutorials>
@@ -11,6 +14,7 @@
<return type="String" />
<param index="0" name="stage" type="int" enum="RenderingDevice.ShaderStage" />
<description>
+ Returns source code for the specified shader [param stage]. Equivalent to getting one of [member source_compute], [member source_fragment], [member source_tesselation_control], [member source_tesselation_evaluation] or [member source_vertex].
</description>
</method>
<method name="set_stage_source">
@@ -18,21 +22,28 @@
<param index="0" name="stage" type="int" enum="RenderingDevice.ShaderStage" />
<param index="1" name="source" type="String" />
<description>
+ Sets [param source] code for the specified shader [param stage]. Equivalent to setting one of [member source_compute], [member source_fragment], [member source_tesselation_control], [member source_tesselation_evaluation] or [member source_vertex].
</description>
</method>
</methods>
<members>
<member name="language" type="int" setter="set_language" getter="get_language" enum="RenderingDevice.ShaderLanguage" default="0">
+ The language the shader is written in.
</member>
<member name="source_compute" type="String" setter="set_stage_source" getter="get_stage_source" default="&quot;&quot;">
+ Source code for the shader's compute stage.
</member>
<member name="source_fragment" type="String" setter="set_stage_source" getter="get_stage_source" default="&quot;&quot;">
+ Source code for the shader's fragment stage.
</member>
<member name="source_tesselation_control" type="String" setter="set_stage_source" getter="get_stage_source" default="&quot;&quot;">
+ Source code for the shader's tessellation control stage.
</member>
<member name="source_tesselation_evaluation" type="String" setter="set_stage_source" getter="get_stage_source" default="&quot;&quot;">
+ Source code for the shader's tessellation evaluation stage.
</member>
<member name="source_vertex" type="String" setter="set_stage_source" getter="get_stage_source" default="&quot;&quot;">
+ Source code for the shader's vertex stage.
</member>
</members>
</class>
diff --git a/doc/classes/RDTextureFormat.xml b/doc/classes/RDTextureFormat.xml
index 6ba5a62113..ff674a8d7e 100644
--- a/doc/classes/RDTextureFormat.xml
+++ b/doc/classes/RDTextureFormat.xml
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="RDTextureFormat" inherits="RefCounted" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
+ Texture format (used by [RenderingDevice]).
</brief_description>
<description>
+ This object is used by [RenderingDevice].
</description>
<tutorials>
</tutorials>
@@ -22,22 +24,31 @@
</methods>
<members>
<member name="array_layers" type="int" setter="set_array_layers" getter="get_array_layers" default="1">
+ The number of layers in the texture. Only relevant for 2D texture arrays.
</member>
<member name="depth" type="int" setter="set_depth" getter="get_depth" default="1">
+ The texture's depth (in pixels). This is always [code]1[/code] for 2D textures.
</member>
<member name="format" type="int" setter="set_format" getter="get_format" enum="RenderingDevice.DataFormat" default="8">
+ The texture's pixel data format.
</member>
<member name="height" type="int" setter="set_height" getter="get_height" default="1">
+ The texture's height (in pixels).
</member>
<member name="mipmaps" type="int" setter="set_mipmaps" getter="get_mipmaps" default="1">
+ The number of mipmaps available in the texture.
</member>
<member name="samples" type="int" setter="set_samples" getter="get_samples" enum="RenderingDevice.TextureSamples" default="0">
+ The number of samples used when sampling the texture.
</member>
<member name="texture_type" type="int" setter="set_texture_type" getter="get_texture_type" enum="RenderingDevice.TextureType" default="1">
+ The texture type.
</member>
<member name="usage_bits" type="int" setter="set_usage_bits" getter="get_usage_bits" enum="RenderingDevice.TextureUsageBits" default="0">
+ The texture's usage bits, which determine what can be done using the texture.
</member>
<member name="width" type="int" setter="set_width" getter="get_width" default="1">
+ The texture's width (in pixels).
</member>
</members>
</class>
diff --git a/doc/classes/RDTextureView.xml b/doc/classes/RDTextureView.xml
index 064bd11319..4e4e93f88a 100644
--- a/doc/classes/RDTextureView.xml
+++ b/doc/classes/RDTextureView.xml
@@ -1,21 +1,28 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="RDTextureView" inherits="RefCounted" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
+ Texture view (used by [RenderingDevice]).
</brief_description>
<description>
+ This object is used by [RenderingDevice].
</description>
<tutorials>
</tutorials>
<members>
<member name="format_override" type="int" setter="set_format_override" getter="get_format_override" enum="RenderingDevice.DataFormat" default="218">
+ Optional override for the data format to return sampled values in. The default value of [constant RenderingDevice.DATA_FORMAT_MAX] does not override the format.
</member>
<member name="swizzle_a" type="int" setter="set_swizzle_a" getter="get_swizzle_a" enum="RenderingDevice.TextureSwizzle" default="6">
+ The channel to sample when sampling the alpha channel.
</member>
<member name="swizzle_b" type="int" setter="set_swizzle_b" getter="get_swizzle_b" enum="RenderingDevice.TextureSwizzle" default="5">
+ The channel to sample when sampling the blue color channel.
</member>
<member name="swizzle_g" type="int" setter="set_swizzle_g" getter="get_swizzle_g" enum="RenderingDevice.TextureSwizzle" default="4">
+ The channel to sample when sampling the green color channel.
</member>
<member name="swizzle_r" type="int" setter="set_swizzle_r" getter="get_swizzle_r" enum="RenderingDevice.TextureSwizzle" default="3">
+ The channel to sample when sampling the red color channel.
</member>
</members>
</class>
diff --git a/doc/classes/RDUniform.xml b/doc/classes/RDUniform.xml
index 9fb2979676..a2d05502e7 100644
--- a/doc/classes/RDUniform.xml
+++ b/doc/classes/RDUniform.xml
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="RDUniform" inherits="RefCounted" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
+ Shader uniform (used by [RenderingDevice]).
</brief_description>
<description>
+ This object is used by [RenderingDevice].
</description>
<tutorials>
</tutorials>
@@ -26,8 +28,10 @@
</methods>
<members>
<member name="binding" type="int" setter="set_binding" getter="get_binding" default="0">
+ The uniform's binding.
</member>
<member name="uniform_type" type="int" setter="set_uniform_type" getter="get_uniform_type" enum="RenderingDevice.UniformType" default="3">
+ The uniform's data type.
</member>
</members>
</class>
diff --git a/doc/classes/RDVertexAttribute.xml b/doc/classes/RDVertexAttribute.xml
index f5c7d08ac9..9347edf9db 100644
--- a/doc/classes/RDVertexAttribute.xml
+++ b/doc/classes/RDVertexAttribute.xml
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="RDVertexAttribute" inherits="RefCounted" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
+ Vertex attribute (used by [RenderingDevice]).
</brief_description>
<description>
+ This object is used by [RenderingDevice].
</description>
<tutorials>
</tutorials>
diff --git a/doc/classes/Rect2.xml b/doc/classes/Rect2.xml
index 143c199cac..c402040c65 100644
--- a/doc/classes/Rect2.xml
+++ b/doc/classes/Rect2.xml
@@ -154,7 +154,7 @@
<param index="0" name="b" type="Rect2" />
<param index="1" name="include_borders" type="bool" default="false" />
<description>
- Returns [code]true[/code] if the [Rect2] overlaps with [code]b[/code] (i.e. they have at least one point in common).
+ Returns [code]true[/code] if the [Rect2] overlaps with [param b] (i.e. they have at least one point in common).
If [param include_borders] is [code]true[/code], they will also be considered overlapping if their borders touch, even without intersection.
</description>
</method>
diff --git a/doc/classes/Rect2i.xml b/doc/classes/Rect2i.xml
index 44c7345edb..ba20bb60e6 100644
--- a/doc/classes/Rect2i.xml
+++ b/doc/classes/Rect2i.xml
@@ -143,7 +143,7 @@
<return type="Rect2i" />
<param index="0" name="b" type="Rect2i" />
<description>
- Returns the intersection of this [Rect2i] and [code]b[/code].
+ Returns the intersection of this [Rect2i] and [param b].
If the rectangles do not intersect, an empty [Rect2i] is returned.
</description>
</method>
@@ -151,7 +151,7 @@
<return type="bool" />
<param index="0" name="b" type="Rect2i" />
<description>
- Returns [code]true[/code] if the [Rect2i] overlaps with [code]b[/code] (i.e. they have at least one point in common).
+ Returns [code]true[/code] if the [Rect2i] overlaps with [param b] (i.e. they have at least one point in common).
</description>
</method>
<method name="merge" qualifiers="const">
diff --git a/doc/classes/ReflectionProbe.xml b/doc/classes/ReflectionProbe.xml
index f890831fa4..42922d51e2 100644
--- a/doc/classes/ReflectionProbe.xml
+++ b/doc/classes/ReflectionProbe.xml
@@ -15,13 +15,13 @@
</tutorials>
<members>
<member name="ambient_color" type="Color" setter="set_ambient_color" getter="get_ambient_color" default="Color(0, 0, 0, 1)">
- The custom ambient color to use within the [ReflectionProbe]'s [member size]. Only effective if [member ambient_mode] is [constant AMBIENT_COLOR].
+ The custom ambient color to use within the [ReflectionProbe]'s box defined by its [member size]. Only effective if [member ambient_mode] is [constant AMBIENT_COLOR].
</member>
<member name="ambient_color_energy" type="float" setter="set_ambient_color_energy" getter="get_ambient_color_energy" default="1.0">
- The custom ambient color energy to use within the [ReflectionProbe]'s [member size]. Only effective if [member ambient_mode] is [constant AMBIENT_COLOR].
+ The custom ambient color energy to use within the [ReflectionProbe]'s box defined by its [member size]. Only effective if [member ambient_mode] is [constant AMBIENT_COLOR].
</member>
<member name="ambient_mode" type="int" setter="set_ambient_mode" getter="get_ambient_mode" enum="ReflectionProbe.AmbientMode" default="1">
- The ambient color to use within the [ReflectionProbe]'s [member size]. The ambient color will smoothly blend with other [ReflectionProbe]s and the rest of the scene (outside the [ReflectionProbe]'s [member size]).
+ The ambient color to use within the [ReflectionProbe]'s box defined by its [member size]. The ambient color will smoothly blend with other [ReflectionProbe]s and the rest of the scene (outside the [ReflectionProbe]'s box defined by its [member size]).
</member>
<member name="box_projection" type="bool" setter="set_enable_box_projection" getter="is_box_projection_enabled" default="false">
If [code]true[/code], enables box projection. This makes reflections look more correct in rectangle-shaped rooms by offsetting the reflection center depending on the camera's location.
@@ -41,7 +41,7 @@
</member>
<member name="max_distance" type="float" setter="set_max_distance" getter="get_max_distance" default="0.0">
The maximum distance away from the [ReflectionProbe] an object can be before it is culled. Decrease this to improve performance, especially when using the [constant UPDATE_ALWAYS] [member update_mode].
- [b]Note:[/b] The maximum reflection distance is always at least equal to the probe's extents. This means that decreasing [member max_distance] will not always cull objects from reflections, especially if the reflection probe's [member size] is already large.
+ [b]Note:[/b] The maximum reflection distance is always at least equal to the probe's extents. This means that decreasing [member max_distance] will not always cull objects from reflections, especially if the reflection probe's box defined by its [member size] is already large.
</member>
<member name="mesh_lod_threshold" type="float" setter="set_mesh_lod_threshold" getter="get_mesh_lod_threshold" default="1.0">
The automatic LOD bias to use for meshes rendered within the [ReflectionProbe] (this is analog to [member Viewport.mesh_lod_threshold]). Higher values will use less detailed versions of meshes that have LOD variations generated. If set to [code]0.0[/code], automatic LOD is disabled. Increase [member mesh_lod_threshold] to improve performance at the cost of geometry detail, especially when using the [constant UPDATE_ALWAYS] [member update_mode].
@@ -66,13 +66,13 @@
Update the probe every frame. This provides better results for fast-moving dynamic objects (such as cars). However, it has a significant performance cost. Due to the cost, it's recommended to only use one ReflectionProbe with [constant UPDATE_ALWAYS] at most per scene. For all other use cases, use [constant UPDATE_ONCE].
</constant>
<constant name="AMBIENT_DISABLED" value="0" enum="AmbientMode">
- Do not apply any ambient lighting inside the [ReflectionProbe]'s [member size].
+ Do not apply any ambient lighting inside the [ReflectionProbe]'s box defined by its [member size].
</constant>
<constant name="AMBIENT_ENVIRONMENT" value="1" enum="AmbientMode">
- Apply automatically-sourced environment lighting inside the [ReflectionProbe]'s [member size].
+ Apply automatically-sourced environment lighting inside the [ReflectionProbe]'s box defined by its [member size].
</constant>
<constant name="AMBIENT_COLOR" value="2" enum="AmbientMode">
- Apply custom ambient lighting inside the [ReflectionProbe]'s [member size]. See [member ambient_color] and [member ambient_color_energy].
+ Apply custom ambient lighting inside the [ReflectionProbe]'s box defined by its [member size]. See [member ambient_color] and [member ambient_color_energy].
</constant>
</constants>
</class>
diff --git a/doc/classes/RenderingDevice.xml b/doc/classes/RenderingDevice.xml
index ec25b0a515..98e2730740 100644
--- a/doc/classes/RenderingDevice.xml
+++ b/doc/classes/RenderingDevice.xml
@@ -4,13 +4,14 @@
Abstraction for working with modern low-level graphics APIs.
</brief_description>
<description>
- [RenderingDevice] is an abstraction for working with modern low-level graphics APIs such as Vulkan.
- On startup, Godot creates a global [RenderingDevice] which can be retrieved using [method RenderingServer.get_rendering_device]. This global RenderingDevice performs drawing to the screen.
- Internally, [RenderingDevice] is used in Godot to provide support for several modern low-level graphics APIs while reducing the amount of code duplication required.
+ [RenderingDevice] is an abstraction for working with modern low-level graphics APIs such as Vulkan. Compared to [RenderingServer] (which works with Godot's own rendering subsystems), [RenderingDevice] is much lower-level and allows working more directly with the underlying graphics APIs. [RenderingDevice] is used in Godot to provide support for several modern low-level graphics APIs while reducing the amount of code duplication required. [RenderingDevice] can also be used in your own projects to perform things that are not exposed by [RenderingServer] or high-level nodes, such as using compute shaders.
+ On startup, Godot creates a global [RenderingDevice] which can be retrieved using [method RenderingServer.get_rendering_device]. This global [RenderingDevice] performs drawing to the screen.
[b]Local RenderingDevices:[/b] Using [method RenderingServer.create_local_rendering_device], you can create "secondary" rendering devices to perform drawing and GPU compute operations on separate threads.
+ [b]Note:[/b] [RenderingDevice] assumes intermediate knowledge of modern graphics APIs such as Vulkan, Direct3D 12, Metal or WebGPU. These graphics APIs are lower-level than OpenGL or Direct3D 11, requiring you to perform what was previously done by the graphics driver itself. If you have difficulty understanding the concepts used in this class, follow the [url=https://vulkan-tutorial.com/]Vulkan Tutorial[/url] or [url=https://vkguide.dev/]Vulkan Guide[/url]. It's recommended to have existing modern OpenGL or Direct3D 11 knowledge before attempting to learn a low-level graphics API.
[b]Note:[/b] [RenderingDevice] is not available when running in headless mode or when using the Compatibility rendering method.
</description>
<tutorials>
+ <link title="Using compute shaders">https://docs.godotengine.org/en/latest/tutorials/shaders/compute_shaders.html</link>
</tutorials>
<methods>
<method name="barrier">
@@ -18,6 +19,7 @@
<param index="0" name="from" type="int" enum="RenderingDevice.BarrierMask" default="7" />
<param index="1" name="to" type="int" enum="RenderingDevice.BarrierMask" default="7" />
<description>
+ Puts a memory barrier in place. This is used for synchronization to avoid data races. See also [method full_barrier], which may be useful for debugging.
</description>
</method>
<method name="buffer_clear">
@@ -52,6 +54,7 @@
<return type="void" />
<param index="0" name="name" type="String" />
<description>
+ Creates a timestamp marker with the specified [param name]. This is used for performance reporting with the [method get_captured_timestamp_cpu_time], [method get_captured_timestamp_gpu_time] and [method get_captured_timestamp_name] methods.
</description>
</method>
<method name="compute_list_add_barrier">
@@ -64,6 +67,24 @@
<return type="int" />
<param index="0" name="allow_draw_overlap" type="bool" default="false" />
<description>
+ Starts a list of compute commands created with the [code]compute_*[/code] methods. The returned value should be passed to other [code]compute_list_*[/code] functions.
+ If [code]allow_draw_overlap[/code] is true, you may have one draw list running at the same time as one compute list. Multiple compute lists cannot be created at the same time; you must finish the previous compute list first using [method compute_list_end].
+ A simple compute operation might look like this (code is not a complete example):
+ [codeblock]
+ var rd = RenderingDevice.new()
+ var compute_list = rd.compute_list_begin()
+
+ rd.compute_list_bind_compute_pipeline(compute_list, compute_shader_dilate_pipeline)
+ rd.compute_list_bind_uniform_set(compute_list, compute_base_uniform_set, 0)
+ rd.compute_list_bind_uniform_set(compute_list, dilate_uniform_set, 1)
+
+ for i in atlas_slices:
+ rd.compute_list_set_push_constant(compute_list, push_constant, push_constant.size())
+ rd.compute_list_dispatch(compute_list, group_size.x, group_size.y, group_size.z)
+ # No barrier, let them run all together.
+
+ rd.compute_list_end()
+ [/codeblock]
</description>
</method>
<method name="compute_list_bind_compute_pipeline">
@@ -88,12 +109,14 @@
<param index="2" name="y_groups" type="int" />
<param index="3" name="z_groups" type="int" />
<description>
+ Submits the compute list for processing on the GPU. This is the compute equivalent to [method draw_list_draw].
</description>
</method>
<method name="compute_list_end">
<return type="void" />
<param index="0" name="post_barrier" type="int" enum="RenderingDevice.BarrierMask" default="7" />
<description>
+ Finishes a list of compute commands created with the [code]compute_*[/code] methods.
</description>
</method>
<method name="compute_list_set_push_constant">
@@ -102,6 +125,7 @@
<param index="1" name="buffer" type="PackedByteArray" />
<param index="2" name="size_bytes" type="int" />
<description>
+ Sets the push constant data to [param buffer] for the specified [param compute_list]. The shader determines how this binary data is used. The buffer's size in bytes must also be specified in [param size_bytes] (this can be obtained by calling the [method PackedByteArray.size] method on the passed [param buffer]).
</description>
</method>
<method name="compute_pipeline_create">
@@ -109,17 +133,21 @@
<param index="0" name="shader" type="RID" />
<param index="1" name="specialization_constants" type="RDPipelineSpecializationConstant[]" default="[]" />
<description>
+ Creates a new compute pipeline. It can be accessed with the RID that is returned.
+ Once finished with your RID, you will want to free the RID using the RenderingDevice's [method free_rid] method.
</description>
</method>
<method name="compute_pipeline_is_valid">
<return type="bool" />
<param index="0" name="compute_pipeline" type="RID" />
<description>
+ Returns [code]true[/code] if the compute pipeline specified by the [param compute_pipeline] RID is valid, [code]false[/code] otherwise.
</description>
</method>
<method name="create_local_device">
<return type="RenderingDevice" />
<description>
+ Create a new local [RenderingDevice]. This is most useful for performing compute operations on the GPU independently from the rest of the engine.
</description>
</method>
<method name="draw_command_begin_label">
@@ -127,11 +155,14 @@
<param index="0" name="name" type="String" />
<param index="1" name="color" type="Color" />
<description>
+ Create a command buffer debug label region that can be displayed in third-party tools such as [url=https://renderdoc.org/]RenderDoc[/url]. All regions must be ended with a [method draw_command_end_label] call. When viewed from the linear series of submissions to a single queue, calls to [method draw_command_begin_label] and [method draw_command_end_label] must be matched and balanced.
+ The [code]VK_EXT_DEBUG_UTILS_EXTENSION_NAME[/code] Vulkan extension must be available and enabled for command buffer debug label region to work. See also [method draw_command_insert_label] and [method draw_command_end_label].
</description>
</method>
<method name="draw_command_end_label">
<return type="void" />
<description>
+ Ends the command buffer debug label region started by a [method draw_command_begin_label] call.
</description>
</method>
<method name="draw_command_insert_label">
@@ -139,6 +170,7 @@
<param index="0" name="name" type="String" />
<param index="1" name="color" type="Color" />
<description>
+ Inserts a command buffer debug label region in the current command buffer. Unlike [method draw_command_begin_label], this region should not be ended with a [method draw_command_end_label] call.
</description>
</method>
<method name="draw_list_begin">
@@ -154,6 +186,27 @@
<param index="8" name="region" type="Rect2" default="Rect2(0, 0, 0, 0)" />
<param index="9" name="storage_textures" type="RID[]" default="[]" />
<description>
+ Starts a list of raster drawing commands created with the [code]draw_*[/code] methods. The returned value should be passed to other [code]draw_list_*[/code] functions.
+ Multiple draw lists cannot be created at the same time; you must finish the previous draw list first using [method draw_list_end].
+ A simple drawing operation might look like this (code is not a complete example):
+ [codeblock]
+ var rd = RenderingDevice.new()
+ var clear_colors = PackedColorArray([Color(0, 0, 0, 0), Color(0, 0, 0, 0), Color(0, 0, 0, 0)]
+ var draw_list = rd.draw_list_begin(framebuffers[i], RenderingDevice.INITIAL_ACTION_CLEAR, RenderingDevice.FINAL_ACTION_READ, RenderingDevice.INITIAL_ACTION_CLEAR, RenderingDevice.FINAL_ACTION_DISCARD, clear_colors)
+
+ # Draw opaque.
+ rd.draw_list_bind_render_pipeline(draw_list, raster_pipeline)
+ rd.draw_list_bind_uniform_set(draw_list, raster_base_uniform, 0)
+ rd.draw_list_set_push_constant(draw_list, raster_push_constant, raster_push_constant.size())
+ rd.draw_list_draw(draw_list, false, 1, slice_triangle_count[i] * 3)
+ # Draw wire.
+ rd.draw_list_bind_render_pipeline(draw_list, raster_pipeline_wire)
+ rd.draw_list_bind_uniform_set(draw_list, raster_base_uniform, 0)
+ rd.draw_list_set_push_constant(draw_list, raster_push_constant, raster_push_constant.size())
+ rd.draw_list_draw(draw_list, false, 1, slice_triangle_count[i] * 3)
+
+ rd.draw_list_end()
+ [/codeblock]
</description>
</method>
<method name="draw_list_begin_for_screen">
@@ -161,6 +214,8 @@
<param index="0" name="screen" type="int" default="0" />
<param index="1" name="clear_color" type="Color" default="Color(0, 0, 0, 1)" />
<description>
+ High-level variant of [method draw_list_begin], with the parameters automtaically being adjusted for drawing onto the window specified by the [param screen] ID.
+ [b]Note:[/b] Cannot be used with local RenderingDevices, as these don't have a screen. If called on a local RenderingDevice, [method draw_list_begin_for_screen] returns [constant INVALID_ID].
</description>
</method>
<method name="draw_list_begin_split">
@@ -177,6 +232,7 @@
<param index="9" name="region" type="Rect2" default="Rect2(0, 0, 0, 0)" />
<param index="10" name="storage_textures" type="RID[]" default="[]" />
<description>
+ Variant of [method draw_list_begin] with support for multiple splits. The [param splits] parameter determines how many splits are created.
</description>
</method>
<method name="draw_list_bind_index_array">
@@ -184,6 +240,7 @@
<param index="0" name="draw_list" type="int" />
<param index="1" name="index_array" type="RID" />
<description>
+ Binds [param index_array] to the specified [param draw_list].
</description>
</method>
<method name="draw_list_bind_render_pipeline">
@@ -191,6 +248,7 @@
<param index="0" name="draw_list" type="int" />
<param index="1" name="render_pipeline" type="RID" />
<description>
+ Binds [param render_pipeline] to the specified [param draw_list].
</description>
</method>
<method name="draw_list_bind_uniform_set">
@@ -199,6 +257,7 @@
<param index="1" name="uniform_set" type="RID" />
<param index="2" name="set_index" type="int" />
<description>
+ Binds [param uniform_set] to the specified [param draw_list]. A [param set_index] must also be specified, which is an identifier starting from [code]0[/code] that must match the one expected by the draw list.
</description>
</method>
<method name="draw_list_bind_vertex_array">
@@ -206,12 +265,14 @@
<param index="0" name="draw_list" type="int" />
<param index="1" name="vertex_array" type="RID" />
<description>
+ Binds [param vertex_array] to the specified [param draw_list].
</description>
</method>
<method name="draw_list_disable_scissor">
<return type="void" />
<param index="0" name="draw_list" type="int" />
<description>
+ Removes and disables the scissor rectangle for the specified [param draw_list]. See also [method draw_list_enable_scissor].
</description>
</method>
<method name="draw_list_draw">
@@ -221,6 +282,7 @@
<param index="2" name="instances" type="int" />
<param index="3" name="procedural_vertex_count" type="int" default="0" />
<description>
+ Submits [param draw_list] for rendering on the GPU. This is the raster equivalent to [method compute_list_dispatch].
</description>
</method>
<method name="draw_list_enable_scissor">
@@ -228,12 +290,15 @@
<param index="0" name="draw_list" type="int" />
<param index="1" name="rect" type="Rect2" default="Rect2(0, 0, 0, 0)" />
<description>
+ Creates a scissor rectangle and enables it for the specified [param draw_list]. Scissor rectangles are used for clipping by discarding fragments that fall outside a specified rectangular portion of the screen. See also [method draw_list_disable_scissor].
+ [b]Note:[/b] The specified [param rect] is automatically intersected with the screen's dimensions, which means it cannot exceed the screen's dimensions.
</description>
</method>
<method name="draw_list_end">
<return type="void" />
<param index="0" name="post_barrier" type="int" enum="RenderingDevice.BarrierMask" default="7" />
<description>
+ Finishes a list of raster drawing commands created with the [code]draw_*[/code] methods.
</description>
</method>
<method name="draw_list_set_blend_constants">
@@ -241,7 +306,7 @@
<param index="0" name="draw_list" type="int" />
<param index="1" name="color" type="Color" />
<description>
- Sets blend constants for draw list, blend constants are used only if the graphics pipeline is created with [constant DYNAMIC_STATE_BLEND_CONSTANTS] flag set.
+ Sets blend constants for the specified [param draw_list] to [param color]. Blend constants are used only if the graphics pipeline is created with [constant DYNAMIC_STATE_BLEND_CONSTANTS] flag set.
</description>
</method>
<method name="draw_list_set_push_constant">
@@ -250,17 +315,20 @@
<param index="1" name="buffer" type="PackedByteArray" />
<param index="2" name="size_bytes" type="int" />
<description>
+ Sets the push constant data to [param buffer] for the specified [param draw_list]. The shader determines how this binary data is used. The buffer's size in bytes must also be specified in [param size_bytes] (this can be obtained by calling the [method PackedByteArray.size] method on the passed [param buffer]).
</description>
</method>
<method name="draw_list_switch_to_next_pass">
<return type="int" />
<description>
+ Switches to the next draw pass and returns the split's ID. Equivalent to [method draw_list_switch_to_next_pass_split] with [code]splits[/code] set to [code]1[/code].
</description>
</method>
<method name="draw_list_switch_to_next_pass_split">
<return type="PackedInt64Array" />
<param index="0" name="splits" type="int" />
<description>
+ Switches to the next draw pass, with the number of splits allocated specified in [param splits]. The return value is an array containing the ID of each split. For single-split usage, see [method draw_list_switch_to_next_pass].
</description>
</method>
<method name="framebuffer_create">
@@ -269,6 +337,8 @@
<param index="1" name="validate_with_format" type="int" default="-1" />
<param index="2" name="view_count" type="int" default="1" />
<description>
+ Creates a new framebuffer. It can be accessed with the RID that is returned.
+ Once finished with your RID, you will want to free the RID using the RenderingDevice's [method free_rid] method.
</description>
</method>
<method name="framebuffer_create_empty">
@@ -277,6 +347,8 @@
<param index="1" name="samples" type="int" enum="RenderingDevice.TextureSamples" default="0" />
<param index="2" name="validate_with_format" type="int" default="-1" />
<description>
+ Creates a new empty framebuffer. It can be accessed with the RID that is returned.
+ Once finished with your RID, you will want to free the RID using the RenderingDevice's [method free_rid] method.
</description>
</method>
<method name="framebuffer_create_multipass">
@@ -286,6 +358,8 @@
<param index="2" name="validate_with_format" type="int" default="-1" />
<param index="3" name="view_count" type="int" default="1" />
<description>
+ Creates a new multipass framebuffer. It can be accessed with the RID that is returned.
+ Once finished with your RID, you will want to free the RID using the RenderingDevice's [method free_rid] method.
</description>
</method>
<method name="framebuffer_format_create">
@@ -293,12 +367,15 @@
<param index="0" name="attachments" type="RDAttachmentFormat[]" />
<param index="1" name="view_count" type="int" default="1" />
<description>
+ Creates a new framebuffer format with the specified [param attachments] and [param view_count]. Returns the new framebuffer's unique framebuffer format ID.
+ If [code]view_count[/code] is greater than or equal to [code]2[/code], enables multiview which is used for VR rendering. This requires support for the Vulkan multiview extension.
</description>
</method>
<method name="framebuffer_format_create_empty">
<return type="int" />
<param index="0" name="samples" type="int" enum="RenderingDevice.TextureSamples" default="0" />
<description>
+ Creates a new empty framebuffer format with the specified number of [param samples] and returns its ID.
</description>
</method>
<method name="framebuffer_format_create_multipass">
@@ -307,6 +384,7 @@
<param index="1" name="passes" type="RDFramebufferPass[]" />
<param index="2" name="view_count" type="int" default="1" />
<description>
+ Creates a multipass framebuffer format with the specified [param attachments], [param passes] and [param view_count] and returns its ID. If [code]view_count[/code] is greater than or equal to [code]2[/code], enables multiview which is used for VR rendering. This requires support for the Vulkan multiview extension.
</description>
</method>
<method name="framebuffer_format_get_texture_samples">
@@ -314,72 +392,85 @@
<param index="0" name="format" type="int" />
<param index="1" name="render_pass" type="int" default="0" />
<description>
+ Returns the number of texture samples used for the given framebuffer [param format] ID (returned by [method framebuffer_get_format]).
</description>
</method>
<method name="framebuffer_get_format">
<return type="int" />
<param index="0" name="framebuffer" type="RID" />
<description>
+ Returns the format ID of the framebuffer specified by the [param framebuffer] RID. This ID is guaranteed to be unique for the same formats and does not need to be freed.
</description>
</method>
<method name="framebuffer_is_valid" qualifiers="const">
<return type="bool" />
<param index="0" name="framebuffer" type="RID" />
<description>
+ Returns [code]true[/code] if the framebuffer specified by the [param framebuffer] RID is valid, [code]false[/code] otherwise.
</description>
</method>
<method name="free_rid">
<return type="void" />
<param index="0" name="rid" type="RID" />
<description>
+ Tries to free an object in the RenderingDevice. To avoid memory leaks, this should be called after using an object as memory management does not occur automatically when using RenderingDevice directly.
</description>
</method>
<method name="full_barrier">
<return type="void" />
<description>
+ Puts a [i]full[/i] memory barrier in place. This is a memory [method barrier] with all flags enabled. [method full_barrier] it should only be used for debugging as it can severely impact performance.
</description>
</method>
<method name="get_captured_timestamp_cpu_time" qualifiers="const">
<return type="int" />
<param index="0" name="index" type="int" />
<description>
+ Returns the timestamp in CPU time for the rendering step specified by [param index] (in microseconds since the engine started). See also [method get_captured_timestamp_gpu_time] and [method capture_timestamp].
</description>
</method>
<method name="get_captured_timestamp_gpu_time" qualifiers="const">
<return type="int" />
<param index="0" name="index" type="int" />
<description>
+ Returns the timestamp in GPU time for the rendering step specified by [param index] (in microseconds since the engine started). See also [method get_captured_timestamp_cpu_time] and [method capture_timestamp].
</description>
</method>
<method name="get_captured_timestamp_name" qualifiers="const">
<return type="String" />
<param index="0" name="index" type="int" />
<description>
+ Returns the timestamp's name for the rendering step specified by [param index]. See also [method capture_timestamp].
</description>
</method>
<method name="get_captured_timestamps_count" qualifiers="const">
<return type="int" />
<description>
+ Returns the total number of timestamps (rendering steps) available for profiling.
</description>
</method>
<method name="get_captured_timestamps_frame" qualifiers="const">
<return type="int" />
<description>
+ Returns the index of the last frame rendered that has rendering timestamps available for querying.
</description>
</method>
<method name="get_device_name" qualifiers="const">
<return type="String" />
<description>
+ Returns the name of the video adapter (e.g. "GeForce GTX 1080/PCIe/SSE2"). Equivalent to [method RenderingServer.get_video_adapter_name]. See also [method get_device_vendor_name].
</description>
</method>
<method name="get_device_pipeline_cache_uuid" qualifiers="const">
<return type="String" />
<description>
+ Returns the universally unique identifier for the pipeline cache. This is used to cache shader files on disk, which avoids shader recompilations on subsequent engine runs. This UUID varies depending on the graphics card model, but also the driver version. Therefore, updating graphics drivers will invalidate the shader cache.
</description>
</method>
<method name="get_device_vendor_name" qualifiers="const">
<return type="String" />
<description>
+ Returns the vendor of the video adapter (e.g. "NVIDIA Corporation"). Equivalent to [method RenderingServer.get_video_adapter_vendor]. See also [method get_device_name].
</description>
</method>
<method name="get_driver_resource">
@@ -388,17 +479,20 @@
<param index="1" name="rid" type="RID" />
<param index="2" name="index" type="int" />
<description>
+ Returns the unique identifier of the driver [param resource] for the specified [param rid]. Some driver resource types ignore the specified [param rid] (see [enum DriverResource] descriptions). [param index] is always ignored but must be specified anyway.
</description>
</method>
<method name="get_frame_delay" qualifiers="const">
<return type="int" />
<description>
+ Returns the frame count kept by the graphics API. Higher values result in higher input lag, but with more consistent throughput. For the main [RenderingDevice], frames are cycled (usually 3 with triple-buffered V-Sync enabled). However, local [RenderingDevice]s only have 1 frame.
</description>
</method>
<method name="get_memory_usage" qualifiers="const">
<return type="int" />
<param index="0" name="type" type="int" enum="RenderingDevice.MemoryType" />
<description>
+ Returns the memory usage in bytes corresponding to the given [param type]. When using Vulkan, these statistics are calculated by [url=https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator]Vulkan Memory Allocator[/url].
</description>
</method>
<method name="index_array_create">
@@ -407,6 +501,8 @@
<param index="1" name="index_offset" type="int" />
<param index="2" name="index_count" type="int" />
<description>
+ Creates a new index array. It can be accessed with the RID that is returned.
+ Once finished with your RID, you will want to free the RID using the RenderingDevice's [method free_rid] method.
</description>
</method>
<method name="index_buffer_create">
@@ -416,12 +512,16 @@
<param index="2" name="data" type="PackedByteArray" default="PackedByteArray()" />
<param index="3" name="use_restart_indices" type="bool" default="false" />
<description>
+ Creates a new index buffer. It can be accessed with the RID that is returned.
+ Once finished with your RID, you will want to free the RID using the RenderingDevice's [method free_rid] method.
</description>
</method>
<method name="limit_get" qualifiers="const">
<return type="int" />
<param index="0" name="limit" type="int" enum="RenderingDevice.Limit" />
<description>
+ Returns the value of the specified [param limit]. This limit varies depending on the current graphics hardware (and sometimes the driver version). If the given limit is exceeded, rendering errors will occur.
+ Limits for various graphics hardware can be found in the [url=https://vulkan.gpuinfo.org/]Vulkan Hardware Database[/url].
</description>
</method>
<method name="render_pipeline_create">
@@ -438,35 +538,54 @@
<param index="9" name="for_render_pass" type="int" default="0" />
<param index="10" name="specialization_constants" type="RDPipelineSpecializationConstant[]" default="[]" />
<description>
+ Creates a new render pipeline. It can be accessed with the RID that is returned.
+ Once finished with your RID, you will want to free the RID using the RenderingDevice's [method free_rid] method.
</description>
</method>
<method name="render_pipeline_is_valid">
<return type="bool" />
<param index="0" name="render_pipeline" type="RID" />
<description>
+ Returns [code]true[/code] if the render pipeline specified by the [param render_pipeline] RID is valid, [code]false[/code] otherwise.
</description>
</method>
<method name="sampler_create">
<return type="RID" />
<param index="0" name="state" type="RDSamplerState" />
<description>
+ Creates a new sampler. It can be accessed with the RID that is returned.
+ Once finished with your RID, you will want to free the RID using the RenderingDevice's [method free_rid] method.
+ </description>
+ </method>
+ <method name="sampler_is_format_supported_for_filter" qualifiers="const">
+ <return type="bool" />
+ <param index="0" name="format" type="int" enum="RenderingDevice.DataFormat" />
+ <param index="1" name="sampler_filter" type="int" enum="RenderingDevice.SamplerFilter" />
+ <description>
+ Returns [code]true[/code] if implementation supports using a texture of [param format] with the given [param sampler_filter].
</description>
</method>
<method name="screen_get_framebuffer_format" qualifiers="const">
<return type="int" />
<description>
+ Returns the screen's framebuffer format.
+ [b]Note:[/b] Only the main [RenderingDevice] returned by [method RenderingServer.get_rendering_device] has a format. If called on a local [RenderingDevice], this method prints an error and returns [constant INVALID_ID].
</description>
</method>
<method name="screen_get_height" qualifiers="const">
<return type="int" />
<param index="0" name="screen" type="int" default="0" />
<description>
+ Returns the window height matching the graphics API context for the given window ID (in pixels). Despite the parameter being named [param screen], this returns the [i]window[/i] size. See also [method screen_get_width].
+ [b]Note:[/b] Only the main [RenderingDevice] returned by [method RenderingServer.get_rendering_device] has a height. If called on a local [RenderingDevice], this method prints an error and returns [constant INVALID_ID].
</description>
</method>
<method name="screen_get_width" qualifiers="const">
<return type="int" />
<param index="0" name="screen" type="int" default="0" />
<description>
+ Returns the window width matching the graphics API context for the given window ID (in pixels). Despite the parameter being named [param screen], this returns the [i]window[/i] size. See also [method screen_get_height].
+ [b]Note:[/b] Only the main [RenderingDevice] returned by [method RenderingServer.get_rendering_device] has a width. If called on a local [RenderingDevice], this method prints an error and returns [constant INVALID_ID].
</description>
</method>
<method name="set_resource_name">
@@ -474,6 +593,9 @@
<param index="0" name="id" type="RID" />
<param index="1" name="name" type="String" />
<description>
+ Sets the resource name for [param id] to [param name]. This is used for debugging with third-party tools such as [url=https://renderdoc.org/]RenderDoc[/url].
+ The following types of resources can be named: texture, sampler, vertex buffer, index buffer, uniform buffer, texture buffer, storage buffer, uniform set buffer, shader, render pipeline and compute pipeline. Framebuffers cannot be named. Attempting to name an incompatible resource type will print an error.
+ [b]Note:[/b] Resource names are only set when the engine runs in verbose mode ([method OS.is_stdout_verbose] = [code]true[/code]), or when using an engine build compiled with the [code]dev_mode=yes[/code] SCons option. The graphics driver must also support the [code]VK_EXT_DEBUG_UTILS_EXTENSION_NAME[/code] Vulkan extension for named resources to work.
</description>
</method>
<method name="shader_compile_binary_from_spirv">
@@ -481,6 +603,8 @@
<param index="0" name="spirv_data" type="RDShaderSPIRV" />
<param index="1" name="name" type="String" default="&quot;&quot;" />
<description>
+ Compiles a binary shader from [param spirv_data] and returns the compiled binary data as a [PackedByteArray]. This compiled shader is specific to the GPU model and driver version used; it will not work on different GPU models or even different driver versions. See also [method shader_compile_spirv_from_source].
+ [param name] is an optional human-readable name that can be given to the compiled shader for organizational purposes.
</description>
</method>
<method name="shader_compile_spirv_from_source">
@@ -488,12 +612,16 @@
<param index="0" name="shader_source" type="RDShaderSource" />
<param index="1" name="allow_cache" type="bool" default="true" />
<description>
+ Compiles a SPIR-V from the shader source code in [param shader_source] and returns the SPIR-V as a [RDShaderSPIRV]. This intermediate language shader is portable across different GPU models and driver versions, but cannot be run directly by GPUs until compiled into a binary shader using [method shader_compile_binary_from_spirv].
+ If [param allow_cache] is [code]true[/code], make use of the shader cache generated by Godot. This avoids a potentially lengthy shader compilation step if the shader is already in cache. If [param allow_cache] is [code]false[/code], Godot's shader cache is ignored and the shader will always be recompiled.
</description>
</method>
<method name="shader_create_from_bytecode">
<return type="RID" />
<param index="0" name="binary_data" type="PackedByteArray" />
<description>
+ Creates a new shader instance from a binary compiled shader. It can be accessed with the RID that is returned.
+ Once finished with your RID, you will want to free the RID using the RenderingDevice's [method free_rid] method. See also [method shader_compile_binary_from_spirv] and [method shader_create_from_spirv].
</description>
</method>
<method name="shader_create_from_spirv">
@@ -501,6 +629,8 @@
<param index="0" name="spirv_data" type="RDShaderSPIRV" />
<param index="1" name="name" type="String" default="&quot;&quot;" />
<description>
+ Creates a new shader instance from SPIR-V intermediate code. It can be accessed with the RID that is returned.
+ Once finished with your RID, you will want to free the RID using the RenderingDevice's [method free_rid] method. See also [method shader_compile_spirv_from_source] and [method shader_create_from_bytecode].
</description>
</method>
<method name="shader_get_vertex_input_attribute_mask">
@@ -515,16 +645,23 @@
<param index="1" name="data" type="PackedByteArray" default="PackedByteArray()" />
<param index="2" name="usage" type="int" enum="RenderingDevice.StorageBufferUsage" default="0" />
<description>
+ Creates a [url=https://vkguide.dev/docs/chapter-4/storage_buffers/]storage buffer[/url] with the specified [param data] and [param usage]. It can be accessed with the RID that is returned.
+ Once finished with your RID, you will want to free the RID using the RenderingDevice's [method free_rid] method.
</description>
</method>
<method name="submit">
<return type="void" />
<description>
+ Pushes the frame setup and draw command buffers then marks the local device as currently processing (which allows calling [method sync]).
+ [b]Note:[/b] Only available in local RenderingDevices.
</description>
</method>
<method name="sync">
<return type="void" />
<description>
+ Forces a synchronization between the CPU and GPU, which may be required in certain cases. Only call this when needed, as CPU-GPU synchronization has a performance cost.
+ [b]Note:[/b] Only available in local RenderingDevices.
+ [b]Note:[/b] [method sync] can only be called after a [method submit].
</description>
</method>
<method name="texture_buffer_create">
@@ -533,6 +670,8 @@
<param index="1" name="format" type="int" enum="RenderingDevice.DataFormat" />
<param index="2" name="data" type="PackedByteArray" default="PackedByteArray()" />
<description>
+ Creates a new texture buffer. It can be accessed with the RID that is returned.
+ Once finished with your RID, you will want to free the RID using the RenderingDevice's [method free_rid] method.
</description>
</method>
<method name="texture_clear">
@@ -545,6 +684,8 @@
<param index="5" name="layer_count" type="int" />
<param index="6" name="post_barrier" type="int" enum="RenderingDevice.BarrierMask" default="7" />
<description>
+ Clears the specified [param texture] by replacing all of its pixels with the specified [param color]. [param base_mipmap] and [param mipmap_count] determine which mipmaps of the texture are affected by this clear operation, while [param base_layer] and [param layer_count] determine which layers of a 3D texture (or texture array) are affected by this clear operation. For 2D textures (which only have one layer by design), [param base_layer] and [param layer_count] must both be [code]0[/code].
+ [b]Note:[/b] [param texture] can't be cleared while a draw list that uses it as part of a framebuffer is being created. Ensure the draw list is finalized (and that the color/depth texture using it is not set to [constant FINAL_ACTION_CONTINUE]) to clear this texture.
</description>
</method>
<method name="texture_copy">
@@ -560,6 +701,12 @@
<param index="8" name="dst_layer" type="int" />
<param index="9" name="post_barrier" type="int" enum="RenderingDevice.BarrierMask" default="7" />
<description>
+ Copies the [param from_texture] to [param to_texture] with the specified [param from_pos], [param to_pos] and [param size] coordinates. The Z axis of the [param from_pos], [param to_pos] and [param size] must be [code]0[/code] for 2-dimensional textures. Source and destination mipmaps/layers must also be specified, with these parameters being [code]0[/code] for textures without mipmaps or single-layer textures. Returns [constant @GlobalScope.OK] if the texture copy was successful or [constant @GlobalScope.ERR_INVALID_PARAMETER] otherwise.
+ [b]Note:[/b] [param from_texture] texture can't be copied while a draw list that uses it as part of a framebuffer is being created. Ensure the draw list is finalized (and that the color/depth texture using it is not set to [constant FINAL_ACTION_CONTINUE]) to copy this texture.
+ [b]Note:[/b] [param from_texture] texture requires the [constant TEXTURE_USAGE_CAN_COPY_FROM_BIT] to be retrieved.
+ [b]Note:[/b] [param to_texture] can't be copied while a draw list that uses it as part of a framebuffer is being created. Ensure the draw list is finalized (and that the color/depth texture using it is not set to [constant FINAL_ACTION_CONTINUE]) to copy this texture.
+ [b]Note:[/b] [param to_texture] requires the [constant TEXTURE_USAGE_CAN_COPY_TO_BIT] to be retrieved.
+ [b]Note:[/b] [param from_texture] and [param to_texture] must be of the same type (color or depth).
</description>
</method>
<method name="texture_create">
@@ -568,6 +715,9 @@
<param index="1" name="view" type="RDTextureView" />
<param index="2" name="data" type="PackedByteArray[]" default="[]" />
<description>
+ Creates a new texture. It can be accessed with the RID that is returned.
+ Once finished with your RID, you will want to free the RID using the RenderingDevice's [method free_rid] method.
+ [b]Note:[/b] Not to be confused with [method RenderingServer.texture_2d_create], which creates the Godot-specific [Texture2D] resource as opposed to the graphics API's own texture type.
</description>
</method>
<method name="texture_create_shared">
@@ -575,6 +725,7 @@
<param index="0" name="view" type="RDTextureView" />
<param index="1" name="with_texture" type="RID" />
<description>
+ Creates a shared texture using the specified [param view] and the texture information from [param with_texture].
</description>
</method>
<method name="texture_create_shared_from_slice">
@@ -586,6 +737,9 @@
<param index="4" name="mipmaps" type="int" default="1" />
<param index="5" name="slice_type" type="int" enum="RenderingDevice.TextureSliceType" default="0" />
<description>
+ Creates a shared texture using the specified [param view] and the texture information from [param with_texture]'s [param layer] and [param mipmap]. The number of included mipmaps from the original texture can be controlled using the [param mipmaps] parameter. Only relevant for textures with multiple layers, such as 3D textures, texture arrays and cubemaps. For single-layer textures, use [method texture_create_shared]
+ For 2D textures (which only have one layer), [param layer] must be [code]0[/code].
+ [b]Note:[/b] Layer slicing is only supported for 2D texture arrays, not 3D textures or cubemaps.
</description>
</method>
<method name="texture_get_data">
@@ -593,6 +747,9 @@
<param index="0" name="texture" type="RID" />
<param index="1" name="layer" type="int" />
<description>
+ Returns the [param texture] data for the specified [param layer] as raw binary data. For 2D textures (which only have one layer), [param layer] must be [code]0[/code].
+ [b]Note:[/b] [param texture] can't be retrieved while a draw list that uses it as part of a framebuffer is being created. Ensure the draw list is finalized (and that the color/depth texture using it is not set to [constant FINAL_ACTION_CONTINUE]) to retrieve this texture. Otherwise, an error is printed and a empty [PackedByteArray] is returned.
+ [b]Note:[/b] [param texture] requires the [constant TEXTURE_USAGE_CAN_COPY_FROM_BIT] to be retrieved. Otherwise, an error is printed and a empty [PackedByteArray] is returned.
</description>
</method>
<method name="texture_is_format_supported_for_usage" qualifiers="const">
@@ -600,18 +757,21 @@
<param index="0" name="format" type="int" enum="RenderingDevice.DataFormat" />
<param index="1" name="usage_flags" type="int" enum="RenderingDevice.TextureUsageBits" />
<description>
+ Returns [code]true[/code] if the specified [param format] is supported for the given [param usage_flags], [code]false[/code] otherwise.
</description>
</method>
<method name="texture_is_shared">
<return type="bool" />
<param index="0" name="texture" type="RID" />
<description>
+ Returns [code]true[/code] if the [param texture] is shared, [code]false[/code] otherwise. See [RDTextureView].
</description>
</method>
<method name="texture_is_valid">
<return type="bool" />
<param index="0" name="texture" type="RID" />
<description>
+ Returns [code]true[/code] if the [param texture] is valid, [code]false[/code] otherwise.
</description>
</method>
<method name="texture_resolve_multisample">
@@ -620,6 +780,14 @@
<param index="1" name="to_texture" type="RID" />
<param index="2" name="post_barrier" type="int" enum="RenderingDevice.BarrierMask" default="7" />
<description>
+ Resolves the [param from_texture] texture onto [param to_texture] with multisample antialiasing enabled. This must be used when rendering a framebuffer for MSAA to work. Returns [constant @GlobalScope.OK] if successful, [constant @GlobalScope.ERR_INVALID_PARAMETER] otherwise.
+ [b]Note:[/b] [param from_texture] and [param to_texture] textures must have the same dimension, format and type (color or depth).
+ [b]Note:[/b] [param from_texture] can't be copied while a draw list that uses it as part of a framebuffer is being created. Ensure the draw list is finalized (and that the color/depth texture using it is not set to [constant FINAL_ACTION_CONTINUE]) to resolve this texture.
+ [b]Note:[/b] [param from_texture] requires the [constant TEXTURE_USAGE_CAN_COPY_FROM_BIT] to be retrieved.
+ [b]Note:[/b] [param from_texture] must be multisampled and must also be 2D (or a slice of a 3D/cubemap texture).
+ [b]Note:[/b] [param to_texture] can't be copied while a draw list that uses it as part of a framebuffer is being created. Ensure the draw list is finalized (and that the color/depth texture using it is not set to [constant FINAL_ACTION_CONTINUE]) to resolve this texture.
+ [b]Note:[/b] [param to_texture] texture requires the [constant TEXTURE_USAGE_CAN_COPY_TO_BIT] to be retrieved.
+ [b]Note:[/b] [param to_texture] texture must [b]not[/b] be multisampled and must also be 2D (or a slice of a 3D/cubemap texture).
</description>
</method>
<method name="texture_update">
@@ -629,6 +797,10 @@
<param index="2" name="data" type="PackedByteArray" />
<param index="3" name="post_barrier" type="int" enum="RenderingDevice.BarrierMask" default="7" />
<description>
+ Updates texture data with new data, replacing the previous data in place. The updated texture data must have the same dimensions and format. For 2D textures (which only have one layer), [param layer] must be [code]0[/code]. Returns [constant @GlobalScope.OK] if the update was successful, [constant @GlobalScope.ERR_INVALID_PARAMETER] otherwise.
+ [b]Note:[/b] Updating textures is forbidden during creation of a draw or compute list.
+ [b]Note:[/b] The existing [param texture] can't be updated while a draw list that uses it as part of a framebuffer is being created. Ensure the draw list is finalized (and that the color/depth texture using it is not set to [constant FINAL_ACTION_CONTINUE]) to update this texture.
+ [b]Note:[/b] The existing [param texture] requires the [constant TEXTURE_USAGE_CAN_UPDATE_BIT] to be updatable.
</description>
</method>
<method name="uniform_buffer_create">
@@ -636,6 +808,8 @@
<param index="0" name="size_bytes" type="int" />
<param index="1" name="data" type="PackedByteArray" default="PackedByteArray()" />
<description>
+ It can be accessed with the RID that is returned.
+ Once finished with your RID, you will want to free the RID using the RenderingDevice's [method free_rid] method.
</description>
</method>
<method name="uniform_set_create">
@@ -644,6 +818,8 @@
<param index="1" name="shader" type="RID" />
<param index="2" name="shader_set" type="int" />
<description>
+ It can be accessed with the RID that is returned.
+ Once finished with your RID, you will want to free the RID using the RenderingDevice's [method free_rid] method.
</description>
</method>
<method name="uniform_set_is_valid">
@@ -668,12 +844,15 @@
<param index="1" name="data" type="PackedByteArray" default="PackedByteArray()" />
<param index="2" name="use_as_storage" type="bool" default="false" />
<description>
+ It can be accessed with the RID that is returned.
+ Once finished with your RID, you will want to free the RID using the RenderingDevice's [method free_rid] method.
</description>
</method>
<method name="vertex_format_create">
<return type="int" />
<param index="0" name="vertex_descriptions" type="RDVertexAttribute[]" />
<description>
+ Creates a new vertex format with the specified [param vertex_descriptions]. Returns a unique vertex format ID corresponding to the newly created vertex format.
</description>
</method>
</methods>
@@ -697,478 +876,716 @@
Represents the size of the [enum DeviceType] enum.
</constant>
<constant name="DRIVER_RESOURCE_VULKAN_DEVICE" value="0" enum="DriverResource">
+ Vulkan device driver resource. This is a "global" resource and ignores the RID passed in
</constant>
<constant name="DRIVER_RESOURCE_VULKAN_PHYSICAL_DEVICE" value="1" enum="DriverResource">
+ Physical device (graphics card) driver resource.
</constant>
<constant name="DRIVER_RESOURCE_VULKAN_INSTANCE" value="2" enum="DriverResource">
+ Vulkan instance driver resource.
</constant>
<constant name="DRIVER_RESOURCE_VULKAN_QUEUE" value="3" enum="DriverResource">
+ Vulkan queue driver resource.
</constant>
<constant name="DRIVER_RESOURCE_VULKAN_QUEUE_FAMILY_INDEX" value="4" enum="DriverResource">
+ Vulkan queue family index driver resource.
</constant>
<constant name="DRIVER_RESOURCE_VULKAN_IMAGE" value="5" enum="DriverResource">
+ Vulkan image driver resource.
</constant>
<constant name="DRIVER_RESOURCE_VULKAN_IMAGE_VIEW" value="6" enum="DriverResource">
+ Vulkan image view driver resource.
</constant>
<constant name="DRIVER_RESOURCE_VULKAN_IMAGE_NATIVE_TEXTURE_FORMAT" value="7" enum="DriverResource">
+ Vulkan image native texture format driver resource.
</constant>
<constant name="DRIVER_RESOURCE_VULKAN_SAMPLER" value="8" enum="DriverResource">
+ Vulkan sampler driver resource.
</constant>
<constant name="DRIVER_RESOURCE_VULKAN_DESCRIPTOR_SET" value="9" enum="DriverResource">
+ Vulkan [url=https://vkguide.dev/docs/chapter-4/descriptors/]descriptor set[/url] driver resource.
</constant>
<constant name="DRIVER_RESOURCE_VULKAN_BUFFER" value="10" enum="DriverResource">
+ Vulkan buffer driver resource.
</constant>
<constant name="DRIVER_RESOURCE_VULKAN_COMPUTE_PIPELINE" value="11" enum="DriverResource">
+ Vulkan compute pipeline driver resource.
</constant>
<constant name="DRIVER_RESOURCE_VULKAN_RENDER_PIPELINE" value="12" enum="DriverResource">
+ Vulkan render pipeline driver resource.
</constant>
<constant name="DATA_FORMAT_R4G4_UNORM_PACK8" value="0" enum="DataFormat">
+ 4-bit-per-channel red/green channel data format, packed into 8 bits. Values are in the [code][0.0, 1.0][/code] range.
+ [b]Note:[/b] More information on all data formats can be found on the [url=https://registry.khronos.org/vulkan/specs/1.1/html/vkspec.html#_identification_of_formats]Identification of formats[/url] section of the Vulkan specification, as well as the [url=https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkFormat.html]VkFormat[/url] enum.
</constant>
<constant name="DATA_FORMAT_R4G4B4A4_UNORM_PACK16" value="1" enum="DataFormat">
+ 4-bit-per-channel red/green/blue/alpha channel data format, packed into 16 bits. Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_B4G4R4A4_UNORM_PACK16" value="2" enum="DataFormat">
+ 4-bit-per-channel blue/green/red/alpha channel data format, packed into 16 bits. Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R5G6B5_UNORM_PACK16" value="3" enum="DataFormat">
+ Red/green/blue channel data format with 5 bits of red, 6 bits of green and 5 bits of blue, packed into 16 bits. Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_B5G6R5_UNORM_PACK16" value="4" enum="DataFormat">
+ Blue/green/red channel data format with 5 bits of blue, 6 bits of green and 5 bits of red, packed into 16 bits. Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R5G5B5A1_UNORM_PACK16" value="5" enum="DataFormat">
+ Red/green/blue/alpha channel data format with 5 bits of red, 6 bits of green, 5 bits of blue and 1 bit of alpha, packed into 16 bits. Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_B5G5R5A1_UNORM_PACK16" value="6" enum="DataFormat">
+ Blue/green/red/alpha channel data format with 5 bits of blue, 6 bits of green, 5 bits of red and 1 bit of alpha, packed into 16 bits. Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_A1R5G5B5_UNORM_PACK16" value="7" enum="DataFormat">
+ Alpha/red/green/blue channel data format with 1 bit of alpha, 5 bits of red, 6 bits of green and 5 bits of blue, packed into 16 bits. Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R8_UNORM" value="8" enum="DataFormat">
+ 8-bit-per-channel unsigned floating-point red channel data format with normalized value. Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R8_SNORM" value="9" enum="DataFormat">
+ 8-bit-per-channel signed floating-point red channel data format with normalized value. Values are in the [code][-1.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R8_USCALED" value="10" enum="DataFormat">
+ 8-bit-per-channel unsigned floating-point red channel data format with scaled value (value is converted from integer to float). Values are in the [code][0.0, 255.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R8_SSCALED" value="11" enum="DataFormat">
+ 8-bit-per-channel signed floating-point red channel data format with scaled value (value is converted from integer to float). Values are in the [code][-127.0, 127.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R8_UINT" value="12" enum="DataFormat">
+ 8-bit-per-channel unsigned integer red channel data format. Values are in the [code][0, 255][/code] range.
</constant>
<constant name="DATA_FORMAT_R8_SINT" value="13" enum="DataFormat">
+ 8-bit-per-channel signed integer red channel data format. Values are in the [code][-127, 127][/code] range.
</constant>
<constant name="DATA_FORMAT_R8_SRGB" value="14" enum="DataFormat">
+ 8-bit-per-channel unsigned floating-point red channel data format with normalized value and non-linear sRGB encoding. Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R8G8_UNORM" value="15" enum="DataFormat">
+ 8-bit-per-channel unsigned floating-point red/green channel data format with normalized value. Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R8G8_SNORM" value="16" enum="DataFormat">
+ 8-bit-per-channel signed floating-point red/green channel data format with normalized value. Values are in the [code][-1.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R8G8_USCALED" value="17" enum="DataFormat">
+ 8-bit-per-channel unsigned floating-point red/green channel data format with scaled value (value is converted from integer to float). Values are in the [code][0.0, 255.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R8G8_SSCALED" value="18" enum="DataFormat">
+ 8-bit-per-channel signed floating-point red/green channel data format with scaled value (value is converted from integer to float). Values are in the [code][-127.0, 127.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R8G8_UINT" value="19" enum="DataFormat">
+ 8-bit-per-channel unsigned integer red/green channel data format. Values are in the [code][0, 255][/code] range.
</constant>
<constant name="DATA_FORMAT_R8G8_SINT" value="20" enum="DataFormat">
+ 8-bit-per-channel signed integer red/green channel data format. Values are in the [code][-127, 127][/code] range.
</constant>
<constant name="DATA_FORMAT_R8G8_SRGB" value="21" enum="DataFormat">
+ 8-bit-per-channel unsigned floating-point red/green channel data format with normalized value and non-linear sRGB encoding. Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R8G8B8_UNORM" value="22" enum="DataFormat">
+ 8-bit-per-channel unsigned floating-point red/green/blue channel data format with normalized value. Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R8G8B8_SNORM" value="23" enum="DataFormat">
+ 8-bit-per-channel signed floating-point red/green/blue channel data format with normalized value. Values are in the [code][-1.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R8G8B8_USCALED" value="24" enum="DataFormat">
+ 8-bit-per-channel unsigned floating-point red/green/blue channel data format with scaled value (value is converted from integer to float). Values are in the [code][0.0, 255.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R8G8B8_SSCALED" value="25" enum="DataFormat">
+ 8-bit-per-channel signed floating-point red/green/blue channel data format with scaled value (value is converted from integer to float). Values are in the [code][-127.0, 127.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R8G8B8_UINT" value="26" enum="DataFormat">
+ 8-bit-per-channel unsigned integer red/green/blue channel data format. Values are in the [code][0, 255][/code] range.
</constant>
<constant name="DATA_FORMAT_R8G8B8_SINT" value="27" enum="DataFormat">
+ 8-bit-per-channel signed integer red/green/blue channel data format. Values are in the [code][-127, 127][/code] range.
</constant>
<constant name="DATA_FORMAT_R8G8B8_SRGB" value="28" enum="DataFormat">
+ 8-bit-per-channel unsigned floating-point red/green/blue/blue channel data format with normalized value and non-linear sRGB encoding. Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_B8G8R8_UNORM" value="29" enum="DataFormat">
+ 8-bit-per-channel unsigned floating-point blue/green/red channel data format with normalized value. Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_B8G8R8_SNORM" value="30" enum="DataFormat">
+ 8-bit-per-channel signed floating-point blue/green/red channel data format with normalized value. Values are in the [code][-1.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_B8G8R8_USCALED" value="31" enum="DataFormat">
+ 8-bit-per-channel unsigned floating-point blue/green/red channel data format with scaled value (value is converted from integer to float). Values are in the [code][0.0, 255.0][/code] range.
</constant>
<constant name="DATA_FORMAT_B8G8R8_SSCALED" value="32" enum="DataFormat">
+ 8-bit-per-channel signed floating-point blue/green/red channel data format with scaled value (value is converted from integer to float). Values are in the [code][-127.0, 127.0][/code] range.
</constant>
<constant name="DATA_FORMAT_B8G8R8_UINT" value="33" enum="DataFormat">
+ 8-bit-per-channel unsigned integer blue/green/red channel data format. Values are in the [code][0, 255][/code] range.
</constant>
<constant name="DATA_FORMAT_B8G8R8_SINT" value="34" enum="DataFormat">
+ 8-bit-per-channel signed integer blue/green/red channel data format. Values are in the [code][-127, 127][/code] range.
</constant>
<constant name="DATA_FORMAT_B8G8R8_SRGB" value="35" enum="DataFormat">
+ 8-bit-per-channel unsigned floating-point blue/green/red data format with normalized value and non-linear sRGB encoding. Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R8G8B8A8_UNORM" value="36" enum="DataFormat">
+ 8-bit-per-channel unsigned floating-point red/green/blue/alpha channel data format with normalized value. Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R8G8B8A8_SNORM" value="37" enum="DataFormat">
+ 8-bit-per-channel signed floating-point red/green/blue/alpha channel data format with normalized value. Values are in the [code][-1.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R8G8B8A8_USCALED" value="38" enum="DataFormat">
+ 8-bit-per-channel unsigned floating-point red/green/blue/alpha channel data format with scaled value (value is converted from integer to float). Values are in the [code][0.0, 255.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R8G8B8A8_SSCALED" value="39" enum="DataFormat">
+ 8-bit-per-channel signed floating-point red/green/blue/alpha channel data format with scaled value (value is converted from integer to float). Values are in the [code][-127.0, 127.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R8G8B8A8_UINT" value="40" enum="DataFormat">
+ 8-bit-per-channel unsigned integer red/green/blue/alpha channel data format. Values are in the [code][0, 255][/code] range.
</constant>
<constant name="DATA_FORMAT_R8G8B8A8_SINT" value="41" enum="DataFormat">
+ 8-bit-per-channel signed integer red/green/blue/alpha channel data format. Values are in the [code][-127, 127][/code] range.
</constant>
<constant name="DATA_FORMAT_R8G8B8A8_SRGB" value="42" enum="DataFormat">
+ 8-bit-per-channel unsigned floating-point red/green/blue/alpha channel data format with normalized value and non-linear sRGB encoding. Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_B8G8R8A8_UNORM" value="43" enum="DataFormat">
+ 8-bit-per-channel unsigned floating-point blue/green/red/alpha channel data format with normalized value. Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_B8G8R8A8_SNORM" value="44" enum="DataFormat">
+ 8-bit-per-channel signed floating-point blue/green/red/alpha channel data format with normalized value. Values are in the [code][-1.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_B8G8R8A8_USCALED" value="45" enum="DataFormat">
+ 8-bit-per-channel unsigned floating-point blue/green/red/alpha channel data format with scaled value (value is converted from integer to float). Values are in the [code][0.0, 255.0][/code] range.
</constant>
<constant name="DATA_FORMAT_B8G8R8A8_SSCALED" value="46" enum="DataFormat">
+ 8-bit-per-channel signed floating-point blue/green/red/alpha channel data format with scaled value (value is converted from integer to float). Values are in the [code][-127.0, 127.0][/code] range.
</constant>
<constant name="DATA_FORMAT_B8G8R8A8_UINT" value="47" enum="DataFormat">
+ 8-bit-per-channel unsigned integer blue/green/red/alpha channel data format. Values are in the [code][0, 255][/code] range.
</constant>
<constant name="DATA_FORMAT_B8G8R8A8_SINT" value="48" enum="DataFormat">
+ 8-bit-per-channel signed integer blue/green/red/alpha channel data format. Values are in the [code][-127, 127][/code] range.
</constant>
<constant name="DATA_FORMAT_B8G8R8A8_SRGB" value="49" enum="DataFormat">
+ 8-bit-per-channel unsigned floating-point blue/green/red/alpha channel data format with normalized value and non-linear sRGB encoding. Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_A8B8G8R8_UNORM_PACK32" value="50" enum="DataFormat">
+ 8-bit-per-channel unsigned floating-point alpha/red/green/blue channel data format with normalized value, packed in 32 bits. Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_A8B8G8R8_SNORM_PACK32" value="51" enum="DataFormat">
+ 8-bit-per-channel signed floating-point alpha/red/green/blue channel data format with normalized value, packed in 32 bits. Values are in the [code][-1.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_A8B8G8R8_USCALED_PACK32" value="52" enum="DataFormat">
+ 8-bit-per-channel unsigned floating-point alpha/red/green/blue channel data format with scaled value (value is converted from integer to float), packed in 32 bits. Values are in the [code][0.0, 255.0][/code] range.
</constant>
<constant name="DATA_FORMAT_A8B8G8R8_SSCALED_PACK32" value="53" enum="DataFormat">
+ 8-bit-per-channel signed floating-point alpha/red/green/blue channel data format with scaled value (value is converted from integer to float), packed in 32 bits. Values are in the [code][-127.0, 127.0][/code] range.
</constant>
<constant name="DATA_FORMAT_A8B8G8R8_UINT_PACK32" value="54" enum="DataFormat">
+ 8-bit-per-channel unsigned integer alpha/red/green/blue channel data format, packed in 32 bits. Values are in the [code][0, 255][/code] range.
</constant>
<constant name="DATA_FORMAT_A8B8G8R8_SINT_PACK32" value="55" enum="DataFormat">
+ 8-bit-per-channel signed integer alpha/red/green/blue channel data format, packed in 32 bits. Values are in the [code][-127, 127][/code] range.
</constant>
<constant name="DATA_FORMAT_A8B8G8R8_SRGB_PACK32" value="56" enum="DataFormat">
+ 8-bit-per-channel unsigned floating-point alpha/red/green/blue channel data format with normalized value and non-linear sRGB encoding, packed in 32 bits. Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_A2R10G10B10_UNORM_PACK32" value="57" enum="DataFormat">
+ Unsigned floating-point alpha/red/green/blue channel data format with normalized value, packed in 32 bits. Format contains 2 bits of alpha, 10 bits of red, 10 bits of green and 10 bits of blue. Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_A2R10G10B10_SNORM_PACK32" value="58" enum="DataFormat">
+ Signed floating-point alpha/red/green/blue channel data format with normalized value, packed in 32 bits. Format contains 2 bits of alpha, 10 bits of red, 10 bits of green and 10 bits of blue. Values are in the [code][-1.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_A2R10G10B10_USCALED_PACK32" value="59" enum="DataFormat">
+ Unsigned floating-point alpha/red/green/blue channel data format with normalized value, packed in 32 bits. Format contains 2 bits of alpha, 10 bits of red, 10 bits of green and 10 bits of blue. Values are in the [code][0.0, 1023.0][/code] range for red/green/blue and [code][0.0, 3.0][/code] for alpha.
</constant>
<constant name="DATA_FORMAT_A2R10G10B10_SSCALED_PACK32" value="60" enum="DataFormat">
+ Signed floating-point alpha/red/green/blue channel data format with normalized value, packed in 32 bits. Format contains 2 bits of alpha, 10 bits of red, 10 bits of green and 10 bits of blue. Values are in the [code][-511.0, 511.0][/code] range for red/green/blue and [code][-1.0, 1.0][/code] for alpha.
</constant>
<constant name="DATA_FORMAT_A2R10G10B10_UINT_PACK32" value="61" enum="DataFormat">
+ Unsigned integer alpha/red/green/blue channel data format with normalized value, packed in 32 bits. Format contains 2 bits of alpha, 10 bits of red, 10 bits of green and 10 bits of blue. Values are in the [code][0, 1023][/code] range for red/green/blue and [code][0, 3][/code] for alpha.
</constant>
<constant name="DATA_FORMAT_A2R10G10B10_SINT_PACK32" value="62" enum="DataFormat">
+ Signed integer alpha/red/green/blue channel data format with normalized value, packed in 32 bits. Format contains 2 bits of alpha, 10 bits of red, 10 bits of green and 10 bits of blue. Values are in the [code][-511, 511][/code] range for red/green/blue and [code][-1, 1][/code] for alpha.
</constant>
<constant name="DATA_FORMAT_A2B10G10R10_UNORM_PACK32" value="63" enum="DataFormat">
+ Unsigned floating-point alpha/blue/green/red channel data format with normalized value, packed in 32 bits. Format contains 2 bits of alpha, 10 bits of blue, 10 bits of green and 10 bits of red. Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_A2B10G10R10_SNORM_PACK32" value="64" enum="DataFormat">
+ Signed floating-point alpha/blue/green/red channel data format with normalized value, packed in 32 bits. Format contains 2 bits of alpha, 10 bits of blue, 10 bits of green and 10 bits of red. Values are in the [code][-1.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_A2B10G10R10_USCALED_PACK32" value="65" enum="DataFormat">
+ Unsigned floating-point alpha/blue/green/red channel data format with normalized value, packed in 32 bits. Format contains 2 bits of alpha, 10 bits of blue, 10 bits of green and 10 bits of red. Values are in the [code][0.0, 1023.0][/code] range for blue/green/red and [code][0.0, 3.0][/code] for alpha.
</constant>
<constant name="DATA_FORMAT_A2B10G10R10_SSCALED_PACK32" value="66" enum="DataFormat">
+ Signed floating-point alpha/blue/green/red channel data format with normalized value, packed in 32 bits. Format contains 2 bits of alpha, 10 bits of blue, 10 bits of green and 10 bits of red. Values are in the [code][-511.0, 511.0][/code] range for blue/green/red and [code][-1.0, 1.0][/code] for alpha.
</constant>
<constant name="DATA_FORMAT_A2B10G10R10_UINT_PACK32" value="67" enum="DataFormat">
+ Unsigned integer alpha/blue/green/red channel data format with normalized value, packed in 32 bits. Format contains 2 bits of alpha, 10 bits of blue, 10 bits of green and 10 bits of red. Values are in the [code][0, 1023][/code] range for blue/green/red and [code][0, 3][/code] for alpha.
</constant>
<constant name="DATA_FORMAT_A2B10G10R10_SINT_PACK32" value="68" enum="DataFormat">
+ Signed integer alpha/blue/green/red channel data format with normalized value, packed in 32 bits. Format contains 2 bits of alpha, 10 bits of blue, 10 bits of green and 10 bits of red. Values are in the [code][-511, 511][/code] range for blue/green/red and [code][-1, 1][/code] for alpha.
</constant>
<constant name="DATA_FORMAT_R16_UNORM" value="69" enum="DataFormat">
+ 16-bit-per-channel unsigned floating-point red channel data format with normalized value. Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R16_SNORM" value="70" enum="DataFormat">
+ 16-bit-per-channel signed floating-point red channel data format with normalized value. Values are in the [code][-1.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R16_USCALED" value="71" enum="DataFormat">
+ 16-bit-per-channel unsigned floating-point red channel data format with scaled value (value is converted from integer to float). Values are in the [code][0.0, 65535.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R16_SSCALED" value="72" enum="DataFormat">
+ 16-bit-per-channel signed floating-point red channel data format with scaled value (value is converted from integer to float). Values are in the [code][-32767.0, 32767.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R16_UINT" value="73" enum="DataFormat">
+ 16-bit-per-channel unsigned integer red channel data format. Values are in the [code][0.0, 65535][/code] range.
</constant>
<constant name="DATA_FORMAT_R16_SINT" value="74" enum="DataFormat">
+ 16-bit-per-channel signed integer red channel data format. Values are in the [code][-32767, 32767][/code] range.
</constant>
<constant name="DATA_FORMAT_R16_SFLOAT" value="75" enum="DataFormat">
+ 16-bit-per-channel signed floating-point red channel data format with the value stored as-is.
</constant>
<constant name="DATA_FORMAT_R16G16_UNORM" value="76" enum="DataFormat">
+ 16-bit-per-channel unsigned floating-point red/green channel data format with normalized value. Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R16G16_SNORM" value="77" enum="DataFormat">
+ 16-bit-per-channel signed floating-point red/green channel data format with normalized value. Values are in the [code][-1.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R16G16_USCALED" value="78" enum="DataFormat">
+ 16-bit-per-channel unsigned floating-point red/green channel data format with scaled value (value is converted from integer to float). Values are in the [code][0.0, 65535.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R16G16_SSCALED" value="79" enum="DataFormat">
+ 16-bit-per-channel signed floating-point red/green channel data format with scaled value (value is converted from integer to float). Values are in the [code][-32767.0, 32767.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R16G16_UINT" value="80" enum="DataFormat">
+ 16-bit-per-channel unsigned integer red/green channel data format. Values are in the [code][0.0, 65535][/code] range.
</constant>
<constant name="DATA_FORMAT_R16G16_SINT" value="81" enum="DataFormat">
+ 16-bit-per-channel signed integer red/green channel data format. Values are in the [code][-32767, 32767][/code] range.
</constant>
<constant name="DATA_FORMAT_R16G16_SFLOAT" value="82" enum="DataFormat">
+ 16-bit-per-channel signed floating-point red/green channel data format with the value stored as-is.
</constant>
<constant name="DATA_FORMAT_R16G16B16_UNORM" value="83" enum="DataFormat">
+ 16-bit-per-channel unsigned floating-point red/green/blue channel data format with normalized value. Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R16G16B16_SNORM" value="84" enum="DataFormat">
+ 16-bit-per-channel signed floating-point red/green/blue channel data format with normalized value. Values are in the [code][-1.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R16G16B16_USCALED" value="85" enum="DataFormat">
+ 16-bit-per-channel unsigned floating-point red/green/blue channel data format with scaled value (value is converted from integer to float). Values are in the [code][0.0, 65535.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R16G16B16_SSCALED" value="86" enum="DataFormat">
+ 16-bit-per-channel signed floating-point red/green/blue channel data format with scaled value (value is converted from integer to float). Values are in the [code][-32767.0, 32767.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R16G16B16_UINT" value="87" enum="DataFormat">
+ 16-bit-per-channel unsigned integer red/green/blue channel data format. Values are in the [code][0.0, 65535][/code] range.
</constant>
<constant name="DATA_FORMAT_R16G16B16_SINT" value="88" enum="DataFormat">
+ 16-bit-per-channel signed integer red/green/blue channel data format. Values are in the [code][-32767, 32767][/code] range.
</constant>
<constant name="DATA_FORMAT_R16G16B16_SFLOAT" value="89" enum="DataFormat">
+ 16-bit-per-channel signed floating-point red/green/blue channel data format with the value stored as-is.
</constant>
<constant name="DATA_FORMAT_R16G16B16A16_UNORM" value="90" enum="DataFormat">
+ 16-bit-per-channel unsigned floating-point red/green/blue/alpha channel data format with normalized value. Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R16G16B16A16_SNORM" value="91" enum="DataFormat">
+ 16-bit-per-channel signed floating-point red/green/blue/alpha channel data format with normalized value. Values are in the [code][-1.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R16G16B16A16_USCALED" value="92" enum="DataFormat">
+ 16-bit-per-channel unsigned floating-point red/green/blue/alpha channel data format with scaled value (value is converted from integer to float). Values are in the [code][0.0, 65535.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R16G16B16A16_SSCALED" value="93" enum="DataFormat">
+ 16-bit-per-channel signed floating-point red/green/blue/alpha channel data format with scaled value (value is converted from integer to float). Values are in the [code][-32767.0, 32767.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R16G16B16A16_UINT" value="94" enum="DataFormat">
+ 16-bit-per-channel unsigned integer red/green/blue/alpha channel data format. Values are in the [code][0.0, 65535][/code] range.
</constant>
<constant name="DATA_FORMAT_R16G16B16A16_SINT" value="95" enum="DataFormat">
+ 16-bit-per-channel signed integer red/green/blue/alpha channel data format. Values are in the [code][-32767, 32767][/code] range.
</constant>
<constant name="DATA_FORMAT_R16G16B16A16_SFLOAT" value="96" enum="DataFormat">
+ 16-bit-per-channel signed floating-point red/green/blue/alpha channel data format with the value stored as-is.
</constant>
<constant name="DATA_FORMAT_R32_UINT" value="97" enum="DataFormat">
+ 32-bit-per-channel unsigned integer red channel data format. Values are in the [code][0, 2^32 - 1][/code] range.
</constant>
<constant name="DATA_FORMAT_R32_SINT" value="98" enum="DataFormat">
+ 32-bit-per-channel signed integer red channel data format. Values are in the [code][2^31 + 1, 2^31 - 1][/code] range.
</constant>
<constant name="DATA_FORMAT_R32_SFLOAT" value="99" enum="DataFormat">
+ 32-bit-per-channel signed floating-point red channel data format with the value stored as-is.
</constant>
<constant name="DATA_FORMAT_R32G32_UINT" value="100" enum="DataFormat">
+ 32-bit-per-channel unsigned integer red/green channel data format. Values are in the [code][0, 2^32 - 1][/code] range.
</constant>
<constant name="DATA_FORMAT_R32G32_SINT" value="101" enum="DataFormat">
+ 32-bit-per-channel signed integer red/green channel data format. Values are in the [code][2^31 + 1, 2^31 - 1][/code] range.
</constant>
<constant name="DATA_FORMAT_R32G32_SFLOAT" value="102" enum="DataFormat">
+ 32-bit-per-channel signed floating-point red/green channel data format with the value stored as-is.
</constant>
<constant name="DATA_FORMAT_R32G32B32_UINT" value="103" enum="DataFormat">
+ 32-bit-per-channel unsigned integer red/green/blue channel data format. Values are in the [code][0, 2^32 - 1][/code] range.
</constant>
<constant name="DATA_FORMAT_R32G32B32_SINT" value="104" enum="DataFormat">
+ 32-bit-per-channel signed integer red/green/blue channel data format. Values are in the [code][2^31 + 1, 2^31 - 1][/code] range.
</constant>
<constant name="DATA_FORMAT_R32G32B32_SFLOAT" value="105" enum="DataFormat">
+ 32-bit-per-channel signed floating-point red/green/blue channel data format with the value stored as-is.
</constant>
<constant name="DATA_FORMAT_R32G32B32A32_UINT" value="106" enum="DataFormat">
+ 32-bit-per-channel unsigned integer red/green/blue/alpha channel data format. Values are in the [code][0, 2^32 - 1][/code] range.
</constant>
<constant name="DATA_FORMAT_R32G32B32A32_SINT" value="107" enum="DataFormat">
+ 32-bit-per-channel signed integer red/green/blue/alpha channel data format. Values are in the [code][2^31 + 1, 2^31 - 1][/code] range.
</constant>
<constant name="DATA_FORMAT_R32G32B32A32_SFLOAT" value="108" enum="DataFormat">
+ 32-bit-per-channel signed floating-point red/green/blue/alpha channel data format with the value stored as-is.
</constant>
<constant name="DATA_FORMAT_R64_UINT" value="109" enum="DataFormat">
+ 64-bit-per-channel unsigned integer red channel data format. Values are in the [code][0, 2^64 - 1][/code] range.
</constant>
<constant name="DATA_FORMAT_R64_SINT" value="110" enum="DataFormat">
+ 64-bit-per-channel signed integer red channel data format. Values are in the [code][2^63 + 1, 2^63 - 1][/code] range.
</constant>
<constant name="DATA_FORMAT_R64_SFLOAT" value="111" enum="DataFormat">
+ 64-bit-per-channel signed floating-point red channel data format with the value stored as-is.
</constant>
<constant name="DATA_FORMAT_R64G64_UINT" value="112" enum="DataFormat">
+ 64-bit-per-channel unsigned integer red/green channel data format. Values are in the [code][0, 2^64 - 1][/code] range.
</constant>
<constant name="DATA_FORMAT_R64G64_SINT" value="113" enum="DataFormat">
+ 64-bit-per-channel signed integer red/green channel data format. Values are in the [code][2^63 + 1, 2^63 - 1][/code] range.
</constant>
<constant name="DATA_FORMAT_R64G64_SFLOAT" value="114" enum="DataFormat">
+ 64-bit-per-channel signed floating-point red/green channel data format with the value stored as-is.
</constant>
<constant name="DATA_FORMAT_R64G64B64_UINT" value="115" enum="DataFormat">
+ 64-bit-per-channel unsigned integer red/green/blue channel data format. Values are in the [code][0, 2^64 - 1][/code] range.
</constant>
<constant name="DATA_FORMAT_R64G64B64_SINT" value="116" enum="DataFormat">
+ 64-bit-per-channel signed integer red/green/blue channel data format. Values are in the [code][2^63 + 1, 2^63 - 1][/code] range.
</constant>
<constant name="DATA_FORMAT_R64G64B64_SFLOAT" value="117" enum="DataFormat">
+ 64-bit-per-channel signed floating-point red/green/blue channel data format with the value stored as-is.
</constant>
<constant name="DATA_FORMAT_R64G64B64A64_UINT" value="118" enum="DataFormat">
+ 64-bit-per-channel unsigned integer red/green/blue/alpha channel data format. Values are in the [code][0, 2^64 - 1][/code] range.
</constant>
<constant name="DATA_FORMAT_R64G64B64A64_SINT" value="119" enum="DataFormat">
+ 64-bit-per-channel signed integer red/green/blue/alpha channel data format. Values are in the [code][2^63 + 1, 2^63 - 1][/code] range.
</constant>
<constant name="DATA_FORMAT_R64G64B64A64_SFLOAT" value="120" enum="DataFormat">
+ 64-bit-per-channel signed floating-point red/green/blue/alpha channel data format with the value stored as-is.
</constant>
<constant name="DATA_FORMAT_B10G11R11_UFLOAT_PACK32" value="121" enum="DataFormat">
+ Unsigned floating-point blue/green/red data format with the value stored as-is, packed in 32 bits. The format's precision is 10 bits of blue channel, 11 bits of green channel and 11 bits of red channel.
</constant>
<constant name="DATA_FORMAT_E5B9G9R9_UFLOAT_PACK32" value="122" enum="DataFormat">
+ Unsigned floating-point exposure/blue/green/red data format with the value stored as-is, packed in 32 bits. The format's precision is 5 bits of exposure, 9 bits of blue channel, 9 bits of green channel and 9 bits of red channel.
</constant>
<constant name="DATA_FORMAT_D16_UNORM" value="123" enum="DataFormat">
+ 16-bit unsigned floating-point depth data format with normalized value. Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_X8_D24_UNORM_PACK32" value="124" enum="DataFormat">
+ 24-bit unsigned floating-point depth data format with normalized value, plus 8 unused bits, packed in 32 bits. Values for depth are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_D32_SFLOAT" value="125" enum="DataFormat">
+ 32-bit signed floating-point depth data format with the value stored as-is.
</constant>
<constant name="DATA_FORMAT_S8_UINT" value="126" enum="DataFormat">
+ 8-bit unsigned integer stencil data format.
</constant>
<constant name="DATA_FORMAT_D16_UNORM_S8_UINT" value="127" enum="DataFormat">
+ 16-bit unsigned floating-point depth data format with normalized value, plus 8 bits of stencil in unsigned integer format. Values for depth are in the [code][0.0, 1.0][/code] range. Values for stencil are in the [code][0, 255][/code] range.
</constant>
<constant name="DATA_FORMAT_D24_UNORM_S8_UINT" value="128" enum="DataFormat">
+ 24-bit unsigned floating-point depth data format with normalized value, plus 8 bits of stencil in unsigned integer format. Values for depth are in the [code][0.0, 1.0][/code] range. Values for stencil are in the [code][0, 255][/code] range.
</constant>
<constant name="DATA_FORMAT_D32_SFLOAT_S8_UINT" value="129" enum="DataFormat">
+ 32-bit signed floating-point depth data format with the value stored as-is, plus 8 bits of stencil in unsigned integer format. Values for stencil are in the [code][0, 255][/code] range.
</constant>
<constant name="DATA_FORMAT_BC1_RGB_UNORM_BLOCK" value="130" enum="DataFormat">
+ VRAM-compressed unsigned red/green/blue channel data format with normalized value. Values are in the [code][0.0, 1.0][/code] range. The format's precision is 5 bits of red channel, 6 bits of green channel and 5 bits of blue channel. Using BC1 texture compression (also known as S3TC DXT1).
</constant>
<constant name="DATA_FORMAT_BC1_RGB_SRGB_BLOCK" value="131" enum="DataFormat">
+ VRAM-compressed unsigned red/green/blue channel data format with normalized value and non-linear sRGB encoding. Values are in the [code][0.0, 1.0][/code] range. The format's precision is 5 bits of red channel, 6 bits of green channel and 5 bits of blue channel. Using BC1 texture compression (also known as S3TC DXT1).
</constant>
<constant name="DATA_FORMAT_BC1_RGBA_UNORM_BLOCK" value="132" enum="DataFormat">
+ VRAM-compressed unsigned red/green/blue/alpha channel data format with normalized value. Values are in the [code][0.0, 1.0][/code] range. The format's precision is 5 bits of red channel, 6 bits of green channel, 5 bits of blue channel and 1 bit of alpha channel. Using BC1 texture compression (also known as S3TC DXT1).
</constant>
<constant name="DATA_FORMAT_BC1_RGBA_SRGB_BLOCK" value="133" enum="DataFormat">
+ VRAM-compressed unsigned red/green/blue/alpha channel data format with normalized value and non-linear sRGB encoding. Values are in the [code][0.0, 1.0][/code] range. The format's precision is 5 bits of red channel, 6 bits of green channel, 5 bits of blue channel and 1 bit of alpha channel. Using BC1 texture compression (also known as S3TC DXT1).
</constant>
<constant name="DATA_FORMAT_BC2_UNORM_BLOCK" value="134" enum="DataFormat">
+ VRAM-compressed unsigned red/green/blue/alpha channel data format with normalized value. Values are in the [code][0.0, 1.0][/code] range. The format's precision is 5 bits of red channel, 6 bits of green channel, 5 bits of blue channel and 4 bits of alpha channel. Using BC2 texture compression (also known as S3TC DXT3).
</constant>
<constant name="DATA_FORMAT_BC2_SRGB_BLOCK" value="135" enum="DataFormat">
+ VRAM-compressed unsigned red/green/blue/alpha channel data format with normalized value and non-linear sRGB encoding. Values are in the [code][0.0, 1.0][/code] range. The format's precision is 5 bits of red channel, 6 bits of green channel, 5 bits of blue channel and 4 bits of alpha channel. Using BC2 texture compression (also known as S3TC DXT3).
</constant>
<constant name="DATA_FORMAT_BC3_UNORM_BLOCK" value="136" enum="DataFormat">
+ VRAM-compressed unsigned red/green/blue/alpha channel data format with normalized value. Values are in the [code][0.0, 1.0][/code] range. The format's precision is 5 bits of red channel, 6 bits of green channel, 5 bits of blue channel and 8 bits of alpha channel. Using BC3 texture compression (also known as S3TC DXT5).
</constant>
<constant name="DATA_FORMAT_BC3_SRGB_BLOCK" value="137" enum="DataFormat">
+ VRAM-compressed unsigned red/green/blue/alpha channel data format with normalized value and non-linear sRGB encoding. Values are in the [code][0.0, 1.0][/code] range. The format's precision is 5 bits of red channel, 6 bits of green channel, 5 bits of blue channel and 8 bits of alpha channel. Using BC3 texture compression (also known as S3TC DXT5).
</constant>
<constant name="DATA_FORMAT_BC4_UNORM_BLOCK" value="138" enum="DataFormat">
+ VRAM-compressed unsigned red channel data format with normalized value. Values are in the [code][0.0, 1.0][/code] range. The format's precision is 8 bits of red channel. Using BC4 texture compression.
</constant>
<constant name="DATA_FORMAT_BC4_SNORM_BLOCK" value="139" enum="DataFormat">
+ VRAM-compressed signed red channel data format with normalized value. Values are in the [code][-1.0, 1.0][/code] range. The format's precision is 8 bits of red channel. Using BC4 texture compression.
</constant>
<constant name="DATA_FORMAT_BC5_UNORM_BLOCK" value="140" enum="DataFormat">
+ VRAM-compressed unsigned red/green channel data format with normalized value. Values are in the [code][0.0, 1.0][/code] range. The format's precision is 8 bits of red channel and 8 bits of green channel. Using BC5 texture compression (also known as S3TC RGTC).
</constant>
<constant name="DATA_FORMAT_BC5_SNORM_BLOCK" value="141" enum="DataFormat">
+ VRAM-compressed signed red/green channel data format with normalized value. Values are in the [code][-1.0, 1.0][/code] range. The format's precision is 8 bits of red channel and 8 bits of green channel. Using BC5 texture compression (also known as S3TC RGTC).
</constant>
<constant name="DATA_FORMAT_BC6H_UFLOAT_BLOCK" value="142" enum="DataFormat">
+ VRAM-compressed unsigned red/green/blue channel data format with the floating-point value stored as-is. The format's precision is 8 bits of red channel and 8 bits of green channel. Using BC6H texture compression (also known as BPTC HDR).
</constant>
<constant name="DATA_FORMAT_BC6H_SFLOAT_BLOCK" value="143" enum="DataFormat">
+ VRAM-compressed signed red/green/blue channel data format with the floating-point value stored as-is. The format's precision is between 4 and 7 bits for the red/green/blue channels and between 0 and 8 bits for the alpha channel. Using BC7 texture compression (also known as BPTC HDR).
</constant>
<constant name="DATA_FORMAT_BC7_UNORM_BLOCK" value="144" enum="DataFormat">
+ VRAM-compressed unsigned red/green/blue/alpha channel data format with normalized value. Values are in the [code][0.0, 1.0][/code] range. The format's precision is between 4 and 7 bits for the red/green/blue channels and between 0 and 8 bits for the alpha channel. Also known as BPTC LDR.
</constant>
<constant name="DATA_FORMAT_BC7_SRGB_BLOCK" value="145" enum="DataFormat">
+ VRAM-compressed unsigned red/green/blue/alpha channel data format with normalized value and non-linear sRGB encoding. Values are in the [code][0.0, 1.0][/code] range. The format's precision is between 4 and 7 bits for the red/green/blue channels and between 0 and 8 bits for the alpha channel. Also known as BPTC LDR.
</constant>
<constant name="DATA_FORMAT_ETC2_R8G8B8_UNORM_BLOCK" value="146" enum="DataFormat">
+ VRAM-compressed unsigned red/green/blue channel data format with normalized value. Values are in the [code][0.0, 1.0][/code] range. Using ETC2 texture compression.
</constant>
<constant name="DATA_FORMAT_ETC2_R8G8B8_SRGB_BLOCK" value="147" enum="DataFormat">
+ VRAM-compressed unsigned red/green/blue channel data format with normalized value and non-linear sRGB encoding. Values are in the [code][0.0, 1.0][/code] range. Using ETC2 texture compression.
</constant>
<constant name="DATA_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK" value="148" enum="DataFormat">
+ VRAM-compressed unsigned red/green/blue/alpha channel data format with normalized value. Values are in the [code][0.0, 1.0][/code] range. Red/green/blue use 8 bit of precision each, with alpha using 1 bit of precision. Using ETC2 texture compression.
</constant>
<constant name="DATA_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK" value="149" enum="DataFormat">
+ VRAM-compressed unsigned red/green/blue/alpha channel data format with normalized value and non-linear sRGB encoding. Values are in the [code][0.0, 1.0][/code] range. Red/green/blue use 8 bit of precision each, with alpha using 1 bit of precision. Using ETC2 texture compression.
</constant>
<constant name="DATA_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK" value="150" enum="DataFormat">
+ VRAM-compressed unsigned red/green/blue/alpha channel data format with normalized value. Values are in the [code][0.0, 1.0][/code] range. Red/green/blue use 8 bits of precision each, with alpha using 8 bits of precision. Using ETC2 texture compression.
</constant>
<constant name="DATA_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK" value="151" enum="DataFormat">
+ VRAM-compressed unsigned red/green/blue/alpha channel data format with normalized value and non-linear sRGB encoding. Values are in the [code][0.0, 1.0][/code] range. Red/green/blue use 8 bits of precision each, with alpha using 8 bits of precision. Using ETC2 texture compression.
</constant>
<constant name="DATA_FORMAT_EAC_R11_UNORM_BLOCK" value="152" enum="DataFormat">
+ 11-bit VRAM-compressed unsigned red channel data format with normalized value. Values are in the [code][0.0, 1.0][/code] range. Using ETC2 texture compression.
</constant>
<constant name="DATA_FORMAT_EAC_R11_SNORM_BLOCK" value="153" enum="DataFormat">
+ 11-bit VRAM-compressed signed red channel data format with normalized value. Values are in the [code][0.0, 1.0][/code] range. Using ETC2 texture compression.
</constant>
<constant name="DATA_FORMAT_EAC_R11G11_UNORM_BLOCK" value="154" enum="DataFormat">
+ 11-bit VRAM-compressed unsigned red/green channel data format with normalized value. Values are in the [code][0.0, 1.0][/code] range. Using ETC2 texture compression.
</constant>
<constant name="DATA_FORMAT_EAC_R11G11_SNORM_BLOCK" value="155" enum="DataFormat">
+ 11-bit VRAM-compressed signed red/green channel data format with normalized value. Values are in the [code][0.0, 1.0][/code] range. Using ETC2 texture compression.
</constant>
<constant name="DATA_FORMAT_ASTC_4x4_UNORM_BLOCK" value="156" enum="DataFormat">
+ VRAM-compressed unsigned floating-point data format with normalized value, packed in 4×4 blocks (highest quality). Values are in the [code][0.0, 1.0][/code] range. Using ASTC compression.
</constant>
<constant name="DATA_FORMAT_ASTC_4x4_SRGB_BLOCK" value="157" enum="DataFormat">
+ VRAM-compressed unsigned floating-point data format with normalized value and non-linear sRGB encoding, packed in 4×4 blocks (highest quality). Values are in the [code][0.0, 1.0][/code] range. Using ASTC compression.
</constant>
<constant name="DATA_FORMAT_ASTC_5x4_UNORM_BLOCK" value="158" enum="DataFormat">
+ VRAM-compressed unsigned floating-point data format with normalized value, packed in 5×4 blocks. Values are in the [code][0.0, 1.0][/code] range. Using ASTC compression.
</constant>
<constant name="DATA_FORMAT_ASTC_5x4_SRGB_BLOCK" value="159" enum="DataFormat">
+ VRAM-compressed unsigned floating-point data format with normalized value and non-linear sRGB encoding, packed in 5×4 blocks. Values are in the [code][0.0, 1.0][/code] range. Using ASTC compression.
</constant>
<constant name="DATA_FORMAT_ASTC_5x5_UNORM_BLOCK" value="160" enum="DataFormat">
+ VRAM-compressed unsigned floating-point data format with normalized value, packed in 5×5 blocks. Values are in the [code][0.0, 1.0][/code] range. Using ASTC compression.
</constant>
<constant name="DATA_FORMAT_ASTC_5x5_SRGB_BLOCK" value="161" enum="DataFormat">
+ VRAM-compressed unsigned floating-point data format with normalized value and non-linear sRGB encoding, packed in 5×5 blocks. Values are in the [code][0.0, 1.0][/code] range. Using ASTC compression.
</constant>
<constant name="DATA_FORMAT_ASTC_6x5_UNORM_BLOCK" value="162" enum="DataFormat">
+ VRAM-compressed unsigned floating-point data format with normalized value, packed in 6×5 blocks. Values are in the [code][0.0, 1.0][/code] range. Using ASTC compression.
</constant>
<constant name="DATA_FORMAT_ASTC_6x5_SRGB_BLOCK" value="163" enum="DataFormat">
+ VRAM-compressed unsigned floating-point data format with normalized value and non-linear sRGB encoding, packed in 6×5 blocks. Values are in the [code][0.0, 1.0][/code] range. Using ASTC compression.
</constant>
<constant name="DATA_FORMAT_ASTC_6x6_UNORM_BLOCK" value="164" enum="DataFormat">
+ VRAM-compressed unsigned floating-point data format with normalized value, packed in 6×6 blocks. Values are in the [code][0.0, 1.0][/code] range. Using ASTC compression.
</constant>
<constant name="DATA_FORMAT_ASTC_6x6_SRGB_BLOCK" value="165" enum="DataFormat">
+ VRAM-compressed unsigned floating-point data format with normalized value and non-linear sRGB encoding, packed in 6×6 blocks. Values are in the [code][0.0, 1.0][/code] range. Using ASTC compression.
</constant>
<constant name="DATA_FORMAT_ASTC_8x5_UNORM_BLOCK" value="166" enum="DataFormat">
+ VRAM-compressed unsigned floating-point data format with normalized value, packed in 8×5 blocks. Values are in the [code][0.0, 1.0][/code] range. Using ASTC compression.
</constant>
<constant name="DATA_FORMAT_ASTC_8x5_SRGB_BLOCK" value="167" enum="DataFormat">
+ VRAM-compressed unsigned floating-point data format with normalized value and non-linear sRGB encoding, packed in 8×5 blocks. Values are in the [code][0.0, 1.0][/code] range. Using ASTC compression.
</constant>
<constant name="DATA_FORMAT_ASTC_8x6_UNORM_BLOCK" value="168" enum="DataFormat">
+ VRAM-compressed unsigned floating-point data format with normalized value, packed in 8×6 blocks. Values are in the [code][0.0, 1.0][/code] range. Using ASTC compression.
</constant>
<constant name="DATA_FORMAT_ASTC_8x6_SRGB_BLOCK" value="169" enum="DataFormat">
+ VRAM-compressed unsigned floating-point data format with normalized value and non-linear sRGB encoding, packed in 8×6 blocks. Values are in the [code][0.0, 1.0][/code] range. Using ASTC compression.
</constant>
<constant name="DATA_FORMAT_ASTC_8x8_UNORM_BLOCK" value="170" enum="DataFormat">
+ VRAM-compressed unsigned floating-point data format with normalized value, packed in 8×8 blocks. Values are in the [code][0.0, 1.0][/code] range. Using ASTC compression.
</constant>
<constant name="DATA_FORMAT_ASTC_8x8_SRGB_BLOCK" value="171" enum="DataFormat">
+ VRAM-compressed unsigned floating-point data format with normalized value and non-linear sRGB encoding, packed in 8×8 blocks. Values are in the [code][0.0, 1.0][/code] range. Using ASTC compression.
</constant>
<constant name="DATA_FORMAT_ASTC_10x5_UNORM_BLOCK" value="172" enum="DataFormat">
+ VRAM-compressed unsigned floating-point data format with normalized value, packed in 10×5 blocks. Values are in the [code][0.0, 1.0][/code] range. Using ASTC compression.
</constant>
<constant name="DATA_FORMAT_ASTC_10x5_SRGB_BLOCK" value="173" enum="DataFormat">
+ VRAM-compressed unsigned floating-point data format with normalized value and non-linear sRGB encoding, packed in 10×5 blocks. Values are in the [code][0.0, 1.0][/code] range. Using ASTC compression.
</constant>
<constant name="DATA_FORMAT_ASTC_10x6_UNORM_BLOCK" value="174" enum="DataFormat">
+ VRAM-compressed unsigned floating-point data format with normalized value, packed in 10×6 blocks. Values are in the [code][0.0, 1.0][/code] range. Using ASTC compression.
</constant>
<constant name="DATA_FORMAT_ASTC_10x6_SRGB_BLOCK" value="175" enum="DataFormat">
+ VRAM-compressed unsigned floating-point data format with normalized value and non-linear sRGB encoding, packed in 10×6 blocks. Values are in the [code][0.0, 1.0][/code] range. Using ASTC compression.
</constant>
<constant name="DATA_FORMAT_ASTC_10x8_UNORM_BLOCK" value="176" enum="DataFormat">
+ VRAM-compressed unsigned floating-point data format with normalized value, packed in 10×8 blocks. Values are in the [code][0.0, 1.0][/code] range. Using ASTC compression.
</constant>
<constant name="DATA_FORMAT_ASTC_10x8_SRGB_BLOCK" value="177" enum="DataFormat">
+ VRAM-compressed unsigned floating-point data format with normalized value and non-linear sRGB encoding, packed in 10×8 blocks. Values are in the [code][0.0, 1.0][/code] range. Using ASTC compression.
</constant>
<constant name="DATA_FORMAT_ASTC_10x10_UNORM_BLOCK" value="178" enum="DataFormat">
+ VRAM-compressed unsigned floating-point data format with normalized value, packed in 10×10 blocks. Values are in the [code][0.0, 1.0][/code] range. Using ASTC compression.
</constant>
<constant name="DATA_FORMAT_ASTC_10x10_SRGB_BLOCK" value="179" enum="DataFormat">
+ VRAM-compressed unsigned floating-point data format with normalized value and non-linear sRGB encoding, packed in 10×10 blocks. Values are in the [code][0.0, 1.0][/code] range. Using ASTC compression.
</constant>
<constant name="DATA_FORMAT_ASTC_12x10_UNORM_BLOCK" value="180" enum="DataFormat">
+ VRAM-compressed unsigned floating-point data format with normalized value, packed in 12×10 blocks. Values are in the [code][0.0, 1.0][/code] range. Using ASTC compression.
</constant>
<constant name="DATA_FORMAT_ASTC_12x10_SRGB_BLOCK" value="181" enum="DataFormat">
+ VRAM-compressed unsigned floating-point data format with normalized value and non-linear sRGB encoding, packed in 12×10 blocks. Values are in the [code][0.0, 1.0][/code] range. Using ASTC compression.
</constant>
<constant name="DATA_FORMAT_ASTC_12x12_UNORM_BLOCK" value="182" enum="DataFormat">
+ VRAM-compressed unsigned floating-point data format with normalized value, packed in 12 blocks (lowest quality). Values are in the [code][0.0, 1.0][/code] range. Using ASTC compression.
</constant>
<constant name="DATA_FORMAT_ASTC_12x12_SRGB_BLOCK" value="183" enum="DataFormat">
+ VRAM-compressed unsigned floating-point data format with normalized value and non-linear sRGB encoding, packed in 12 blocks (lowest quality). Values are in the [code][0.0, 1.0][/code] range. Using ASTC compression.
</constant>
<constant name="DATA_FORMAT_G8B8G8R8_422_UNORM" value="184" enum="DataFormat">
+ 8-bit-per-channel unsigned floating-point green/blue/red channel data format with normalized value. Values are in the [code][0.0, 1.0][/code] range. Blue and red channel data is stored at halved horizontal resolution (i.e. 2 horizontally adjacent pixels will share the same value for the blue/red channel).
</constant>
<constant name="DATA_FORMAT_B8G8R8G8_422_UNORM" value="185" enum="DataFormat">
+ 8-bit-per-channel unsigned floating-point blue/green/red channel data format with normalized value. Values are in the [code][0.0, 1.0][/code] range. Blue and red channel data is stored at halved horizontal resolution (i.e. 2 horizontally adjacent pixels will share the same value for the blue/red channel).
</constant>
<constant name="DATA_FORMAT_G8_B8_R8_3PLANE_420_UNORM" value="186" enum="DataFormat">
+ 8-bit-per-channel unsigned floating-point green/blue/red channel data with normalized value, stored across 3 separate planes (green + blue + red). Values are in the [code][0.0, 1.0][/code] range. Blue and red channel data is stored at halved horizontal and vertical resolution (i.e. 2×2 adjacent pixels will share the same value for the blue/red channel).
</constant>
<constant name="DATA_FORMAT_G8_B8R8_2PLANE_420_UNORM" value="187" enum="DataFormat">
+ 8-bit-per-channel unsigned floating-point green/blue/red channel data with normalized value, stored across 2 separate planes (green + blue/red). Values are in the [code][0.0, 1.0][/code] range. Blue and red channel data is stored at halved horizontal and vertical resolution (i.e. 2×2 adjacent pixels will share the same value for the blue/red channel).
</constant>
<constant name="DATA_FORMAT_G8_B8_R8_3PLANE_422_UNORM" value="188" enum="DataFormat">
+ 8-bit-per-channel unsigned floating-point green/blue/red channel data with normalized value, stored across 2 separate planes (green + blue + red). Values are in the [code][0.0, 1.0][/code] range. Blue and red channel data is stored at halved horizontal resolution (i.e. 2 horizontally adjacent pixels will share the same value for the blue/red channel).
</constant>
<constant name="DATA_FORMAT_G8_B8R8_2PLANE_422_UNORM" value="189" enum="DataFormat">
+ 8-bit-per-channel unsigned floating-point green/blue/red channel data with normalized value, stored across 2 separate planes (green + blue/red). Values are in the [code][0.0, 1.0][/code] range. Blue and red channel data is stored at halved horizontal resolution (i.e. 2 horizontally adjacent pixels will share the same value for the blue/red channel).
</constant>
<constant name="DATA_FORMAT_G8_B8_R8_3PLANE_444_UNORM" value="190" enum="DataFormat">
+ 8-bit-per-channel unsigned floating-point green/blue/red channel data with normalized value, stored across 3 separate planes. Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R10X6_UNORM_PACK16" value="191" enum="DataFormat">
+ 10-bit-per-channel unsigned floating-point red channel data with normalized value, plus 6 unused bits, packed in 16 bits. Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R10X6G10X6_UNORM_2PACK16" value="192" enum="DataFormat">
+ 10-bit-per-channel unsigned floating-point red/green channel data with normalized value, plus 6 unused bits after each channel, packed in 2×16 bits. Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16" value="193" enum="DataFormat">
+ 10-bit-per-channel unsigned floating-point red/green/blue/alpha channel data with normalized value, plus 6 unused bits after each channel, packed in 4×16 bits. Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16" value="194" enum="DataFormat">
+ 10-bit-per-channel unsigned floating-point green/blue/green/red channel data with normalized value, plus 6 unused bits after each channel, packed in 4×16 bits. Values are in the [code][0.0, 1.0][/code] range. Blue and red channel data is stored at halved horizontal resolution (i.e. 2 horizontally adjacent pixels will share the same value for the blue/red channel). The green channel is listed twice, but contains different values to allow it to be represented at full resolution.
</constant>
<constant name="DATA_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16" value="195" enum="DataFormat">
+ 10-bit-per-channel unsigned floating-point blue/green/red/green channel data with normalized value, plus 6 unused bits after each channel, packed in 4×16 bits. Values are in the [code][0.0, 1.0][/code] range. Blue and red channel data is stored at halved horizontal resolution (i.e. 2 horizontally adjacent pixels will share the same value for the blue/red channel). The green channel is listed twice, but contains different values to allow it to be represented at full resolution.
</constant>
<constant name="DATA_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16" value="196" enum="DataFormat">
+ 10-bit-per-channel unsigned floating-point green/blue/red channel data with normalized value, plus 6 unused bits after each channel. Packed in 3×16 bits and stored across 2 separate planes (green + blue + red). Values are in the [code][0.0, 1.0][/code] range. Blue and red channel data is stored at halved horizontal and vertical resolution (i.e. 2×2 adjacent pixels will share the same value for the blue/red channel).
</constant>
<constant name="DATA_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16" value="197" enum="DataFormat">
+ 10-bit-per-channel unsigned floating-point green/blue/red channel data with normalized value, plus 6 unused bits after each channel. Packed in 3×16 bits and stored across 2 separate planes (green + blue/red). Values are in the [code][0.0, 1.0][/code] range. Blue and red channel data is stored at halved horizontal and vertical resolution (i.e. 2×2 adjacent pixels will share the same value for the blue/red channel).
</constant>
<constant name="DATA_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16" value="198" enum="DataFormat">
+ 10-bit-per-channel unsigned floating-point green/blue/red channel data with normalized value, plus 6 unused bits after each channel. Packed in 3×16 bits and stored across 3 separate planes (green + blue + red). Values are in the [code][0.0, 1.0][/code] range. Blue and red channel data is stored at halved horizontal resolution (i.e. 2 horizontally adjacent pixels will share the same value for the blue/red channel).
</constant>
<constant name="DATA_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16" value="199" enum="DataFormat">
+ 10-bit-per-channel unsigned floating-point green/blue/red channel data with normalized value, plus 6 unused bits after each channel. Packed in 3×16 bits and stored across 3 separate planes (green + blue/red). Values are in the [code][0.0, 1.0][/code] range. Blue and red channel data is stored at halved horizontal resolution (i.e. 2 horizontally adjacent pixels will share the same value for the blue/red channel).
</constant>
<constant name="DATA_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16" value="200" enum="DataFormat">
+ 10-bit-per-channel unsigned floating-point green/blue/red channel data with normalized value, plus 6 unused bits after each channel. Packed in 3×16 bits and stored across 3 separate planes (green + blue + red). Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R12X4_UNORM_PACK16" value="201" enum="DataFormat">
+ 12-bit-per-channel unsigned floating-point red channel data with normalized value, plus 6 unused bits, packed in 16 bits. Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R12X4G12X4_UNORM_2PACK16" value="202" enum="DataFormat">
+ 12-bit-per-channel unsigned floating-point red/green channel data with normalized value, plus 6 unused bits after each channel, packed in 2×16 bits. Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16" value="203" enum="DataFormat">
+ 12-bit-per-channel unsigned floating-point red/green/blue/alpha channel data with normalized value, plus 6 unused bits after each channel, packed in 4×16 bits. Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16" value="204" enum="DataFormat">
+ 12-bit-per-channel unsigned floating-point green/blue/green/red channel data with normalized value, plus 6 unused bits after each channel, packed in 4×16 bits. Values are in the [code][0.0, 1.0][/code] range. Blue and red channel data is stored at halved horizontal resolution (i.e. 2 horizontally adjacent pixels will share the same value for the blue/red channel). The green channel is listed twice, but contains different values to allow it to be represented at full resolution.
</constant>
<constant name="DATA_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16" value="205" enum="DataFormat">
+ 12-bit-per-channel unsigned floating-point blue/green/red/green channel data with normalized value, plus 6 unused bits after each channel, packed in 4×16 bits. Values are in the [code][0.0, 1.0][/code] range. Blue and red channel data is stored at halved horizontal resolution (i.e. 2 horizontally adjacent pixels will share the same value for the blue/red channel). The green channel is listed twice, but contains different values to allow it to be represented at full resolution.
</constant>
<constant name="DATA_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16" value="206" enum="DataFormat">
+ 12-bit-per-channel unsigned floating-point green/blue/red channel data with normalized value, plus 6 unused bits after each channel. Packed in 3×16 bits and stored across 2 separate planes (green + blue + red). Values are in the [code][0.0, 1.0][/code] range. Blue and red channel data is stored at halved horizontal and vertical resolution (i.e. 2×2 adjacent pixels will share the same value for the blue/red channel).
</constant>
<constant name="DATA_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16" value="207" enum="DataFormat">
+ 12-bit-per-channel unsigned floating-point green/blue/red channel data with normalized value, plus 6 unused bits after each channel. Packed in 3×16 bits and stored across 2 separate planes (green + blue/red). Values are in the [code][0.0, 1.0][/code] range. Blue and red channel data is stored at halved horizontal and vertical resolution (i.e. 2×2 adjacent pixels will share the same value for the blue/red channel).
</constant>
<constant name="DATA_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16" value="208" enum="DataFormat">
+ 12-bit-per-channel unsigned floating-point green/blue/red channel data with normalized value, plus 6 unused bits after each channel. Packed in 3×16 bits and stored across 3 separate planes (green + blue + red). Values are in the [code][0.0, 1.0][/code] range. Blue and red channel data is stored at halved horizontal resolution (i.e. 2 horizontally adjacent pixels will share the same value for the blue/red channel).
</constant>
<constant name="DATA_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16" value="209" enum="DataFormat">
+ 12-bit-per-channel unsigned floating-point green/blue/red channel data with normalized value, plus 6 unused bits after each channel. Packed in 3×16 bits and stored across 3 separate planes (green + blue/red). Values are in the [code][0.0, 1.0][/code] range. Blue and red channel data is stored at halved horizontal resolution (i.e. 2 horizontally adjacent pixels will share the same value for the blue/red channel).
</constant>
<constant name="DATA_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16" value="210" enum="DataFormat">
+ 12-bit-per-channel unsigned floating-point green/blue/red channel data with normalized value, plus 6 unused bits after each channel. Packed in 3×16 bits and stored across 3 separate planes (green + blue + red). Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_G16B16G16R16_422_UNORM" value="211" enum="DataFormat">
+ 16-bit-per-channel unsigned floating-point green/blue/red channel data format with normalized value. Values are in the [code][0.0, 1.0][/code] range. Blue and red channel data is stored at halved horizontal resolution (i.e. 2 horizontally adjacent pixels will share the same value for the blue/red channel).
</constant>
<constant name="DATA_FORMAT_B16G16R16G16_422_UNORM" value="212" enum="DataFormat">
+ 16-bit-per-channel unsigned floating-point blue/green/red channel data format with normalized value. Values are in the [code][0.0, 1.0][/code] range. Blue and red channel data is stored at halved horizontal resolution (i.e. 2 horizontally adjacent pixels will share the same value for the blue/red channel).
</constant>
<constant name="DATA_FORMAT_G16_B16_R16_3PLANE_420_UNORM" value="213" enum="DataFormat">
+ 16-bit-per-channel unsigned floating-point green/blue/red channel data with normalized value, plus 6 unused bits after each channel. Stored across 2 separate planes (green + blue + red). Values are in the [code][0.0, 1.0][/code] range. Blue and red channel data is stored at halved horizontal and vertical resolution (i.e. 2×2 adjacent pixels will share the same value for the blue/red channel).
</constant>
<constant name="DATA_FORMAT_G16_B16R16_2PLANE_420_UNORM" value="214" enum="DataFormat">
+ 16-bit-per-channel unsigned floating-point green/blue/red channel data with normalized value, plus 6 unused bits after each channel. Stored across 2 separate planes (green + blue/red). Values are in the [code][0.0, 1.0][/code] range. Blue and red channel data is stored at halved horizontal and vertical resolution (i.e. 2×2 adjacent pixels will share the same value for the blue/red channel).
</constant>
<constant name="DATA_FORMAT_G16_B16_R16_3PLANE_422_UNORM" value="215" enum="DataFormat">
+ 16-bit-per-channel unsigned floating-point green/blue/red channel data with normalized value, plus 6 unused bits after each channel. Stored across 3 separate planes (green + blue + red). Values are in the [code][0.0, 1.0][/code] range. Blue and red channel data is stored at halved horizontal resolution (i.e. 2 horizontally adjacent pixels will share the same value for the blue/red channel).
</constant>
<constant name="DATA_FORMAT_G16_B16R16_2PLANE_422_UNORM" value="216" enum="DataFormat">
+ 16-bit-per-channel unsigned floating-point green/blue/red channel data with normalized value, plus 6 unused bits after each channel. Stored across 3 separate planes (green + blue/red). Values are in the [code][0.0, 1.0][/code] range. Blue and red channel data is stored at halved horizontal resolution (i.e. 2 horizontally adjacent pixels will share the same value for the blue/red channel).
</constant>
<constant name="DATA_FORMAT_G16_B16_R16_3PLANE_444_UNORM" value="217" enum="DataFormat">
+ 16-bit-per-channel unsigned floating-point green/blue/red channel data with normalized value, plus 6 unused bits after each channel. Stored across 3 separate planes (green + blue + red). Values are in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="DATA_FORMAT_MAX" value="218" enum="DataFormat">
+ Represents the size of the [enum DataFormat] enum.
</constant>
<constant name="BARRIER_MASK_RASTER" value="1" enum="BarrierMask" is_bitfield="true">
+ Raster barrier mask.
</constant>
<constant name="BARRIER_MASK_COMPUTE" value="2" enum="BarrierMask" is_bitfield="true">
+ Compute barrier mask.
</constant>
<constant name="BARRIER_MASK_TRANSFER" value="4" enum="BarrierMask" is_bitfield="true">
+ Transfer barrier mask.
</constant>
<constant name="BARRIER_MASK_ALL_BARRIERS" value="7" enum="BarrierMask" is_bitfield="true">
+ Barrier mask for all types (raster, compute, transfer). Equivalent to [code]BARRIER_MASK_RASTER | BARRIER_MASK_COMPUTE | BARRIER_MASK_TRANSFER[/code].
</constant>
<constant name="BARRIER_MASK_NO_BARRIER" value="8" enum="BarrierMask" is_bitfield="true">
+ No barrier for any type.
</constant>
<constant name="TEXTURE_TYPE_1D" value="0" enum="TextureType">
1-dimensional texture.
@@ -1195,63 +1612,91 @@
Represents the size of the [enum TextureType] enum.
</constant>
<constant name="TEXTURE_SAMPLES_1" value="0" enum="TextureSamples">
+ Perform 1 texture sample (this is the fastest but lowest-quality for antialiasing).
</constant>
<constant name="TEXTURE_SAMPLES_2" value="1" enum="TextureSamples">
+ Perform 2 texture samples.
</constant>
<constant name="TEXTURE_SAMPLES_4" value="2" enum="TextureSamples">
+ Perform 4 texture samples.
</constant>
<constant name="TEXTURE_SAMPLES_8" value="3" enum="TextureSamples">
+ Perform 8 texture samples. Not supported on mobile GPUs (including Apple Silicon).
</constant>
<constant name="TEXTURE_SAMPLES_16" value="4" enum="TextureSamples">
+ Perform 16 texture samples. Not supported on mobile GPUs and many desktop GPUs.
</constant>
<constant name="TEXTURE_SAMPLES_32" value="5" enum="TextureSamples">
+ Perform 32 texture samples. Not supported on most GPUs.
</constant>
<constant name="TEXTURE_SAMPLES_64" value="6" enum="TextureSamples">
+ Perform 64 texture samples (this is the slowest but highest-quality for antialiasing). Not supported on most GPUs.
</constant>
<constant name="TEXTURE_SAMPLES_MAX" value="7" enum="TextureSamples">
Represents the size of the [enum TextureSamples] enum.
</constant>
<constant name="TEXTURE_USAGE_SAMPLING_BIT" value="1" enum="TextureUsageBits" is_bitfield="true">
+ Texture can be sampled.
</constant>
<constant name="TEXTURE_USAGE_COLOR_ATTACHMENT_BIT" value="2" enum="TextureUsageBits" is_bitfield="true">
+ Texture can be used as a color attachment in a framebuffer.
</constant>
<constant name="TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT" value="4" enum="TextureUsageBits" is_bitfield="true">
+ Texture can be used as a depth/stencil attachment in a framebuffer.
</constant>
<constant name="TEXTURE_USAGE_STORAGE_BIT" value="8" enum="TextureUsageBits" is_bitfield="true">
+ Texture can be used as a [url=https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#descriptorsets-storageimage]storage image[/url].
</constant>
<constant name="TEXTURE_USAGE_STORAGE_ATOMIC_BIT" value="16" enum="TextureUsageBits" is_bitfield="true">
+ Texture can be used as a [url=https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#descriptorsets-storageimage]storage image[/url] with support for atomic operations.
</constant>
<constant name="TEXTURE_USAGE_CPU_READ_BIT" value="32" enum="TextureUsageBits" is_bitfield="true">
+ Texture can be read back on the CPU using [method texture_get_data] faster than without this bit, since it is always kept in the system memory.
</constant>
<constant name="TEXTURE_USAGE_CAN_UPDATE_BIT" value="64" enum="TextureUsageBits" is_bitfield="true">
+ Texture can be updated using [method texture_update].
</constant>
<constant name="TEXTURE_USAGE_CAN_COPY_FROM_BIT" value="128" enum="TextureUsageBits" is_bitfield="true">
+ Texture can be a source for [method texture_copy].
</constant>
<constant name="TEXTURE_USAGE_CAN_COPY_TO_BIT" value="256" enum="TextureUsageBits" is_bitfield="true">
+ Texture can be a destination for [method texture_copy].
</constant>
<constant name="TEXTURE_USAGE_INPUT_ATTACHMENT_BIT" value="512" enum="TextureUsageBits" is_bitfield="true">
+ Texture can be used as a [url=https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#descriptorsets-inputattachment]input attachment[/url] in a framebuffer.
</constant>
<constant name="TEXTURE_SWIZZLE_IDENTITY" value="0" enum="TextureSwizzle">
+ Return the sampled value as-is.
</constant>
<constant name="TEXTURE_SWIZZLE_ZERO" value="1" enum="TextureSwizzle">
+ Always return [code]0.0[/code] when sampling.
</constant>
<constant name="TEXTURE_SWIZZLE_ONE" value="2" enum="TextureSwizzle">
+ Always return [code]1.0[/code] when sampling.
</constant>
<constant name="TEXTURE_SWIZZLE_R" value="3" enum="TextureSwizzle">
+ Sample the red color channel.
</constant>
<constant name="TEXTURE_SWIZZLE_G" value="4" enum="TextureSwizzle">
+ Sample the green color channel.
</constant>
<constant name="TEXTURE_SWIZZLE_B" value="5" enum="TextureSwizzle">
+ Sample the blue color channel.
</constant>
<constant name="TEXTURE_SWIZZLE_A" value="6" enum="TextureSwizzle">
+ Sample the alpha channel.
</constant>
<constant name="TEXTURE_SWIZZLE_MAX" value="7" enum="TextureSwizzle">
+ Represents the size of the [enum TextureSwizzle] enum.
</constant>
<constant name="TEXTURE_SLICE_2D" value="0" enum="TextureSliceType">
+ 2-dimensional texture slice.
</constant>
<constant name="TEXTURE_SLICE_CUBEMAP" value="1" enum="TextureSliceType">
+ Cubemap texture slice.
</constant>
<constant name="TEXTURE_SLICE_3D" value="2" enum="TextureSliceType">
+ 3-dimensional texture slice.
</constant>
<constant name="SAMPLER_FILTER_NEAREST" value="0" enum="SamplerFilter">
Nearest-neighbor sampler filtering. Sampling at higher resolutions than the source will result in a pixelated look.
@@ -1260,209 +1705,311 @@
Bilinear sampler filtering. Sampling at higher resolutions than the source will result in a blurry look.
</constant>
<constant name="SAMPLER_REPEAT_MODE_REPEAT" value="0" enum="SamplerRepeatMode">
+ Sample with repeating enabled.
</constant>
<constant name="SAMPLER_REPEAT_MODE_MIRRORED_REPEAT" value="1" enum="SamplerRepeatMode">
+ Sample with mirrored repeating enabled. When sampling outside the [code][0.0, 1.0][/code] range, return a mirrored version of the sampler. This mirrored version is mirrored again if sampling further away, with the pattern repeating indefinitely.
</constant>
<constant name="SAMPLER_REPEAT_MODE_CLAMP_TO_EDGE" value="2" enum="SamplerRepeatMode">
+ Sample with repeating disabled. When sampling outside the [code][0.0, 1.0][/code] range, return the color of the last pixel on the edge.
</constant>
<constant name="SAMPLER_REPEAT_MODE_CLAMP_TO_BORDER" value="3" enum="SamplerRepeatMode">
+ Sample with repeating disabled. When sampling outside the [code][0.0, 1.0][/code] range, return the specified [member RDSamplerState.border_color].
</constant>
<constant name="SAMPLER_REPEAT_MODE_MIRROR_CLAMP_TO_EDGE" value="4" enum="SamplerRepeatMode">
+ Sample with mirrored repeating enabled, but only once. When sampling in the [code][-1.0, 0.0][/code] range, return a mirrored version of the sampler. When sampling outside the [code][-1.0, 1.0][/code] range, return the color of the last pixel on the edge.
</constant>
<constant name="SAMPLER_REPEAT_MODE_MAX" value="5" enum="SamplerRepeatMode">
+ Represents the size of the [enum SamplerRepeatMode] enum.
</constant>
<constant name="SAMPLER_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK" value="0" enum="SamplerBorderColor">
+ Return a floating-point transparent black color when sampling outside the [code][0.0, 1.0][/code] range. Only effective if the sampler repeat mode is [constant SAMPLER_REPEAT_MODE_CLAMP_TO_BORDER].
</constant>
<constant name="SAMPLER_BORDER_COLOR_INT_TRANSPARENT_BLACK" value="1" enum="SamplerBorderColor">
+ Return a integer transparent black color when sampling outside the [code][0.0, 1.0][/code] range. Only effective if the sampler repeat mode is [constant SAMPLER_REPEAT_MODE_CLAMP_TO_BORDER].
</constant>
<constant name="SAMPLER_BORDER_COLOR_FLOAT_OPAQUE_BLACK" value="2" enum="SamplerBorderColor">
+ Return a floating-point opaque black color when sampling outside the [code][0.0, 1.0][/code] range. Only effective if the sampler repeat mode is [constant SAMPLER_REPEAT_MODE_CLAMP_TO_BORDER].
</constant>
<constant name="SAMPLER_BORDER_COLOR_INT_OPAQUE_BLACK" value="3" enum="SamplerBorderColor">
+ Return a integer opaque black color when sampling outside the [code][0.0, 1.0][/code] range. Only effective if the sampler repeat mode is [constant SAMPLER_REPEAT_MODE_CLAMP_TO_BORDER].
</constant>
<constant name="SAMPLER_BORDER_COLOR_FLOAT_OPAQUE_WHITE" value="4" enum="SamplerBorderColor">
+ Return a floating-point opaque white color when sampling outside the [code][0.0, 1.0][/code] range. Only effective if the sampler repeat mode is [constant SAMPLER_REPEAT_MODE_CLAMP_TO_BORDER].
</constant>
<constant name="SAMPLER_BORDER_COLOR_INT_OPAQUE_WHITE" value="5" enum="SamplerBorderColor">
+ Return a integer opaque white color when sampling outside the [code][0.0, 1.0][/code] range. Only effective if the sampler repeat mode is [constant SAMPLER_REPEAT_MODE_CLAMP_TO_BORDER].
</constant>
<constant name="SAMPLER_BORDER_COLOR_MAX" value="6" enum="SamplerBorderColor">
+ Represents the size of the [enum SamplerBorderColor] enum.
</constant>
<constant name="VERTEX_FREQUENCY_VERTEX" value="0" enum="VertexFrequency">
+ Vertex attribute addressing is a function of the vertex. This is used to specify the rate at which vertex attributes are pulled from buffers.
</constant>
<constant name="VERTEX_FREQUENCY_INSTANCE" value="1" enum="VertexFrequency">
+ Vertex attribute addressing is a function of the instance index. This is used to specify the rate at which vertex attributes are pulled from buffers.
</constant>
<constant name="INDEX_BUFFER_FORMAT_UINT16" value="0" enum="IndexBufferFormat">
+ Index buffer in 16-bit unsigned integer format. This limits the maximum index that can be specified to [code]65535[/code].
</constant>
<constant name="INDEX_BUFFER_FORMAT_UINT32" value="1" enum="IndexBufferFormat">
+ Index buffer in 32-bit unsigned integer format. This limits the maximum index that can be specified to [code]4294967295[/code].
</constant>
<constant name="STORAGE_BUFFER_USAGE_DISPATCH_INDIRECT" value="1" enum="StorageBufferUsage" is_bitfield="true">
</constant>
<constant name="UNIFORM_TYPE_SAMPLER" value="0" enum="UniformType">
+ Sampler uniform. TODO: Difference between sampler and texture uniform
</constant>
<constant name="UNIFORM_TYPE_SAMPLER_WITH_TEXTURE" value="1" enum="UniformType">
+ Sampler uniform with a texture.
</constant>
<constant name="UNIFORM_TYPE_TEXTURE" value="2" enum="UniformType">
+ Texture uniform.
</constant>
<constant name="UNIFORM_TYPE_IMAGE" value="3" enum="UniformType">
+ Image uniform. TODO: Difference between texture and image uniform
</constant>
<constant name="UNIFORM_TYPE_TEXTURE_BUFFER" value="4" enum="UniformType">
+ Texture buffer uniform. TODO: Difference between texture and texture buffe uniformr
</constant>
<constant name="UNIFORM_TYPE_SAMPLER_WITH_TEXTURE_BUFFER" value="5" enum="UniformType">
+ Sampler uniform with a texture buffer. TODO: Difference between texture and texture buffer uniform
</constant>
<constant name="UNIFORM_TYPE_IMAGE_BUFFER" value="6" enum="UniformType">
+ Image buffer uniform. TODO: Difference between texture and image uniforms
</constant>
<constant name="UNIFORM_TYPE_UNIFORM_BUFFER" value="7" enum="UniformType">
+ Uniform buffer uniform.
</constant>
<constant name="UNIFORM_TYPE_STORAGE_BUFFER" value="8" enum="UniformType">
+ [url=https://vkguide.dev/docs/chapter-4/storage_buffers/]Storage buffer[/url] uniform.
</constant>
<constant name="UNIFORM_TYPE_INPUT_ATTACHMENT" value="9" enum="UniformType">
+ Input attachment uniform.
</constant>
<constant name="UNIFORM_TYPE_MAX" value="10" enum="UniformType">
+ Represents the size of the [enum UniformType] enum.
</constant>
<constant name="RENDER_PRIMITIVE_POINTS" value="0" enum="RenderPrimitive">
Point rendering primitive (with constant size, regardless of distance from camera).
</constant>
<constant name="RENDER_PRIMITIVE_LINES" value="1" enum="RenderPrimitive">
- Line rendering primitive.
+ Line list rendering primitive. Lines are drawn separated from each other.
</constant>
<constant name="RENDER_PRIMITIVE_LINES_WITH_ADJACENCY" value="2" enum="RenderPrimitive">
+ [url=https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#drawing-line-lists-with-adjacency]Line list rendering primitive with adjacency.[/url]
+ [b]Note:[/b] Adjacency is only useful with geometry shaders, which Godot does not expose.
</constant>
<constant name="RENDER_PRIMITIVE_LINESTRIPS" value="3" enum="RenderPrimitive">
+ Line strip rendering primitive. Lines drawn are connected to the previous vertex.
</constant>
<constant name="RENDER_PRIMITIVE_LINESTRIPS_WITH_ADJACENCY" value="4" enum="RenderPrimitive">
+ [url=https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#drawing-line-strips-with-adjacency]Line strip rendering primitive with adjacency.[/url]
+ [b]Note:[/b] Adjacency is only useful with geometry shaders, which Godot does not expose.
</constant>
<constant name="RENDER_PRIMITIVE_TRIANGLES" value="5" enum="RenderPrimitive">
+ Triangle list rendering primitive. Triangles are drawn separated from each other.
</constant>
<constant name="RENDER_PRIMITIVE_TRIANGLES_WITH_ADJACENCY" value="6" enum="RenderPrimitive">
+ [url=https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#drawing-triangle-lists-with-adjacency]Triangle list rendering primitive with adjacency.[/url]
+ [b]Note:[/b] Adjacency is only useful with geometry shaders, which Godot does not expose.
</constant>
<constant name="RENDER_PRIMITIVE_TRIANGLE_STRIPS" value="7" enum="RenderPrimitive">
+ Triangle strip rendering primitive. Triangles drawn are connected to the previous triangle.
</constant>
<constant name="RENDER_PRIMITIVE_TRIANGLE_STRIPS_WITH_AJACENCY" value="8" enum="RenderPrimitive">
+ [url=https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#drawing-triangle-strips-with-adjacency]Triangle strip rendering primitive with adjacency.[/url]
+ [b]Note:[/b] Adjacency is only useful with geometry shaders, which Godot does not expose.
</constant>
<constant name="RENDER_PRIMITIVE_TRIANGLE_STRIPS_WITH_RESTART_INDEX" value="9" enum="RenderPrimitive">
+ Triangle strip rendering primitive with [i]primitive restart[/i] enabled. Triangles drawn are connected to the previous triangle, but a primitive restart index can be specified before drawing to create a second triangle strip after the specified index.
+ [b]Note:[/b] Only compatible with indexed draws.
</constant>
<constant name="RENDER_PRIMITIVE_TESSELATION_PATCH" value="10" enum="RenderPrimitive">
+ Tessellation patch rendering primitive. Only useful with tessellation shaders, which can be used to deform these patches.
</constant>
<constant name="RENDER_PRIMITIVE_MAX" value="11" enum="RenderPrimitive">
+ Represents the size of the [enum RenderPrimitive] enum.
</constant>
<constant name="POLYGON_CULL_DISABLED" value="0" enum="PolygonCullMode">
+ Do not use polygon front face or backface culling.
</constant>
<constant name="POLYGON_CULL_FRONT" value="1" enum="PolygonCullMode">
+ Use polygon frontface culling (faces pointing towards the camera are hidden).
</constant>
<constant name="POLYGON_CULL_BACK" value="2" enum="PolygonCullMode">
+ Use polygon backface culling (faces pointing away from the camera are hidden).
</constant>
<constant name="POLYGON_FRONT_FACE_CLOCKWISE" value="0" enum="PolygonFrontFace">
+ Clockwise winding order to determine which face of a polygon is its front face.
</constant>
<constant name="POLYGON_FRONT_FACE_COUNTER_CLOCKWISE" value="1" enum="PolygonFrontFace">
+ Counter-clockwise winding order to determine which face of a polygon is its front face.
</constant>
<constant name="STENCIL_OP_KEEP" value="0" enum="StencilOperation">
+ Keep the current stencil value.
</constant>
<constant name="STENCIL_OP_ZERO" value="1" enum="StencilOperation">
+ Set the stencil value to [code]0[/code].
</constant>
<constant name="STENCIL_OP_REPLACE" value="2" enum="StencilOperation">
+ Replace the existing stencil value with the new one.
</constant>
<constant name="STENCIL_OP_INCREMENT_AND_CLAMP" value="3" enum="StencilOperation">
+ Increment the existing stencil value and clamp to the maximum representable unsigned value if reached. Stencil bits are considered as an unsigned integer.
</constant>
<constant name="STENCIL_OP_DECREMENT_AND_CLAMP" value="4" enum="StencilOperation">
+ Decrement the existing stencil value and clamp to the minimum value if reached. Stencil bits are considered as an unsigned integer.
</constant>
<constant name="STENCIL_OP_INVERT" value="5" enum="StencilOperation">
+ Bitwise-invert the existing stencil value.
</constant>
<constant name="STENCIL_OP_INCREMENT_AND_WRAP" value="6" enum="StencilOperation">
+ Increment the stencil value and wrap around to [code]0[/code] if reaching the maximum representable unsigned. Stencil bits are considered as an unsigned integer.
</constant>
<constant name="STENCIL_OP_DECREMENT_AND_WRAP" value="7" enum="StencilOperation">
+ Decrement the stencil value and wrap around to the maximum representable unsigned if reaching the minimum. Stencil bits are considered as an unsigned integer.
</constant>
<constant name="STENCIL_OP_MAX" value="8" enum="StencilOperation">
+ Represents the size of the [enum StencilOperation] enum.
</constant>
<constant name="COMPARE_OP_NEVER" value="0" enum="CompareOperator">
+ "Never" comparison (opposite of [constant COMPARE_OP_ALWAYS]).
</constant>
<constant name="COMPARE_OP_LESS" value="1" enum="CompareOperator">
+ "Less than" comparison.
</constant>
<constant name="COMPARE_OP_EQUAL" value="2" enum="CompareOperator">
+ "Equal" comparison.
</constant>
<constant name="COMPARE_OP_LESS_OR_EQUAL" value="3" enum="CompareOperator">
+ "Less than or equal" comparison.
</constant>
<constant name="COMPARE_OP_GREATER" value="4" enum="CompareOperator">
+ "Greater than" comparison.
</constant>
<constant name="COMPARE_OP_NOT_EQUAL" value="5" enum="CompareOperator">
+ "Not equal" comparison.
</constant>
<constant name="COMPARE_OP_GREATER_OR_EQUAL" value="6" enum="CompareOperator">
+ "Greater than or equal" comparison.
</constant>
<constant name="COMPARE_OP_ALWAYS" value="7" enum="CompareOperator">
+ "Always" comparison (opposite of [constant COMPARE_OP_NEVER]).
</constant>
<constant name="COMPARE_OP_MAX" value="8" enum="CompareOperator">
+ Represents the size of the [enum CompareOperator] enum.
</constant>
<constant name="LOGIC_OP_CLEAR" value="0" enum="LogicOperation">
+ Clear logic operation (result is always [code]0[/code]). See also [constant LOGIC_OP_SET].
</constant>
<constant name="LOGIC_OP_AND" value="1" enum="LogicOperation">
+ AND logic operation.
</constant>
<constant name="LOGIC_OP_AND_REVERSE" value="2" enum="LogicOperation">
+ AND logic operation with the [i]destination[/i] operand being inverted. See also [constant LOGIC_OP_AND_INVERTED].
</constant>
<constant name="LOGIC_OP_COPY" value="3" enum="LogicOperation">
+ Copy logic operation (keeps the [i]source[/i] value as-is). See also [constant LOGIC_OP_COPY_INVERTED] and [constant LOGIC_OP_NO_OP].
</constant>
<constant name="LOGIC_OP_AND_INVERTED" value="4" enum="LogicOperation">
+ AND logic operation with the [i]source[/i] operand being inverted. See also [constant LOGIC_OP_AND_REVERSE].
</constant>
<constant name="LOGIC_OP_NO_OP" value="5" enum="LogicOperation">
+ No-op logic operation (keeps the [i]destination[/i] value as-is). See also [constant LOGIC_OP_COPY].
</constant>
<constant name="LOGIC_OP_XOR" value="6" enum="LogicOperation">
Exclusive or (XOR) logic operation.
</constant>
<constant name="LOGIC_OP_OR" value="7" enum="LogicOperation">
+ OR logic operation.
</constant>
<constant name="LOGIC_OP_NOR" value="8" enum="LogicOperation">
+ Not-OR (NOR) logic operation.
</constant>
<constant name="LOGIC_OP_EQUIVALENT" value="9" enum="LogicOperation">
+ Not-XOR (XNOR) logic operation.
</constant>
<constant name="LOGIC_OP_INVERT" value="10" enum="LogicOperation">
+ Invert logic operation.
</constant>
<constant name="LOGIC_OP_OR_REVERSE" value="11" enum="LogicOperation">
+ OR logic operation with the [i]destination[/i] operand being inverted. See also [constant LOGIC_OP_OR_REVERSE].
</constant>
<constant name="LOGIC_OP_COPY_INVERTED" value="12" enum="LogicOperation">
+ NOT logic operation (inverts the value). See also [constant LOGIC_OP_COPY].
</constant>
<constant name="LOGIC_OP_OR_INVERTED" value="13" enum="LogicOperation">
+ OR logic operation with the [i]source[/i] operand being inverted. See also [constant LOGIC_OP_OR_REVERSE].
</constant>
<constant name="LOGIC_OP_NAND" value="14" enum="LogicOperation">
+ Not-AND (NAND) logic operation.
</constant>
<constant name="LOGIC_OP_SET" value="15" enum="LogicOperation">
+ SET logic operation (result is always [code]1[/code]). See also [constant LOGIC_OP_CLEAR].
</constant>
<constant name="LOGIC_OP_MAX" value="16" enum="LogicOperation">
+ Represents the size of the [enum LogicOperation] enum.
</constant>
<constant name="BLEND_FACTOR_ZERO" value="0" enum="BlendFactor">
+ Constant [code]0.0[/code] blend factor.
</constant>
<constant name="BLEND_FACTOR_ONE" value="1" enum="BlendFactor">
+ Constant [code]1.0[/code] blend factor.
</constant>
<constant name="BLEND_FACTOR_SRC_COLOR" value="2" enum="BlendFactor">
+ Color blend factor is [code]source color[/code]. Alpha blend factor is [code]source alpha[/code].
</constant>
<constant name="BLEND_FACTOR_ONE_MINUS_SRC_COLOR" value="3" enum="BlendFactor">
+ Color blend factor is [code]1.0 - source color[/code]. Alpha blend factor is [code]1.0 - source alpha[/code].
</constant>
<constant name="BLEND_FACTOR_DST_COLOR" value="4" enum="BlendFactor">
+ Color blend factor is [code]destination color[/code]. Alpha blend factor is [code]destination alpha[/code].
</constant>
<constant name="BLEND_FACTOR_ONE_MINUS_DST_COLOR" value="5" enum="BlendFactor">
+ Color blend factor is [code]1.0 - destination color[/code]. Alpha blend factor is [code]1.0 - destination alpha[/code].
</constant>
<constant name="BLEND_FACTOR_SRC_ALPHA" value="6" enum="BlendFactor">
+ Color and alpha blend factor is [code]source alpha[/code].
</constant>
<constant name="BLEND_FACTOR_ONE_MINUS_SRC_ALPHA" value="7" enum="BlendFactor">
+ Color and alpha blend factor is [code]1.0 - source alpha[/code].
</constant>
<constant name="BLEND_FACTOR_DST_ALPHA" value="8" enum="BlendFactor">
+ Color and alpha blend factor is [code]destination alpha[/code].
</constant>
<constant name="BLEND_FACTOR_ONE_MINUS_DST_ALPHA" value="9" enum="BlendFactor">
+ Color and alpha blend factor is [code]1.0 - destination alpha[/code].
</constant>
<constant name="BLEND_FACTOR_CONSTANT_COLOR" value="10" enum="BlendFactor">
+ Color blend factor is [code]blend constant color[/code]. Alpha blend factor is [code]blend constant alpha[/code] (see [method draw_list_set_blend_constants]).
</constant>
<constant name="BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR" value="11" enum="BlendFactor">
+ Color blend factor is [code]1.0 - blend constant color[/code]. Alpha blend factor is [code]1.0 - blend constant alpha[/code] (see [method draw_list_set_blend_constants]).
</constant>
<constant name="BLEND_FACTOR_CONSTANT_ALPHA" value="12" enum="BlendFactor">
+ Color and alpha blend factor is [code]blend constant alpha[/code] (see [method draw_list_set_blend_constants]).
</constant>
<constant name="BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA" value="13" enum="BlendFactor">
+ Color and alpha blend factor is [code]1.0 - blend constant alpha[/code] (see [method draw_list_set_blend_constants]).
</constant>
<constant name="BLEND_FACTOR_SRC_ALPHA_SATURATE" value="14" enum="BlendFactor">
+ Color blend factor is [code]min(source alpha, 1.0 - destination alpha)[/code]. Alpha blend factor is [code]1.0[/code].
</constant>
<constant name="BLEND_FACTOR_SRC1_COLOR" value="15" enum="BlendFactor">
+ Color blend factor is [code]second source color[/code]. Alpha blend factor is [code]second source alpha[/code]. Only relevant for dual-source blending.
</constant>
<constant name="BLEND_FACTOR_ONE_MINUS_SRC1_COLOR" value="16" enum="BlendFactor">
+ Color blend factor is [code]1.0 - second source color[/code]. Alpha blend factor is [code]1.0 - second source alpha[/code]. Only relevant for dual-source blending.
</constant>
<constant name="BLEND_FACTOR_SRC1_ALPHA" value="17" enum="BlendFactor">
+ Color and alpha blend factor is [code]second source alpha[/code]. Only relevant for dual-source blending.
</constant>
<constant name="BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA" value="18" enum="BlendFactor">
+ Color and alpha blend factor is [code]1.0 - second source alpha[/code]. Only relevant for dual-source blending.
</constant>
<constant name="BLEND_FACTOR_MAX" value="19" enum="BlendFactor">
+ Represents the size of the [enum BlendFactor] enum.
</constant>
<constant name="BLEND_OP_ADD" value="0" enum="BlendOperation">
Additive blending operation ([code]source + destination[/code]).
@@ -1509,68 +2056,100 @@
<constant name="INITIAL_ACTION_CONTINUE" value="5" enum="InitialAction">
</constant>
<constant name="INITIAL_ACTION_MAX" value="6" enum="InitialAction">
+ Represents the size of the [enum InitialAction] enum.
</constant>
<constant name="FINAL_ACTION_READ" value="0" enum="FinalAction">
+ Store the texture for reading and make it read-only if it has the [constant TEXTURE_USAGE_SAMPLING_BIT] bit (only applies to color, depth and stencil attachments).
</constant>
<constant name="FINAL_ACTION_DISCARD" value="1" enum="FinalAction">
+ Discard the texture data and make it read-only if it has the [constant TEXTURE_USAGE_SAMPLING_BIT] bit (only applies to color, depth and stencil attachments).
</constant>
<constant name="FINAL_ACTION_CONTINUE" value="2" enum="FinalAction">
+ Store the texture and continue for further processing. Similar to [constant FINAL_ACTION_READ], but does not make the texture read-only if it has the [constant TEXTURE_USAGE_SAMPLING_BIT] bit.
</constant>
<constant name="FINAL_ACTION_MAX" value="3" enum="FinalAction">
+ Represents the size of the [enum FinalAction] enum.
</constant>
<constant name="SHADER_STAGE_VERTEX" value="0" enum="ShaderStage">
+ Vertex shader stage. This can be used to manipulate vertices from a shader (but not create new vertices).
</constant>
<constant name="SHADER_STAGE_FRAGMENT" value="1" enum="ShaderStage">
+ Fragment shader stage (called "pixel shader" in Direct3D). This can be used to manipulate pixels from a shader.
</constant>
<constant name="SHADER_STAGE_TESSELATION_CONTROL" value="2" enum="ShaderStage">
+ Tessellation control shader stage. This can be used to create additional geometry from a shader.
</constant>
<constant name="SHADER_STAGE_TESSELATION_EVALUATION" value="3" enum="ShaderStage">
+ Tessellation evaluation shader stage. This can be used to create additional geometry from a shader.
</constant>
<constant name="SHADER_STAGE_COMPUTE" value="4" enum="ShaderStage">
+ Compute shader stage. This can be used to run arbitrary computing tasks in a shader, performing them on the GPU instead of the CPU.
</constant>
<constant name="SHADER_STAGE_MAX" value="5" enum="ShaderStage">
+ Represents the size of the [enum ShaderStage] enum.
</constant>
<constant name="SHADER_STAGE_VERTEX_BIT" value="1" enum="ShaderStage">
+ Vertex shader stage bit (see also [constant SHADER_STAGE_VERTEX]).
</constant>
<constant name="SHADER_STAGE_FRAGMENT_BIT" value="2" enum="ShaderStage">
+ Fragment shader stage bit (see also [constant SHADER_STAGE_FRAGMENT]).
</constant>
<constant name="SHADER_STAGE_TESSELATION_CONTROL_BIT" value="4" enum="ShaderStage">
+ Tessellation control shader stage bit (see also [constant SHADER_STAGE_TESSELATION_CONTROL]).
</constant>
<constant name="SHADER_STAGE_TESSELATION_EVALUATION_BIT" value="8" enum="ShaderStage">
+ Tessellation evaluation shader stage bit (see also [constant SHADER_STAGE_TESSELATION_EVALUATION]).
</constant>
<constant name="SHADER_STAGE_COMPUTE_BIT" value="16" enum="ShaderStage">
+ Compute shader stage bit (see also [constant SHADER_STAGE_COMPUTE]).
</constant>
<constant name="SHADER_LANGUAGE_GLSL" value="0" enum="ShaderLanguage">
+ Khronos' GLSL shading language (used natively by OpenGL and Vulkan). This is the language used for core Godot shaders.
</constant>
<constant name="SHADER_LANGUAGE_HLSL" value="1" enum="ShaderLanguage">
+ Microsoft's High-Level Shading Language (used natively by Direct3D, but can also be used in Vulkan).
</constant>
<constant name="PIPELINE_SPECIALIZATION_CONSTANT_TYPE_BOOL" value="0" enum="PipelineSpecializationConstantType">
+ Boolean specialization constant.
</constant>
<constant name="PIPELINE_SPECIALIZATION_CONSTANT_TYPE_INT" value="1" enum="PipelineSpecializationConstantType">
+ Integer specialization constant.
</constant>
<constant name="PIPELINE_SPECIALIZATION_CONSTANT_TYPE_FLOAT" value="2" enum="PipelineSpecializationConstantType">
+ Floating-point specialization constant.
</constant>
<constant name="LIMIT_MAX_BOUND_UNIFORM_SETS" value="0" enum="Limit">
+ Maximum number of uniform sets that can be bound at a given time.
</constant>
<constant name="LIMIT_MAX_FRAMEBUFFER_COLOR_ATTACHMENTS" value="1" enum="Limit">
+ Maximum number of color framebuffer attachments that can be used at a given time.
</constant>
<constant name="LIMIT_MAX_TEXTURES_PER_UNIFORM_SET" value="2" enum="Limit">
+ Maximum number of textures that can be used per uniform set.
</constant>
<constant name="LIMIT_MAX_SAMPLERS_PER_UNIFORM_SET" value="3" enum="Limit">
+ Maximum number of samplers that can be used per uniform set.
</constant>
<constant name="LIMIT_MAX_STORAGE_BUFFERS_PER_UNIFORM_SET" value="4" enum="Limit">
+ Maximum number of [url=https://vkguide.dev/docs/chapter-4/storage_buffers/]storage buffers[/url] per uniform set.
</constant>
<constant name="LIMIT_MAX_STORAGE_IMAGES_PER_UNIFORM_SET" value="5" enum="Limit">
+ Maximum number of storage images per uniform set.
</constant>
<constant name="LIMIT_MAX_UNIFORM_BUFFERS_PER_UNIFORM_SET" value="6" enum="Limit">
+ Maximum number of uniform buffers per uniform set.
</constant>
<constant name="LIMIT_MAX_DRAW_INDEXED_INDEX" value="7" enum="Limit">
+ Maximum index for an indexed draw command.
</constant>
<constant name="LIMIT_MAX_FRAMEBUFFER_HEIGHT" value="8" enum="Limit">
+ Maximum height of a framebuffer (in pixels).
</constant>
<constant name="LIMIT_MAX_FRAMEBUFFER_WIDTH" value="9" enum="Limit">
+ Maximum width of a framebuffer (in pixels).
</constant>
<constant name="LIMIT_MAX_TEXTURE_ARRAY_LAYERS" value="10" enum="Limit">
+ Maximum number of texture array layers.
</constant>
<constant name="LIMIT_MAX_TEXTURE_SIZE_1D" value="11" enum="Limit">
Maximum supported 1-dimensional texture size (in pixels on a single axis).
@@ -1585,48 +2164,70 @@
Maximum supported cubemap texture size (in pixels on a single axis of a single face).
</constant>
<constant name="LIMIT_MAX_TEXTURES_PER_SHADER_STAGE" value="15" enum="Limit">
+ Maximum number of textures per shader stage.
</constant>
<constant name="LIMIT_MAX_SAMPLERS_PER_SHADER_STAGE" value="16" enum="Limit">
+ Maximum number of samplers per shader stage.
</constant>
<constant name="LIMIT_MAX_STORAGE_BUFFERS_PER_SHADER_STAGE" value="17" enum="Limit">
+ Maximum number of [url=https://vkguide.dev/docs/chapter-4/storage_buffers/]storage buffers[/url] per shader stage.
</constant>
<constant name="LIMIT_MAX_STORAGE_IMAGES_PER_SHADER_STAGE" value="18" enum="Limit">
+ Maximum number of storage images per shader stage.
</constant>
<constant name="LIMIT_MAX_UNIFORM_BUFFERS_PER_SHADER_STAGE" value="19" enum="Limit">
+ Maximum number of uniform buffers per uniform set.
</constant>
<constant name="LIMIT_MAX_PUSH_CONSTANT_SIZE" value="20" enum="Limit">
+ Maximum size of a push constant. A lot of devices are limited to 128 bytes, so try to avoid exceeding 128 bytes in push constants to ensure compatibility even if your GPU is reporting a higher value.
</constant>
<constant name="LIMIT_MAX_UNIFORM_BUFFER_SIZE" value="21" enum="Limit">
+ Maximum size of a uniform buffer.
</constant>
<constant name="LIMIT_MAX_VERTEX_INPUT_ATTRIBUTE_OFFSET" value="22" enum="Limit">
+ Maximum vertex input attribute offset.
</constant>
<constant name="LIMIT_MAX_VERTEX_INPUT_ATTRIBUTES" value="23" enum="Limit">
+ Maximum number of vertex input attributes.
</constant>
<constant name="LIMIT_MAX_VERTEX_INPUT_BINDINGS" value="24" enum="Limit">
+ Maximum number of vertex input bindings.
</constant>
<constant name="LIMIT_MAX_VERTEX_INPUT_BINDING_STRIDE" value="25" enum="Limit">
+ Maximum vertex input binding stride.
</constant>
<constant name="LIMIT_MIN_UNIFORM_BUFFER_OFFSET_ALIGNMENT" value="26" enum="Limit">
+ Minimum uniform buffer offset alignment.
</constant>
<constant name="LIMIT_MAX_COMPUTE_SHARED_MEMORY_SIZE" value="27" enum="Limit">
+ Maximum shared memory size for compute shaders.
</constant>
<constant name="LIMIT_MAX_COMPUTE_WORKGROUP_COUNT_X" value="28" enum="Limit">
+ Maximum number of workgroups for compute shaders on the X axis.
</constant>
<constant name="LIMIT_MAX_COMPUTE_WORKGROUP_COUNT_Y" value="29" enum="Limit">
+ Maximum number of workgroups for compute shaders on the Y axis.
</constant>
<constant name="LIMIT_MAX_COMPUTE_WORKGROUP_COUNT_Z" value="30" enum="Limit">
+ Maximum number of workgroups for compute shaders on the Z axis.
</constant>
<constant name="LIMIT_MAX_COMPUTE_WORKGROUP_INVOCATIONS" value="31" enum="Limit">
+ Maximum number of workgroup invocations for compute shaders.
</constant>
<constant name="LIMIT_MAX_COMPUTE_WORKGROUP_SIZE_X" value="32" enum="Limit">
+ Maximum workgroup size for compute shaders on the X axis.
</constant>
<constant name="LIMIT_MAX_COMPUTE_WORKGROUP_SIZE_Y" value="33" enum="Limit">
+ Maximum workgroup size for compute shaders on the Y axis.
</constant>
<constant name="LIMIT_MAX_COMPUTE_WORKGROUP_SIZE_Z" value="34" enum="Limit">
+ Maximum workgroup size for compute shaders on the Z axis.
</constant>
<constant name="LIMIT_MAX_VIEWPORT_DIMENSIONS_X" value="35" enum="Limit">
+ Maximum viewport width (in pixels).
</constant>
<constant name="LIMIT_MAX_VIEWPORT_DIMENSIONS_Y" value="36" enum="Limit">
+ Maximum viewport height (in pixels).
</constant>
<constant name="MEMORY_TEXTURES" value="0" enum="MemoryType">
Memory taken by textures.
diff --git a/doc/classes/RenderingServer.xml b/doc/classes/RenderingServer.xml
index 29a12467a8..3a4a25df6f 100644
--- a/doc/classes/RenderingServer.xml
+++ b/doc/classes/RenderingServer.xml
@@ -4,15 +4,14 @@
Server for anything visible.
</brief_description>
<description>
- The rendering server is the API backend for everything visible. The whole scene system mounts on it to display.
- The rendering server is completely opaque, the internals are entirely implementation specific and cannot be accessed.
- The rendering server can be used to bypass the scene/[Node] system entirely.
+ The rendering server is the API backend for everything visible. The whole scene system mounts on it to display. The rendering server is completely opaque: the internals are entirely implementation-specific and cannot be accessed.
+ The rendering server can be used to bypass the scene/[Node] system entirely. This can improve performance in cases where the scene system is the bottleneck, but won't improve performance otherwise (for instance, if the GPU is already fully utilized).
Resources are created using the [code]*_create[/code] functions. These functions return [RID]s which are not references to the objects themselves, but opaque [i]pointers[/i] towards these objects.
All objects are drawn to a viewport. You can use the [Viewport] attached to the [SceneTree] or you can create one yourself with [method viewport_create]. When using a custom scenario or canvas, the scenario or canvas needs to be attached to the viewport using [method viewport_set_scenario] or [method viewport_attach_canvas].
- In 3D, all visual objects must be associated with a scenario. The scenario is a visual representation of the world. If accessing the rendering server from a running game, the scenario can be accessed from the scene tree from any [Node3D] node with [method Node3D.get_world_3d]. Otherwise, a scenario can be created with [method scenario_create].
+ [b]Scenarios:[/b] In 3D, all visual objects must be associated with a scenario. The scenario is a visual representation of the world. If accessing the rendering server from a running game, the scenario can be accessed from the scene tree from any [Node3D] node with [method Node3D.get_world_3d]. Otherwise, a scenario can be created with [method scenario_create].
Similarly, in 2D, a canvas is needed to draw all canvas items.
- In 3D, all visible objects are comprised of a resource and an instance. A resource can be a mesh, a particle system, a light, or any other 3D object. In order to be visible resources must be attached to an instance using [method instance_set_base]. The instance must also be attached to the scenario using [method instance_set_scenario] in order to be visible.
- In 2D, all visible objects are some form of canvas item. In order to be visible, a canvas item needs to be the child of a canvas attached to a viewport, or it needs to be the child of another canvas item that is eventually attached to the canvas.
+ [b]3D:[/b] In 3D, all visible objects are comprised of a resource and an instance. A resource can be a mesh, a particle system, a light, or any other 3D object. In order to be visible resources must be attached to an instance using [method instance_set_base]. The instance must also be attached to the scenario using [method instance_set_scenario] in order to be visible. RenderingServer methods that don't have a prefix are usually 3D-specific (but not always).
+ [b]2D:[/b] In 2D, all visible objects are some form of canvas item. In order to be visible, a canvas item needs to be the child of a canvas attached to a viewport, or it needs to be the child of another canvas item that is eventually attached to the canvas. 2D-specific RenderingServer methods generally start with [code]canvas_*[/code].
[b]Headless mode:[/b] Starting the engine with the [code]--headless[/code] [url=$DOCS_URL/tutorials/editor/command_line_tutorial.html]command line argument[/url] disables all rendering and window management functions. Most functions from [RenderingServer] will return dummy values in this case.
</description>
<tutorials>
@@ -32,8 +31,8 @@
<return type="RID" />
<description>
Creates a camera attributes object and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]camera_attributes_[/code] RenderingServer functions.
- Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method.
- This is the internal equivalent of the [CameraAttributes] resource.
+ Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] method.
+ [b]Note:[/b] The equivalent resource is [CameraAttributes].
</description>
</method>
<method name="camera_attributes_set_auto_exposure">
@@ -99,9 +98,9 @@
<method name="camera_create">
<return type="RID" />
<description>
- Creates a camera and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]camera_*[/code] RenderingServer functions.
- Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method.
- This is the internal equivalent of the [Camera3D] node.
+ Creates a 3D camera and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]camera_*[/code] RenderingServer functions.
+ Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] method.
+ [b]Note:[/b] The equivalent node is [Camera3D].
</description>
</method>
<method name="camera_set_camera_attributes">
@@ -179,7 +178,7 @@
<return type="RID" />
<description>
Creates a canvas and returns the assigned [RID]. It can be accessed with the RID that is returned. This RID will be used in all [code]canvas_*[/code] RenderingServer functions.
- Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method.
+ Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] method.
Canvas has no [Resource] or [Node] equivalent.
</description>
</method>
@@ -260,6 +259,16 @@
See also [method CanvasItem.draw_msdf_texture_rect_region].
</description>
</method>
+ <method name="canvas_item_add_multiline">
+ <return type="void" />
+ <param index="0" name="item" type="RID" />
+ <param index="1" name="points" type="PackedVector2Array" />
+ <param index="2" name="colors" type="PackedColorArray" />
+ <param index="3" name="width" type="float" default="-1.0" />
+ <description>
+ Draws a 2D multiline on the [CanvasItem] pointed to by the [param item] [RID]. See also [method CanvasItem.draw_multiline] and [method CanvasItem.draw_multiline_colors].
+ </description>
+ </method>
<method name="canvas_item_add_multimesh">
<return type="void" />
<param index="0" name="item" type="RID" />
@@ -302,7 +311,7 @@
<param index="3" name="uvs" type="PackedVector2Array" default="PackedVector2Array()" />
<param index="4" name="texture" type="RID" />
<description>
- Draws a 2D polygon on the [CanvasItem] pointed to by the [param item] [RID]. See also [method CanvasItem.draw_polygon].
+ Draws a 2D polygon on the [CanvasItem] pointed to by the [param item] [RID]. If you need more flexibility (such as being able to use bones), use [method canvas_item_add_triangle_array] instead. See also [method CanvasItem.draw_polygon].
</description>
</method>
<method name="canvas_item_add_polyline">
@@ -313,7 +322,7 @@
<param index="3" name="width" type="float" default="-1.0" />
<param index="4" name="antialiased" type="bool" default="false" />
<description>
- Draws a 2D polyline on the [CanvasItem] pointed to by the [param item] [RID]. See also [method CanvasItem.draw_polyline].
+ Draws a 2D polyline on the [CanvasItem] pointed to by the [param item] [RID]. See also [method CanvasItem.draw_polyline] and [method CanvasItem.draw_polyline_colors].
</description>
</method>
<method name="canvas_item_add_primitive">
@@ -381,6 +390,8 @@
<param index="7" name="texture" type="RID" />
<param index="8" name="count" type="int" default="-1" />
<description>
+ Draws a triangle array on the [CanvasItem] pointed to by the [param item] [RID]. This is internally used by [Line2D] and [StyleBoxFlat] for rendering. [method canvas_item_add_triangle_array] is highly flexible, but more complex to use than [method canvas_item_add_polygon].
+ [b]Note:[/b] [param count] is unused and can be left unspecified.
</description>
</method>
<method name="canvas_item_clear">
@@ -393,9 +404,9 @@
<method name="canvas_item_create">
<return type="RID" />
<description>
- Creates a canvas item and returns the assigned [RID]. It can be accessed with the RID that is returned. This RID will be used in all [code]canvas_item_*[/code] RenderingServer functions.
- Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method.
- This is the internal equivalent of the [CanvasItem] node.
+ Creates a new CanvasItem instance and returns its [RID]. It can be accessed with the RID that is returned. This RID will be used in all [code]canvas_item_*[/code] RenderingServer functions.
+ Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] method.
+ [b]Note:[/b] The equivalent node is [CanvasItem].
</description>
</method>
<method name="canvas_item_set_canvas_group_mode">
@@ -407,6 +418,8 @@
<param index="4" name="fit_margin" type="float" default="0.0" />
<param index="5" name="blur_mipmaps" type="bool" default="false" />
<description>
+ Sets the canvas group mode used during 2D rendering for the canvas item specified by the [param item] RID. For faster but more limited clipping, use [method canvas_item_set_clip] instead.
+ [b]Note:[/b] The equivalent node functionality is found in [CanvasGroup] and [member CanvasItem.clip_children].
</description>
</method>
<method name="canvas_item_set_clip">
@@ -414,6 +427,8 @@
<param index="0" name="item" type="RID" />
<param index="1" name="clip" type="bool" />
<description>
+ If [param clip] is [code]true[/code], makes the canvas item specified by the [param item] RID not draw anything outside of its rect's coordinates. This clipping is fast, but works only with axis-aligned rectangles. This means that rotation is ignored by the clipping rectangle. For more advanced clipping shapes, use [method canvas_item_set_canvas_group_mode] instead.
+ [b]Note:[/b] The equivalent node functionality is found in [member Label.clip_text], [RichTextLabel] (always enabled) and more.
</description>
</method>
<method name="canvas_item_set_copy_to_backbuffer">
@@ -431,6 +446,7 @@
<param index="1" name="use_custom_rect" type="bool" />
<param index="2" name="rect" type="Rect2" default="Rect2(0, 0, 0, 0)" />
<description>
+ If [param use_custom_rect] is [code]true[/code], sets the custom visibility rectangle (used for culling) to [param rect] for the canvas item specified by [param item]. Setting a custom visibility rect can reduce CPU load when drawing lots of 2D instances. If [param use_custom_rect] is [code]false[/code], automatically computes a visibility rectangle based on the canvas item's draw commands.
</description>
</method>
<method name="canvas_item_set_default_texture_filter">
@@ -438,6 +454,7 @@
<param index="0" name="item" type="RID" />
<param index="1" name="filter" type="int" enum="RenderingServer.CanvasItemTextureFilter" />
<description>
+ Sets the default texture filter mode for the canvas item specified by the [param item] RID. Equivalent to [member CanvasItem.texture_filter].
</description>
</method>
<method name="canvas_item_set_default_texture_repeat">
@@ -445,6 +462,7 @@
<param index="0" name="item" type="RID" />
<param index="1" name="repeat" type="int" enum="RenderingServer.CanvasItemTextureRepeat" />
<description>
+ Sets the default texture repeat mode for the canvas item specified by the [param item] RID. Equivalent to [member CanvasItem.texture_repeat].
</description>
</method>
<method name="canvas_item_set_distance_field_mode">
@@ -452,6 +470,7 @@
<param index="0" name="item" type="RID" />
<param index="1" name="enabled" type="bool" />
<description>
+ If [param enabled] is [code]true[/code], enables multichannel signed distance field rendering mode for the canvas item specified by the [param item] RID. This is meant to be used for font rendering, or with specially generated images using [url=https://github.com/Chlumsky/msdfgen]msdfgen[/url].
</description>
</method>
<method name="canvas_item_set_draw_behind_parent">
@@ -459,6 +478,7 @@
<param index="0" name="item" type="RID" />
<param index="1" name="enabled" type="bool" />
<description>
+ If [param enabled] is [code]true[/code], draws the canvas item specified by the [param item] RID behind its parent. Equivalent to [member CanvasItem.show_behind_parent].
</description>
</method>
<method name="canvas_item_set_draw_index">
@@ -474,6 +494,7 @@
<param index="0" name="item" type="RID" />
<param index="1" name="mask" type="int" />
<description>
+ Sets the light [param mask] for the canvas item specified by the [param item] RID. Equivalent to [member CanvasItem.light_mask].
</description>
</method>
<method name="canvas_item_set_material">
@@ -481,7 +502,7 @@
<param index="0" name="item" type="RID" />
<param index="1" name="material" type="RID" />
<description>
- Sets a new material to the [CanvasItem].
+ Sets a new [param material] to the canvas item specified by the [param item] RID. Equivalent to [member CanvasItem.material].
</description>
</method>
<method name="canvas_item_set_modulate">
@@ -489,7 +510,7 @@
<param index="0" name="item" type="RID" />
<param index="1" name="color" type="Color" />
<description>
- Sets a color modulation to the [CanvasItem]. This also affects child canvas items.
+ Multiplies the color of the canvas item specified by the [param item] RID, while affecting its children. See also [method canvas_item_set_self_modulate]. Equivalent to [member CanvasItem.modulate].
</description>
</method>
<method name="canvas_item_set_parent">
@@ -505,7 +526,7 @@
<param index="0" name="item" type="RID" />
<param index="1" name="color" type="Color" />
<description>
- Sets a color self-modulation to the [CanvasItem]. It does not affect the child canvas items.
+ Multiplies the color of the canvas item specified by the [param item] RID, without affecting its children. See also [method canvas_item_set_modulate]. Equivalent to [member CanvasItem.self_modulate].
</description>
</method>
<method name="canvas_item_set_sort_children_by_y">
@@ -513,7 +534,7 @@
<param index="0" name="item" type="RID" />
<param index="1" name="enabled" type="bool" />
<description>
- Enables or disables Y-sorting of a [CanvasItem].
+ If [param enabled] is [code]true[/code], child nodes with the lowest Y position are drawn before those with a higher Y position. Y-sorting only affects children that inherit from the canvas item specified by the [param item] RID, not the canvas item itself. Equivalent to [member CanvasItem.y_sort_enabled].
</description>
</method>
<method name="canvas_item_set_transform">
@@ -521,7 +542,7 @@
<param index="0" name="item" type="RID" />
<param index="1" name="transform" type="Transform2D" />
<description>
- Sets the transform of the [CanvasItem]. It affects where and how the item will be drawn. Child canvas items' transforms are multiplied by their parent's transform.
+ Sets the [param transform] of the canvas item specified by the [param item] RID. This affects where and how the item will be drawn. Child canvas items' transforms are multiplied by their parent's transform. Equivalent to [member Node2D.transform].
</description>
</method>
<method name="canvas_item_set_use_parent_material">
@@ -588,7 +609,8 @@
<return type="RID" />
<description>
Creates a canvas light and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]canvas_light_*[/code] RenderingServer functions.
- Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method.
+ Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] method.
+ [b]Note:[/b] The equivalent node is [Light2D].
</description>
</method>
<method name="canvas_light_occluder_attach_to_canvas">
@@ -603,7 +625,8 @@
<return type="RID" />
<description>
Creates a light occluder and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]canvas_light_occluder_*[/code] RenderingServer functions.
- Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method.
+ Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] method.
+ [b]Note:[/b] The equivalent node is [LightOccluder2D].
</description>
</method>
<method name="canvas_light_occluder_set_as_sdf_collision">
@@ -795,7 +818,8 @@
<return type="RID" />
<description>
Creates a new light occluder polygon and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]canvas_occluder_polygon_*[/code] RenderingServer functions.
- Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method.
+ Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] method.
+ [b]Note:[/b] The equivalent resource is [OccluderPolygon2D].
</description>
</method>
<method name="canvas_occluder_polygon_set_cull_mode">
@@ -842,14 +866,15 @@
<return type="void" />
<param index="0" name="size" type="int" />
<description>
+ Sets the [member ProjectSettings.rendering/2d/shadow_atlas/size] to use for [Light2D] shadow rendering (in pixels). The value is rounded up to the nearest power of 2.
</description>
</method>
<method name="canvas_texture_create">
<return type="RID" />
<description>
Creates a canvas texture and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]canvas_texture_*[/code] RenderingServer functions.
- Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method.
- This is the internal equivalent of the [CanvasTexture] resource.
+ Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] method. See also [method texture_2d_create].
+ [b]Note:[/b] The equivalent resource is [CanvasTexture] and is only meant to be used in 2D rendering, not 3D.
</description>
</method>
<method name="canvas_texture_set_channel">
@@ -858,6 +883,7 @@
<param index="1" name="channel" type="int" enum="RenderingServer.CanvasTextureChannel" />
<param index="2" name="texture" type="RID" />
<description>
+ Sets the [param channel]'s [param texture] for the canvas texture specified by the [param canvas_texture] RID. Equivalent to [member CanvasTexture.diffuse_texture], [member CanvasTexture.normal_texture] and [member CanvasTexture.specular_texture].
</description>
</method>
<method name="canvas_texture_set_shading_parameters">
@@ -866,6 +892,7 @@
<param index="1" name="base_color" type="Color" />
<param index="2" name="shininess" type="float" />
<description>
+ Sets the [param base_color] and [param shininess] to use for the canvas texture specified by the [param canvas_texture] RID. Equivalent to [member CanvasTexture.specular_color] and [member CanvasTexture.specular_shininess].
</description>
</method>
<method name="canvas_texture_set_texture_filter">
@@ -873,7 +900,7 @@
<param index="0" name="canvas_texture" type="RID" />
<param index="1" name="filter" type="int" enum="RenderingServer.CanvasItemTextureFilter" />
<description>
- Sets the texture filter used by the [CanvasTexture].
+ Sets the texture [param filter] mode to use for the canvas texture specified by the [param canvas_texture] RID.
</description>
</method>
<method name="canvas_texture_set_texture_repeat">
@@ -881,7 +908,7 @@
<param index="0" name="canvas_texture" type="RID" />
<param index="1" name="repeat" type="int" enum="RenderingServer.CanvasItemTextureRepeat" />
<description>
- Sets the texture repeat used by the [CanvasTexture].
+ Sets the texture [param repeat] mode to use for the canvas texture specified by the [param canvas_texture] RID.
</description>
</method>
<method name="create_local_rendering_device" qualifiers="const">
@@ -895,8 +922,9 @@
<return type="RID" />
<description>
Creates a decal and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]decal_*[/code] RenderingServer functions.
- Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method.
- This is the internal equivalent of the [Decal] node.
+ Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] method.
+ To place in a scene, attach this decal to an instance using [method instance_set_base] using the returned RID.
+ [b]Note:[/b] The equivalent node is [Decal].
</description>
</method>
<method name="decal_set_albedo_mix">
@@ -904,6 +932,7 @@
<param index="0" name="decal" type="RID" />
<param index="1" name="albedo_mix" type="float" />
<description>
+ Sets the [param albedo_mix] in the decal specified by the [param decal] RID. Equivalent to [member Decal.albedo_mix].
</description>
</method>
<method name="decal_set_cull_mask">
@@ -911,6 +940,7 @@
<param index="0" name="decal" type="RID" />
<param index="1" name="mask" type="int" />
<description>
+ Sets the cull [param mask] in the decal specified by the [param decal] RID. Equivalent to [member Decal.cull_mask].
</description>
</method>
<method name="decal_set_distance_fade">
@@ -920,6 +950,7 @@
<param index="2" name="begin" type="float" />
<param index="3" name="length" type="float" />
<description>
+ Sets the distance fade parameters in the decal specified by the [param decal] RID. Equivalent to [member Decal.distance_fade_enabled], [member Decal.distance_fade_begin] and [member Decal.distance_fade_length].
</description>
</method>
<method name="decal_set_emission_energy">
@@ -927,6 +958,7 @@
<param index="0" name="decal" type="RID" />
<param index="1" name="energy" type="float" />
<description>
+ Sets the emission [param energy] in the decal specified by the [param decal] RID. Equivalent to [member Decal.emission_energy].
</description>
</method>
<method name="decal_set_fade">
@@ -935,6 +967,7 @@
<param index="1" name="above" type="float" />
<param index="2" name="below" type="float" />
<description>
+ Sets the upper fade ([param above]) and lower fade ([param below]) in the decal specified by the [param decal] RID. Equivalent to [member Decal.upper_fade] and [member Decal.lower_fade].
</description>
</method>
<method name="decal_set_modulate">
@@ -942,7 +975,7 @@
<param index="0" name="decal" type="RID" />
<param index="1" name="color" type="Color" />
<description>
- Sets the color modulation of the [Decal].
+ Sets the color multiplier in the decal specified by the [param decal] RID to [param color]. Equivalent to [member Decal.modulate].
</description>
</method>
<method name="decal_set_normal_fade">
@@ -950,6 +983,7 @@
<param index="0" name="decal" type="RID" />
<param index="1" name="fade" type="float" />
<description>
+ Sets the normal [param fade] in the decal specified by the [param decal] RID. Equivalent to [member Decal.normal_fade].
</description>
</method>
<method name="decal_set_size">
@@ -957,7 +991,7 @@
<param index="0" name="decal" type="RID" />
<param index="1" name="size" type="Vector3" />
<description>
- Sets the size of the [Decal].
+ Sets the [param size] of the decal specified by the [param decal] RID. Equivalent to [member Decal.size].
</description>
</method>
<method name="decal_set_texture">
@@ -966,22 +1000,23 @@
<param index="1" name="type" type="int" enum="RenderingServer.DecalTexture" />
<param index="2" name="texture" type="RID" />
<description>
- Sets the texture of the [Decal].
+ Sets the [param texture] in the given texture [param type] slot for the specified decal. Equivalent to [method Decal.set_texture].
</description>
</method>
<method name="decals_set_filter">
<return type="void" />
<param index="0" name="filter" type="int" enum="RenderingServer.DecalFilter" />
<description>
+ Sets the texture [param filter] mode to use when rendering decals. This parameter is global and cannot be set on a per-decal basis.
</description>
</method>
<method name="directional_light_create">
<return type="RID" />
<description>
Creates a directional light and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID can be used in most [code]light_*[/code] RenderingServer functions.
- Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method.
+ Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] method.
To place in a scene, attach this directional light to an instance using [method instance_set_base] using the returned RID.
- This is the internal equivalent of the [DirectionalLight3D] node.
+ [b]Note:[/b] The equivalent node is [DirectionalLight3D].
</description>
</method>
<method name="directional_shadow_atlas_set_size">
@@ -989,12 +1024,14 @@
<param index="0" name="size" type="int" />
<param index="1" name="is_16bits" type="bool" />
<description>
+ Sets the [param size] of the directional light shadows in 3D. See also [member ProjectSettings.rendering/lights_and_shadows/directional_shadow/size]. This parameter is global and cannot be set on a per-viewport basis.
</description>
</method>
<method name="directional_soft_shadow_filter_set_quality">
<return type="void" />
<param index="0" name="quality" type="int" enum="RenderingServer.ShadowQuality" />
<description>
+ Sets the filter [param quality] for directional light shadows in 3D. See also [member ProjectSettings.rendering/lights_and_shadows/directional_shadow/soft_shadow_filter_quality]. This parameter is global and cannot be set on a per-viewport basis.
</description>
</method>
<method name="environment_bake_panorama">
@@ -1003,20 +1040,24 @@
<param index="1" name="bake_irradiance" type="bool" />
<param index="2" name="size" type="Vector2i" />
<description>
+ Generates and returns an [Image] containing the radiance map for the specified [param environment] RID's sky. This supports built-in sky material and custom sky shaders. If [param bake_irradiance] is [code]true[/code], the irradiance map is saved instead of the radiance map. The radiance map is used to render reflected light, while the irradiance map is used to render ambient light. See also [method sky_bake_panorama].
+ [b]Note:[/b] The image is saved in linear color space without any tonemapping performed, which means it will look too dark if viewed directly in an image editor.
+ [b]Note:[/b] [param size] should be a 2:1 aspect ratio for the generated panorama to have square pixels. For radiance maps, there is no point in using a height greater than [member Sky.radiance_size], as it won't increase detail. Irradiance maps only contain low-frequency data, so there is usually no point in going past a size of 128×64 pixels when saving an irradiance map.
</description>
</method>
<method name="environment_create">
<return type="RID" />
<description>
Creates an environment and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]environment_*[/code] RenderingServer functions.
- Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method.
- This is the internal equivalent of the [Environment] resource.
+ Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] method.
+ [b]Note:[/b] The equivalent resource is [Environment].
</description>
</method>
<method name="environment_glow_set_use_bicubic_upscale">
<return type="void" />
<param index="0" name="enable" type="bool" />
<description>
+ If [param enable] is [code]true[/code], enables bicubic upscaling for glow which improves quality at the cost of performance. Equivalent to [member ProjectSettings.rendering/environment/glow/upscale_mode].
</description>
</method>
<method name="environment_set_adjustment">
@@ -1029,7 +1070,7 @@
<param index="5" name="use_1d_color_correction" type="bool" />
<param index="6" name="color_correction" type="RID" />
<description>
- Sets the values to be used with the "Adjustment" post-process effect. See [Environment] for more details.
+ Sets the values to be used with the "adjustments" post-process effect. See [Environment] for more details.
</description>
</method>
<method name="environment_set_ambient_light">
@@ -1041,6 +1082,7 @@
<param index="4" name="sky_contibution" type="float" default="0.0" />
<param index="5" name="reflection_source" type="int" enum="RenderingServer.EnvironmentReflectionSource" default="0" />
<description>
+ Sets the values to be used for ambient light rendering. See [Environment] for more details.
</description>
</method>
<method name="environment_set_background">
@@ -1048,7 +1090,7 @@
<param index="0" name="env" type="RID" />
<param index="1" name="bg" type="int" enum="RenderingServer.EnvironmentBG" />
<description>
- Sets the [i]BGMode[/i] of the environment. Equivalent to [member Environment.background_mode].
+ Sets the environment's background mode. Equivalent to [member Environment.background_mode].
</description>
</method>
<method name="environment_set_bg_color">
@@ -1056,7 +1098,7 @@
<param index="0" name="env" type="RID" />
<param index="1" name="color" type="Color" />
<description>
- Color displayed for clear areas of the scene (if using Custom color or Color+Sky background modes).
+ Color displayed for clear areas of the scene. Only effective if using the [constant ENV_BG_COLOR] background mode.
</description>
</method>
<method name="environment_set_bg_energy">
@@ -1089,6 +1131,7 @@
<param index="8" name="aerial_perspective" type="float" />
<param index="9" name="sky_affect" type="float" />
<description>
+ Configures fog for the specified environment RID. See [code]fog_*[/code] properties in [Environment] for more information.
</description>
</method>
<method name="environment_set_glow">
@@ -1107,6 +1150,7 @@
<param index="11" name="glow_map_strength" type="float" />
<param index="12" name="glow_map" type="RID" />
<description>
+ Configures glow for the specified environment RID. See [code]glow_*[/code] properties in [Environment] for more information.
</description>
</method>
<method name="environment_set_sdfgi">
@@ -1123,24 +1167,28 @@
<param index="9" name="normal_bias" type="float" />
<param index="10" name="probe_bias" type="float" />
<description>
+ Configures signed distance field global illumination for the specified environment RID. See [code]sdfgi_*[/code] properties in [Environment] for more information.
</description>
</method>
<method name="environment_set_sdfgi_frames_to_converge">
<return type="void" />
<param index="0" name="frames" type="int" enum="RenderingServer.EnvironmentSDFGIFramesToConverge" />
<description>
+ Sets the number of frames to use for converging signed distance field global illumination. Equivalent to [member ProjectSettings.rendering/global_illumination/sdfgi/frames_to_converge].
</description>
</method>
<method name="environment_set_sdfgi_frames_to_update_light">
<return type="void" />
<param index="0" name="frames" type="int" enum="RenderingServer.EnvironmentSDFGIFramesToUpdateLight" />
<description>
+ Sets the update speed for dynamic lights' indirect lighting when computing signed distance field global illumination. Equivalent to [member ProjectSettings.rendering/global_illumination/sdfgi/frames_to_update_lights].
</description>
</method>
<method name="environment_set_sdfgi_ray_count">
<return type="void" />
<param index="0" name="ray_count" type="int" enum="RenderingServer.EnvironmentSDFGIRayCount" />
<description>
+ Sets the number of rays to throw per frame when computing signed distance field global illumination. Equivalent to [member ProjectSettings.rendering/global_illumination/sdfgi/probe_ray_count].
</description>
</method>
<method name="environment_set_sky">
@@ -1216,7 +1264,7 @@
<param index="4" name="fade_out" type="float" />
<param index="5" name="depth_tolerance" type="float" />
<description>
- Sets the variables to be used with the "screen space reflections" post-process effect. See [Environment] for more details.
+ Sets the variables to be used with the screen-space reflections (SSR) post-process effect. See [Environment] for more details.
</description>
</method>
<method name="environment_set_ssr_roughness_quality">
@@ -1252,6 +1300,7 @@
<param index="12" name="ambient_inject" type="float" />
<param index="13" name="sky_affect" type="float" />
<description>
+ Sets the variables to be used with the volumetric fog post-process effect. See [Environment] for more details.
</description>
</method>
<method name="environment_set_volumetric_fog_filter_active">
@@ -1272,9 +1321,9 @@
<method name="fog_volume_create">
<return type="RID" />
<description>
- Creates a fog volume and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]fog_volume_*[/code] RenderingServer functions.
- Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method.
- This is the internal equivalent of the [FogVolume] node.
+ Creates a new fog volume and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]fog_volume_*[/code] RenderingServer functions.
+ Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] method.
+ [b]Note:[/b] The equivalent node is [FogVolume].
</description>
</method>
<method name="fog_volume_set_material">
@@ -1306,29 +1355,32 @@
<param index="0" name="swap_buffers" type="bool" default="true" />
<param index="1" name="frame_step" type="float" default="0.0" />
<description>
+ Forces redrawing of all viewports at once.
</description>
</method>
<method name="force_sync">
<return type="void" />
<description>
+ Forces a synchronization between the CPU and GPU, which may be required in certain cases. Only call this when needed, as CPU-GPU synchronization has a performance cost.
</description>
</method>
<method name="free_rid">
<return type="void" />
<param index="0" name="rid" type="RID" />
<description>
- Tries to free an object in the RenderingServer.
+ Tries to free an object in the RenderingServer. To avoid memory leaks, this should be called after using an object as memory management does not occur automatically when using RendeeringServer directly.
</description>
</method>
<method name="get_default_clear_color">
<return type="Color" />
<description>
- Returns the default clear color which is used when a specific clear color has not been selected.
+ Returns the default clear color which is used when a specific clear color has not been selected. See also [method set_default_clear_color].
</description>
</method>
<method name="get_frame_setup_time_cpu" qualifiers="const">
<return type="float" />
<description>
+ Returns the time taken to setup rendering on the CPU in milliseconds. This value is shared across all viewports and does [i]not[/i] require [method viewport_set_measure_render_time] to be enabled on a viewport to be queried. See also [method viewport_get_measured_render_time_cpu].
</description>
</method>
<method name="get_rendering_device" qualifiers="const">
@@ -1342,6 +1394,16 @@
<return type="int" />
<param index="0" name="info" type="int" enum="RenderingServer.RenderingInfo" />
<description>
+ Returns a statistic about the rendering engine which can be used for performance profiling. See [enum RenderingServer.RenderingInfo] for a list of values that can be queried. See also [method viewport_get_render_info], which returns information specific to a viewport.
+ [b]Note:[/b] Only 3D rendering is currently taken into account by some of these values, such as the number of draw calls.
+ [b]Note:[/b] Rendering information is not available until at least 2 frames have been rendered by the engine. If rendering information is not available, [method get_rendering_info] returns [code]0[/code]. To print rendering information in [code]_ready()[/code] successfully, use the following:
+ [codeblock]
+ func _ready():
+ for _i in 2:
+ await get_tree().process_frame
+
+ print(RenderingServer.get_rendering_info(RENDERING_INFO_TOTAL_DRAW_CALLS_IN_FRAME))
+ [/codeblock]
</description>
</method>
<method name="get_shader_parameter_list" qualifiers="const">
@@ -1354,19 +1416,25 @@
<method name="get_test_cube">
<return type="RID" />
<description>
- Returns the ID of the test cube. Creates one if none exists.
+ Returns the RID of the test cube. This mesh will be created and returned on the first call to [method get_test_cube], then it will be cached for subsequent calls. See also [method make_sphere_mesh].
</description>
</method>
<method name="get_test_texture">
<return type="RID" />
<description>
- Returns the ID of the test texture. Creates one if none exists.
+ Returns the RID of a 256×256 texture with a testing pattern on it (in [constant Image.FORMAT_RGB8] format). This texture will be created and returned on the first call to [method get_test_texture], then it will be cached for subsequent calls. See also [method get_white_texture].
+ Example of getting the test texture and applying it to a [Sprite2D] node:
+ [codeblock]
+ var texture_rid = RenderingServer.get_test_texture()
+ var texture = ImageTexture.create_from_image(RenderingServer.texture_2d_get(texture_rid))
+ $Sprite2D.texture = texture
+ [/codeblock]
</description>
</method>
<method name="get_video_adapter_api_version" qualifiers="const">
<return type="String" />
<description>
- Returns the version of the graphics video adapter [i]currently in use[/i] (e.g. "1.2.189" for Vulkan, "3.3.0 NVIDIA 510.60.02" for OpenGL). This version may be different from the actual latest version supported by the hardware, as Godot may not always request the latest version.
+ Returns the version of the graphics video adapter [i]currently in use[/i] (e.g. "1.2.189" for Vulkan, "3.3.0 NVIDIA 510.60.02" for OpenGL). This version may be different from the actual latest version supported by the hardware, as Godot may not always request the latest version. See also [method OS.get_video_adapter_driver_info].
[b]Note:[/b] When running a headless or server binary, this function returns an empty string.
</description>
</method>
@@ -1394,14 +1462,20 @@
<method name="get_white_texture">
<return type="RID" />
<description>
- Returns the ID of a white texture. Creates one if none exists.
+ Returns the ID of a 4×4 white texture (in [constant Image.FORMAT_RGB8] format). This texture will be created and returned on the first call to [method get_white_texture], then it will be cached for subsequent calls. See also [method get_test_texture].
+ Example of getting the white texture and applying it to a [Sprite2D] node:
+ [codeblock]
+ var texture_rid = RenderingServer.get_white_texture()
+ var texture = ImageTexture.create_from_image(RenderingServer.texture_2d_get(texture_rid))
+ $Sprite2D.texture = texture
+ [/codeblock]
</description>
</method>
<method name="gi_set_use_half_resolution">
<return type="void" />
<param index="0" name="half_resolution" type="bool" />
<description>
- If [param half_resolution] is [code]true[/code], renders [VoxelGI] and SDFGI ([member Environment.sdfgi_enabled]) buffers at halved resolution (e.g. 960×540 when the viewport size is 1920×1080). This improves performance significantly when VoxelGI or SDFGI is enabled, at the cost of artifacts that may be visible on polygon edges. The loss in quality becomes less noticeable as the viewport resolution increases. [LightmapGI] rendering is not affected by this setting. See also [member ProjectSettings.rendering/global_illumination/gi/use_half_resolution].
+ If [param half_resolution] is [code]true[/code], renders [VoxelGI] and SDFGI ([member Environment.sdfgi_enabled]) buffers at halved resolution on each axis (e.g. 960×540 when the viewport size is 1920×1080). This improves performance significantly when VoxelGI or SDFGI is enabled, at the cost of artifacts that may be visible on polygon edges. The loss in quality becomes less noticeable as the viewport resolution increases. [LightmapGI] rendering is not affected by this setting. Equivalent to [member ProjectSettings.rendering/global_illumination/gi/use_half_resolution].
</description>
</method>
<method name="global_shader_parameter_add">
@@ -1410,29 +1484,38 @@
<param index="1" name="type" type="int" enum="RenderingServer.GlobalShaderParameterType" />
<param index="2" name="default_value" type="Variant" />
<description>
+ Creates a new global shader uniform.
+ [b]Note:[/b] Global shader parameter names are case-sensitive.
</description>
</method>
<method name="global_shader_parameter_get" qualifiers="const">
<return type="Variant" />
<param index="0" name="name" type="StringName" />
<description>
+ Returns the value of the global shader uniform specified by [param name].
+ [b]Note:[/b] [method global_shader_parameter_get] has a large performance penalty as the rendering thread needs to synchronize with the calling thread, which is slow. Do not use this method during gameplay to avoid stuttering. If you need to read values in a script after setting them, consider creating an autoload where you store the values you need to query at the same time you're setting them as global parameters.
</description>
</method>
<method name="global_shader_parameter_get_list" qualifiers="const">
<return type="StringName[]" />
<description>
+ Returns the list of global shader uniform names.
+ [b]Note:[/b] [method global_shader_parameter_get] has a large performance penalty as the rendering thread needs to synchronize with the calling thread, which is slow. Do not use this method during gameplay to avoid stuttering. If you need to read values in a script after setting them, consider creating an autoload where you store the values you need to query at the same time you're setting them as global parameters.
</description>
</method>
<method name="global_shader_parameter_get_type" qualifiers="const">
<return type="int" enum="RenderingServer.GlobalShaderParameterType" />
<param index="0" name="name" type="StringName" />
<description>
+ Returns the type associated to the global shader uniform specified by [param name].
+ [b]Note:[/b] [method global_shader_parameter_get] has a large performance penalty as the rendering thread needs to synchronize with the calling thread, which is slow. Do not use this method during gameplay to avoid stuttering. If you need to read values in a script after setting them, consider creating an autoload where you store the values you need to query at the same time you're setting them as global parameters.
</description>
</method>
<method name="global_shader_parameter_remove">
<return type="void" />
<param index="0" name="name" type="StringName" />
<description>
+ Removes the global shader uniform specified by [param name].
</description>
</method>
<method name="global_shader_parameter_set">
@@ -1440,6 +1523,7 @@
<param index="0" name="name" type="StringName" />
<param index="1" name="value" type="Variant" />
<description>
+ Sets the global shader uniform [param name] to [param value].
</description>
</method>
<method name="global_shader_parameter_set_override">
@@ -1447,6 +1531,7 @@
<param index="0" name="name" type="StringName" />
<param index="1" name="value" type="Variant" />
<description>
+ Overrides the global shader uniform [param name] with [param value]. Equivalent to the [ShaderGlobalsOverride] node.
</description>
</method>
<method name="has_changed" qualifiers="const">
@@ -1489,9 +1574,9 @@
<return type="RID" />
<description>
Creates a visual instance and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]instance_*[/code] RenderingServer functions.
- Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method.
- An instance is a way of placing a 3D object in the scenario. Objects like particles, meshes, and reflection probes need to be associated with an instance to be visible in the scenario using [method instance_set_base].
- This is the internal equivalent of the [VisualInstance3D] node.
+ Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] method.
+ An instance is a way of placing a 3D object in the scenario. Objects like particles, meshes, reflection probes and decals need to be associated with an instance to be visible in the scenario using [method instance_set_base].
+ [b]Note:[/b] The equivalent node is [VisualInstance3D].
</description>
</method>
<method name="instance_create2">
@@ -1500,7 +1585,7 @@
<param index="1" name="scenario" type="RID" />
<description>
Creates a visual instance, adds it to the RenderingServer, and sets both base and scenario. It can be accessed with the RID that is returned. This RID will be used in all [code]instance_*[/code] RenderingServer functions.
- Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method.
+ Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] method. This is a shorthand for using [method instance_create] and setting the base and scenario manually.
</description>
</method>
<method name="instance_geometry_get_shader_parameter" qualifiers="const">
@@ -1508,6 +1593,8 @@
<param index="0" name="instance" type="RID" />
<param index="1" name="parameter" type="StringName" />
<description>
+ Returns the value of the per-instance shader uniform from the specified 3D geometry instance. Equivalent to [method GeometryInstance3D.get_instance_shader_parameter].
+ [b]Note:[/b] Per-instance shader parameter names are case-sensitive.
</description>
</method>
<method name="instance_geometry_get_shader_parameter_default_value" qualifiers="const">
@@ -1515,12 +1602,14 @@
<param index="0" name="instance" type="RID" />
<param index="1" name="parameter" type="StringName" />
<description>
+ Returns the default value of the per-instance shader uniform from the specified 3D geometry instance. Equivalent to [method GeometryInstance3D.get_instance_shader_parameter].
</description>
</method>
<method name="instance_geometry_get_shader_parameter_list" qualifiers="const">
<return type="Dictionary[]" />
<param index="0" name="instance" type="RID" />
<description>
+ Returns a dictionary of per-instance shader uniform names of the per-instance shader uniform from the specified 3D geometry instance. The returned dictionary is in PropertyInfo format, with the keys [code]name[/code], [code]class_name[/code], [code]type[/code], [code]hint[/code], [code]hint_string[/code] and [code]usage[/code]. Equivalent to [method GeometryInstance3D.get_instance_shader_parameter].
</description>
</method>
<method name="instance_geometry_set_cast_shadows_setting">
@@ -1547,6 +1636,7 @@
<param index="2" name="lightmap_uv_scale" type="Rect2" />
<param index="3" name="lightmap_slice" type="int" />
<description>
+ Sets the lightmap GI instance to use for the specified 3D geometry instance. The lightmap UV scale for the specified instance (equivalent to [member GeometryInstance3D.gi_lightmap_scale]) and lightmap atlas slice must also be specified.
</description>
</method>
<method name="instance_geometry_set_lod_bias">
@@ -1554,6 +1644,7 @@
<param index="0" name="instance" type="RID" />
<param index="1" name="lod_bias" type="float" />
<description>
+ Sets the level of detail bias to use when rendering the specified 3D geometry instance. Higher values result in higher detail from further away. Equivalent to [member GeometryInstance3D.lod_bias].
</description>
</method>
<method name="instance_geometry_set_material_overlay">
@@ -1578,6 +1669,7 @@
<param index="1" name="parameter" type="StringName" />
<param index="2" name="value" type="Variant" />
<description>
+ Sets the per-instance shader uniform on the specified 3D geometry instance. Equivalent to [method GeometryInstance3D.set_instance_shader_parameter].
</description>
</method>
<method name="instance_geometry_set_transparency">
@@ -1608,7 +1700,7 @@
<param index="0" name="instance" type="RID" />
<param index="1" name="base" type="RID" />
<description>
- Sets the base of the instance. A base can be any of the 3D objects that are created in the RenderingServer that can be displayed. For example, any of the light types, mesh, multimesh, immediate geometry, particle system, reflection probe, lightmap, and the GI probe are all types that can be set as the base of an instance in order to be displayed in the scenario.
+ Sets the base of the instance. A base can be any of the 3D objects that are created in the RenderingServer that can be displayed. For example, any of the light types, mesh, multimesh, particle system, reflection probe, decal, lightmap, voxel GI and visibility notifiers are all types that can be set as the base of an instance in order to be displayed in the scenario.
</description>
</method>
<method name="instance_set_blend_shape_weight">
@@ -1641,6 +1733,7 @@
<param index="0" name="instance" type="RID" />
<param index="1" name="enabled" type="bool" />
<description>
+ If [code]true[/code], ignores both frustum and occlusion culling on the specified 3D geometry instance. This is not the same as [member GeometryInstance3D.ignore_occlusion_culling], which only ignores occlusion culling and leaves frustum culling intact.
</description>
</method>
<method name="instance_set_layer_mask">
@@ -1706,7 +1799,7 @@
<param index="0" name="aabb" type="AABB" />
<param index="1" name="scenario" type="RID" />
<description>
- Returns an array of object IDs intersecting with the provided AABB. Only visual 3D nodes are considered, such as [MeshInstance3D] or [DirectionalLight3D]. Use [method @GlobalScope.instance_from_id] to obtain the actual nodes. A scenario RID must be provided, which is available in the [World3D] you want to query. This forces an update for all resources queued to update.
+ Returns an array of object IDs intersecting with the provided AABB. Only 3D nodes that inherit from [VisualInstance3D] are considered, such as [MeshInstance3D] or [DirectionalLight3D]. Use [method @GlobalScope.instance_from_id] to obtain the actual nodes. A scenario RID must be provided, which is available in the [World3D] you want to query. This forces an update for all resources queued to update.
[b]Warning:[/b] This function is primarily intended for editor usage. For in-game use cases, prefer physics collision.
</description>
</method>
@@ -1715,7 +1808,7 @@
<param index="0" name="convex" type="Plane[]" />
<param index="1" name="scenario" type="RID" />
<description>
- Returns an array of object IDs intersecting with the provided convex shape. Only visual 3D nodes are considered, such as [MeshInstance3D] or [DirectionalLight3D]. Use [method @GlobalScope.instance_from_id] to obtain the actual nodes. A scenario RID must be provided, which is available in the [World3D] you want to query. This forces an update for all resources queued to update.
+ Returns an array of object IDs intersecting with the provided convex shape. Only 3D nodes that inherit from [VisualInstance3D] are considered, such as [MeshInstance3D] or [DirectionalLight3D]. Use [method @GlobalScope.instance_from_id] to obtain the actual nodes. A scenario RID must be provided, which is available in the [World3D] you want to query. This forces an update for all resources queued to update.
[b]Warning:[/b] This function is primarily intended for editor usage. For in-game use cases, prefer physics collision.
</description>
</method>
@@ -1725,7 +1818,7 @@
<param index="1" name="to" type="Vector3" />
<param index="2" name="scenario" type="RID" />
<description>
- Returns an array of object IDs intersecting with the provided 3D ray. Only visual 3D nodes are considered, such as [MeshInstance3D] or [DirectionalLight3D]. Use [method @GlobalScope.instance_from_id] to obtain the actual nodes. A scenario RID must be provided, which is available in the [World3D] you want to query. This forces an update for all resources queued to update.
+ Returns an array of object IDs intersecting with the provided 3D ray. Only 3D nodes that inherit from [VisualInstance3D] are considered, such as [MeshInstance3D] or [DirectionalLight3D]. Use [method @GlobalScope.instance_from_id] to obtain the actual nodes. A scenario RID must be provided, which is available in the [World3D] you want to query. This forces an update for all resources queued to update.
[b]Warning:[/b] This function is primarily intended for editor usage. For in-game use cases, prefer physics collision.
</description>
</method>
@@ -1765,6 +1858,7 @@
<return type="void" />
<param index="0" name="filter" type="int" enum="RenderingServer.LightProjectorFilter" />
<description>
+ Sets the texture filter mode to use when rendering light projectors. This parameter is global and cannot be set on a per-light basis.
</description>
</method>
<method name="light_set_bake_mode">
@@ -1772,6 +1866,7 @@
<param index="0" name="light" type="RID" />
<param index="1" name="bake_mode" type="int" enum="RenderingServer.LightBakeMode" />
<description>
+ Sets the bake mode to use for the specified 3D light. Equivalent to [member Light3D.light_bake_mode].
</description>
</method>
<method name="light_set_color">
@@ -1787,7 +1882,7 @@
<param index="0" name="light" type="RID" />
<param index="1" name="mask" type="int" />
<description>
- Sets the cull mask for this Light3D. Lights only affect objects in the selected layers. Equivalent to [member Light3D.light_cull_mask].
+ Sets the cull mask for this 3D light. Lights only affect objects in the selected layers. Equivalent to [member Light3D.light_cull_mask].
</description>
</method>
<method name="light_set_distance_fade">
@@ -1798,7 +1893,7 @@
<param index="3" name="shadow" type="float" />
<param index="4" name="length" type="float" />
<description>
- Sets the distance fade for this Light3D. This acts as a form of level of detail (LOD) and can be used to improve performance. Equivalent to [member Light3D.distance_fade_enabled], [member Light3D.distance_fade_begin], [member Light3D.distance_fade_shadow], and [member Light3D.distance_fade_length].
+ Sets the distance fade for this 3D light. This acts as a form of level of detail (LOD) and can be used to improve performance. Equivalent to [member Light3D.distance_fade_enabled], [member Light3D.distance_fade_begin], [member Light3D.distance_fade_shadow], and [member Light3D.distance_fade_length].
</description>
</method>
<method name="light_set_max_sdfgi_cascade">
@@ -1806,6 +1901,7 @@
<param index="0" name="light" type="RID" />
<param index="1" name="cascade" type="int" />
<description>
+ Sets the maximum SDFGI cascade in which the 3D light's indirect lighting is rendered. Higher values allow the light to be rendered in SDFGI further away from the camera.
</description>
</method>
<method name="light_set_negative">
@@ -1813,7 +1909,7 @@
<param index="0" name="light" type="RID" />
<param index="1" name="enable" type="bool" />
<description>
- If [code]true[/code], light will subtract light instead of adding light. Equivalent to [member Light3D.light_negative].
+ If [code]true[/code], the 3D light will subtract light instead of adding light. Equivalent to [member Light3D.light_negative].
</description>
</method>
<method name="light_set_param">
@@ -1822,7 +1918,7 @@
<param index="1" name="param" type="int" enum="RenderingServer.LightParam" />
<param index="2" name="value" type="float" />
<description>
- Sets the specified light parameter. See [enum LightParam] for options. Equivalent to [method Light3D.set_param].
+ Sets the specified 3D light parameter. See [enum LightParam] for options. Equivalent to [method Light3D.set_param].
</description>
</method>
<method name="light_set_projector">
@@ -1830,7 +1926,7 @@
<param index="0" name="light" type="RID" />
<param index="1" name="texture" type="RID" />
<description>
- Not implemented in Godot 3.x.
+ Sets the projector texture to use for the specified 3D light. Equivalent to [member Light3D.light_projector].
</description>
</method>
<method name="light_set_reverse_cull_face_mode">
@@ -1852,9 +1948,9 @@
<method name="lightmap_create">
<return type="RID" />
<description>
- Creates a lightmap GI and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]lightmap_*[/code] RenderingServer functions.
- Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method.
- This is the internal equivalent of the [LightmapGI] node.
+ Creates a new lightmap global illumination instance and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]lightmap_*[/code] RenderingServer functions.
+ Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] method.
+ [b]Note:[/b] The equivalent node is [LightmapGI].
</description>
</method>
<method name="lightmap_get_probe_capture_bsp_tree" qualifiers="const">
@@ -1925,6 +2021,7 @@
<param index="1" name="light" type="RID" />
<param index="2" name="uses_sh" type="bool" />
<description>
+ Set the textures on the given [param lightmap] GI instance to the texture array pointed to by the [param light] RID. If the lightmap texture was baked with [member LightmapGI.directional] set to [code]true[/code], then [param uses_sh] must also be [code]true[/code].
</description>
</method>
<method name="make_sphere_mesh">
@@ -1933,15 +2030,15 @@
<param index="1" name="longitudes" type="int" />
<param index="2" name="radius" type="float" />
<description>
- Returns a mesh of a sphere with the given number of horizontal and vertical subdivisions.
+ Returns a mesh of a sphere with the given number of horizontal subdivisions, vertical subdivisions and radius. See also [method get_test_cube].
</description>
</method>
<method name="material_create">
<return type="RID" />
<description>
Creates an empty material and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]material_*[/code] RenderingServer functions.
- Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method.
- This is the internal equivalent of the [Material] resource.
+ Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] method.
+ [b]Note:[/b] The equivalent resource is [Material].
</description>
</method>
<method name="material_get_param" qualifiers="const">
@@ -2014,9 +2111,9 @@
<return type="RID" />
<description>
Creates a new mesh and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]mesh_*[/code] RenderingServer functions.
- Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method.
+ Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] method.
To place in a scene, attach this mesh to an instance using [method instance_set_base] using the returned RID.
- This is the internal equivalent of the [Mesh] resource.
+ [b]Note:[/b] The equivalent resource is [Mesh].
</description>
</method>
<method name="mesh_create_from_surfaces">
@@ -2187,9 +2284,9 @@
<return type="RID" />
<description>
Creates a new multimesh on the RenderingServer and returns an [RID] handle. This RID will be used in all [code]multimesh_*[/code] RenderingServer functions.
- Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method.
+ Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] method.
To place in a scene, attach this multimesh to an instance using [method instance_set_base] using the returned RID.
- This is the internal equivalent of the [MultiMesh] resource.
+ [b]Note:[/b] The equivalent resource is [MultiMesh].
</description>
</method>
<method name="multimesh_get_aabb" qualifiers="const">
@@ -2203,6 +2300,8 @@
<return type="PackedFloat32Array" />
<param index="0" name="multimesh" type="RID" />
<description>
+ Returns the MultiMesh data (such as instance transforms, colors, etc). See [method multimesh_set_buffer] for a description of the returned data.
+ [b]Note:[/b] If the buffer is in the engine's internal cache, it will have to be fetched from GPU memory and possibly decompressed. This means [method multimesh_get_buffer] is potentially a slow operation and should be avoided whenever possible.
</description>
</method>
<method name="multimesh_get_instance_count" qualifiers="const">
@@ -2299,6 +2398,20 @@
<param index="0" name="multimesh" type="RID" />
<param index="1" name="buffer" type="PackedFloat32Array" />
<description>
+ Set the entire data to use for drawing the [param multimesh] at once to [param buffer] (such as instance transforms and colors). [param buffer]'s size must match the number of instances multiplied by the per-instance data size (which depends on the enabled MultiMesh fields). Otherwise, an error message is printed and nothing is rendered. See also [method multimesh_get_buffer].
+ The per-instance data size and expected data order is:
+ [codeblock]
+ 2D:
+ - Position: 8 floats (8 floats for Transform2D)
+ - Position + Vertex color: 12 floats (8 floats for Transform2D, 4 floats for Color)
+ - Position + Custom data: 12 floats (8 floats for Transform2D, 4 floats of custom data)
+ - Position + Vertex color + Custom data: 16 floats (8 floats for Transform2D, 4 floats for Color, 4 floats of custom data)
+ 3D:
+ - Position: 12 floats (12 floats for Transform3D)
+ - Position + Vertex color: 16 floats (12 floats for Transform3D, 4 floats for Color)
+ - Position + Custom data: 16 floats (12 floats for Transform3D, 4 floats of custom data)
+ - Position + Vertex color + Custom data: 20 floats (12 floats for Transform3D, 4 floats for Color, 4 floats of custom data)
+ [/codeblock]
</description>
</method>
<method name="multimesh_set_mesh">
@@ -2320,6 +2433,9 @@
<method name="occluder_create">
<return type="RID" />
<description>
+ Creates an occluder instance and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]occluder_*[/code] RenderingServer functions.
+ Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] method.
+ [b]Note:[/b] The equivalent resource is [Occluder3D] (not to be confused with the [OccluderInstance3D] node).
</description>
</method>
<method name="occluder_set_mesh">
@@ -2328,25 +2444,30 @@
<param index="1" name="vertices" type="PackedVector3Array" />
<param index="2" name="indices" type="PackedInt32Array" />
<description>
+ Sets the mesh data for the given occluder RID, which controls the shape of the occlusion culling that will be performed.
</description>
</method>
<method name="omni_light_create">
<return type="RID" />
<description>
Creates a new omni light and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID can be used in most [code]light_*[/code] RenderingServer functions.
- Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method.
+ Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] method.
To place in a scene, attach this omni light to an instance using [method instance_set_base] using the returned RID.
+ [b]Note:[/b] The equivalent node is [OmniLight3D].
</description>
</method>
<method name="particles_collision_create">
<return type="RID" />
<description>
+ Creates a new 3D GPU particle collision or attractor and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID can be used in most [code]particles_collision_*[/code] RenderingServer functions.
+ [b]Note:[/b] The equivalent nodes are [GPUParticlesCollision3D] and [GPUParticlesAttractor3D].
</description>
</method>
<method name="particles_collision_height_field_update">
<return type="void" />
<param index="0" name="particles_collision" type="RID" />
<description>
+ Requests an update for the 3D GPU particle collision heightfield. This may be automatically called by the 3D GPU particle collision heightfield depending on its [member GPUParticlesCollisionHeightField3D.update_mode].
</description>
</method>
<method name="particles_collision_set_attractor_attenuation">
@@ -2354,6 +2475,7 @@
<param index="0" name="particles_collision" type="RID" />
<param index="1" name="curve" type="float" />
<description>
+ Sets the attenuation [param curve] for the 3D GPU particles attractor specified by the [param particles_collision] RID. Only used for attractors, not colliders. Equivalent to [member GPUParticlesAttractor3D.attenuation].
</description>
</method>
<method name="particles_collision_set_attractor_directionality">
@@ -2361,6 +2483,7 @@
<param index="0" name="particles_collision" type="RID" />
<param index="1" name="amount" type="float" />
<description>
+ Sets the directionality [param amount] for the 3D GPU particles attractor specified by the [param particles_collision] RID. Only used for attractors, not colliders. Equivalent to [member GPUParticlesAttractor3D.directionality].
</description>
</method>
<method name="particles_collision_set_attractor_strength">
@@ -2368,6 +2491,7 @@
<param index="0" name="particles_collision" type="RID" />
<param index="1" name="strength" type="float" />
<description>
+ Sets the [param strength] for the 3D GPU particles attractor specified by the [param particles_collision] RID. Only used for attractors, not colliders. Equivalent to [member GPUParticlesAttractor3D.strength].
</description>
</method>
<method name="particles_collision_set_box_extents">
@@ -2375,6 +2499,7 @@
<param index="0" name="particles_collision" type="RID" />
<param index="1" name="extents" type="Vector3" />
<description>
+ Sets the [param extents] for the 3D GPU particles collision by the [param particles_collision] RID. Equivalent to [member GPUParticlesCollisionBox3D.size], [member GPUParticlesCollisionSDF3D.size], [member GPUParticlesCollisionHeightField3D.size], [member GPUParticlesAttractorBox3D.size] or [member GPUParticlesAttractorVectorField3D.size] depending on the [param particles_collision] type.
</description>
</method>
<method name="particles_collision_set_collision_type">
@@ -2382,6 +2507,7 @@
<param index="0" name="particles_collision" type="RID" />
<param index="1" name="type" type="int" enum="RenderingServer.ParticlesCollisionType" />
<description>
+ Sets the collision or attractor shape [param type] for the 3D GPU particles collision or attractor specified by the [param particles_collision] RID.
</description>
</method>
<method name="particles_collision_set_cull_mask">
@@ -2389,6 +2515,7 @@
<param index="0" name="particles_collision" type="RID" />
<param index="1" name="mask" type="int" />
<description>
+ Sets the cull [param mask] for the 3D GPU particles collision or attractor specified by the [param particles_collision] RID. Equivalent to [member GPUParticlesCollision3D.cull_mask] or [member GPUParticlesAttractor3D.cull_mask] depending on the [param particles_collision] type.
</description>
</method>
<method name="particles_collision_set_field_texture">
@@ -2396,6 +2523,7 @@
<param index="0" name="particles_collision" type="RID" />
<param index="1" name="texture" type="RID" />
<description>
+ Sets the signed distance field [param texture] for the 3D GPU particles collision specified by the [param particles_collision] RID. Equivalent to [member GPUParticlesCollisionSDF3D.texture] or [member GPUParticlesAttractorVectorField3D.texture] depending on the [param particles_collision] type.
</description>
</method>
<method name="particles_collision_set_height_field_resolution">
@@ -2403,6 +2531,7 @@
<param index="0" name="particles_collision" type="RID" />
<param index="1" name="resolution" type="int" enum="RenderingServer.ParticlesCollisionHeightfieldResolution" />
<description>
+ Sets the heightmap [param resolution] for the 3D GPU particles heightfield collision specified by the [param particles_collision] RID. Equivalent to [member GPUParticlesCollisionHeightField3D.resolution].
</description>
</method>
<method name="particles_collision_set_sphere_radius">
@@ -2410,14 +2539,17 @@
<param index="0" name="particles_collision" type="RID" />
<param index="1" name="radius" type="float" />
<description>
+ Sets the [param radius] for the 3D GPU particles sphere collision or attractor specified by the [param particles_collision] RID. Equivalent to [member GPUParticlesCollisionSphere3D.radius] or [member GPUParticlesAttractorSphere3D.radius] depending on the [param particles_collision] type.
</description>
</method>
<method name="particles_create">
<return type="RID" />
<description>
- Creates a particle system and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]particles_*[/code] RenderingServer functions.
- Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method.
+ Creates a GPU-based particle system and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]particles_*[/code] RenderingServer functions.
+ Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] method.
To place in a scene, attach these particles to an instance using [method instance_set_base] using the returned RID.
+ [b]Note:[/b] The equivalent nodes are [GPUParticles2D] and [GPUParticles3D].
+ [b]Note:[/b] All [code]particles_*[/code] methods only apply to GPU-based particles, not CPU-based particles. [CPUParticles2D] and [CPUParticles3D] do not have equivalent RenderingServer functions available, as these use [MultiMeshInstance2D] and [MultiMeshInstance3D] under the hood (see [code]multimesh_*[/code] methods).
</description>
</method>
<method name="particles_emit">
@@ -2429,6 +2561,7 @@
<param index="4" name="custom" type="Color" />
<param index="5" name="emit_flags" type="int" />
<description>
+ Manually emits particles from the [param particles] instance.
</description>
</method>
<method name="particles_get_current_aabb">
@@ -2574,6 +2707,7 @@
<param index="0" name="particles" type="RID" />
<param index="1" name="mode" type="int" enum="RenderingServer.ParticlesMode" />
<description>
+ Sets whether the GPU particles specified by the [param particles] RID should be rendered in 2D or 3D according to [param mode].
</description>
</method>
<method name="particles_set_one_shot">
@@ -2637,6 +2771,7 @@
<param index="1" name="enable" type="bool" />
<param index="2" name="length_sec" type="float" />
<description>
+ If [param enable] is [code]true[/code], enables trails for the [param particles] with the specified [param length_sec] in seconds. Equivalent to [member GPUParticles3D.trail_enabled] and [member GPUParticles3D.trail_lifetime].
</description>
</method>
<method name="particles_set_transform_align">
@@ -2658,14 +2793,16 @@
<return type="void" />
<param index="0" name="quality" type="int" enum="RenderingServer.ShadowQuality" />
<description>
+ Sets the filter quality for omni and spot light shadows in 3D. See also [member ProjectSettings.rendering/lights_and_shadows/positional_shadow/soft_shadow_filter_quality]. This parameter is global and cannot be set on a per-viewport basis.
</description>
</method>
<method name="reflection_probe_create">
<return type="RID" />
<description>
Creates a reflection probe and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]reflection_probe_*[/code] RenderingServer functions.
- Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method.
+ Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] method.
To place in a scene, attach this reflection probe to an instance using [method instance_set_base] using the returned RID.
+ [b]Note:[/b] The equivalent node is [ReflectionProbe].
</description>
</method>
<method name="reflection_probe_set_ambient_color">
@@ -2673,6 +2810,7 @@
<param index="0" name="probe" type="RID" />
<param index="1" name="color" type="Color" />
<description>
+ Sets the reflection probe's custom ambient light color. Equivalent to [member ReflectionProbe.ambient_color].
</description>
</method>
<method name="reflection_probe_set_ambient_energy">
@@ -2680,6 +2818,7 @@
<param index="0" name="probe" type="RID" />
<param index="1" name="energy" type="float" />
<description>
+ Sets the reflection probe's custom ambient light energy. Equivalent to [member ReflectionProbe.ambient_color_energy].
</description>
</method>
<method name="reflection_probe_set_ambient_mode">
@@ -2687,6 +2826,7 @@
<param index="0" name="probe" type="RID" />
<param index="1" name="mode" type="int" enum="RenderingServer.ReflectionProbeAmbientMode" />
<description>
+ Sets the reflection probe's ambient light mode. Equivalent to [member ReflectionProbe.ambient_mode].
</description>
</method>
<method name="reflection_probe_set_as_interior">
@@ -2742,6 +2882,7 @@
<param index="0" name="probe" type="RID" />
<param index="1" name="pixels" type="float" />
<description>
+ Sets the mesh level of detail to use in the reflection probe rendering. Higher values will use less detailed versions of meshes that have LOD variations generated, which can improve performance. Equivalent to [member ReflectionProbe.mesh_lod_threshold].
</description>
</method>
<method name="reflection_probe_set_origin_offset">
@@ -2757,6 +2898,7 @@
<param index="0" name="probe" type="RID" />
<param index="1" name="resolution" type="int" />
<description>
+ Sets the resolution to use when rendering the specified reflection probe. The [param resolution] is specified for each cubemap face: for instance, specifying [code]512[/code] will allocate 6 faces of 512×512 each (plus mipmaps for roughness levels).
</description>
</method>
<method name="reflection_probe_set_size">
@@ -2786,7 +2928,7 @@
<return type="RID" />
<description>
Creates a scenario and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]scenario_*[/code] RenderingServer functions.
- Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method.
+ Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] method.
The scenario is the 3D world that all the visual instances exist in.
</description>
</method>
@@ -2795,6 +2937,7 @@
<param index="0" name="scenario" type="RID" />
<param index="1" name="effects" type="RID" />
<description>
+ Sets the camera attributes ([param effects]) that will be used with this scenario. See also [CameraAttributes].
</description>
</method>
<method name="scenario_set_environment">
@@ -2802,7 +2945,7 @@
<param index="0" name="scenario" type="RID" />
<param index="1" name="environment" type="RID" />
<description>
- Sets the environment that will be used with this scenario.
+ Sets the environment that will be used with this scenario. See also [Environment].
</description>
</method>
<method name="scenario_set_fallback_environment">
@@ -2819,6 +2962,7 @@
<param index="1" name="amount" type="float" />
<param index="2" name="limit" type="float" />
<description>
+ Sets the screen-space roughness limiter parameters, such as whether it should be enabled and its thresholds. Equivalent to [member ProjectSettings.rendering/anti_aliasing/screen_space_roughness_limiter/enabled], [member ProjectSettings.rendering/anti_aliasing/screen_space_roughness_limiter/amount] and [member ProjectSettings.rendering/anti_aliasing/screen_space_roughness_limiter/limit].
</description>
</method>
<method name="set_boot_image">
@@ -2835,28 +2979,29 @@
<return type="void" />
<param index="0" name="generate" type="bool" />
<description>
- If [code]true[/code], the engine will generate wireframes for use with the wireframe debug mode.
+ This method is currently unimplemented and does nothing if called with [param generate] set to [code]true[/code].
</description>
</method>
<method name="set_default_clear_color">
<return type="void" />
<param index="0" name="color" type="Color" />
<description>
- Sets the default clear color which is used when a specific clear color has not been selected.
+ Sets the default clear color which is used when a specific clear color has not been selected. See also [method get_default_clear_color].
</description>
</method>
<method name="shader_create">
<return type="RID" />
<description>
Creates an empty shader and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]shader_*[/code] RenderingServer functions.
- Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method.
+ Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] method.
+ [b]Note:[/b] The equivalent resource is [Shader].
</description>
</method>
<method name="shader_get_code" qualifiers="const">
<return type="String" />
<param index="0" name="shader" type="RID" />
<description>
- Returns a shader's code.
+ Returns a shader's source code as a string.
</description>
</method>
<method name="shader_get_default_texture_parameter" qualifiers="const">
@@ -2874,6 +3019,7 @@
<param index="0" name="shader" type="RID" />
<param index="1" name="name" type="StringName" />
<description>
+ Returns the default value for the specified shader uniform. This is usually the value written in the shader source code.
</description>
</method>
<method name="shader_set_code">
@@ -2881,6 +3027,7 @@
<param index="0" name="shader" type="RID" />
<param index="1" name="code" type="String" />
<description>
+ Sets the shader's source code (which triggers recompilation after being changed).
</description>
</method>
<method name="shader_set_default_texture_parameter">
@@ -2899,6 +3046,7 @@
<param index="0" name="shader" type="RID" />
<param index="1" name="path" type="String" />
<description>
+ Sets the path hint for the specified shader. This should generally match the [Shader] resource's [member Resource.resource_path].
</description>
</method>
<method name="skeleton_allocate_data">
@@ -2947,7 +3095,7 @@
<return type="RID" />
<description>
Creates a skeleton and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]skeleton_*[/code] RenderingServer functions.
- Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method.
+ Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] method.
</description>
</method>
<method name="skeleton_get_bone_count" qualifiers="const">
@@ -2971,13 +3119,16 @@
<param index="2" name="bake_irradiance" type="bool" />
<param index="3" name="size" type="Vector2i" />
<description>
+ Generates and returns an [Image] containing the radiance map for the specified [param sky] RID. This supports built-in sky material and custom sky shaders. If [param bake_irradiance] is [code]true[/code], the irradiance map is saved instead of the radiance map. The radiance map is used to render reflected light, while the irradiance map is used to render ambient light. See also [method environment_bake_panorama].
+ [b]Note:[/b] The image is saved in linear color space without any tonemapping performed, which means it will look too dark if viewed directly in an image editor. [param energy] values above [code]1.0[/code] can be used to brighten the resulting image.
+ [b]Note:[/b] [param size] should be a 2:1 aspect ratio for the generated panorama to have square pixels. For radiance maps, there is no point in using a height greater than [member Sky.radiance_size], as it won't increase detail. Irradiance maps only contain low-frequency data, so there is usually no point in going past a size of 128×64 pixels when saving an irradiance map.
</description>
</method>
<method name="sky_create">
<return type="RID" />
<description>
Creates an empty sky and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]sky_*[/code] RenderingServer functions.
- Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method.
+ Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] method.
</description>
</method>
<method name="sky_set_material">
@@ -2985,7 +3136,7 @@
<param index="0" name="sky" type="RID" />
<param index="1" name="material" type="RID" />
<description>
- Sets the material that the sky uses to render the background and reflection maps.
+ Sets the material that the sky uses to render the background, ambient and reflection maps.
</description>
</method>
<method name="sky_set_mode">
@@ -2993,6 +3144,7 @@
<param index="0" name="sky" type="RID" />
<param index="1" name="mode" type="int" enum="RenderingServer.SkyMode" />
<description>
+ Sets the process [param mode] of the sky specified by the [param sky] RID. Equivalent to [member Sky.process_mode].
</description>
</method>
<method name="sky_set_radiance_size">
@@ -3000,13 +3152,14 @@
<param index="0" name="sky" type="RID" />
<param index="1" name="radiance_size" type="int" />
<description>
+ Sets the [param radiance_size] of the sky specified by the [param sky] RID (in pixels). Equivalent to [member Sky.radiance_size].
</description>
</method>
<method name="spot_light_create">
<return type="RID" />
<description>
Creates a spot light and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID can be used in most [code]light_*[/code] RenderingServer functions.
- Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method.
+ Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] method.
To place in a scene, attach this spot light to an instance using [method instance_set_base] using the returned RID.
</description>
</method>
@@ -3014,6 +3167,7 @@
<return type="void" />
<param index="0" name="quality" type="int" enum="RenderingServer.SubSurfaceScatteringQuality" />
<description>
+ Sets [member ProjectSettings.rendering/environment/subsurface_scattering/subsurface_scattering_quality] to use when rendering materials that have subsurface scattering enabled.
</description>
</method>
<method name="sub_surface_scattering_set_scale">
@@ -3021,18 +3175,30 @@
<param index="0" name="scale" type="float" />
<param index="1" name="depth_scale" type="float" />
<description>
+ Sets the [member ProjectSettings.rendering/environment/subsurface_scattering/subsurface_scattering_scale] and [member ProjectSettings.rendering/environment/subsurface_scattering/subsurface_scattering_depth_scale] to use when rendering materials that have subsurface scattering enabled.
</description>
</method>
<method name="texture_2d_create">
<return type="RID" />
<param index="0" name="image" type="Image" />
<description>
+ Creates a 2-dimensional texture and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]texture_2d_*[/code] RenderingServer functions.
+ Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] method.
+ [b]Note:[/b] The equivalent resource is [Texture2D].
+ [b]Note:[/b] Not to be confused with [method RenderingDevice.texture_create], which creates the graphics API's own texture type as opposed to the Godot-specific [Texture2D] resource.
</description>
</method>
<method name="texture_2d_get" qualifiers="const">
<return type="Image" />
<param index="0" name="texture" type="RID" />
<description>
+ Returns an [Image] instance from the given [param texture] [RID].
+ Example of getting the test texture from [method get_test_texture] and applying it to a [Sprite2D] node:
+ [codeblock]
+ var texture_rid = RenderingServer.get_test_texture()
+ var texture = ImageTexture.create_from_image(RenderingServer.texture_2d_get(texture_rid))
+ $Sprite2D.texture = texture
+ [/codeblock]
</description>
</method>
<method name="texture_2d_layer_get" qualifiers="const">
@@ -3040,6 +3206,7 @@
<param index="0" name="texture" type="RID" />
<param index="1" name="layer" type="int" />
<description>
+ Returns an [Image] instance from the given [param texture] [RID] and [param layer].
</description>
</method>
<method name="texture_2d_layered_create">
@@ -3047,17 +3214,25 @@
<param index="0" name="layers" type="Image[]" />
<param index="1" name="layered_type" type="int" enum="RenderingServer.TextureLayeredType" />
<description>
+ Creates a 2-dimensional layered texture and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]texture_2d_layered_*[/code] RenderingServer functions.
+ Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] method.
+ [b]Note:[/b] The equivalent resource is [TextureLayered].
</description>
</method>
<method name="texture_2d_layered_placeholder_create">
<return type="RID" />
<param index="0" name="layered_type" type="int" enum="RenderingServer.TextureLayeredType" />
<description>
+ Creates a placeholder for a 2-dimensional layered texture and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]texture_2d_layered_*[/code] RenderingServer functions, although it does nothing when used. See also [method texture_2d_placeholder_create].
+ [b]Note:[/b] The equivalent resource is [PlaceholderTextureLayered].
</description>
</method>
<method name="texture_2d_placeholder_create">
<return type="RID" />
<description>
+ Creates a placeholder for a 2-dimensional layered texture and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]texture_2d_layered_*[/code] RenderingServer functions, although it does nothing when used. See also [method texture_2d_layered_placeholder_create]
+ Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] method.
+ [b]Note:[/b] The equivalent resource is [PlaceholderTexture2D].
</description>
</method>
<method name="texture_2d_update">
@@ -3066,6 +3241,8 @@
<param index="1" name="image" type="Image" />
<param index="2" name="layer" type="int" />
<description>
+ Updates the texture specified by the [param texture] [RID] with the data in [param image]. A [param layer] must also be specified, which should be [code]0[/code] when updating a single-layer texture ([Texture2D]).
+ [b]Note:[/b] The [param image] must have the same width, height and format as the current [param texture] data. Otherwise, an error will be printed and the original texture won't be modified. If you need to use different width, height or format, use [method texture_replace] instead.
</description>
</method>
<method name="texture_3d_create">
@@ -3077,17 +3254,22 @@
<param index="4" name="mipmaps" type="bool" />
<param index="5" name="data" type="Image[]" />
<description>
+ [b]Note:[/b] The equivalent resource is [Texture3D].
</description>
</method>
<method name="texture_3d_get" qualifiers="const">
<return type="Image[]" />
<param index="0" name="texture" type="RID" />
<description>
+ Returns 3D texture data as an array of [Image]s for the specified texture [RID].
</description>
</method>
<method name="texture_3d_placeholder_create">
<return type="RID" />
<description>
+ Creates a placeholder for a 3-dimensional texture and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]texture_3d_*[/code] RenderingServer functions, although it does nothing when used.
+ Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] method.
+ [b]Note:[/b] The equivalent resource is [PlaceholderTexture3D].
</description>
</method>
<method name="texture_3d_update">
@@ -3095,6 +3277,8 @@
<param index="0" name="texture" type="RID" />
<param index="1" name="data" type="Image[]" />
<description>
+ Updates the texture specified by the [param texture] [RID]'s data with the data in [param data]. All the texture's layers must be replaced at once.
+ [b]Note:[/b] The [param texture] must have the same width, height, depth and format as the current texture data. Otherwise, an error will be printed and the original texture won't be modified. If you need to use different width, height, depth or format, use [method texture_replace] instead.
</description>
</method>
<method name="texture_get_path" qualifiers="const">
@@ -3115,6 +3299,7 @@
<return type="RID" />
<param index="0" name="base" type="RID" />
<description>
+ [i]Deprecated.[/i] As ProxyTexture was removed in Godot 4, this method does nothing when called and always returns a null [RID].
</description>
</method>
<method name="texture_proxy_update">
@@ -3122,6 +3307,7 @@
<param index="0" name="texture" type="RID" />
<param index="1" name="proxy_to" type="RID" />
<description>
+ [i]Deprecated.[/i] ProxyTexture was removed in Godot 4, so this method cannot be used anymore.
</description>
</method>
<method name="texture_replace">
@@ -3129,6 +3315,7 @@
<param index="0" name="texture" type="RID" />
<param index="1" name="by_texture" type="RID" />
<description>
+ Replaces [param texture]'s texture data by the texture specified by the [param by_texture] RID, without changing [param texture]'s RID.
</description>
</method>
<method name="texture_set_force_redraw_if_visible">
@@ -3192,19 +3379,25 @@
<return type="RID" />
<description>
Creates an empty viewport and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]viewport_*[/code] RenderingServer functions.
- Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method.
+ Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] method.
+ [b]Note:[/b] The equivalent node is [Viewport].
</description>
</method>
<method name="viewport_get_measured_render_time_cpu" qualifiers="const">
<return type="float" />
<param index="0" name="viewport" type="RID" />
<description>
+ Returns the CPU time taken to render the last frame in milliseconds. This [i]only[/i] includes time spent in rendering-related operations; scripts' [code]_process[/code] functions and other engine subsystems are not included in this readout. To get a complete readout of CPU time spent to render the scene, sum the render times of all viewports that are drawn every frame plus [method get_frame_setup_time_cpu]. Unlike [method Engine.get_frames_per_second], this method will accurately reflect CPU utilization even if framerate is capped via V-Sync or [member Engine.max_fps]. See also [method viewport_get_measured_render_time_gpu].
+ [b]Note:[/b] Requires measurements to be enabled on the specified [param viewport] using [method viewport_set_measure_render_time]. Otherwise, this method returns [code]0.0[/code].
</description>
</method>
<method name="viewport_get_measured_render_time_gpu" qualifiers="const">
<return type="float" />
<param index="0" name="viewport" type="RID" />
<description>
+ Returns the GPU time taken to render the last frame in milliseconds. To get a complete readout of GPU time spent to render the scene, sum the render times of all viewports that are drawn every frame. Unlike [method Engine.get_frames_per_second], this method accurately reflects GPU utilization even if framerate is capped via V-Sync or [member Engine.max_fps]. See also [method viewport_get_measured_render_time_gpu].
+ [b]Note:[/b] Requires measurements to be enabled on the specified [param viewport] using [method viewport_set_measure_render_time]. Otherwise, this method returns [code]0.0[/code].
+ [b]Note:[/b] When GPU utilization is low enough during a certain period of time, GPUs will decrease their power state (which in turn decreases core and memory clock speeds). This can cause the reported GPU time to increase if GPU utilization is kept low enough by a framerate cap (compared to what it would be at the GPU's highest power state). Keep this in mind when benchmarking using [method viewport_get_measured_render_time_gpu]. This behavior can be overridden in the graphics driver settings at the cost of higher power usage.
</description>
</method>
<method name="viewport_get_render_info">
@@ -3213,6 +3406,27 @@
<param index="1" name="type" type="int" enum="RenderingServer.ViewportRenderInfoType" />
<param index="2" name="info" type="int" enum="RenderingServer.ViewportRenderInfo" />
<description>
+ Returns a statistic about the rendering engine which can be used for performance profiling. This is separated into render pass [param type]s, each of them having the same [param info]s you can query (different passes will return different values). See [enum RenderingServer.ViewportRenderInfoType] for a list of render pass types and [enum RenderingServer.ViewportRenderInfo] for a list of information that can be queried.
+ See also [method get_rendering_info], which returns global information across all viewports.
+ [b]Note:[/b] Viewport rendering information is not available until at least 2 frames have been rendered by the engine. If rendering information is not available, [method viewport_get_render_info] returns [code]0[/code]. To print rendering information in [code]_ready()[/code] successfully, use the following:
+ [codeblock]
+ func _ready():
+ for _i in 2:
+ await get_tree().process_frame
+
+ print(
+ RenderingServer.viewport_get_render_info(get_viewport().get_viewport_rid(),
+ RenderingServer.VIEWPORT_RENDER_INFO_TYPE_VISIBLE,
+ RenderingServer.VIEWPORT_RENDER_INFO_DRAW_CALLS_IN_FRAME)
+ )
+ [/codeblock]
+ </description>
+ </method>
+ <method name="viewport_get_render_target" qualifiers="const">
+ <return type="RID" />
+ <param index="0" name="viewport" type="RID" />
+ <description>
+ Returns the render target for the viewport.
</description>
</method>
<method name="viewport_get_texture" qualifiers="const">
@@ -3287,6 +3501,7 @@
<param index="0" name="viewport" type="RID" />
<param index="1" name="filter" type="int" enum="RenderingServer.CanvasItemTextureFilter" />
<description>
+ Sets the default texture filtering mode for the specified [param viewport] RID. See [enum CanvasItemTextureFilter] for options.
</description>
</method>
<method name="viewport_set_default_canvas_item_texture_repeat">
@@ -3294,6 +3509,7 @@
<param index="0" name="viewport" type="RID" />
<param index="1" name="repeat" type="int" enum="RenderingServer.CanvasItemTextureRepeat" />
<description>
+ Sets the default texture repeat mode for the specified [param viewport] RID. See [enum CanvasItemTextureRepeat] for options.
</description>
</method>
<method name="viewport_set_disable_2d">
@@ -3301,7 +3517,7 @@
<param index="0" name="viewport" type="RID" />
<param index="1" name="disable" type="bool" />
<description>
- If [code]true[/code], the viewport's canvas is not rendered.
+ If [code]true[/code], the viewport's canvas (i.e. 2D and GUI elements) is not rendered.
</description>
</method>
<method name="viewport_set_disable_3d">
@@ -3309,6 +3525,7 @@
<param index="0" name="viewport" type="RID" />
<param index="1" name="disable" type="bool" />
<description>
+ If [code]true[/code], the viewport's 3D elements are not rendered.
</description>
</method>
<method name="viewport_set_environment_mode">
@@ -3340,6 +3557,7 @@
<param index="0" name="viewport" type="RID" />
<param index="1" name="enable" type="bool" />
<description>
+ Sets the measurement for the given [param viewport] RID (obtained using [method Viewport.get_viewport_rid]). Once enabled, [method viewport_get_measured_render_time_cpu] and [method viewport_get_measured_render_time_gpu] will return values greater than [code]0.0[/code] when queried with the given [param viewport].
</description>
</method>
<method name="viewport_set_msaa_2d">
@@ -3347,7 +3565,7 @@
<param index="0" name="viewport" type="RID" />
<param index="1" name="msaa" type="int" enum="RenderingServer.ViewportMSAA" />
<description>
- Sets the multisample anti-aliasing mode for 2D/Canvas. See [enum ViewportMSAA] for options.
+ Sets the multisample anti-aliasing mode for 2D/Canvas on the specified [param viewport] RID. See [enum ViewportMSAA] for options.
</description>
</method>
<method name="viewport_set_msaa_3d">
@@ -3355,19 +3573,21 @@
<param index="0" name="viewport" type="RID" />
<param index="1" name="msaa" type="int" enum="RenderingServer.ViewportMSAA" />
<description>
- Sets the multisample anti-aliasing mode for 3D. See [enum ViewportMSAA] for options.
+ Sets the multisample anti-aliasing mode for 3D on the specified [param viewport] RID. See [enum ViewportMSAA] for options.
</description>
</method>
<method name="viewport_set_occlusion_culling_build_quality">
<return type="void" />
<param index="0" name="quality" type="int" enum="RenderingServer.ViewportOcclusionCullingBuildQuality" />
<description>
+ Sets the [member ProjectSettings.rendering/occlusion_culling/bvh_build_quality] to use for occlusion culling. This parameter is global and cannot be set on a per-viewport basis.
</description>
</method>
<method name="viewport_set_occlusion_rays_per_thread">
<return type="void" />
<param index="0" name="rays_per_thread" type="int" />
<description>
+ Sets the [member ProjectSettings.rendering/occlusion_culling/occlusion_rays_per_thread] to use for occlusion culling. This parameter is global and cannot be set on a per-viewport basis.
</description>
</method>
<method name="viewport_set_parent_viewport">
@@ -3375,7 +3595,7 @@
<param index="0" name="viewport" type="RID" />
<param index="1" name="parent_viewport" type="RID" />
<description>
- Sets the viewport's parent to another viewport.
+ Sets the viewport's parent to the viewport specified by the [param parent_viewport] RID.
</description>
</method>
<method name="viewport_set_positional_shadow_atlas_quadrant_subdivision">
@@ -3384,7 +3604,7 @@
<param index="1" name="quadrant" type="int" />
<param index="2" name="subdivision" type="int" />
<description>
- Sets the shadow atlas quadrant's subdivision.
+ Sets the number of subdivisions to use in the specified shadow atlas [param quadrant] for omni and spot shadows. See also [method Viewport.set_positional_shadow_atlas_quadrant_subdiv].
</description>
</method>
<method name="viewport_set_positional_shadow_atlas_size">
@@ -3393,8 +3613,8 @@
<param index="1" name="size" type="int" />
<param index="2" name="use_16_bits" type="bool" default="false" />
<description>
- Sets the size of the shadow atlas's images (used for omni and spot lights). The value will be rounded up to the nearest power of 2.
- [b]Note:[/b] If this is set to [code]0[/code], no shadows will be visible at all (including directional shadows).
+ Sets the [param size] of the shadow atlas's images (used for omni and spot lights) on the viewport specified by the [param viewport] RID. The value is rounded up to the nearest power of 2. If [code]use_16_bits[/code] is [code]true[/code], use 16 bits for the omni/spot shadow depth map. Enabling this results in shadows having less precision and may result in shadow acne, but can lead to performance improvements on some devices.
+ [b]Note:[/b] If this is set to [code]0[/code], no positional shadows will be visible at all. This can improve performance significantly on low-end systems by reducing both the CPU and GPU load (as fewer draw calls are needed to draw the scene without shadows).
</description>
</method>
<method name="viewport_set_render_direct_to_screen">
@@ -3410,7 +3630,7 @@
<param index="0" name="viewport" type="RID" />
<param index="1" name="scaling_3d_mode" type="int" enum="RenderingServer.ViewportScaling3DMode" />
<description>
- Sets scaling 3d mode. Bilinear scaling renders at different resolution to either undersample or supersample the viewport. FidelityFX Super Resolution 1.0, abbreviated to FSR, is an upscaling technology that produces high quality images at fast framerates by using a spatially aware upscaling algorithm. FSR is slightly more expensive than bilinear, but it produces significantly higher image quality. FSR should be used where possible.
+ Sets the 3D resolution scaling mode. Bilinear scaling renders at different resolution to either undersample or supersample the viewport. FidelityFX Super Resolution 1.0, abbreviated to FSR, is an upscaling technology that produces high quality images at fast framerates by using a spatially aware upscaling algorithm. FSR is slightly more expensive than bilinear, but it produces significantly higher image quality. FSR should be used where possible.
</description>
</method>
<method name="viewport_set_scaling_3d_scale">
@@ -3427,8 +3647,7 @@
<param index="0" name="viewport" type="RID" />
<param index="1" name="scenario" type="RID" />
<description>
- Sets a viewport's scenario.
- The scenario contains information about environment information, reflection atlas etc.
+ Sets a viewport's scenario. The scenario contains information about environment information, reflection atlas, etc.
</description>
</method>
<method name="viewport_set_screen_space_aa">
@@ -3436,6 +3655,7 @@
<param index="0" name="viewport" type="RID" />
<param index="1" name="mode" type="int" enum="RenderingServer.ViewportScreenSpaceAA" />
<description>
+ Sets the viewport's screen-space antialiasing mode.
</description>
</method>
<method name="viewport_set_sdf_oversize_and_scale">
@@ -3444,6 +3664,7 @@
<param index="1" name="oversize" type="int" enum="RenderingServer.ViewportSDFOversize" />
<param index="2" name="scale" type="int" enum="RenderingServer.ViewportSDFScale" />
<description>
+ Sets the viewport's 2D signed distance field [member ProjectSettings.rendering/2d/sdf/oversize] and [member ProjectSettings.rendering/2d/sdf/scale]. This is used when sampling the signed distance field in [CanvasItem] shaders as well as [GPUParticles2D] collision. This is [i]not[/i] used by SDFGI in 3D rendering.
</description>
</method>
<method name="viewport_set_size">
@@ -3452,7 +3673,7 @@
<param index="1" name="width" type="int" />
<param index="2" name="height" type="int" />
<description>
- Sets the viewport's width and height.
+ Sets the viewport's width and height in pixels.
</description>
</method>
<method name="viewport_set_snap_2d_transforms_to_pixel">
@@ -3460,6 +3681,7 @@
<param index="0" name="viewport" type="RID" />
<param index="1" name="enabled" type="bool" />
<description>
+ If [code]true[/code], canvas item transforms (i.e. origin position) are snapped to the nearest pixel when rendering. This can lead to a crisper appearance at the cost of less smooth movement, especially when [Camera2D] smoothing is enabled. Equivalent to [member ProjectSettings.rendering/2d/snap/snap_2d_transforms_to_pixel].
</description>
</method>
<method name="viewport_set_snap_2d_vertices_to_pixel">
@@ -3467,6 +3689,7 @@
<param index="0" name="viewport" type="RID" />
<param index="1" name="enabled" type="bool" />
<description>
+ If [code]true[/code], canvas item vertices (i.e. polygon points) are snapped to the nearest pixel when rendering. This can lead to a crisper appearance at the cost of less smooth movement, especially when [Camera2D] smoothing is enabled. Equivalent to [member ProjectSettings.rendering/2d/snap/snap_2d_vertices_to_pixel].
</description>
</method>
<method name="viewport_set_texture_mipmap_bias">
@@ -3499,6 +3722,7 @@
<param index="0" name="viewport" type="RID" />
<param index="1" name="enable" type="bool" />
<description>
+ If [code]true[/code], enables debanding on the specified viewport. Equivalent to [member ProjectSettings.rendering/anti_aliasing/quality/use_debanding].
</description>
</method>
<method name="viewport_set_use_occlusion_culling">
@@ -3506,6 +3730,7 @@
<param index="0" name="viewport" type="RID" />
<param index="1" name="enable" type="bool" />
<description>
+ If [code]true[/code], enables occlusion culling on the specified viewport. Equivalent to [member ProjectSettings.rendering/occlusion_culling/use_occlusion_culling].
</description>
</method>
<method name="viewport_set_use_taa">
@@ -3513,7 +3738,7 @@
<param index="0" name="viewport" type="RID" />
<param index="1" name="enable" type="bool" />
<description>
- If [code]true[/code], use Temporal Anti-Aliasing.
+ If [code]true[/code], use Temporal Anti-Aliasing. Equivalent to [member ProjectSettings.rendering/anti_aliasing/quality/use_taa].
</description>
</method>
<method name="viewport_set_use_xr">
@@ -3529,7 +3754,7 @@
<param index="0" name="viewport" type="RID" />
<param index="1" name="mode" type="int" enum="RenderingServer.ViewportVRSMode" />
<description>
- Sets the Variable Rate Shading (VRS) mode for the viewport. Note, if hardware does not support VRS this property is ignored.
+ Sets the Variable Rate Shading (VRS) mode for the viewport. If the GPU does not support VRS, this property is ignored. Equivalent to [member ProjectSettings.rendering/vrs/mode].
</description>
</method>
<method name="viewport_set_vrs_texture">
@@ -3537,12 +3762,16 @@
<param index="0" name="viewport" type="RID" />
<param index="1" name="texture" type="RID" />
<description>
- Texture to use when the VRS mode is set to [constant RenderingServer.VIEWPORT_VRS_TEXTURE].
+ The texture to use when the VRS mode is set to [constant RenderingServer.VIEWPORT_VRS_TEXTURE]. Equivalent to [member ProjectSettings.rendering/vrs/texture].
</description>
</method>
<method name="visibility_notifier_create">
<return type="RID" />
<description>
+ Creates a new 3D visibility notifier object and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]visibility_notifier_*[/code] RenderingServer functions.
+ Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] method.
+ To place in a scene, attach this mesh to an instance using [method instance_set_base] using the returned RID.
+ [b]Note:[/b] The equivalent node is [VisibleOnScreenNotifier3D].
</description>
</method>
<method name="visibility_notifier_set_aabb">
@@ -3576,6 +3805,9 @@
<method name="voxel_gi_create">
<return type="RID" />
<description>
+ Creates a new voxel-based global illumination object and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]voxel_gi_*[/code] RenderingServer functions.
+ Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] method.
+ [b]Note:[/b] The equivalent node is [VoxelGI].
</description>
</method>
<method name="voxel_gi_get_data_cells" qualifiers="const">
@@ -3627,6 +3859,7 @@
<param index="0" name="voxel_gi" type="RID" />
<param index="1" name="bias" type="float" />
<description>
+ Sets the [member VoxelGIData.bias] value to use on the specified [param voxel_gi]'s [RID].
</description>
</method>
<method name="voxel_gi_set_dynamic_range">
@@ -3634,6 +3867,7 @@
<param index="0" name="voxel_gi" type="RID" />
<param index="1" name="range" type="float" />
<description>
+ Sets the [member VoxelGIData.dynamic_range] value to use on the specified [param voxel_gi]'s [RID].
</description>
</method>
<method name="voxel_gi_set_energy">
@@ -3641,6 +3875,7 @@
<param index="0" name="voxel_gi" type="RID" />
<param index="1" name="energy" type="float" />
<description>
+ Sets the [member VoxelGIData.energy] value to use on the specified [param voxel_gi]'s [RID].
</description>
</method>
<method name="voxel_gi_set_interior">
@@ -3648,6 +3883,7 @@
<param index="0" name="voxel_gi" type="RID" />
<param index="1" name="enable" type="bool" />
<description>
+ Sets the [member VoxelGIData.interior] value to use on the specified [param voxel_gi]'s [RID].
</description>
</method>
<method name="voxel_gi_set_normal_bias">
@@ -3655,6 +3891,7 @@
<param index="0" name="voxel_gi" type="RID" />
<param index="1" name="bias" type="float" />
<description>
+ Sets the [member VoxelGIData.normal_bias] value to use on the specified [param voxel_gi]'s [RID].
</description>
</method>
<method name="voxel_gi_set_propagation">
@@ -3662,12 +3899,14 @@
<param index="0" name="voxel_gi" type="RID" />
<param index="1" name="amount" type="float" />
<description>
+ Sets the [member VoxelGIData.propagation] value to use on the specified [param voxel_gi]'s [RID].
</description>
</method>
<method name="voxel_gi_set_quality">
<return type="void" />
<param index="0" name="quality" type="int" enum="RenderingServer.VoxelGIQuality" />
<description>
+ Sets the [member ProjectSettings.rendering/global_illumination/voxel_gi/quality] value to use when rendering. This parameter is global and cannot be set on a per-VoxelGI basis.
</description>
</method>
<method name="voxel_gi_set_use_two_bounces">
@@ -3675,6 +3914,7 @@
<param index="0" name="voxel_gi" type="RID" />
<param index="1" name="enable" type="bool" />
<description>
+ Sets the [member VoxelGIData.use_two_bounces] value to use on the specified [param voxel_gi]'s [RID].
</description>
</method>
</methods>
@@ -3709,30 +3949,40 @@
The maximum Z-layer for canvas items.
</constant>
<constant name="MAX_GLOW_LEVELS" value="7">
- Max number of glow levels that can be used with glow post-process effect.
+ The maximum number of glow levels that can be used with the glow post-processing effect.
</constant>
<constant name="MAX_CURSORS" value="8">
- Unused enum in Godot 3.x.
+ [i]Deprecated.[/i] This constant is unused.
</constant>
<constant name="MAX_2D_DIRECTIONAL_LIGHTS" value="8">
+ The maximum number of directional lights that can be rendered at a given time in 2D.
</constant>
<constant name="TEXTURE_LAYERED_2D_ARRAY" value="0" enum="TextureLayeredType">
+ Array of 2-dimensional textures (see [Texture2DArray]).
</constant>
<constant name="TEXTURE_LAYERED_CUBEMAP" value="1" enum="TextureLayeredType">
+ Cubemap texture (see [Cubemap]).
</constant>
<constant name="TEXTURE_LAYERED_CUBEMAP_ARRAY" value="2" enum="TextureLayeredType">
+ Array of cubemap textures (see [CubemapArray]).
</constant>
<constant name="CUBEMAP_LAYER_LEFT" value="0" enum="CubeMapLayer">
+ Left face of a [Cubemap].
</constant>
<constant name="CUBEMAP_LAYER_RIGHT" value="1" enum="CubeMapLayer">
+ Right face of a [Cubemap].
</constant>
<constant name="CUBEMAP_LAYER_BOTTOM" value="2" enum="CubeMapLayer">
+ Bottom face of a [Cubemap].
</constant>
<constant name="CUBEMAP_LAYER_TOP" value="3" enum="CubeMapLayer">
+ Top face of a [Cubemap].
</constant>
<constant name="CUBEMAP_LAYER_FRONT" value="4" enum="CubeMapLayer">
+ Front face of a [Cubemap].
</constant>
<constant name="CUBEMAP_LAYER_BACK" value="5" enum="CubeMapLayer">
+ Back face of a [Cubemap].
</constant>
<constant name="SHADER_SPATIAL" value="0" enum="ShaderMode">
Shader is a 3D shader.
@@ -3741,13 +3991,13 @@
Shader is a 2D shader.
</constant>
<constant name="SHADER_PARTICLES" value="2" enum="ShaderMode">
- Shader is a particle shader.
+ Shader is a particle shader (can be used in both 2D and 3D).
</constant>
<constant name="SHADER_SKY" value="3" enum="ShaderMode">
- Shader is a sky shader.
+ Shader is a 3D sky shader.
</constant>
<constant name="SHADER_FOG" value="4" enum="ShaderMode">
- Shader is a fog shader.
+ Shader is a 3D fog shader.
</constant>
<constant name="SHADER_MAX" value="5" enum="ShaderMode">
Represents the size of the [enum ShaderMode] enum.
@@ -3759,7 +4009,7 @@
The maximum renderpriority of all materials.
</constant>
<constant name="ARRAY_VERTEX" value="0" enum="ArrayType">
- Array is a vertex array.
+ Array is a vertex position array.
</constant>
<constant name="ARRAY_NORMAL" value="1" enum="ArrayType">
Array is a normal array.
@@ -3768,21 +4018,25 @@
Array is a tangent array.
</constant>
<constant name="ARRAY_COLOR" value="3" enum="ArrayType">
- Array is a color array.
+ Array is a vertex color array.
</constant>
<constant name="ARRAY_TEX_UV" value="4" enum="ArrayType">
Array is an UV coordinates array.
</constant>
<constant name="ARRAY_TEX_UV2" value="5" enum="ArrayType">
- Array is an UV coordinates array for the second UV coordinates.
+ Array is an UV coordinates array for the second set of UV coordinates.
</constant>
<constant name="ARRAY_CUSTOM0" value="6" enum="ArrayType">
+ Array is a custom data array for the first set of custom data.
</constant>
<constant name="ARRAY_CUSTOM1" value="7" enum="ArrayType">
+ Array is a custom data array for the second set of custom data.
</constant>
<constant name="ARRAY_CUSTOM2" value="8" enum="ArrayType">
+ Array is a custom data array for the third set of custom data.
</constant>
<constant name="ARRAY_CUSTOM3" value="9" enum="ArrayType">
+ Array is a custom data array for the fourth set of custom data.
</constant>
<constant name="ARRAY_BONES" value="10" enum="ArrayType">
Array contains bone information.
@@ -3791,33 +4045,43 @@
Array is weight information.
</constant>
<constant name="ARRAY_INDEX" value="12" enum="ArrayType">
- Array is index array.
+ Array is an index array.
</constant>
<constant name="ARRAY_MAX" value="13" enum="ArrayType">
Represents the size of the [enum ArrayType] enum.
</constant>
<constant name="ARRAY_CUSTOM_COUNT" value="4">
+ The number of custom data arrays available ([constant ARRAY_CUSTOM0], [constant ARRAY_CUSTOM1], [constant ARRAY_CUSTOM2], [constant ARRAY_CUSTOM3]).
</constant>
<constant name="ARRAY_CUSTOM_RGBA8_UNORM" value="0" enum="ArrayCustomFormat">
+ Custom data array contains 8-bit-per-channel red/green/blue/alpha color data. Values are normalized, unsigned floating-point in the [code][0.0, 1.0][/code] range.
</constant>
<constant name="ARRAY_CUSTOM_RGBA8_SNORM" value="1" enum="ArrayCustomFormat">
+ Custom data array contains 8-bit-per-channel red/green/blue/alpha color data. Values are normalized, signed floating-point in the [code][-1.0, 1.0][/code] range.
</constant>
<constant name="ARRAY_CUSTOM_RG_HALF" value="2" enum="ArrayCustomFormat">
+ Custom data array contains 16-bit-per-channel red/green color data. Values are floating-point in half precision.
</constant>
<constant name="ARRAY_CUSTOM_RGBA_HALF" value="3" enum="ArrayCustomFormat">
+ Custom data array contains 16-bit-per-channel red/green/blue/alpha color data. Values are floating-point in half precision.
</constant>
<constant name="ARRAY_CUSTOM_R_FLOAT" value="4" enum="ArrayCustomFormat">
+ Custom data array contains 32-bit-per-channel red color data. Values are floating-point in single precision.
</constant>
<constant name="ARRAY_CUSTOM_RG_FLOAT" value="5" enum="ArrayCustomFormat">
+ Custom data array contains 32-bit-per-channel red/green color data. Values are floating-point in single precision.
</constant>
<constant name="ARRAY_CUSTOM_RGB_FLOAT" value="6" enum="ArrayCustomFormat">
+ Custom data array contains 32-bit-per-channel red/green/blue color data. Values are floating-point in single precision.
</constant>
<constant name="ARRAY_CUSTOM_RGBA_FLOAT" value="7" enum="ArrayCustomFormat">
+ Custom data array contains 32-bit-per-channel red/green/blue/alpha color data. Values are floating-point in single precision.
</constant>
<constant name="ARRAY_CUSTOM_MAX" value="8" enum="ArrayCustomFormat">
+ Represents the size of the [enum ArrayCustomFormat] enum.
</constant>
<constant name="ARRAY_FORMAT_VERTEX" value="1" enum="ArrayFormat" is_bitfield="true">
- Flag used to mark a vertex array.
+ Flag used to mark a vertex position array.
</constant>
<constant name="ARRAY_FORMAT_NORMAL" value="2" enum="ArrayFormat" is_bitfield="true">
Flag used to mark a normal array.
@@ -3826,7 +4090,7 @@
Flag used to mark a tangent array.
</constant>
<constant name="ARRAY_FORMAT_COLOR" value="8" enum="ArrayFormat" is_bitfield="true">
- Flag used to mark a color array.
+ Flag used to mark a vertex color array.
</constant>
<constant name="ARRAY_FORMAT_TEX_UV" value="16" enum="ArrayFormat" is_bitfield="true">
Flag used to mark an UV coordinates array.
@@ -3835,12 +4099,16 @@
Flag used to mark an UV coordinates array for the second UV coordinates.
</constant>
<constant name="ARRAY_FORMAT_CUSTOM0" value="64" enum="ArrayFormat" is_bitfield="true">
+ Flag used to mark an array of custom per-vertex data for the first set of custom data.
</constant>
<constant name="ARRAY_FORMAT_CUSTOM1" value="128" enum="ArrayFormat" is_bitfield="true">
+ Flag used to mark an array of custom per-vertex data for the second set of custom data.
</constant>
<constant name="ARRAY_FORMAT_CUSTOM2" value="256" enum="ArrayFormat" is_bitfield="true">
+ Flag used to mark an array of custom per-vertex data for the third set of custom data.
</constant>
<constant name="ARRAY_FORMAT_CUSTOM3" value="512" enum="ArrayFormat" is_bitfield="true">
+ Flag used to mark an array of custom per-vertex data for the fourth set of custom data.
</constant>
<constant name="ARRAY_FORMAT_BONES" value="1024" enum="ArrayFormat" is_bitfield="true">
Flag used to mark a bone information array.
@@ -3875,6 +4143,7 @@
<constant name="ARRAY_FLAG_USE_DYNAMIC_UPDATE" value="67108864" enum="ArrayFormat" is_bitfield="true">
</constant>
<constant name="ARRAY_FLAG_USE_8_BONE_WEIGHTS" value="134217728" enum="ArrayFormat" is_bitfield="true">
+ Flag used to mark that the array uses 8 bone weighs instead of 4.
</constant>
<constant name="ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY" value="268435456" enum="ArrayFormat" is_bitfield="true">
</constant>
@@ -3927,13 +4196,13 @@
Linear filter for light projectors (use for non-pixel art light projectors). Anisotropic mipmaps are used for rendering, which means light projectors at a distance will look smooth and sharp when viewed from oblique angles. This looks better compared to isotropic mipmaps, but is slower. The level of anisotropic filtering is defined by [member ProjectSettings.rendering/textures/default_filters/anisotropic_filtering_level].
</constant>
<constant name="LIGHT_DIRECTIONAL" value="0" enum="LightType">
- Is a directional (sun) light.
+ Directional (sun/moon) light (see [DirectionalLight3D]).
</constant>
<constant name="LIGHT_OMNI" value="1" enum="LightType">
- Is an omni light.
+ Omni light (see [OmniLight3D]).
</constant>
<constant name="LIGHT_SPOT" value="2" enum="LightType">
- Is a spot light.
+ Spot light (see [SpotLight3D]).
</constant>
<constant name="LIGHT_PARAM_ENERGY" value="0" enum="LightParam">
The light's energy multiplier.
@@ -3963,7 +4232,7 @@
The spotlight's attenuation.
</constant>
<constant name="LIGHT_PARAM_SHADOW_MAX_DISTANCE" value="9" enum="LightParam">
- Max distance that shadows will be rendered.
+ The maximum distance for shadow splits. Increasing this value will make directional shadows visible from further away, at the cost of lower overall shadow detail and performance (since more objects need to be included in the directional shadow rendering).
</constant>
<constant name="LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET" value="10" enum="LightParam">
Proportion of shadow atlas occupied by the first split.
@@ -3998,10 +4267,13 @@
Represents the size of the [enum LightParam] enum.
</constant>
<constant name="LIGHT_BAKE_DISABLED" value="0" enum="LightBakeMode">
+ Light is ignored when baking. This is the fastest mode, but the light will be taken into account when baking global illumination. This mode should generally be used for dynamic lights that change quickly, as the effect of global illumination is less noticeable on those lights.
</constant>
<constant name="LIGHT_BAKE_STATIC" value="1" enum="LightBakeMode">
+ Light is taken into account in static baking ([VoxelGI], [LightmapGI], SDFGI ([member Environment.sdfgi_enabled])). The light can be moved around or modified, but its global illumination will not update in real-time. This is suitable for subtle changes (such as flickering torches), but generally not large changes such as toggling a light on and off.
</constant>
<constant name="LIGHT_BAKE_DYNAMIC" value="2" enum="LightBakeMode">
+ Light is taken into account in dynamic baking ([VoxelGI] and SDFGI ([member Environment.sdfgi_enabled]) only). The light can be moved around or modified with global illumination updating in real-time. The light's global illumination appearance will be slightly different compared to [constant LIGHT_BAKE_STATIC]. This has a greater performance cost compared to [constant LIGHT_BAKE_STATIC]. When using SDFGI, the update speed of dynamic lights is affected by [member ProjectSettings.rendering/global_illumination/sdfgi/frames_to_update_lights].
</constant>
<constant name="LIGHT_OMNI_SHADOW_DUAL_PARABOLOID" value="0" enum="LightOmniShadowMode">
Use a dual paraboloid shadow map for omni lights.
@@ -4047,6 +4319,7 @@
Highest low shadow filtering quality (slowest). When using this quality setting, [member Light3D.shadow_blur] is automatically multiplied by 2× to better make use of the high sample count. This increased blur also improves the stability of dynamic object shadows. This multiplier only applies to lights whose [member Light3D.light_size] or [member Light3D.light_angular_distance] is [code]0.0[/code]).
</constant>
<constant name="SHADOW_QUALITY_MAX" value="6" enum="ShadowQuality">
+ Represents the size of the [enum ShadowQuality] enum.
</constant>
<constant name="REFLECTION_PROBE_UPDATE_ONCE" value="0" enum="ReflectionProbeUpdateMode">
Reflection probe will update reflections once and then stop.
@@ -4055,20 +4328,28 @@
Reflection probe will update each frame. This mode is necessary to capture moving objects.
</constant>
<constant name="REFLECTION_PROBE_AMBIENT_DISABLED" value="0" enum="ReflectionProbeAmbientMode">
+ Do not apply any ambient lighting inside the reflection probe's box defined by its size.
</constant>
<constant name="REFLECTION_PROBE_AMBIENT_ENVIRONMENT" value="1" enum="ReflectionProbeAmbientMode">
+ Apply automatically-sourced environment lighting inside the reflection probe's box defined by its size.
</constant>
<constant name="REFLECTION_PROBE_AMBIENT_COLOR" value="2" enum="ReflectionProbeAmbientMode">
+ Apply custom ambient lighting inside the reflection probe's box defined by its size. See [method reflection_probe_set_ambient_color] and [method reflection_probe_set_ambient_energy].
</constant>
<constant name="DECAL_TEXTURE_ALBEDO" value="0" enum="DecalTexture">
+ Albedo texture slot in a decal ([member Decal.texture_albedo]).
</constant>
<constant name="DECAL_TEXTURE_NORMAL" value="1" enum="DecalTexture">
+ Normal map texture slot in a decal ([member Decal.texture_normal]).
</constant>
<constant name="DECAL_TEXTURE_ORM" value="2" enum="DecalTexture">
+ Occlusion/Roughness/Metallic texture slot in a decal ([member Decal.texture_orm]).
</constant>
<constant name="DECAL_TEXTURE_EMISSION" value="3" enum="DecalTexture">
+ Emission texture slot in a decal ([member Decal.texture_emission]).
</constant>
<constant name="DECAL_TEXTURE_MAX" value="4" enum="DecalTexture">
+ Represents the size of the [enum DecalTexture] enum.
</constant>
<constant name="DECAL_FILTER_NEAREST" value="0" enum="DecalFilter">
Nearest-neighbor filter for decals (use for pixel art decals). No mipmaps are used for rendering, which means decals at a distance will look sharp but grainy. This has roughly the same performance cost as using mipmaps.
@@ -4089,12 +4370,16 @@
Linear filter for decals (use for non-pixel art decals). Anisotropic mipmaps are used for rendering, which means decals at a distance will look smooth and sharp when viewed from oblique angles. This looks better compared to isotropic mipmaps, but is slower. The level of anisotropic filtering is defined by [member ProjectSettings.rendering/textures/default_filters/anisotropic_filtering_level].
</constant>
<constant name="VOXEL_GI_QUALITY_LOW" value="0" enum="VoxelGIQuality">
+ Low [VoxelGI] rendering quality using 4 cones.
</constant>
<constant name="VOXEL_GI_QUALITY_HIGH" value="1" enum="VoxelGIQuality">
+ High [VoxelGI] rendering quality using 6 cones.
</constant>
<constant name="PARTICLES_MODE_2D" value="0" enum="ParticlesMode">
+ 2D particles.
</constant>
<constant name="PARTICLES_MODE_3D" value="1" enum="ParticlesMode">
+ 3D particles.
</constant>
<constant name="PARTICLES_TRANSFORM_ALIGN_DISABLED" value="0" enum="ParticlesTransformAlign">
</constant>
@@ -4152,6 +4437,7 @@
<constant name="PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_8192" value="5" enum="ParticlesCollisionHeightfieldResolution">
</constant>
<constant name="PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_MAX" value="6" enum="ParticlesCollisionHeightfieldResolution">
+ Represents the size of the [enum ParticlesCollisionHeightfieldResolution] enum.
</constant>
<constant name="FOG_VOLUME_SHAPE_ELLIPSOID" value="0" enum="FogVolumeShape">
[FogVolume] will be shaped like an ellipsoid (stretched sphere).
@@ -4169,6 +4455,7 @@
[FogVolume] will have no shape, will cover the whole world and will not be culled.
</constant>
<constant name="FOG_VOLUME_SHAPE_MAX" value="5" enum="FogVolumeShape">
+ Represents the size of the [enum FogVolumeShape] enum.
</constant>
<constant name="VIEWPORT_SCALING_3D_MODE_BILINEAR" value="0" enum="ViewportScaling3DMode">
Use bilinear scaling for the viewport's 3D buffer. The amount of scaling can be set using [member Viewport.scaling_3d_scale]. Values less than [code]1.0[/code] will result in undersampling while values greater than [code]1.0[/code] will result in supersampling. A value of [code]1.0[/code] disables scaling.
@@ -4177,29 +4464,31 @@
Use AMD FidelityFX Super Resolution 1.0 upscaling for the viewport's 3D buffer. The amount of scaling can be set using [member Viewport.scaling_3d_scale]. Values less than [code]1.0[/code] will be result in the viewport being upscaled using FSR. Values greater than [code]1.0[/code] are not supported and bilinear downsampling will be used instead. A value of [code]1.0[/code] disables scaling.
</constant>
<constant name="VIEWPORT_SCALING_3D_MODE_MAX" value="2" enum="ViewportScaling3DMode">
+ Represents the size of the [enum ViewportScaling3DMode] enum.
</constant>
<constant name="VIEWPORT_UPDATE_DISABLED" value="0" enum="ViewportUpdateMode">
- Do not update the viewport.
+ Do not update the viewport's render target.
</constant>
<constant name="VIEWPORT_UPDATE_ONCE" value="1" enum="ViewportUpdateMode">
- Update the viewport once then set to disabled.
+ Update the viewport's render target once, then switch to [constant VIEWPORT_UPDATE_DISABLED].
</constant>
<constant name="VIEWPORT_UPDATE_WHEN_VISIBLE" value="2" enum="ViewportUpdateMode">
- Update the viewport whenever it is visible.
+ Update the viewport's render target only when it is visible. This is the default value.
</constant>
<constant name="VIEWPORT_UPDATE_WHEN_PARENT_VISIBLE" value="3" enum="ViewportUpdateMode">
+ Update the viewport's render target only when its parent is visible.
</constant>
<constant name="VIEWPORT_UPDATE_ALWAYS" value="4" enum="ViewportUpdateMode">
- Always update the viewport.
+ Always update the viewport's render target.
</constant>
<constant name="VIEWPORT_CLEAR_ALWAYS" value="0" enum="ViewportClearMode">
- The viewport is always cleared before drawing.
+ Always clear the viewport's render target before drawing.
</constant>
<constant name="VIEWPORT_CLEAR_NEVER" value="1" enum="ViewportClearMode">
- The viewport is never cleared before drawing.
+ Never clear the viewport's render target.
</constant>
<constant name="VIEWPORT_CLEAR_ONLY_NEXT_FRAME" value="2" enum="ViewportClearMode">
- The viewport is cleared once, then the clear mode is set to [constant VIEWPORT_CLEAR_NEVER].
+ Clear the viewport's render target on the next frame, then switch to [constant VIEWPORT_CLEAR_NEVER].
</constant>
<constant name="VIEWPORT_ENVIRONMENT_DISABLED" value="0" enum="ViewportEnvironmentMode">
Disable rendering of 3D environment over 2D canvas.
@@ -4208,28 +4497,37 @@
Enable rendering of 3D environment over 2D canvas.
</constant>
<constant name="VIEWPORT_ENVIRONMENT_INHERIT" value="2" enum="ViewportEnvironmentMode">
- Inherit enable/disable value from parent. If topmost parent is also set to inherit, then this has the same behavior as [constant VIEWPORT_ENVIRONMENT_ENABLED].
+ Inherit enable/disable value from parent. If the topmost parent is also set to [constant VIEWPORT_ENVIRONMENT_INHERIT], then this has the same behavior as [constant VIEWPORT_ENVIRONMENT_ENABLED].
</constant>
<constant name="VIEWPORT_ENVIRONMENT_MAX" value="3" enum="ViewportEnvironmentMode">
- Max value of [enum ViewportEnvironmentMode] enum.
+ Represents the size of the [enum ViewportEnvironmentMode] enum.
</constant>
<constant name="VIEWPORT_SDF_OVERSIZE_100_PERCENT" value="0" enum="ViewportSDFOversize">
+ Do not oversize the 2D signed distance field. Occluders may disappear when touching the viewport's edges, and [GPUParticles3D] collision may stop working earlier than intended. This has the lowest GPU requirements.
</constant>
<constant name="VIEWPORT_SDF_OVERSIZE_120_PERCENT" value="1" enum="ViewportSDFOversize">
+ 2D signed distance field covers 20% of the viewport's size outside the viewport on each side (top, right, bottom, left).
</constant>
<constant name="VIEWPORT_SDF_OVERSIZE_150_PERCENT" value="2" enum="ViewportSDFOversize">
+ 2D signed distance field covers 50% of the viewport's size outside the viewport on each side (top, right, bottom, left).
</constant>
<constant name="VIEWPORT_SDF_OVERSIZE_200_PERCENT" value="3" enum="ViewportSDFOversize">
+ 2D signed distance field covers 100% of the viewport's size outside the viewport on each side (top, right, bottom, left). This has the highest GPU requirements.
</constant>
<constant name="VIEWPORT_SDF_OVERSIZE_MAX" value="4" enum="ViewportSDFOversize">
+ Represents the size of the [enum ViewportSDFOversize] enum.
</constant>
<constant name="VIEWPORT_SDF_SCALE_100_PERCENT" value="0" enum="ViewportSDFScale">
+ Full resolution 2D signed distance field scale. This has the highest GPU requirements.
</constant>
<constant name="VIEWPORT_SDF_SCALE_50_PERCENT" value="1" enum="ViewportSDFScale">
+ Half resolution 2D signed distance field scale on each axis (25% of the viewport pixel count).
</constant>
<constant name="VIEWPORT_SDF_SCALE_25_PERCENT" value="2" enum="ViewportSDFScale">
+ Quarter resolution 2D signed distance field scale on each axis (6.25% of the viewport pixel count). This has the lowest GPU requirements.
</constant>
<constant name="VIEWPORT_SDF_SCALE_MAX" value="3" enum="ViewportSDFScale">
+ Represents the size of the [enum ViewportSDFScale] enum.
</constant>
<constant name="VIEWPORT_MSAA_DISABLED" value="0" enum="ViewportMSAA">
Multisample antialiasing for 3D is disabled. This is the default value, and also the fastest setting.
@@ -4244,18 +4542,25 @@
Multisample antialiasing uses 8 samples per pixel for 3D. This has a very high impact on performance. Likely unsupported on low-end and older hardware.
</constant>
<constant name="VIEWPORT_MSAA_MAX" value="4" enum="ViewportMSAA">
+ Represents the size of the [enum ViewportMSAA] enum.
</constant>
<constant name="VIEWPORT_SCREEN_SPACE_AA_DISABLED" value="0" enum="ViewportScreenSpaceAA">
+ Do not perform any antialiasing in the full screen post-process.
</constant>
<constant name="VIEWPORT_SCREEN_SPACE_AA_FXAA" value="1" enum="ViewportScreenSpaceAA">
+ Use fast approximate antialiasing. FXAA is a popular screen-space antialiasing method, which is fast but will make the image look blurry, especially at lower resolutions. It can still work relatively well at large resolutions such as 1440p and 4K.
</constant>
<constant name="VIEWPORT_SCREEN_SPACE_AA_MAX" value="2" enum="ViewportScreenSpaceAA">
+ Represents the size of the [enum ViewportScreenSpaceAA] enum.
</constant>
<constant name="VIEWPORT_OCCLUSION_BUILD_QUALITY_LOW" value="0" enum="ViewportOcclusionCullingBuildQuality">
+ Low occlusion culling BVH build quality (as defined by Embree). Results in the lowest CPU usage, but least effective culling.
</constant>
<constant name="VIEWPORT_OCCLUSION_BUILD_QUALITY_MEDIUM" value="1" enum="ViewportOcclusionCullingBuildQuality">
+ Medium occlusion culling BVH build quality (as defined by Embree).
</constant>
<constant name="VIEWPORT_OCCLUSION_BUILD_QUALITY_HIGH" value="2" enum="ViewportOcclusionCullingBuildQuality">
+ High occlusion culling BVH build quality (as defined by Embree). Results in the highest CPU usage, but most effective culling.
</constant>
<constant name="VIEWPORT_RENDER_INFO_OBJECTS_IN_FRAME" value="0" enum="ViewportRenderInfo">
Number of objects drawn in a single frame.
@@ -4270,10 +4575,13 @@
Represents the size of the [enum ViewportRenderInfo] enum.
</constant>
<constant name="VIEWPORT_RENDER_INFO_TYPE_VISIBLE" value="0" enum="ViewportRenderInfoType">
+ Visible render pass (excluding shadows).
</constant>
<constant name="VIEWPORT_RENDER_INFO_TYPE_SHADOW" value="1" enum="ViewportRenderInfoType">
+ Shadow render pass. Objects will be rendered several times depending on the number of amounts of lights with shadows and the number of directional shadow splits.
</constant>
<constant name="VIEWPORT_RENDER_INFO_TYPE_MAX" value="2" enum="ViewportRenderInfoType">
+ Represents the size of the [enum ViewportRenderInfoType] enum.
</constant>
<constant name="VIEWPORT_DEBUG_DRAW_DISABLED" value="0" enum="ViewportDebugDraw">
Debug draw is disabled. Default setting.
@@ -4310,6 +4618,7 @@
Draws the shadow atlas that stores shadows from [DirectionalLight3D]s in the upper left quadrant of the [Viewport].
</constant>
<constant name="VIEWPORT_DEBUG_DRAW_SCENE_LUMINANCE" value="11" enum="ViewportDebugDraw">
+ Draws the estimated scene luminance. This is a 1×1 texture that is generated when autoexposure is enabled to control the scene's exposure.
</constant>
<constant name="VIEWPORT_DEBUG_DRAW_SSAO" value="12" enum="ViewportDebugDraw">
Draws the screen space ambient occlusion texture instead of the scene so that you can clearly see how it is affecting objects. In order for this display mode to work, you must have [member Environment.ssao_enabled] set in your [WorldEnvironment].
@@ -4321,49 +4630,62 @@
Colors each PSSM split for the [DirectionalLight3D]s in the scene a different color so you can see where the splits are. In order they will be colored red, green, blue, yellow.
</constant>
<constant name="VIEWPORT_DEBUG_DRAW_DECAL_ATLAS" value="15" enum="ViewportDebugDraw">
+ Draws the decal atlas that stores decal textures from [Decal]s.
</constant>
<constant name="VIEWPORT_DEBUG_DRAW_SDFGI" value="16" enum="ViewportDebugDraw">
+ Draws SDFGI cascade data. This is the data structure that is used to bounce lighting against and create reflections.
</constant>
<constant name="VIEWPORT_DEBUG_DRAW_SDFGI_PROBES" value="17" enum="ViewportDebugDraw">
+ Draws SDFGI probe data. This is the data structure that is used to give indirect lighting dynamic objects moving within the scene.
</constant>
<constant name="VIEWPORT_DEBUG_DRAW_GI_BUFFER" value="18" enum="ViewportDebugDraw">
+ Draws the global illumination buffer ([VoxelGI] or SDFGI).
</constant>
<constant name="VIEWPORT_DEBUG_DRAW_DISABLE_LOD" value="19" enum="ViewportDebugDraw">
+ Disable mesh LOD. All meshes are drawn with full detail, which can be used to compare performance.
</constant>
<constant name="VIEWPORT_DEBUG_DRAW_CLUSTER_OMNI_LIGHTS" value="20" enum="ViewportDebugDraw">
+ Draws the [OmniLight3D] cluster. Clustering determines where lights are positioned in screen-space, which allows the engine to only process these portions of the screen for lighting.
</constant>
<constant name="VIEWPORT_DEBUG_DRAW_CLUSTER_SPOT_LIGHTS" value="21" enum="ViewportDebugDraw">
+ Draws the [SpotLight3D] cluster. Clustering determines where lights are positioned in screen-space, which allows the engine to only process these portions of the screen for lighting.
</constant>
<constant name="VIEWPORT_DEBUG_DRAW_CLUSTER_DECALS" value="22" enum="ViewportDebugDraw">
+ Draws the [Decal] cluster. Clustering determines where decals are positioned in screen-space, which allows the engine to only process these portions of the screen for decals.
</constant>
<constant name="VIEWPORT_DEBUG_DRAW_CLUSTER_REFLECTION_PROBES" value="23" enum="ViewportDebugDraw">
+ Draws the [ReflectionProbe] cluster. Clustering determines where reflection probes are positioned in screen-space, which allows the engine to only process these portions of the screen for reflection probes.
</constant>
<constant name="VIEWPORT_DEBUG_DRAW_OCCLUDERS" value="24" enum="ViewportDebugDraw">
+ Draws the occlusion culling buffer. This low-resolution occlusion culling buffer is rasterized on the CPU and is used to check whether instances are occluded by other objects.
</constant>
<constant name="VIEWPORT_DEBUG_DRAW_MOTION_VECTORS" value="25" enum="ViewportDebugDraw">
+ Draws the motion vectors buffer. This is used by temporal antialiasing to correct for motion that occurs during gameplay.
</constant>
<constant name="VIEWPORT_VRS_DISABLED" value="0" enum="ViewportVRSMode">
- VRS is disabled.
+ Variable rate shading is disabled.
</constant>
<constant name="VIEWPORT_VRS_TEXTURE" value="1" enum="ViewportVRSMode">
- VRS uses a texture. Note, for stereoscopic use a texture atlas with a texture for each view.
+ Variable rate shading uses a texture. Note, for stereoscopic use a texture atlas with a texture for each view.
</constant>
<constant name="VIEWPORT_VRS_XR" value="2" enum="ViewportVRSMode">
- VRS texture is supplied by the primary [XRInterface].
+ Variable rate shading texture is supplied by the primary [XRInterface].
</constant>
<constant name="VIEWPORT_VRS_MAX" value="3" enum="ViewportVRSMode">
Represents the size of the [enum ViewportVRSMode] enum.
</constant>
<constant name="SKY_MODE_AUTOMATIC" value="0" enum="SkyMode">
+ Automatically selects the appropriate process mode based on your sky shader. If your shader uses [code]TIME[/code] or [code]POSITION[/code], this will use [constant SKY_MODE_REALTIME]. If your shader uses any of the [code]LIGHT_*[/code] variables or any custom uniforms, this uses [constant SKY_MODE_INCREMENTAL]. Otherwise, this defaults to [constant SKY_MODE_QUALITY].
</constant>
<constant name="SKY_MODE_QUALITY" value="1" enum="SkyMode">
- Uses high quality importance sampling to process the radiance map. In general, this results in much higher quality than [constant Sky.PROCESS_MODE_REALTIME] but takes much longer to generate. This should not be used if you plan on changing the sky at runtime. If you are finding that the reflection is not blurry enough and is showing sparkles or fireflies, try increasing [member ProjectSettings.rendering/reflections/sky_reflections/ggx_samples].
+ Uses high quality importance sampling to process the radiance map. In general, this results in much higher quality than [constant SKY_MODE_REALTIME] but takes much longer to generate. This should not be used if you plan on changing the sky at runtime. If you are finding that the reflection is not blurry enough and is showing sparkles or fireflies, try increasing [member ProjectSettings.rendering/reflections/sky_reflections/ggx_samples].
</constant>
<constant name="SKY_MODE_INCREMENTAL" value="2" enum="SkyMode">
+ Uses the same high quality importance sampling to process the radiance map as [constant SKY_MODE_QUALITY], but updates over several frames. The number of frames is determined by [member ProjectSettings.rendering/reflections/sky_reflections/roughness_layers]. Use this when you need highest quality radiance maps, but have a sky that updates slowly.
</constant>
<constant name="SKY_MODE_REALTIME" value="3" enum="SkyMode">
- Uses the fast filtering algorithm to process the radiance map. In general this results in lower quality, but substantially faster run times.
- [b]Note:[/b] The fast filtering algorithm is limited to 256x256 cubemaps, so [member Sky.radiance_size] must be set to [constant Sky.RADIANCE_SIZE_256].
+ Uses the fast filtering algorithm to process the radiance map. In general this results in lower quality, but substantially faster run times. If you need better quality, but still need to update the sky every frame, consider turning on [member ProjectSettings.rendering/reflections/sky_reflections/fast_filter_high_quality].
+ [b]Note:[/b] The fast filtering algorithm is limited to 256×256 cubemaps, so [method sky_set_radiance_size] must be set to [code]256[/code]. Otherwise, a warning is printed and the overridden radiance size is ignored.
</constant>
<constant name="ENV_BG_CLEAR_COLOR" value="0" enum="EnvironmentBG">
Use the clear color as background.
@@ -4478,60 +4800,88 @@
Highest quality screen-space indirect lighting. Uses the adaptive target setting which can be dynamically adjusted to smoothly balance performance and visual quality.
</constant>
<constant name="ENV_SDFGI_Y_SCALE_50_PERCENT" value="0" enum="EnvironmentSDFGIYScale">
+ Use 50% scale for SDFGI on the Y (vertical) axis. SDFGI cells will be twice as short as they are wide. This allows providing increased GI detail and reduced light leaking with thin floors and ceilings. This is usually the best choice for scenes that don't feature much verticality.
</constant>
<constant name="ENV_SDFGI_Y_SCALE_75_PERCENT" value="1" enum="EnvironmentSDFGIYScale">
+ Use 75% scale for SDFGI on the Y (vertical) axis. This is a balance between the 50% and 100% SDFGI Y scales.
</constant>
<constant name="ENV_SDFGI_Y_SCALE_100_PERCENT" value="2" enum="EnvironmentSDFGIYScale">
+ Use 100% scale for SDFGI on the Y (vertical) axis. SDFGI cells will be as tall as they are wide. This is usually the best choice for highly vertical scenes. The downside is that light leaking may become more noticeable with thin floors and ceilings.
</constant>
<constant name="ENV_SDFGI_RAY_COUNT_4" value="0" enum="EnvironmentSDFGIRayCount">
+ Throw 4 rays per frame when converging SDFGI. This has the lowest GPU requirements, but creates the most noisy result.
</constant>
<constant name="ENV_SDFGI_RAY_COUNT_8" value="1" enum="EnvironmentSDFGIRayCount">
+ Throw 8 rays per frame when converging SDFGI.
</constant>
<constant name="ENV_SDFGI_RAY_COUNT_16" value="2" enum="EnvironmentSDFGIRayCount">
+ Throw 16 rays per frame when converging SDFGI.
</constant>
<constant name="ENV_SDFGI_RAY_COUNT_32" value="3" enum="EnvironmentSDFGIRayCount">
+ Throw 32 rays per frame when converging SDFGI.
</constant>
<constant name="ENV_SDFGI_RAY_COUNT_64" value="4" enum="EnvironmentSDFGIRayCount">
+ Throw 64 rays per frame when converging SDFGI.
</constant>
<constant name="ENV_SDFGI_RAY_COUNT_96" value="5" enum="EnvironmentSDFGIRayCount">
+ Throw 96 rays per frame when converging SDFGI. This has high GPU requirements.
</constant>
<constant name="ENV_SDFGI_RAY_COUNT_128" value="6" enum="EnvironmentSDFGIRayCount">
+ Throw 128 rays per frame when converging SDFGI. This has very high GPU requirements, but creates the least noisy result.
</constant>
<constant name="ENV_SDFGI_RAY_COUNT_MAX" value="7" enum="EnvironmentSDFGIRayCount">
+ Represents the size of the [enum EnvironmentSDFGIRayCount] enum.
</constant>
<constant name="ENV_SDFGI_CONVERGE_IN_5_FRAMES" value="0" enum="EnvironmentSDFGIFramesToConverge">
+ Converge SDFGI over 5 frames. This is the most responsive, but creates the most noisy result with a given ray count.
</constant>
<constant name="ENV_SDFGI_CONVERGE_IN_10_FRAMES" value="1" enum="EnvironmentSDFGIFramesToConverge">
+ Configure SDFGI to fully converge over 10 frames.
</constant>
<constant name="ENV_SDFGI_CONVERGE_IN_15_FRAMES" value="2" enum="EnvironmentSDFGIFramesToConverge">
+ Configure SDFGI to fully converge over 15 frames.
</constant>
<constant name="ENV_SDFGI_CONVERGE_IN_20_FRAMES" value="3" enum="EnvironmentSDFGIFramesToConverge">
+ Configure SDFGI to fully converge over 20 frames.
</constant>
<constant name="ENV_SDFGI_CONVERGE_IN_25_FRAMES" value="4" enum="EnvironmentSDFGIFramesToConverge">
+ Configure SDFGI to fully converge over 25 frames.
</constant>
<constant name="ENV_SDFGI_CONVERGE_IN_30_FRAMES" value="5" enum="EnvironmentSDFGIFramesToConverge">
+ Configure SDFGI to fully converge over 30 frames. This is the least responsive, but creates the least noisy result with a given ray count.
</constant>
<constant name="ENV_SDFGI_CONVERGE_MAX" value="6" enum="EnvironmentSDFGIFramesToConverge">
+ Represents the size of the [enum EnvironmentSDFGIFramesToConverge] enum.
</constant>
<constant name="ENV_SDFGI_UPDATE_LIGHT_IN_1_FRAME" value="0" enum="EnvironmentSDFGIFramesToUpdateLight">
+ Update indirect light from dynamic lights in SDFGI over 1 frame. This is the most responsive, but has the highest GPU requirements.
</constant>
<constant name="ENV_SDFGI_UPDATE_LIGHT_IN_2_FRAMES" value="1" enum="EnvironmentSDFGIFramesToUpdateLight">
+ Update indirect light from dynamic lights in SDFGI over 2 frames.
</constant>
<constant name="ENV_SDFGI_UPDATE_LIGHT_IN_4_FRAMES" value="2" enum="EnvironmentSDFGIFramesToUpdateLight">
+ Update indirect light from dynamic lights in SDFGI over 4 frames.
</constant>
<constant name="ENV_SDFGI_UPDATE_LIGHT_IN_8_FRAMES" value="3" enum="EnvironmentSDFGIFramesToUpdateLight">
+ Update indirect light from dynamic lights in SDFGI over 8 frames.
</constant>
<constant name="ENV_SDFGI_UPDATE_LIGHT_IN_16_FRAMES" value="4" enum="EnvironmentSDFGIFramesToUpdateLight">
+ Update indirect light from dynamic lights in SDFGI over 16 frames. This is the least responsive, but has the lowest GPU requirements.
</constant>
<constant name="ENV_SDFGI_UPDATE_LIGHT_MAX" value="5" enum="EnvironmentSDFGIFramesToUpdateLight">
+ Represents the size of the [enum EnvironmentSDFGIFramesToUpdateLight] enum.
</constant>
<constant name="SUB_SURFACE_SCATTERING_QUALITY_DISABLED" value="0" enum="SubSurfaceScatteringQuality">
+ Disables subsurface scattering entirely, even on materials that have [member BaseMaterial3D.subsurf_scatter_enabled] set to [code]true[/code]. This has the lowest GPU requirements.
</constant>
<constant name="SUB_SURFACE_SCATTERING_QUALITY_LOW" value="1" enum="SubSurfaceScatteringQuality">
+ Low subsurface scattering quality.
</constant>
<constant name="SUB_SURFACE_SCATTERING_QUALITY_MEDIUM" value="2" enum="SubSurfaceScatteringQuality">
+ Medium subsurface scattering quality.
</constant>
<constant name="SUB_SURFACE_SCATTERING_QUALITY_HIGH" value="3" enum="SubSurfaceScatteringQuality">
+ High subsurface scattering quality. This has the highest GPU requirements.
</constant>
<constant name="DOF_BOKEH_BOX" value="0" enum="DOFBokehShape">
Calculate the DOF blur using a box filter. The fastest option, but results in obvious lines in blur pattern.
@@ -4567,6 +4917,7 @@
The instance is a particle emitter.
</constant>
<constant name="INSTANCE_PARTICLES_COLLISION" value="4" enum="InstanceType">
+ The instance is a GPUParticles collision shape.
</constant>
<constant name="INSTANCE_LIGHT" value="5" enum="InstanceType">
The instance is a light.
@@ -4584,10 +4935,13 @@
The instance is a lightmap.
</constant>
<constant name="INSTANCE_OCCLUDER" value="10" enum="InstanceType">
+ The instance is an occlusion culling occluder.
</constant>
<constant name="INSTANCE_VISIBLITY_NOTIFIER" value="11" enum="InstanceType">
+ The instance is a visible on-screen notifier.
</constant>
<constant name="INSTANCE_FOG_VOLUME" value="12" enum="InstanceType">
+ The instance is a fog volume.
</constant>
<constant name="INSTANCE_MAX" value="13" enum="InstanceType">
Represents the size of the [enum InstanceType] enum.
@@ -4605,6 +4959,7 @@
When set, manually requests to draw geometry on next frame.
</constant>
<constant name="INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING" value="3" enum="InstanceFlags">
+ Always draw, even if the instance would be culled by occlusion culling. Does not affect view frustum culling.
</constant>
<constant name="INSTANCE_FLAG_MAX" value="4" enum="InstanceFlags">
Represents the size of the [enum InstanceFlags] enum.
@@ -4643,10 +4998,13 @@
Index of [Image] in array of [Image]s returned by [method bake_render_uv2]. Image uses [constant Image.FORMAT_RGBAH] and contains emission color in the [code].rgb[/code] channels and nothing in the [code].a[/code] channel.
</constant>
<constant name="CANVAS_TEXTURE_CHANNEL_DIFFUSE" value="0" enum="CanvasTextureChannel">
+ Diffuse canvas texture ([member CanvasTexture.diffuse_texture]).
</constant>
<constant name="CANVAS_TEXTURE_CHANNEL_NORMAL" value="1" enum="CanvasTextureChannel">
+ Normal map canvas texture ([member CanvasTexture.normal_texture]).
</constant>
<constant name="CANVAS_TEXTURE_CHANNEL_SPECULAR" value="2" enum="CanvasTextureChannel">
+ Specular map canvas texture ([member CanvasTexture.specular_texture]).
</constant>
<constant name="NINE_PATCH_STRETCH" value="0" enum="NinePatchAxisMode">
The nine patch gets stretched where needed.
@@ -4697,16 +5055,21 @@
Max value for [enum CanvasItemTextureRepeat] enum.
</constant>
<constant name="CANVAS_GROUP_MODE_DISABLED" value="0" enum="CanvasGroupMode">
+ Child draws over parent and is not clipped.
</constant>
<constant name="CANVAS_GROUP_MODE_CLIP_ONLY" value="1" enum="CanvasGroupMode">
+ Parent is used for the purposes of clipping only. Child is clipped to the parent's visible area, parent is not drawn.
</constant>
<constant name="CANVAS_GROUP_MODE_CLIP_AND_DRAW" value="2" enum="CanvasGroupMode">
+ Parent is used for clipping child, but parent is also drawn underneath child as normal before clipping child to its visible area.
</constant>
<constant name="CANVAS_GROUP_MODE_TRANSPARENT" value="3" enum="CanvasGroupMode">
</constant>
<constant name="CANVAS_LIGHT_MODE_POINT" value="0" enum="CanvasLightMode">
+ 2D point light (see [PointLight2D]).
</constant>
<constant name="CANVAS_LIGHT_MODE_DIRECTIONAL" value="1" enum="CanvasLightMode">
+ 2D directional (sun/moon) light (see [DirectionalLight2D]).
</constant>
<constant name="CANVAS_LIGHT_BLEND_MODE_ADD" value="0" enum="CanvasLightBlendMode">
Adds light color additive to the canvas.
@@ -4739,74 +5102,109 @@
Culling of the canvas occluder is counterclockwise.
</constant>
<constant name="GLOBAL_VAR_TYPE_BOOL" value="0" enum="GlobalShaderParameterType">
+ Boolean global shader parameter ([code]global uniform bool ...[/code]).
</constant>
<constant name="GLOBAL_VAR_TYPE_BVEC2" value="1" enum="GlobalShaderParameterType">
+ 2-dimensional boolean vector global shader parameter ([code]global uniform bvec2 ...[/code]).
</constant>
<constant name="GLOBAL_VAR_TYPE_BVEC3" value="2" enum="GlobalShaderParameterType">
+ 3-dimensional boolean vector global shader parameter ([code]global uniform bvec3 ...[/code]).
</constant>
<constant name="GLOBAL_VAR_TYPE_BVEC4" value="3" enum="GlobalShaderParameterType">
+ 4-dimensional boolean vector global shader parameter ([code]global uniform bvec4 ...[/code]).
</constant>
<constant name="GLOBAL_VAR_TYPE_INT" value="4" enum="GlobalShaderParameterType">
+ Integer global shader parameter ([code]global uniform int ...[/code]).
</constant>
<constant name="GLOBAL_VAR_TYPE_IVEC2" value="5" enum="GlobalShaderParameterType">
+ 2-dimensional integer vector global shader parameter ([code]global uniform ivec2 ...[/code]).
</constant>
<constant name="GLOBAL_VAR_TYPE_IVEC3" value="6" enum="GlobalShaderParameterType">
+ 3-dimensional integer vector global shader parameter ([code]global uniform ivec3 ...[/code]).
</constant>
<constant name="GLOBAL_VAR_TYPE_IVEC4" value="7" enum="GlobalShaderParameterType">
+ 4-dimensional integer vector global shader parameter ([code]global uniform ivec4 ...[/code]).
</constant>
<constant name="GLOBAL_VAR_TYPE_RECT2I" value="8" enum="GlobalShaderParameterType">
+ 2-dimensional integer rectangle global shader parameter ([code]global uniform ivec4 ...[/code]). Equivalent to [constant GLOBAL_VAR_TYPE_IVEC4] in shader code, but exposed as a [Rect2i] in the editor UI.
</constant>
<constant name="GLOBAL_VAR_TYPE_UINT" value="9" enum="GlobalShaderParameterType">
+ Unsigned integer global shader parameter ([code]global uniform uint ...[/code]).
</constant>
<constant name="GLOBAL_VAR_TYPE_UVEC2" value="10" enum="GlobalShaderParameterType">
+ 2-dimensional unsigned integer vector global shader parameter ([code]global uniform uvec2 ...[/code]).
</constant>
<constant name="GLOBAL_VAR_TYPE_UVEC3" value="11" enum="GlobalShaderParameterType">
+ 3-dimensional unsigned integer vector global shader parameter ([code]global uniform uvec3 ...[/code]).
</constant>
<constant name="GLOBAL_VAR_TYPE_UVEC4" value="12" enum="GlobalShaderParameterType">
+ 4-dimensional unsigned integer vector global shader parameter ([code]global uniform uvec4 ...[/code]).
</constant>
<constant name="GLOBAL_VAR_TYPE_FLOAT" value="13" enum="GlobalShaderParameterType">
+ Single-precision floating-point global shader parameter ([code]global uniform float ...[/code]).
</constant>
<constant name="GLOBAL_VAR_TYPE_VEC2" value="14" enum="GlobalShaderParameterType">
+ 2-dimensional floating-point vector global shader parameter ([code]global uniform vec2 ...[/code]).
</constant>
<constant name="GLOBAL_VAR_TYPE_VEC3" value="15" enum="GlobalShaderParameterType">
+ 3-dimensional floating-point vector global shader parameter ([code]global uniform vec3 ...[/code]).
</constant>
<constant name="GLOBAL_VAR_TYPE_VEC4" value="16" enum="GlobalShaderParameterType">
+ 4-dimensional floating-point vector global shader parameter ([code]global uniform vec4 ...[/code]).
</constant>
<constant name="GLOBAL_VAR_TYPE_COLOR" value="17" enum="GlobalShaderParameterType">
+ Color global shader parameter ([code]global uniform vec4 ...[/code]). Equivalent to [constant GLOBAL_VAR_TYPE_VEC4] in shader code, but exposed as a [Color] in the editor UI.
</constant>
<constant name="GLOBAL_VAR_TYPE_RECT2" value="18" enum="GlobalShaderParameterType">
+ 2-dimensional floating-point rectangle global shader parameter ([code]global uniform vec4 ...[/code]). Equivalent to [constant GLOBAL_VAR_TYPE_VEC4] in shader code, but exposed as a [Rect2] in the editor UI.
</constant>
<constant name="GLOBAL_VAR_TYPE_MAT2" value="19" enum="GlobalShaderParameterType">
+ 2×2 matrix global shader parameter ([code]global uniform mat2 ...[/code]). Exposed as a [PackedInt32Array] in the editor UI.
</constant>
<constant name="GLOBAL_VAR_TYPE_MAT3" value="20" enum="GlobalShaderParameterType">
+ 3×3 matrix global shader parameter ([code]global uniform mat3 ...[/code]). Exposed as a [Basis] in the editor UI.
</constant>
<constant name="GLOBAL_VAR_TYPE_MAT4" value="21" enum="GlobalShaderParameterType">
+ 4×4 matrix global shader parameter ([code]global uniform mat4 ...[/code]). Exposed as a [Projection] in the editor UI.
</constant>
<constant name="GLOBAL_VAR_TYPE_TRANSFORM_2D" value="22" enum="GlobalShaderParameterType">
+ 2-dimensional transform global shader parameter ([code]global uniform mat2x3 ...[/code]). Exposed as a [Transform2D] in the editor UI.
</constant>
<constant name="GLOBAL_VAR_TYPE_TRANSFORM" value="23" enum="GlobalShaderParameterType">
+ 3-dimensional transform global shader parameter ([code]global uniform mat3x4 ...[/code]). Exposed as a [Transform3D] in the editor UI.
</constant>
<constant name="GLOBAL_VAR_TYPE_SAMPLER2D" value="24" enum="GlobalShaderParameterType">
+ 2D sampler global shader parameter ([code]global uniform sampler2D ...[/code]). Exposed as a [Texture2D] in the editor UI.
</constant>
<constant name="GLOBAL_VAR_TYPE_SAMPLER2DARRAY" value="25" enum="GlobalShaderParameterType">
+ 2D sampler array global shader parameter ([code]global uniform sampler2DArray ...[/code]). Exposed as a [Texture2DArray] in the editor UI.
</constant>
<constant name="GLOBAL_VAR_TYPE_SAMPLER3D" value="26" enum="GlobalShaderParameterType">
+ 3D sampler global shader parameter ([code]global uniform sampler3D ...[/code]). Exposed as a [Texture3D] in the editor UI.
</constant>
<constant name="GLOBAL_VAR_TYPE_SAMPLERCUBE" value="27" enum="GlobalShaderParameterType">
+ Cubemap sampler global shader parameter ([code]global uniform samplerCube ...[/code]). Exposed as a [Cubemap] in the editor UI.
</constant>
<constant name="GLOBAL_VAR_TYPE_MAX" value="28" enum="GlobalShaderParameterType">
+ Represents the size of the [enum GlobalShaderParameterType] enum.
</constant>
<constant name="RENDERING_INFO_TOTAL_OBJECTS_IN_FRAME" value="0" enum="RenderingInfo">
+ Number of objects rendered in the current 3D scene. This varies depending on camera position and rotation.
</constant>
<constant name="RENDERING_INFO_TOTAL_PRIMITIVES_IN_FRAME" value="1" enum="RenderingInfo">
+ Number of vertices/indices rendered in the current 3D scene. This varies depending on camera position and rotation.
</constant>
<constant name="RENDERING_INFO_TOTAL_DRAW_CALLS_IN_FRAME" value="2" enum="RenderingInfo">
+ Number of draw calls performed to render in the current 3D scene. This varies depending on camera position and rotation.
</constant>
<constant name="RENDERING_INFO_TEXTURE_MEM_USED" value="3" enum="RenderingInfo">
+ Texture memory used (in bytes).
</constant>
<constant name="RENDERING_INFO_BUFFER_MEM_USED" value="4" enum="RenderingInfo">
+ Buffer memory used (in bytes).
</constant>
<constant name="RENDERING_INFO_VIDEO_MEM_USED" value="5" enum="RenderingInfo">
+ Video memory used (in bytes). This is always greater than the sum of [constant RENDERING_INFO_TEXTURE_MEM_USED] and [constant RENDERING_INFO_BUFFER_MEM_USED], since there is miscellaneous data not accounted for by those two metrics.
</constant>
<constant name="FEATURE_SHADERS" value="0" enum="Features">
Hardware supports shaders. This enum is currently unused in Godot 3.x.
diff --git a/doc/classes/RibbonTrailMesh.xml b/doc/classes/RibbonTrailMesh.xml
index db5c8d097c..c049570310 100644
--- a/doc/classes/RibbonTrailMesh.xml
+++ b/doc/classes/RibbonTrailMesh.xml
@@ -1,29 +1,42 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="RibbonTrailMesh" inherits="PrimitiveMesh" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
+ Represents a straight ribbon-shaped [PrimitiveMesh] with variable width.
</brief_description>
<description>
+ [RibbonTrailMesh] represents a straight ribbon-shaped mesh with variable width. The ribbon is composed of a number of flat or cross-shaped sections, each with the same [member section_length] and number of [member section_segments]. A [member curve] is sampled along the total length of the ribbon, meaning that the curve determines the size of the ribbon along its length.
+ This primitive mesh is usually used for particle trails.
</description>
<tutorials>
+ <link title="3D Particle trails">$DOCS_URL/tutorials/3d/particles/trails.html</link>
+ <link title="Particle systems (3D)">$DOCS_URL/tutorials/3d/particles/index.html</link>
</tutorials>
<members>
<member name="curve" type="Curve" setter="set_curve" getter="get_curve">
+ Determines the size of the ribbon along its length. The size of a particular section segment is obtained by multiplying the baseline [member size] by the value of this curve at the given distance. For values smaller than [code]0[/code], the faces will be inverted.
</member>
<member name="section_length" type="float" setter="set_section_length" getter="get_section_length" default="0.2">
+ The length of a section of the ribbon.
</member>
<member name="section_segments" type="int" setter="set_section_segments" getter="get_section_segments" default="3">
+ The number of segments in a section. The [member curve] is sampled on each segment to determine its size. Higher values result in a more detailed ribbon at the cost of performance.
</member>
<member name="sections" type="int" setter="set_sections" getter="get_sections" default="5">
+ The total number of sections on the ribbon.
</member>
<member name="shape" type="int" setter="set_shape" getter="get_shape" enum="RibbonTrailMesh.Shape" default="1">
+ Determines the shape of the ribbon.
</member>
<member name="size" type="float" setter="set_size" getter="get_size" default="1.0">
+ The baseline size of the ribbon. The size of a particular section segment is obtained by multiplying this size by the value of the [member curve] at the given distance.
</member>
</members>
<constants>
<constant name="SHAPE_FLAT" value="0" enum="Shape">
+ Gives the mesh a single flat face.
</constant>
<constant name="SHAPE_CROSS" value="1" enum="Shape">
+ Gives the mesh two perpendicular flat faces, making a cross shape.
</constant>
</constants>
</class>
diff --git a/doc/classes/RichTextLabel.xml b/doc/classes/RichTextLabel.xml
index 7f840ee49e..a93fdfd296 100644
--- a/doc/classes/RichTextLabel.xml
+++ b/doc/classes/RichTextLabel.xml
@@ -357,7 +357,7 @@
<method name="push_italics">
<return type="void" />
<description>
- Adds a [code][font][/code] tag with a italics font to the tag stack. This is the same as adding a [code][i][/code] tag if not currently in a [code][b][/code] tag.
+ Adds a [code][font][/code] tag with an italics font to the tag stack. This is the same as adding an [code][i][/code] tag if not currently in a [code][b][/code] tag.
</description>
</method>
<method name="push_list">
diff --git a/doc/classes/RigidBody2D.xml b/doc/classes/RigidBody2D.xml
index 38334b1348..24372e51e0 100644
--- a/doc/classes/RigidBody2D.xml
+++ b/doc/classes/RigidBody2D.xml
@@ -283,7 +283,7 @@
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.
+ In this mode, the body's center of mass is calculated automatically based on its shapes. This assumes that the shapes' origins are also their center of mass.
</constant>
<constant name="CENTER_OF_MASS_MODE_CUSTOM" value="1" enum="CenterOfMassMode">
In this mode, the body's center of mass is set through [member center_of_mass]. Defaults to the body's origin position.
diff --git a/doc/classes/RigidBody3D.xml b/doc/classes/RigidBody3D.xml
index f087f912bc..3bd660d8dd 100644
--- a/doc/classes/RigidBody3D.xml
+++ b/doc/classes/RigidBody3D.xml
@@ -290,7 +290,7 @@
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.
+ In this mode, the body's center of mass is calculated automatically based on its shapes. This assumes that the shapes' origins are also their center of mass.
</constant>
<constant name="CENTER_OF_MASS_MODE_CUSTOM" value="1" enum="CenterOfMassMode">
In this mode, the body's center of mass is set through [member center_of_mass]. Defaults to the body's origin position.
diff --git a/doc/classes/SceneTree.xml b/doc/classes/SceneTree.xml
index 2921117b8b..ce793deec1 100644
--- a/doc/classes/SceneTree.xml
+++ b/doc/classes/SceneTree.xml
@@ -62,9 +62,9 @@
<param index="3" name="ignore_time_scale" type="bool" default="false" />
<description>
Returns a [SceneTreeTimer] which will [signal SceneTreeTimer.timeout] after the given time in seconds elapsed in this [SceneTree].
- If [code]process_always[/code] is set to [code]false[/code], pausing the [SceneTree] will also pause the timer.
- If [code]process_in_physics[/code] is set to [code]true[/code], will update the [SceneTreeTimer] during the physics frame instead of the process frame (fixed framerate processing).
- If [code]ignore_time_scale[/code] is set to [code]true[/code], will ignore [member Engine.time_scale] and update the [SceneTreeTimer] with the actual frame delta.
+ If [param process_always] is set to [code]false[/code], pausing the [SceneTree] will also pause the timer.
+ If [param process_in_physics] is set to [code]true[/code], will update the [SceneTreeTimer] during the physics frame instead of the process frame (fixed framerate processing).
+ If [param ignore_time_scale] is set to [code]true[/code], will ignore [member Engine.time_scale] and update the [SceneTreeTimer] with the actual frame delta.
Commonly used to create a one-shot delay timer as in the following example:
[codeblocks]
[gdscript]
diff --git a/doc/classes/ScrollContainer.xml b/doc/classes/ScrollContainer.xml
index 3c66478cf5..65814d4359 100644
--- a/doc/classes/ScrollContainer.xml
+++ b/doc/classes/ScrollContainer.xml
@@ -54,9 +54,15 @@
<member name="scroll_horizontal" type="int" setter="set_h_scroll" getter="get_h_scroll" default="0">
The current horizontal scroll value.
</member>
+ <member name="scroll_horizontal_custom_step" type="float" setter="set_horizontal_custom_step" getter="get_horizontal_custom_step" default="-1.0">
+ Overrides the [member ScrollBar.custom_step] used when clicking the internal scroll bar's horizontal increment and decrement buttons or when using arrow keys when the [ScrollBar] is focused.
+ </member>
<member name="scroll_vertical" type="int" setter="set_v_scroll" getter="get_v_scroll" default="0">
The current vertical scroll value.
</member>
+ <member name="scroll_vertical_custom_step" type="float" setter="set_vertical_custom_step" getter="get_vertical_custom_step" default="-1.0">
+ Overrides the [member ScrollBar.custom_step] used when clicking the internal scroll bar's vertical increment and decrement buttons or when using arrow keys when the [ScrollBar] is focused.
+ </member>
<member name="vertical_scroll_mode" type="int" setter="set_vertical_scroll_mode" getter="get_vertical_scroll_mode" enum="ScrollContainer.ScrollMode" default="1">
Controls whether vertical scrollbar can be used and when it should be visible. See [enum ScrollMode] for options.
</member>
diff --git a/doc/classes/ShaderGlobalsOverride.xml b/doc/classes/ShaderGlobalsOverride.xml
index 0a13e9485a..bfa3b9fbcd 100644
--- a/doc/classes/ShaderGlobalsOverride.xml
+++ b/doc/classes/ShaderGlobalsOverride.xml
@@ -1,8 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="ShaderGlobalsOverride" inherits="Node" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
+ Overrides global shader parameters' values in a specific scene.
</brief_description>
<description>
+ Similar to how a [WorldEnvironment] node can be used to override the environment while a specific scene is loaded, [ShaderGlobalsOverride] can be used to override global shader parameters temporarily. Once the node is removed, the project-wide values for the global shader parameters are restored. See the [RenderingServer] [code]global_shader_parameter_*[/code] methods for more information.
+ [b]Note:[/b] Only one [ShaderGlobalsOverride] can be used per scene. If there is more than one [ShaderGlobalsOverride] node in the scene tree, only the first node (in tree order) will be taken into account.
+ [b]Note:[/b] All [ShaderGlobalsOverride] nodes are made part of a [code]"shader_overrides_group"[/code] group when they are added to the scene tree. The currently active [ShaderGlobalsOverride] node also has a [code]"shader_overrides_group_active"[/code] group added to it. You can use this to check which [ShaderGlobalsOverride] node is currently active.
</description>
<tutorials>
</tutorials>
diff --git a/doc/classes/Skeleton2D.xml b/doc/classes/Skeleton2D.xml
index e986eb7a9c..e4b157c7ca 100644
--- a/doc/classes/Skeleton2D.xml
+++ b/doc/classes/Skeleton2D.xml
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="Skeleton2D" inherits="Node2D" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
- Skeleton for 2D characters and animated objects.
+ The parent of a hierarchy of [Bone2D]s, used to create a 2D skeletal animation.
</brief_description>
<description>
- Skeleton2D parents a hierarchy of [Bone2D] objects. It is a requirement of [Bone2D]. Skeleton2D holds a reference to the rest pose of its children and acts as a single point of access to its bones.
- To setup different types of inverse kinematics for the given Skeleton2D, a [SkeletonModificationStack2D] should be created. They can be applied by creating the desired number of modifications, which can be done by increasing [member SkeletonModificationStack2D.modification_count].
+ [Skeleton2D] parents a hierarchy of [Bone2D] nodes. It holds a reference to each [Bone2D]'s rest pose and acts as a single point of access to its bones.
+ To set up different types of inverse kinematics for the given Skeleton2D, a [SkeletonModificationStack2D] should be created. The inverse kinematics be applied by increasing [member SkeletonModificationStack2D.modification_count] and creating the desired number of modifications.
</description>
<tutorials>
<link title="2D skeletons">$DOCS_URL/tutorials/animation/2d_skeletons.html</link>
diff --git a/doc/classes/Skeleton3D.xml b/doc/classes/Skeleton3D.xml
index d562a16a2e..8f40c63104 100644
--- a/doc/classes/Skeleton3D.xml
+++ b/doc/classes/Skeleton3D.xml
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="Skeleton3D" inherits="Node3D" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
- Skeleton for characters and animated objects.
+ A node containing a bone hierarchy, used to create a 3D skeletal animation.
</brief_description>
<description>
- Skeleton3D provides a hierarchical interface for managing bones, including pose, rest and animation (see [Animation]). It can also use ragdoll physics.
+ [Skeleton3D] provides an interface for managing a hierarchy of bones, including pose, rest and animation (see [Animation]). It can also use ragdoll physics.
The overall transform of a bone with respect to the skeleton is determined by the following hierarchical order: rest pose, custom pose and pose.
Note that "global pose" below refers to the overall transform of the bone with respect to skeleton, so it not the actual global/world transform of the bone.
To setup different types of inverse kinematics, consider using [SkeletonIK3D], or add a custom IK implementation in [method Node._process] as a child node.
@@ -300,7 +300,7 @@
<member name="animate_physical_bones" type="bool" setter="set_animate_physical_bones" getter="get_animate_physical_bones" default="true">
</member>
<member name="motion_scale" type="float" setter="set_motion_scale" getter="get_motion_scale" default="1.0">
- Multiplies the position 3D track animation.
+ Multiplies the 3D position track animation.
[b]Note:[/b] Unless this value is [code]1.0[/code], the key value in animation will not match the actual position value.
</member>
<member name="show_rest_only" type="bool" setter="set_show_rest_only" getter="is_show_rest_only" default="false">
diff --git a/doc/classes/SkeletonIK3D.xml b/doc/classes/SkeletonIK3D.xml
index 58cf70df6a..6de86c3b10 100644
--- a/doc/classes/SkeletonIK3D.xml
+++ b/doc/classes/SkeletonIK3D.xml
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="SkeletonIK3D" inherits="Node" is_deprecated="true" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
- SkeletonIK3D is used to place the end bone of a [Skeleton3D] bone chain at a certain point in 3D by rotating all bones in the chain accordingly.
+ A node used to rotate all bones of a [Skeleton3D] bone chain a way that places the end bone at a desired 3D position.
</brief_description>
<description>
- SkeletonIK3D is used to place the end bone of a [Skeleton3D] bone chain at a certain point in 3D by rotating all bones in the chain accordingly. A typical scenario for IK in games is to place a characters feet on the ground or a characters hands on a currently hold object. SkeletonIK uses FabrikInverseKinematic internally to solve the bone chain and applies the results to the [Skeleton3D] [code]bones_global_pose_override[/code] property for all affected bones in the chain. If fully applied this overwrites any bone transform from [Animation]s or bone custom poses set by users. The applied amount can be controlled with the [code]interpolation[/code] property.
+ SkeletonIK3D is used to rotate all bones of a [Skeleton3D] bone chain a way that places the end bone at a desired 3D position. A typical scenario for IK in games is to place a character's feet on the ground or a character's hands on a currently held object. SkeletonIK uses FabrikInverseKinematic internally to solve the bone chain and applies the results to the [Skeleton3D] [code]bones_global_pose_override[/code] property for all affected bones in the chain. If fully applied, this overwrites any bone transform from [Animation]s or bone custom poses set by users. The applied amount can be controlled with the [member interpolation] property.
[codeblock]
# Apply IK effect automatically on every new frame (not the current)
skeleton_ik_node.start()
@@ -45,7 +45,7 @@
<return type="void" />
<param index="0" name="one_time" type="bool" default="false" />
<description>
- Starts applying IK effects on each frame to the [Skeleton3D] bones but will only take effect starting on the next frame. If [code]one_time[/code] is [code]true[/code], this will take effect immediately but also reset on the next frame.
+ Starts applying IK effects on each frame to the [Skeleton3D] bones but will only take effect starting on the next frame. If [param one_time] is [code]true[/code], this will take effect immediately but also reset on the next frame.
</description>
</method>
<method name="stop">
diff --git a/doc/classes/SkeletonModification2D.xml b/doc/classes/SkeletonModification2D.xml
index 88062eb4da..f5fa3f8bb9 100644
--- a/doc/classes/SkeletonModification2D.xml
+++ b/doc/classes/SkeletonModification2D.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="SkeletonModification2D" inherits="Resource" is_experimental="true" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
- A resource that operates on [Bone2D] nodes in a [Skeleton2D].
+ Base class for resources that operate on [Bone2D]s in a [Skeleton2D].
</brief_description>
<description>
This resource provides an interface that can be expanded so code that operates on [Bone2D] nodes in a [Skeleton2D] can be mixed and matched together to create complex interactions.
@@ -38,7 +38,7 @@
<param index="2" name="max" type="float" />
<param index="3" name="invert" type="bool" />
<description>
- Takes a angle and clamps it so it is within the passed-in [param min] and [param max] range. [param invert] will inversely clamp the angle, clamping it to the range outside of the given bounds.
+ Takes an angle and clamps it so it is within the passed-in [param min] and [param max] range. [param invert] will inversely clamp the angle, clamping it to the range outside of the given bounds.
</description>
</method>
<method name="get_editor_draw_gizmo" qualifiers="const">
diff --git a/doc/classes/SkeletonModification2DTwoBoneIK.xml b/doc/classes/SkeletonModification2DTwoBoneIK.xml
index 9a8b9bd8f5..254a8df046 100644
--- a/doc/classes/SkeletonModification2DTwoBoneIK.xml
+++ b/doc/classes/SkeletonModification2DTwoBoneIK.xml
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="SkeletonModification2DTwoBoneIK" inherits="SkeletonModification2D" is_experimental="true" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
- A modification that rotates two bones using the law of cosigns to reach the target.
+ A modification that rotates two bones using the law of cosines to reach the target.
</brief_description>
<description>
- This [SkeletonModification2D] uses an algorithm typically called TwoBoneIK. This algorithm works by leveraging the law of cosigns and the lengths of the bones to figure out what rotation the bones currently have, and what rotation they need to make a complete triangle, where the first bone, the second bone, and the target form the three vertices of the triangle. Because the algorithm works by making a triangle, it can only operate on two bones.
+ This [SkeletonModification2D] uses an algorithm typically called TwoBoneIK. This algorithm works by leveraging the law of cosines and the lengths of the bones to figure out what rotation the bones currently have, and what rotation they need to make a complete triangle, where the first bone, the second bone, and the target form the three vertices of the triangle. Because the algorithm works by making a triangle, it can only operate on two bones.
TwoBoneIK is great for arms, legs, and really any joints that can be represented by just two bones that bend to reach a target. This solver is more lightweight than [SkeletonModification2DFABRIK], but gives similar, natural looking results.
</description>
<tutorials>
diff --git a/doc/classes/SkeletonProfile.xml b/doc/classes/SkeletonProfile.xml
index d6a38e9ee6..1796dabcfd 100644
--- a/doc/classes/SkeletonProfile.xml
+++ b/doc/classes/SkeletonProfile.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="SkeletonProfile" inherits="Resource" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
- Profile of a virtual skeleton used as a target for retargeting.
+ Base class for a profile of a virtual skeleton used as a target for retargeting.
</brief_description>
<description>
This resource is used in [EditorScenePostImport]. Some parameters are referring to bones in [Skeleton3D], [Skin], [Animation], and some other nodes are rewritten based on the parameters of [SkeletonProfile].
diff --git a/doc/classes/Sky.xml b/doc/classes/Sky.xml
index e9f4acd168..4adf4737a1 100644
--- a/doc/classes/Sky.xml
+++ b/doc/classes/Sky.xml
@@ -57,7 +57,7 @@
</constant>
<constant name="PROCESS_MODE_REALTIME" value="3" enum="ProcessMode">
Uses the fast filtering algorithm to process the radiance map. In general this results in lower quality, but substantially faster run times. If you need better quality, but still need to update the sky every frame, consider turning on [member ProjectSettings.rendering/reflections/sky_reflections/fast_filter_high_quality].
- [b]Note:[/b] The fast filtering algorithm is limited to 256x256 cubemaps, so [member radiance_size] must be set to [constant RADIANCE_SIZE_256].
+ [b]Note:[/b] The fast filtering algorithm is limited to 256×256 cubemaps, so [member radiance_size] must be set to [constant RADIANCE_SIZE_256]. Otherwise, a warning is printed and the overridden radiance size is ignored.
</constant>
</constants>
</class>
diff --git a/doc/classes/SoftBody3D.xml b/doc/classes/SoftBody3D.xml
index f6935779d6..bbf51114bd 100644
--- a/doc/classes/SoftBody3D.xml
+++ b/doc/classes/SoftBody3D.xml
@@ -69,7 +69,7 @@
<param index="0" name="layer_number" type="int" />
<param index="1" name="value" type="bool" />
<description>
- Based on [code]value[/code], enables or disables the specified layer in the [member collision_layer], given a [param layer_number] between 1 and 32.
+ Based on [param value], enables or disables the specified layer in the [member collision_layer], given a [param layer_number] between 1 and 32.
</description>
</method>
<method name="set_collision_mask_value">
@@ -77,7 +77,7 @@
<param index="0" name="layer_number" type="int" />
<param index="1" name="value" type="bool" />
<description>
- Based on [code]value[/code], enables or disables the specified layer in the [member collision_mask], given a [param layer_number] between 1 and 32.
+ Based on [param value], enables or disables the specified layer in the [member collision_mask], given a [param layer_number] between 1 and 32.
</description>
</method>
<method name="set_point_pinned">
diff --git a/doc/classes/StreamPeerTLS.xml b/doc/classes/StreamPeerTLS.xml
index aa132f5e86..8cf0b646a5 100644
--- a/doc/classes/StreamPeerTLS.xml
+++ b/doc/classes/StreamPeerTLS.xml
@@ -4,7 +4,7 @@
TLS stream peer.
</brief_description>
<description>
- TLS stream peer. This object can be used to connect to an TLS server or accept a single TLS client connection.
+ TLS stream peer. This object can be used to connect to a TLS server or accept a single TLS 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>
diff --git a/doc/classes/String.xml b/doc/classes/String.xml
index fd50b308c3..d771566688 100644
--- a/doc/classes/String.xml
+++ b/doc/classes/String.xml
@@ -175,6 +175,14 @@
Returns [code]true[/code] if the string ends with the given [param text]. See also [method begins_with].
</description>
</method>
+ <method name="erase" qualifiers="const">
+ <return type="String" />
+ <param index="0" name="position" type="int" />
+ <param index="1" name="chars" type="int" default="1" />
+ <description>
+ Returns a string with [param chars] characters erased starting from [param position]. If [param chars] goes beyond the string's length given the specified [param position], fewer characters will be erased from the returned string. Returns an empty string if either [code]position[/code] or [code]chars[/code] is negative. Returns the original string unmodified if [param chars] is [code]0[/code].
+ </description>
+ </method>
<method name="find" qualifiers="const">
<return type="int" />
<param index="0" name="what" type="String" />
diff --git a/doc/classes/StringName.xml b/doc/classes/StringName.xml
index 5b630a092e..a74b78f7e3 100644
--- a/doc/classes/StringName.xml
+++ b/doc/classes/StringName.xml
@@ -158,6 +158,14 @@
Returns [code]true[/code] if the string ends with the given [param text]. See also [method begins_with].
</description>
</method>
+ <method name="erase" qualifiers="const">
+ <return type="String" />
+ <param index="0" name="position" type="int" />
+ <param index="1" name="chars" type="int" default="1" />
+ <description>
+ Returns a string with [param chars] characters erased starting from [param position]. If [param chars] goes beyond the string's length given the specified [param position], fewer characters will be erased from the returned string. Returns an empty string if either [code]position[/code] or [code]chars[/code] is negative. Returns the original string unmodified if [param chars] is [code]0[/code].
+ </description>
+ </method>
<method name="find" qualifiers="const">
<return type="int" />
<param index="0" name="what" type="String" />
diff --git a/doc/classes/SyntaxHighlighter.xml b/doc/classes/SyntaxHighlighter.xml
index 79f4944bae..34063adbb0 100644
--- a/doc/classes/SyntaxHighlighter.xml
+++ b/doc/classes/SyntaxHighlighter.xml
@@ -5,7 +5,7 @@
</brief_description>
<description>
Base syntax highlighter resource all syntax highlighters extend from, provides syntax highlighting data to [TextEdit].
- The associated [TextEdit] node will call into the [SyntaxHighlighter] on a as needed basis.
+ The associated [TextEdit] node will call into the [SyntaxHighlighter] on an as-needed basis.
[b]Note:[/b] Each Syntax highlighter instance should not be shared across multiple [TextEdit] nodes.
</description>
<tutorials>
diff --git a/doc/classes/TextEdit.xml b/doc/classes/TextEdit.xml
index a1552982ae..bf66d27ac6 100644
--- a/doc/classes/TextEdit.xml
+++ b/doc/classes/TextEdit.xml
@@ -867,7 +867,7 @@
<description>
Moves the caret to the specified [param line] index.
If [param adjust_viewport] is [code]true[/code], the viewport will center at the caret position after the move occurs.
- If [param can_be_hidden] is [code]true[/code], the specified [code]line[/code] can be hidden.
+ If [param can_be_hidden] is [code]true[/code], the specified [param line] can be hidden.
[b]Note:[/b] If supporting multiple carets this will not check for any overlap. See [method merge_overlapping_carets].
</description>
</method>
@@ -1061,7 +1061,7 @@
<return type="void" />
<param index="0" name="action" type="int" enum="TextEdit.EditAction" />
<description>
- Starts an action, will end the current action if [code]action[/code] is different.
+ Starts an action, will end the current action if [param action] is different.
An action will also end after a call to [method end_action], after [member ProjectSettings.gui/timers/text_edit_idle_detect_sec] is triggered or a new undoable step outside the [method start_action] and [method end_action] calls.
</description>
</method>
diff --git a/doc/classes/TextServerDummy.xml b/doc/classes/TextServerDummy.xml
index 4770a641dc..4e72b3c5f8 100644
--- a/doc/classes/TextServerDummy.xml
+++ b/doc/classes/TextServerDummy.xml
@@ -1,8 +1,22 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="TextServerDummy" inherits="TextServerExtension" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
+ A dummy text server that can't render text or manage fonts.
</brief_description>
<description>
+ A dummy [TextServer] interface that doesn't do anything. Useful for freeing up memory when rendering text is not needed, as text servers are resource-intensive. It can also be used for performance comparisons in complex GUIs to check the impact of text rendering.
+ A dummy text server is always available at the start of a project. Here's how to access it:
+ [codeblock]
+ var dummy_text_server = TextServerManager.find_interface("Dummy")
+ if dummy_text_server != null:
+ TextServerManager.set_primary_interface(dummy_text_server)
+ # If the other text servers are unneeded, they can be removed:
+ for i in TextServerManager.get_interface_count():
+ var text_server = TextServerManager.get_interface(i)
+ if text_server != dummy_text_server:
+ TextServerManager.remove_interface(text_server)
+ [/codeblock]
+ The command line argument [code]--text-driver Dummy[/code] (case-sensitive) can be used to force the "Dummy" [TextServer] on any project.
</description>
<tutorials>
</tutorials>
diff --git a/doc/classes/TileMap.xml b/doc/classes/TileMap.xml
index 2dd6a1a54e..d4ba3ebb1f 100644
--- a/doc/classes/TileMap.xml
+++ b/doc/classes/TileMap.xml
@@ -134,6 +134,13 @@
Returns the coordinates of the tile for given physics body RID. Such RID can be retrieved from [method KinematicCollision2D.get_collider_rid], when colliding with a tile.
</description>
</method>
+ <method name="get_layer_for_body_rid">
+ <return type="int" />
+ <param index="0" name="body" type="RID" />
+ <description>
+ Returns the tilemap layer of the tile for given physics body RID. Such RID can be retrieved from [method KinematicCollision2D.get_collider_rid], when colliding with a tile.
+ </description>
+ </method>
<method name="get_layer_modulate" qualifiers="const">
<return type="Color" />
<param index="0" name="layer" type="int" />
@@ -303,7 +310,7 @@
<description>
Update all the cells in the [param cells] coordinates array so that they use the given [param terrain] for the given [param terrain_set]. If an updated cell has the same terrain as one of its neighboring cells, this function tries to join the two. This function might update neighboring tiles if needed to create correct terrain transitions.
If [param ignore_empty_terrains] is true, empty terrains will be ignored when trying to find the best fitting tile for the given terrain constraints.
- [b]Note:[/b] To work correctly, [code]set_cells_terrain_connect[/code] requires the TileMap's TileSet to have terrains set up with all required terrain combinations. Otherwise, it may produce unexpected results.
+ [b]Note:[/b] To work correctly, this method requires the TileMap's TileSet to have terrains set up with all required terrain combinations. Otherwise, it may produce unexpected results.
</description>
</method>
<method name="set_cells_terrain_path">
@@ -316,7 +323,7 @@
<description>
Update all the cells in the [param path] coordinates array so that they use the given [param terrain] for the given [param terrain_set]. The function will also connect two successive cell in the path with the same terrain. This function might update neighboring tiles if needed to create correct terrain transitions.
If [param ignore_empty_terrains] is true, empty terrains will be ignored when trying to find the best fitting tile for the given terrain constraints.
- [b]Note:[/b] To work correctly, [code]set_cells_terrain_path[/code] requires the TileMap's TileSet to have terrains set up with all required terrain combinations. Otherwise, it may produce unexpected results.
+ [b]Note:[/b] To work correctly, this method requires the TileMap's TileSet to have terrains set up with all required terrain combinations. Otherwise, it may produce unexpected results.
</description>
</method>
<method name="set_layer_enabled">
@@ -334,7 +341,7 @@
<param index="1" name="modulate" type="Color" />
<description>
Sets a layer's color. It will be multiplied by tile's color and TileMap's modulate.
- If [code]layer[/code] is negative, the layers are accessed from the last one.
+ If [param layer] is negative, the layers are accessed from the last one.
</description>
</method>
<method name="set_layer_name">
@@ -343,7 +350,7 @@
<param index="1" name="name" type="String" />
<description>
Sets a layer's name. This is mostly useful in the editor.
- If [code]layer[/code] is negative, the layers are accessed from the last one.
+ If [param layer] is negative, the layers are accessed from the last one.
</description>
</method>
<method name="set_layer_y_sort_enabled">
@@ -353,7 +360,7 @@
<description>
Enables or disables a layer's Y-sorting. If a layer is Y-sorted, the layer will behave as a CanvasItem node where each of its tile gets Y-sorted.
Y-sorted layers should usually be on different Z-index values than not Y-sorted layers, otherwise, each of those layer will be Y-sorted as whole with the Y-sorted one. This is usually an undesired behavior.
- If [code]layer[/code] is negative, the layers are accessed from the last one.
+ If [param layer] is negative, the layers are accessed from the last one.
</description>
</method>
<method name="set_layer_y_sort_origin">
@@ -363,7 +370,7 @@
<description>
Sets a layer's Y-sort origin value. This Y-sort origin value is added to each tile's Y-sort origin value.
This allows, for example, to fake a different height level on each layer. This can be useful for top-down view games.
- If [code]layer[/code] is negative, the layers are accessed from the last one.
+ If [param layer] is negative, the layers are accessed from the last one.
</description>
</method>
<method name="set_layer_z_index">
@@ -372,7 +379,7 @@
<param index="1" name="z_index" type="int" />
<description>
Sets a layers Z-index value. This Z-index is added to each tile's Z-index value.
- If [code]layer[/code] is negative, the layers are accessed from the last one.
+ If [param layer] is negative, the layers are accessed from the last one.
</description>
</method>
<method name="set_navigation_map">
@@ -401,7 +408,7 @@
</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.
+ [b]Note:[/b] Enabling [member collision_animatable] 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 [constant VISIBILITY_MODE_DEFAULT], this depends on the show collision debug settings.
diff --git a/doc/classes/TileSet.xml b/doc/classes/TileSet.xml
index be6b15fb0d..f80151b722 100644
--- a/doc/classes/TileSet.xml
+++ b/doc/classes/TileSet.xml
@@ -8,7 +8,7 @@
Tiles can either be from a [TileSetAtlasSource], that render tiles out of a texture with support for physics, navigation, etc... or from a [TileSetScenesCollectionSource] which exposes scene-based tiles.
Tiles are referenced by using three IDs: their source ID, their atlas coordinates ID and their alternative tile ID.
A TileSet can be configured so that its tiles expose more or less properties. To do so, the TileSet resources uses property layers, that you can add or remove depending on your needs.
- For example, adding a physics layer allows giving collision shapes to your tiles. Each layer having dedicated properties (physics layer an mask), you may add several TileSet physics layers for each type of collision you need.
+ For example, adding a physics layer allows giving collision shapes to your tiles. Each layer having dedicated properties (physics layer and mask), you may add several TileSet physics layers for each type of collision you need.
See the functions to add new layers for more information.
</description>
<tutorials>
diff --git a/doc/classes/TileSetScenesCollectionSource.xml b/doc/classes/TileSetScenesCollectionSource.xml
index 2bb4146798..e1a3b3e788 100644
--- a/doc/classes/TileSetScenesCollectionSource.xml
+++ b/doc/classes/TileSetScenesCollectionSource.xml
@@ -79,7 +79,7 @@
<param index="0" name="id" type="int" />
<param index="1" name="new_id" type="int" />
<description>
- Changes a scene tile's ID from [param id] to [param new_id]. This will fail if there is already a tile with a ID equal to [param new_id].
+ Changes a scene tile's ID from [param id] to [param new_id]. This will fail if there is already a tile with an ID equal to [param new_id].
</description>
</method>
<method name="set_scene_tile_scene">
diff --git a/doc/classes/Timer.xml b/doc/classes/Timer.xml
index 1205f1627c..2f76f0d27a 100644
--- a/doc/classes/Timer.xml
+++ b/doc/classes/Timer.xml
@@ -5,6 +5,7 @@
</brief_description>
<description>
Counts down a specified interval and emits a signal on reaching 0. Can be set to repeat or "one-shot" mode.
+ [b]Note:[/b] Timers are affected by [member Engine.time_scale], a higher scale means quicker timeouts, and vice versa.
[b]Note:[/b] To create a one-shot timer without instantiating a node, use [method SceneTree.create_timer].
</description>
<tutorials>
@@ -52,7 +53,7 @@
</member>
<member name="wait_time" type="float" setter="set_wait_time" getter="get_wait_time" default="1.0">
The wait time in seconds.
- [b]Note:[/b] Timers can only emit once per rendered frame at most (or once per physics frame if [member process_callback] is [constant TIMER_PROCESS_PHYSICS]). This means very low wait times (lower than 0.05 seconds) will behave in significantly different ways depending on the rendered framerate. For very low wait times, it is recommended to use a process loop in a script instead of using a Timer node.
+ [b]Note:[/b] Timers can only emit once per rendered frame at most (or once per physics frame if [member process_callback] is [constant TIMER_PROCESS_PHYSICS]). This means very low wait times (lower than 0.05 seconds) will behave in significantly different ways depending on the rendered framerate. For very low wait times, it is recommended to use a process loop in a script instead of using a Timer node. Timers are affected by [member Engine.time_scale], a higher scale means quicker timeouts, and vice versa.
</member>
</members>
<signals>
diff --git a/doc/classes/Tree.xml b/doc/classes/Tree.xml
index 1e4282cd0b..2a3cba3a44 100644
--- a/doc/classes/Tree.xml
+++ b/doc/classes/Tree.xml
@@ -335,6 +335,9 @@
<member name="allow_rmb_select" type="bool" setter="set_allow_rmb_select" getter="get_allow_rmb_select" default="false">
If [code]true[/code], a right mouse button click can select items.
</member>
+ <member name="allow_search" type="bool" setter="set_allow_search" getter="get_allow_search" default="true">
+ If [code]true[/code], allows navigating the [Tree] with letter keys through incremental search.
+ </member>
<member name="clip_contents" type="bool" setter="set_clip_contents" getter="is_clipping_contents" overrides="Control" default="true" />
<member name="column_titles_visible" type="bool" setter="set_column_titles_visible" getter="are_column_titles_visible" default="false">
If [code]true[/code], column titles are visible.
diff --git a/doc/classes/TreeItem.xml b/doc/classes/TreeItem.xml
index 49b4622aed..b97b4bf17d 100644
--- a/doc/classes/TreeItem.xml
+++ b/doc/classes/TreeItem.xml
@@ -350,6 +350,13 @@
<description>
</description>
</method>
+ <method name="is_edit_multiline" qualifiers="const">
+ <return type="bool" />
+ <param index="0" name="column" type="int" />
+ <description>
+ Returns [code]true[/code] if the given [param column] is multiline editable.
+ </description>
+ </method>
<method name="is_editable">
<return type="bool" />
<param index="0" name="column" type="int" />
@@ -456,7 +463,7 @@
<param index="0" name="column" type="int" />
<param index="1" name="checked" type="bool" />
<description>
- If [code]true[/code], the given [param column] is checked. Clears column's indeterminate status.
+ If [param checked] is [code]true[/code], the given [param column] is checked. Clears column's indeterminate status.
</description>
</method>
<method name="set_collapsed_recursive">
@@ -516,12 +523,21 @@
Sets custom font size used to draw text in the given [param column].
</description>
</method>
+ <method name="set_edit_multiline">
+ <return type="void" />
+ <param index="0" name="column" type="int" />
+ <param index="1" name="multiline" type="bool" />
+ <description>
+ If [param multiline] is [code]true[/code], the given [param column] is multiline editable.
+ [b]Note:[/b] This option only affects the type of control ([LineEdit] or [TextEdit]) that appears when editing the column. You can set multiline values with [method set_text] even if the column is not multiline editable.
+ </description>
+ </method>
<method name="set_editable">
<return type="void" />
<param index="0" name="column" type="int" />
<param index="1" name="enabled" type="bool" />
<description>
- If [code]true[/code], the given [param column] is editable.
+ If [param enabled] is [code]true[/code], the given [param column] is editable.
</description>
</method>
<method name="set_expand_right">
@@ -529,7 +545,7 @@
<param index="0" name="column" type="int" />
<param index="1" name="enable" type="bool" />
<description>
- If [code]true[/code], the given [param column] is expanded to the right.
+ If [param enable] is [code]true[/code], the given [param column] is expanded to the right.
</description>
</method>
<method name="set_icon">
@@ -569,7 +585,7 @@
<param index="0" name="column" type="int" />
<param index="1" name="indeterminate" type="bool" />
<description>
- If [code]true[/code], the given [param column] is marked [param indeterminate].
+ If [param indeterminate] is [code]true[/code], the given [param column] is marked indeterminate.
[b]Note:[/b] If set [code]true[/code] from [code]false[/code], then column is cleared of checked status.
</description>
</method>
@@ -614,7 +630,7 @@
<param index="0" name="column" type="int" />
<param index="1" name="selectable" type="bool" />
<description>
- If [code]true[/code], the given column is selectable.
+ If [param selectable] is [code]true[/code], the given [param column] is selectable.
</description>
</method>
<method name="set_structured_text_bidi_override">
diff --git a/doc/classes/TubeTrailMesh.xml b/doc/classes/TubeTrailMesh.xml
index aa238af782..e6d446bd60 100644
--- a/doc/classes/TubeTrailMesh.xml
+++ b/doc/classes/TubeTrailMesh.xml
@@ -1,10 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="TubeTrailMesh" inherits="PrimitiveMesh" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
+ Represents a straight tube-shaped [PrimitiveMesh] with variable width.
</brief_description>
<description>
+ [TubeTrailMesh] represents a straight tube-shaped mesh with variable width. The tube is composed of a number of cylindrical sections, each with the same [member section_length] and number of [member section_rings]. A [member curve] is sampled along the total length of the tube, meaning that the curve determines the radius of the tube along its length.
+ This primitive mesh is usually used for particle trails.
</description>
<tutorials>
+ <link title="3D Particle trails">$DOCS_URL/tutorials/3d/particles/trails.html</link>
+ <link title="Particle systems (3D)">$DOCS_URL/tutorials/3d/particles/index.html</link>
</tutorials>
<members>
<member name="cap_bottom" type="bool" setter="set_cap_bottom" getter="is_cap_bottom" default="true">
@@ -14,16 +19,22 @@
If [code]true[/code], generates a cap at the top of the tube. This can be set to [code]false[/code] to speed up generation and rendering when the cap is never seen by the camera.
</member>
<member name="curve" type="Curve" setter="set_curve" getter="get_curve">
+ Determines the radius of the tube along its length. The radius of a particular section ring is obtained by multiplying the baseline [member radius] by the value of this curve at the given distance. For values smaller than [code]0[/code], the faces will be inverted.
</member>
<member name="radial_steps" type="int" setter="set_radial_steps" getter="get_radial_steps" default="8">
+ The number of sides on the tube. For example, a value of [code]5[/code] means the tube will be pentagonal. Higher values result in a more detailed tube at the cost of performance.
</member>
<member name="radius" type="float" setter="set_radius" getter="get_radius" default="0.5">
+ The baseline radius of the tube. The radius of a particular section ring is obtained by multiplying this radius by the value of the [member curve] at the given distance.
</member>
<member name="section_length" type="float" setter="set_section_length" getter="get_section_length" default="0.2">
+ The length of a section of the tube.
</member>
<member name="section_rings" type="int" setter="set_section_rings" getter="get_section_rings" default="3">
+ The number of rings in a section. The [member curve] is sampled on each ring to determine its radius. Higher values result in a more detailed tube at the cost of performance.
</member>
<member name="sections" type="int" setter="set_sections" getter="get_sections" default="5">
+ The total number of sections on the tube.
</member>
</members>
</class>
diff --git a/doc/classes/VSlider.xml b/doc/classes/VSlider.xml
index 4a203d2443..b1906ccef2 100644
--- a/doc/classes/VSlider.xml
+++ b/doc/classes/VSlider.xml
@@ -14,6 +14,9 @@
<member name="size_flags_vertical" type="int" setter="set_v_size_flags" getter="get_v_size_flags" overrides="Control" enum="Control.SizeFlags" default="1" />
</members>
<theme_items>
+ <theme_item name="center_grabber" data_type="constant" type="int" default="0">
+ Boolean constant. If [code]1[/code], the grabber texture size will be ignored and it will fit within slider's bounds based only on its center position.
+ </theme_item>
<theme_item name="grabber_offset" data_type="constant" type="int" default="0">
Horizontal offset of the grabber.
</theme_item>
diff --git a/doc/classes/VideoStreamPlayback.xml b/doc/classes/VideoStreamPlayback.xml
index a81d011e9d..be3b0d4950 100644
--- a/doc/classes/VideoStreamPlayback.xml
+++ b/doc/classes/VideoStreamPlayback.xml
@@ -61,21 +61,21 @@
<return type="void" />
<param index="0" name="time" type="float" />
<description>
- Seeks to [code]time[/code] seconds. Called in response to the [member VideoStreamPlayer.stream_position] setter.
+ Seeks to [param time] seconds. Called in response to the [member VideoStreamPlayer.stream_position] setter.
</description>
</method>
<method name="_set_audio_track" qualifiers="virtual">
<return type="void" />
<param index="0" name="idx" type="int" />
<description>
- Select the audio track [code]idx[/code]. Called when playback starts, and in response to the [member VideoStreamPlayer.audio_track] setter.
+ Select the audio track [param idx]. Called when playback starts, and in response to the [member VideoStreamPlayer.audio_track] setter.
</description>
</method>
<method name="_set_paused" qualifiers="virtual">
<return type="void" />
<param index="0" name="paused" type="bool" />
<description>
- Set the paused status of video playback. [method _is_paused] must return [code]paused[/code]. Called in response to the [member VideoStreamPlayer.paused] setter.
+ Set the paused status of video playback. [method _is_paused] must return [param paused]. Called in response to the [member VideoStreamPlayer.paused] setter.
</description>
</method>
<method name="_stop" qualifiers="virtual">
@@ -88,7 +88,7 @@
<return type="void" />
<param index="0" name="delta" type="float" />
<description>
- Ticks video playback for [code]delta[/code] seconds. Called every frame as long as [method _is_paused] and [method _is_playing] return true.
+ Ticks video playback for [param delta] seconds. Called every frame as long as [method _is_paused] and [method _is_playing] return true.
</description>
</method>
<method name="mix_audio">
@@ -97,7 +97,7 @@
<param index="1" name="buffer" type="PackedFloat32Array" default="PackedFloat32Array()" />
<param index="2" name="offset" type="int" default="0" />
<description>
- Render [code]num_frames[/code] audio frames (of [method _get_channels] floats each) from [code]buffer[/code], starting from index [code]offset[/code] in the array. Returns the number of audio frames rendered, or -1 on error.
+ Render [param num_frames] audio frames (of [method _get_channels] floats each) from [param buffer], starting from index [param offset] in the array. Returns the number of audio frames rendered, or -1 on error.
</description>
</method>
</methods>
diff --git a/doc/classes/Viewport.xml b/doc/classes/Viewport.xml
index 7c131202c8..81838f397f 100644
--- a/doc/classes/Viewport.xml
+++ b/doc/classes/Viewport.xml
@@ -284,6 +284,7 @@
[b]Note:[/b] This setting is disabled by default because of its potential expensive computational cost.
</member>
<member name="positional_shadow_atlas_16_bits" type="bool" setter="set_positional_shadow_atlas_16_bits" getter="get_positional_shadow_atlas_16_bits" default="true">
+ Use 16 bits for the omni/spot shadow depth map. Enabling this results in shadows having less precision and may result in shadow acne, but can lead to performance improvements on some devices.
</member>
<member name="positional_shadow_atlas_quad_0" type="int" setter="set_positional_shadow_atlas_quadrant_subdiv" getter="get_positional_shadow_atlas_quadrant_subdiv" enum="Viewport.PositionalShadowAtlasQuadrantSubdiv" default="2">
The subdivision amount of the first quadrant on the shadow atlas.
@@ -298,8 +299,8 @@
The subdivision amount of the fourth quadrant on the shadow atlas.
</member>
<member name="positional_shadow_atlas_size" type="int" setter="set_positional_shadow_atlas_size" getter="get_positional_shadow_atlas_size" default="2048">
- The shadow atlas' resolution (used for omni and spot lights). The value will be rounded up to the nearest power of 2.
- [b]Note:[/b] If this is set to [code]0[/code], no shadows will be visible at all (including directional shadows).
+ The shadow atlas' resolution (used for omni and spot lights). The value is rounded up to the nearest power of 2.
+ [b]Note:[/b] If this is set to [code]0[/code], no positional shadows will be visible at all. This can improve performance significantly on low-end systems by reducing both the CPU and GPU load (as fewer draw calls are needed to draw the scene without shadows).
</member>
<member name="scaling_3d_mode" type="int" setter="set_scaling_3d_mode" getter="get_scaling_3d_mode" enum="Viewport.Scaling3DMode" default="0">
Sets scaling 3d mode. Bilinear scaling renders at different resolution to either undersample or supersample the viewport. FidelityFX Super Resolution 1.0, abbreviated to FSR, is an upscaling technology that produces high quality images at fast framerates by using a spatially aware upscaling algorithm. FSR is slightly more expensive than bilinear, but it produces significantly higher image quality. FSR should be used where possible.
diff --git a/doc/classes/VisualInstance3D.xml b/doc/classes/VisualInstance3D.xml
index c563c0e014..6e7042431b 100644
--- a/doc/classes/VisualInstance3D.xml
+++ b/doc/classes/VisualInstance3D.xml
@@ -36,7 +36,7 @@
<return type="bool" />
<param index="0" name="layer_number" type="int" />
<description>
- Returns whether or not the specified layer of the [member layers] is enabled, given a [code]layer_number[/code] between 1 and 20.
+ Returns whether or not the specified layer of the [member layers] is enabled, given a [param layer_number] between 1 and 20.
</description>
</method>
<method name="set_base">
diff --git a/doc/classes/VoxelGI.xml b/doc/classes/VoxelGI.xml
index d72139d483..a019eac910 100644
--- a/doc/classes/VoxelGI.xml
+++ b/doc/classes/VoxelGI.xml
@@ -20,7 +20,7 @@
<param index="0" name="from_node" type="Node" default="null" />
<param index="1" name="create_visual_debug" type="bool" default="false" />
<description>
- Bakes the effect from all [GeometryInstance3D]s marked with [constant GeometryInstance3D.GI_MODE_STATIC] and [Light3D]s marked with either [constant Light3D.BAKE_STATIC] or [constant Light3D.BAKE_DYNAMIC]. If [code]create_visual_debug[/code] is [code]true[/code], after baking the light, this will generate a [MultiMesh] that has a cube representing each solid cell with each cube colored to the cell's albedo color. This can be used to visualize the [VoxelGI]'s data and debug any issues that may be occurring.
+ Bakes the effect from all [GeometryInstance3D]s marked with [constant GeometryInstance3D.GI_MODE_STATIC] and [Light3D]s marked with either [constant Light3D.BAKE_STATIC] or [constant Light3D.BAKE_DYNAMIC]. If [param create_visual_debug] is [code]true[/code], after baking the light, this will generate a [MultiMesh] that has a cube representing each solid cell with each cube colored to the cell's albedo color. This can be used to visualize the [VoxelGI]'s data and debug any issues that may be occurring.
[b]Note:[/b] [method bake] works from the editor and in exported projects. This makes it suitable for procedurally generated or user-built levels. Baking a [VoxelGI] node generally takes from 5 to 20 seconds in most scenes. Reducing [member subdiv] can speed up baking.
[b]Note:[/b] [GeometryInstance3D]s and [Light3D]s must be fully ready before [method bake] is called. If you are procedurally creating those and some meshes or lights are missing from your baked [VoxelGI], use [code]call_deferred("bake")[/code] instead of calling [method bake] directly.
</description>
diff --git a/doc/classes/Window.xml b/doc/classes/Window.xml
index 87fef49aac..336d73290f 100644
--- a/doc/classes/Window.xml
+++ b/doc/classes/Window.xml
@@ -348,16 +348,14 @@
<return type="void" />
<param index="0" name="rect" type="Rect2i" default="Rect2i(0, 0, 0, 0)" />
<description>
- Shows the [Window] and makes it transient (see [member transient]). If [param rect] is provided, it will be set as the [Window]'s size.
- Fails if called on the main window.
+ Shows the [Window] and makes it transient (see [member transient]). If [param rect] is provided, it will be set as the [Window]'s size. Fails if called on the main window.
</description>
</method>
<method name="popup_centered">
<return type="void" />
<param index="0" name="minsize" type="Vector2i" default="Vector2i(0, 0)" />
<description>
- Popups the [Window] at the center of the current screen, with optionally given minimum size.
- If the [Window] is embedded, it will be centered in the parent [Viewport] instead.
+ Popups the [Window] at the center of the current screen, with optionally given minimum size. If the [Window] is embedded, it will be centered in the parent [Viewport] instead.
[b]Note:[/b] Calling it with the default value of [param minsize] is equivalent to calling it with [member size].
</description>
</method>
@@ -366,8 +364,7 @@
<param index="0" name="minsize" type="Vector2i" default="Vector2i(0, 0)" />
<param index="1" name="fallback_ratio" type="float" default="0.75" />
<description>
- Popups the [Window] centered inside its parent [Window].
- [code]fallback_ratio[/code] determines the maximum size of the [Window], in relation to its parent.
+ Popups the [Window] centered inside its parent [Window]. [param fallback_ratio] determines the maximum size of the [Window], in relation to its parent.
[b]Note:[/b] Calling it with the default value of [param minsize] is equivalent to calling it with [member size].
</description>
</method>
@@ -382,8 +379,7 @@
<return type="void" />
<param index="0" name="parent_rect" type="Rect2i" />
<description>
- Popups the [Window] with a position shifted by parent [Window]'s position.
- If the [Window] is embedded, has the same effect as [method popup].
+ Popups the [Window] with a position shifted by parent [Window]'s position. If the [Window] is embedded, has the same effect as [method popup].
</description>
</method>
<method name="remove_theme_color_override">
@@ -567,6 +563,7 @@
</member>
<member name="position" type="Vector2i" setter="set_position" getter="get_position" default="Vector2i(0, 0)">
The window's position in pixels.
+ If [member ProjectSettings.display/window/subwindows/embed_subwindows] is [code]false[/code], the position is in absolute screen coordinates. This typically applies to editor plugins. If the setting is [code]false[/code], the window's position is in the coordinates of its parent [Viewport].
</member>
<member name="size" type="Vector2i" setter="set_size" getter="get_size" default="Vector2i(100, 100)">
The window's size in pixels.
@@ -714,7 +711,7 @@
Regardless of the platform, enabling full screen will change the window size to match the monitor's size. Therefore, make sure your project supports [url=$DOCS_URL/tutorials/rendering/multiple_resolutions.html]multiple resolutions[/url] when enabling full screen mode.
</constant>
<constant name="FLAG_RESIZE_DISABLED" value="0" enum="Flags">
- The window can't be resizing by dragging its resize grip. It's still possible to resize the window using [member size]. This flag is ignored for full screen windows. Set with [member unresizable].
+ The window can't be resized by dragging its resize grip. It's still possible to resize the window using [member size]. This flag is ignored for full screen windows. Set with [member unresizable].
</constant>
<constant name="FLAG_BORDERLESS" value="1" enum="Flags">
The window do not have native title bar and other decorations. This flag is ignored for full-screen windows. Set with [member borderless].
diff --git a/doc/classes/X509Certificate.xml b/doc/classes/X509Certificate.xml
index 6123d35d1f..a55e7d09b9 100644
--- a/doc/classes/X509Certificate.xml
+++ b/doc/classes/X509Certificate.xml
@@ -5,7 +5,7 @@
</brief_description>
<description>
The X509Certificate class represents an X509 certificate. Certificates can be loaded and saved like any other [Resource].
- They can be used as the server certificate in [method StreamPeerTLS.accept_stream] (along with the proper [CryptoKey]), and to specify the only certificate that should be accepted when connecting to an TLS server via [method StreamPeerTLS.connect_to_stream].
+ They can be used as the server certificate in [method StreamPeerTLS.accept_stream] (along with the proper [CryptoKey]), and to specify the only certificate that should be accepted when connecting to a TLS server via [method StreamPeerTLS.connect_to_stream].
</description>
<tutorials>
</tutorials>
diff --git a/doc/tools/make_rst.py b/doc/tools/make_rst.py
index 3655a60c35..2594fa8cbd 100755
--- a/doc/tools/make_rst.py
+++ b/doc/tools/make_rst.py
@@ -33,6 +33,7 @@ BASE_STRINGS = [
"Globals",
"Nodes",
"Resources",
+ "Editor-only",
"Other objects",
"Variant types",
"Description",
@@ -74,13 +75,22 @@ CLASS_GROUPS: Dict[str, str] = {
"node": "Nodes",
"resource": "Resources",
"object": "Other objects",
+ "editor": "Editor-only",
"variant": "Variant types",
}
CLASS_GROUPS_BASE: Dict[str, str] = {
"node": "Node",
"resource": "Resource",
"object": "Object",
+ "variant": "Variant",
}
+# Sync with editor\register_editor_types.cpp
+EDITOR_CLASSES: List[str] = [
+ "FileSystemDock",
+ "ScriptCreateDialog",
+ "ScriptEditor",
+ "ScriptEditorBase",
+]
class State:
@@ -635,6 +645,11 @@ def main() -> None:
grouped_classes[group_name] = []
grouped_classes[group_name].append(class_name)
+ if is_editor_class(class_def):
+ if "editor" not in grouped_classes:
+ grouped_classes["editor"] = []
+ grouped_classes["editor"].append(class_name)
+
print("")
print("Generating the index file...")
@@ -724,6 +739,17 @@ def get_class_group(class_def: ClassDef, state: State) -> str:
return group_name
+def is_editor_class(class_def: ClassDef) -> bool:
+ class_name = class_def.name
+
+ if class_name.startswith("Editor"):
+ return True
+ if class_name in EDITOR_CLASSES:
+ return True
+
+ return False
+
+
# Generator methods.
@@ -1472,6 +1498,9 @@ def make_rst_index(grouped_classes: Dict[str, List[str]], dry_run: bool, output_
f.write(f" class_{CLASS_GROUPS_BASE[group_name].lower()}\n")
for class_name in grouped_classes[group_name]:
+ if group_name in CLASS_GROUPS_BASE and CLASS_GROUPS_BASE[group_name].lower() == class_name.lower():
+ continue
+
f.write(f" class_{class_name.lower()}\n")
f.write("\n")
@@ -1649,6 +1678,26 @@ def format_text_block(
inside_code_tag = cmd
escape_pre = True
+ valid_context = isinstance(context, (MethodDef, SignalDef, AnnotationDef))
+ if valid_context:
+ endcode_pos = text.find("[/code]", endq_pos + 1)
+ if endcode_pos == -1:
+ print_error(
+ f"{state.current_class}.xml: Tag depth mismatch for [code]: no closing [/code] in {context_name}.",
+ state,
+ )
+ break
+
+ inside_code_text = text[endq_pos + 1 : endcode_pos]
+ context_params: List[ParameterDef] = context.parameters # type: ignore
+ for param_def in context_params:
+ if param_def.name == inside_code_text:
+ print_warning(
+ f'{state.current_class}.xml: Potential error inside of a code tag, found a string "{inside_code_text}" that matches one of the parameters in {context_name}.',
+ state,
+ )
+ break
+
# Cross-references to items in this or other class documentation pages.
elif is_in_tagset(cmd, RESERVED_CROSSLINK_TAGS):
link_type: str = ""
diff --git a/drivers/alsa/audio_driver_alsa.cpp b/drivers/alsa/audio_driver_alsa.cpp
index 6095fef035..966137920a 100644
--- a/drivers/alsa/audio_driver_alsa.cpp
+++ b/drivers/alsa/audio_driver_alsa.cpp
@@ -44,7 +44,8 @@ extern int initialize_pulse(int verbose);
#endif
Error AudioDriverALSA::init_output_device() {
- mix_rate = GLOBAL_GET("audio/driver/mix_rate");
+ mix_rate = _get_configured_mix_rate();
+
speaker_mode = SPEAKER_MODE_STEREO;
channels = 2;
@@ -338,7 +339,9 @@ void AudioDriverALSA::finish_output_device() {
void AudioDriverALSA::finish() {
exit_thread.set();
- thread.wait_to_finish();
+ if (thread.is_started()) {
+ thread.wait_to_finish();
+ }
finish_output_device();
}
diff --git a/drivers/alsamidi/midi_driver_alsamidi.cpp b/drivers/alsamidi/midi_driver_alsamidi.cpp
index 81472fe70c..6b35987f70 100644
--- a/drivers/alsamidi/midi_driver_alsamidi.cpp
+++ b/drivers/alsamidi/midi_driver_alsamidi.cpp
@@ -207,7 +207,9 @@ Error MIDIDriverALSAMidi::open() {
void MIDIDriverALSAMidi::close() {
exit_thread.set();
- thread.wait_to_finish();
+ if (thread.is_started()) {
+ thread.wait_to_finish();
+ }
for (int i = 0; i < connected_inputs.size(); i++) {
snd_rawmidi_t *midi_in = connected_inputs[i].rawmidi_ptr;
diff --git a/drivers/coreaudio/audio_driver_coreaudio.cpp b/drivers/coreaudio/audio_driver_coreaudio.cpp
index 2c959bb07b..4011727433 100644
--- a/drivers/coreaudio/audio_driver_coreaudio.cpp
+++ b/drivers/coreaudio/audio_driver_coreaudio.cpp
@@ -116,7 +116,7 @@ Error AudioDriverCoreAudio::init() {
break;
}
- mix_rate = GLOBAL_GET("audio/driver/mix_rate");
+ mix_rate = _get_configured_mix_rate();
memset(&strdesc, 0, sizeof(strdesc));
strdesc.mFormatID = kAudioFormatLinearPCM;
@@ -405,7 +405,7 @@ Error AudioDriverCoreAudio::init_input_device() {
break;
}
- mix_rate = GLOBAL_GET("audio/driver/mix_rate");
+ mix_rate = _get_configured_mix_rate();
memset(&strdesc, 0, sizeof(strdesc));
strdesc.mFormatID = kAudioFormatLinearPCM;
diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp
index 7cbce428cb..4e5e103884 100644
--- a/drivers/gles3/rasterizer_gles3.cpp
+++ b/drivers/gles3/rasterizer_gles3.cpp
@@ -300,12 +300,13 @@ void RasterizerGLES3::_blit_render_target_to_screen(RID p_render_target, Display
}
GLuint read_fbo = 0;
+ glGenFramebuffers(1, &read_fbo);
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, read_fbo);
+
if (rt->view_count > 1) {
- glGenFramebuffers(1, &read_fbo);
- glBindFramebuffer(GL_READ_FRAMEBUFFER, read_fbo);
glFramebufferTextureLayer(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, rt->color, 0, p_layer);
} else {
- glBindFramebuffer(GL_READ_FRAMEBUFFER, rt->fbo);
+ glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, rt->color, 0);
}
glReadBuffer(GL_COLOR_ATTACHMENT0);
diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl
index ac5d0faccf..37976bb9a0 100644
--- a/drivers/gles3/shaders/scene.glsl
+++ b/drivers/gles3/shaders/scene.glsl
@@ -771,7 +771,7 @@ void light_compute(vec3 N, vec3 L, vec3 V, float A, vec3 light_color, bool is_di
alpha = min(alpha, clamp(1.0 - attenuation, 0.0, 1.0));
#endif
-#endif // LIGHT_CODE_USED
+#endif // USE_LIGHT_SHADER_CODE
}
float get_omni_spot_attenuation(float distance, float inv_range, float decay) {
diff --git a/drivers/gles3/storage/material_storage.cpp b/drivers/gles3/storage/material_storage.cpp
index 60a8a41abe..c7b2a715be 100644
--- a/drivers/gles3/storage/material_storage.cpp
+++ b/drivers/gles3/storage/material_storage.cpp
@@ -1651,7 +1651,7 @@ MaterialStorage::MaterialStorage() {
actions.renames["CAMERA_POSITION_WORLD"] = "scene_data.inv_view_matrix[3].xyz";
actions.renames["CAMERA_DIRECTION_WORLD"] = "scene_data.view_matrix[3].xyz";
actions.renames["CAMERA_VISIBLE_LAYERS"] = "scene_data.camera_visible_layers";
- actions.renames["NODE_POSITION_VIEW"] = "(model_matrix * scene_data.view_matrix)[3].xyz";
+ actions.renames["NODE_POSITION_VIEW"] = "(scene_data.view_matrix * model_matrix)[3].xyz";
actions.renames["VIEW_INDEX"] = "ViewIndex";
actions.renames["VIEW_MONO_LEFT"] = "uint(0)";
@@ -1660,6 +1660,7 @@ MaterialStorage::MaterialStorage() {
//for light
actions.renames["VIEW"] = "view";
+ actions.renames["SPECULAR_AMOUNT"] = "specular_amount";
actions.renames["LIGHT_COLOR"] = "light_color";
actions.renames["LIGHT_IS_DIRECTIONAL"] = "is_directional";
actions.renames["LIGHT"] = "light";
diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.cpp b/drivers/pulseaudio/audio_driver_pulseaudio.cpp
index 9ae74a8906..3114be9163 100644
--- a/drivers/pulseaudio/audio_driver_pulseaudio.cpp
+++ b/drivers/pulseaudio/audio_driver_pulseaudio.cpp
@@ -305,7 +305,7 @@ Error AudioDriverPulseAudio::init() {
active.clear();
exit_thread.clear();
- mix_rate = GLOBAL_GET("audio/driver/mix_rate");
+ mix_rate = _get_configured_mix_rate();
pa_ml = pa_mainloop_new();
ERR_FAIL_COND_V(pa_ml == nullptr, ERR_CANT_OPEN);
@@ -676,7 +676,9 @@ void AudioDriverPulseAudio::finish() {
}
exit_thread.set();
- thread.wait_to_finish();
+ if (thread.is_started()) {
+ thread.wait_to_finish();
+ }
finish_output_device();
diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp
index 186c323bf7..84b391d18a 100644
--- a/drivers/vulkan/rendering_device_vulkan.cpp
+++ b/drivers/vulkan/rendering_device_vulkan.cpp
@@ -2462,10 +2462,10 @@ Error RenderingDeviceVulkan::_texture_update(RID p_texture, uint32_t p_layer, co
}
ERR_FAIL_COND_V_MSG(texture->bound, ERR_CANT_ACQUIRE_RESOURCE,
- "Texture can't be updated while a render pass that uses it is being created. Ensure render pass is finalized (and that it was created with RENDER_PASS_CONTENTS_FINISH) to unbind this texture.");
+ "Texture can't be updated while a draw list that uses it as part of a framebuffer is being created. Ensure the draw list is finalized (and that the color/depth texture using it is not set to `RenderingDevice.FINAL_ACTION_CONTINUE`) to update this texture.");
ERR_FAIL_COND_V_MSG(!(texture->usage_flags & TEXTURE_USAGE_CAN_UPDATE_BIT), ERR_INVALID_PARAMETER,
- "Texture requires the TEXTURE_USAGE_CAN_UPDATE_BIT in order to be updatable.");
+ "Texture requires the `RenderingDevice.TEXTURE_USAGE_CAN_UPDATE_BIT` to be set to be updatable.");
uint32_t layer_count = texture->layers;
if (texture->type == TEXTURE_TYPE_CUBE || texture->type == TEXTURE_TYPE_CUBE_ARRAY) {
@@ -2738,9 +2738,9 @@ Vector<uint8_t> RenderingDeviceVulkan::texture_get_data(RID p_texture, uint32_t
ERR_FAIL_COND_V(!tex, Vector<uint8_t>());
ERR_FAIL_COND_V_MSG(tex->bound, Vector<uint8_t>(),
- "Texture can't be retrieved while a render pass that uses it is being created. Ensure render pass is finalized (and that it was created with RENDER_PASS_CONTENTS_FINISH) to unbind this texture.");
+ "Texture can't be retrieved while a draw list that uses it as part of a framebuffer is being created. Ensure the draw list is finalized (and that the color/depth texture using it is not set to `RenderingDevice.FINAL_ACTION_CONTINUE`) to retrieve this texture.");
ERR_FAIL_COND_V_MSG(!(tex->usage_flags & TEXTURE_USAGE_CAN_COPY_FROM_BIT), Vector<uint8_t>(),
- "Texture requires the TEXTURE_USAGE_CAN_COPY_FROM_BIT in order to be retrieved.");
+ "Texture requires the `RenderingDevice.TEXTURE_USAGE_CAN_COPY_FROM_BIT` to be set to be retrieved.");
uint32_t layer_count = tex->layers;
if (tex->type == TEXTURE_TYPE_CUBE || tex->type == TEXTURE_TYPE_CUBE_ARRAY) {
@@ -2888,9 +2888,9 @@ Error RenderingDeviceVulkan::texture_copy(RID p_from_texture, RID p_to_texture,
ERR_FAIL_COND_V(!src_tex, ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V_MSG(src_tex->bound, ERR_INVALID_PARAMETER,
- "Source texture can't be copied while a render pass that uses it is being created. Ensure render pass is finalized (and that it was created with RENDER_PASS_CONTENTS_FINISH) to unbind this texture.");
+ "Source texture can't be copied while a draw list that uses it as part of a framebuffer is being created. Ensure the draw list is finalized (and that the color/depth texture using it is not set to `RenderingDevice.FINAL_ACTION_CONTINUE`) to copy this texture.");
ERR_FAIL_COND_V_MSG(!(src_tex->usage_flags & TEXTURE_USAGE_CAN_COPY_FROM_BIT), ERR_INVALID_PARAMETER,
- "Source texture requires the TEXTURE_USAGE_CAN_COPY_FROM_BIT in order to be retrieved.");
+ "Source texture requires the `RenderingDevice.TEXTURE_USAGE_CAN_COPY_FROM_BIT` to be set to be retrieved.");
uint32_t src_layer_count = src_tex->layers;
uint32_t src_width, src_height, src_depth;
@@ -2909,9 +2909,9 @@ Error RenderingDeviceVulkan::texture_copy(RID p_from_texture, RID p_to_texture,
ERR_FAIL_COND_V(!dst_tex, ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V_MSG(dst_tex->bound, ERR_INVALID_PARAMETER,
- "Destination texture can't be copied while a render pass that uses it is being created. Ensure render pass is finalized (and that it was created with RENDER_PASS_CONTENTS_FINISH) to unbind this texture.");
+ "Destination texture can't be copied while a draw list that uses it as part of a framebuffer is being created. Ensure the draw list is finalized (and that the color/depth texture using it is not set to `RenderingDevice.FINAL_ACTION_CONTINUE`) to copy this texture.");
ERR_FAIL_COND_V_MSG(!(dst_tex->usage_flags & TEXTURE_USAGE_CAN_COPY_TO_BIT), ERR_INVALID_PARAMETER,
- "Destination texture requires the TEXTURE_USAGE_CAN_COPY_TO_BIT in order to be retrieved.");
+ "Destination texture requires the `RenderingDevice.TEXTURE_USAGE_CAN_COPY_TO_BIT` to be set to be retrieved.");
uint32_t dst_layer_count = dst_tex->layers;
uint32_t dst_width, dst_height, dst_depth;
@@ -3083,9 +3083,9 @@ Error RenderingDeviceVulkan::texture_resolve_multisample(RID p_from_texture, RID
ERR_FAIL_COND_V(!src_tex, ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V_MSG(src_tex->bound, ERR_INVALID_PARAMETER,
- "Source texture can't be copied while a render pass that uses it is being created. Ensure render pass is finalized (and that it was created with RENDER_PASS_CONTENTS_FINISH) to unbind this texture.");
+ "Source texture can't be copied while a draw list that uses it as part of a framebuffer is being created. Ensure the draw list is finalized (and that the color/depth texture using it is not set to `RenderingDevice.FINAL_ACTION_CONTINUE`) to copy this texture.");
ERR_FAIL_COND_V_MSG(!(src_tex->usage_flags & TEXTURE_USAGE_CAN_COPY_FROM_BIT), ERR_INVALID_PARAMETER,
- "Source texture requires the TEXTURE_USAGE_CAN_COPY_FROM_BIT in order to be retrieved.");
+ "Source texture requires the `RenderingDevice.TEXTURE_USAGE_CAN_COPY_FROM_BIT` to be set to be retrieved.");
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.");
@@ -3094,9 +3094,9 @@ Error RenderingDeviceVulkan::texture_resolve_multisample(RID p_from_texture, RID
ERR_FAIL_COND_V(!dst_tex, ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V_MSG(dst_tex->bound, ERR_INVALID_PARAMETER,
- "Destination texture can't be copied while a render pass that uses it is being created. Ensure render pass is finalized (and that it was created with RENDER_PASS_CONTENTS_FINISH) to unbind this texture.");
+ "Destination texture can't be copied while a draw list that uses it as part of a framebuffer is being created. Ensure the draw list is finalized (and that the color/depth texture using it is not set to `RenderingDevice.FINAL_ACTION_CONTINUE`) to copy this texture.");
ERR_FAIL_COND_V_MSG(!(dst_tex->usage_flags & TEXTURE_USAGE_CAN_COPY_TO_BIT), ERR_INVALID_PARAMETER,
- "Destination texture requires the TEXTURE_USAGE_CAN_COPY_TO_BIT in order to be retrieved.");
+ "Destination texture requires the `RenderingDevice.TEXTURE_USAGE_CAN_COPY_TO_BIT` to be set to be retrieved.");
ERR_FAIL_COND_V_MSG(dst_tex->type != TEXTURE_TYPE_2D, ERR_INVALID_PARAMETER, "Destination texture must be 2D (or a slice of a 3D/Cube texture).");
ERR_FAIL_COND_V_MSG(dst_tex->samples != TEXTURE_SAMPLES_1, ERR_INVALID_PARAMETER, "Destination texture must not be multisampled.");
@@ -3254,13 +3254,13 @@ Error RenderingDeviceVulkan::texture_clear(RID p_texture, const Color &p_color,
ERR_FAIL_COND_V(!src_tex, ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V_MSG(src_tex->bound, ERR_INVALID_PARAMETER,
- "Source texture can't be cleared while a render pass that uses it is being created. Ensure render pass is finalized (and that it was created with RENDER_PASS_CONTENTS_FINISH) to unbind this texture.");
+ "Source texture can't be cleared while a draw list that uses it as part of a framebuffer is being created. Ensure the draw list is finalized (and that the color/depth texture using it is not set to `RenderingDevice.FINAL_ACTION_CONTINUE`) to clear this texture.");
ERR_FAIL_COND_V(p_layers == 0, ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V(p_mipmaps == 0, ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V_MSG(!(src_tex->usage_flags & TEXTURE_USAGE_CAN_COPY_TO_BIT), ERR_INVALID_PARAMETER,
- "Source texture requires the TEXTURE_USAGE_CAN_COPY_TO_BIT in order to be cleared.");
+ "Source texture requires the `RenderingDevice.TEXTURE_USAGE_CAN_COPY_TO_BIT` to be set to be cleared.");
uint32_t src_layer_count = src_tex->layers;
if (src_tex->type == TEXTURE_TYPE_CUBE || src_tex->type == TEXTURE_TYPE_CUBE_ARRAY) {
@@ -4305,6 +4305,18 @@ RID RenderingDeviceVulkan::sampler_create(const SamplerState &p_state) {
return id;
}
+bool RenderingDeviceVulkan::sampler_is_format_supported_for_filter(DataFormat p_format, SamplerFilter p_sampler_filter) const {
+ ERR_FAIL_INDEX_V(p_format, DATA_FORMAT_MAX, false);
+
+ _THREAD_SAFE_METHOD_
+
+ // Validate that this image is supported for the intended filtering.
+ VkFormatProperties properties;
+ vkGetPhysicalDeviceFormatProperties(context->get_physical_device(), vulkan_formats[p_format], &properties);
+
+ return p_sampler_filter == RD::SAMPLER_FILTER_NEAREST || (p_sampler_filter == RD::SAMPLER_FILTER_LINEAR && (properties.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT));
+}
+
/**********************/
/**** VERTEX ARRAY ****/
/**********************/
@@ -4313,10 +4325,6 @@ RID RenderingDeviceVulkan::vertex_buffer_create(uint32_t p_size_bytes, const Vec
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(p_data.size() && (uint32_t)p_data.size() != p_size_bytes, RID());
- ERR_FAIL_COND_V_MSG(draw_list != nullptr && p_data.size(), RID(),
- "Creating buffers with data is forbidden during creation of a draw list");
- ERR_FAIL_COND_V_MSG(compute_list != nullptr && p_data.size(), RID(),
- "Creating buffers with data is forbidden during creation of a draw list");
uint32_t usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT;
if (p_use_as_storage) {
@@ -4454,10 +4462,6 @@ RID RenderingDeviceVulkan::vertex_array_create(uint32_t p_vertex_count, VertexFo
RID RenderingDeviceVulkan::index_buffer_create(uint32_t p_index_count, IndexBufferFormat p_format, const Vector<uint8_t> &p_data, bool p_use_restart_indices) {
_THREAD_SAFE_METHOD_
- ERR_FAIL_COND_V_MSG(draw_list != nullptr && p_data.size(), RID(),
- "Creating buffers with data is forbidden during creation of a draw list");
- ERR_FAIL_COND_V_MSG(compute_list != nullptr && p_data.size(), RID(),
- "Creating buffers with data is forbidden during creation of a draw list");
ERR_FAIL_COND_V(p_index_count == 0, RID());
@@ -5140,10 +5144,6 @@ RID RenderingDeviceVulkan::uniform_buffer_create(uint32_t p_size_bytes, const Ve
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(p_data.size() && (uint32_t)p_data.size() != p_size_bytes, RID());
- ERR_FAIL_COND_V_MSG(draw_list != nullptr && p_data.size(), RID(),
- "Creating buffers with data is forbidden during creation of a draw list");
- ERR_FAIL_COND_V_MSG(compute_list != nullptr && p_data.size(), RID(),
- "Creating buffers with data is forbidden during creation of a draw list");
Buffer buffer;
Error err = _buffer_allocate(&buffer, p_size_bytes, VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE, 0);
@@ -5163,10 +5163,6 @@ RID RenderingDeviceVulkan::uniform_buffer_create(uint32_t p_size_bytes, const Ve
RID RenderingDeviceVulkan::storage_buffer_create(uint32_t p_size_bytes, const Vector<uint8_t> &p_data, BitField<StorageBufferUsage> p_usage) {
_THREAD_SAFE_METHOD_
- ERR_FAIL_COND_V_MSG(draw_list != nullptr && p_data.size(), RID(),
- "Creating buffers with data is forbidden during creation of a draw list");
- ERR_FAIL_COND_V_MSG(compute_list != nullptr && p_data.size(), RID(),
- "Creating buffers with data is forbidden during creation of a draw list");
ERR_FAIL_COND_V(p_data.size() && (uint32_t)p_data.size() != p_size_bytes, RID());
@@ -5189,10 +5185,6 @@ RID RenderingDeviceVulkan::storage_buffer_create(uint32_t p_size_bytes, const Ve
RID RenderingDeviceVulkan::texture_buffer_create(uint32_t p_size_elements, DataFormat p_format, const Vector<uint8_t> &p_data) {
_THREAD_SAFE_METHOD_
- ERR_FAIL_COND_V_MSG(draw_list != nullptr && p_data.size(), RID(),
- "Creating buffers with data is forbidden during creation of a draw list");
- ERR_FAIL_COND_V_MSG(compute_list != nullptr && p_data.size(), RID(),
- "Creating buffers with data is forbidden during creation of a draw list");
uint32_t element_size = get_format_vertex_size(p_format);
ERR_FAIL_COND_V_MSG(element_size == 0, RID(), "Format requested is not supported for texture buffers");
@@ -8114,35 +8106,14 @@ void RenderingDeviceVulkan::compute_list_dispatch_indirect(ComputeListID p_list,
}
void RenderingDeviceVulkan::compute_list_add_barrier(ComputeListID p_list) {
-#ifdef FORCE_FULL_BARRIER
- _full_barrier(true);
-#else
- _memory_barrier(VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_ACCESS_SHADER_WRITE_BIT, VK_ACCESS_SHADER_READ_BIT, true);
-#endif
+ uint32_t barrier_flags = VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
+ uint32_t access_flags = VK_ACCESS_SHADER_READ_BIT;
+ _compute_list_add_barrier(BARRIER_MASK_COMPUTE, barrier_flags, access_flags);
}
-void RenderingDeviceVulkan::compute_list_end(BitField<BarrierMask> p_post_barrier) {
+void RenderingDeviceVulkan::_compute_list_add_barrier(BitField<BarrierMask> p_post_barrier, uint32_t p_barrier_flags, uint32_t p_access_flags) {
ERR_FAIL_COND(!compute_list);
- uint32_t barrier_flags = 0;
- uint32_t access_flags = 0;
- if (p_post_barrier.has_flag(BARRIER_MASK_COMPUTE)) {
- barrier_flags |= VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
- access_flags |= VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT;
- }
- if (p_post_barrier.has_flag(BARRIER_MASK_RASTER)) {
- barrier_flags |= VK_PIPELINE_STAGE_VERTEX_INPUT_BIT | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT;
- access_flags |= VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_INDEX_READ_BIT | VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT | VK_ACCESS_INDIRECT_COMMAND_READ_BIT;
- }
- if (p_post_barrier.has_flag(BARRIER_MASK_TRANSFER)) {
- barrier_flags |= VK_PIPELINE_STAGE_TRANSFER_BIT;
- access_flags |= VK_ACCESS_TRANSFER_WRITE_BIT | VK_ACCESS_TRANSFER_READ_BIT;
- }
-
- if (barrier_flags == 0) {
- barrier_flags = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
- }
-
VkImageMemoryBarrier *image_barriers = nullptr;
uint32_t image_barrier_count = compute_list->state.textures_to_sampled_layout.size();
@@ -8151,27 +8122,29 @@ void RenderingDeviceVulkan::compute_list_end(BitField<BarrierMask> p_post_barrie
image_barriers = (VkImageMemoryBarrier *)alloca(sizeof(VkImageMemoryBarrier) * image_barrier_count);
}
- uint32_t barrier_idx = 0;
+ image_barrier_count = 0; // We'll count how many we end up issuing.
for (Texture *E : compute_list->state.textures_to_sampled_layout) {
- VkImageMemoryBarrier &image_memory_barrier = image_barriers[barrier_idx++];
- image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
- image_memory_barrier.pNext = nullptr;
- image_memory_barrier.srcAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT;
- image_memory_barrier.dstAccessMask = access_flags;
- image_memory_barrier.oldLayout = E->layout;
- image_memory_barrier.newLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
+ if (E->layout != VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL) {
+ VkImageMemoryBarrier &image_memory_barrier = image_barriers[image_barrier_count++];
+ image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
+ image_memory_barrier.pNext = nullptr;
+ image_memory_barrier.srcAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT;
+ image_memory_barrier.dstAccessMask = p_access_flags;
+ image_memory_barrier.oldLayout = E->layout;
+ image_memory_barrier.newLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
- image_memory_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
- image_memory_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
- image_memory_barrier.image = E->image;
- image_memory_barrier.subresourceRange.aspectMask = E->read_aspect_mask;
- image_memory_barrier.subresourceRange.baseMipLevel = E->base_mipmap;
- image_memory_barrier.subresourceRange.levelCount = E->mipmaps;
- image_memory_barrier.subresourceRange.baseArrayLayer = E->base_layer;
- image_memory_barrier.subresourceRange.layerCount = E->layers;
+ image_memory_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
+ image_memory_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
+ image_memory_barrier.image = E->image;
+ image_memory_barrier.subresourceRange.aspectMask = E->read_aspect_mask;
+ image_memory_barrier.subresourceRange.baseMipLevel = E->base_mipmap;
+ image_memory_barrier.subresourceRange.levelCount = E->mipmaps;
+ image_memory_barrier.subresourceRange.baseArrayLayer = E->base_layer;
+ image_memory_barrier.subresourceRange.layerCount = E->layers;
- E->layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
+ E->layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
+ }
if (E->used_in_frame != frames_drawn) {
E->used_in_transfer = false;
@@ -8181,19 +8154,40 @@ void RenderingDeviceVulkan::compute_list_end(BitField<BarrierMask> p_post_barrie
}
}
- VkMemoryBarrier mem_barrier;
- mem_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER;
- mem_barrier.pNext = nullptr;
- mem_barrier.srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT;
- mem_barrier.dstAccessMask = access_flags;
-
- if (image_barrier_count > 0 || p_post_barrier != BARRIER_MASK_NO_BARRIER) {
- vkCmdPipelineBarrier(compute_list->command_buffer, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, barrier_flags, 0, 1, &mem_barrier, 0, nullptr, image_barrier_count, image_barriers);
+ if (p_barrier_flags) {
+ VkMemoryBarrier mem_barrier;
+ mem_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER;
+ mem_barrier.pNext = nullptr;
+ mem_barrier.srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT;
+ mem_barrier.dstAccessMask = p_access_flags;
+ vkCmdPipelineBarrier(compute_list->command_buffer, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, p_barrier_flags, 0, 1, &mem_barrier, 0, nullptr, image_barrier_count, image_barriers);
+ } else if (image_barrier_count) {
+ vkCmdPipelineBarrier(compute_list->command_buffer, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, 0, nullptr, 0, nullptr, image_barrier_count, image_barriers);
}
#ifdef FORCE_FULL_BARRIER
_full_barrier(true);
#endif
+}
+
+void RenderingDeviceVulkan::compute_list_end(BitField<BarrierMask> p_post_barrier) {
+ ERR_FAIL_COND(!compute_list);
+
+ uint32_t barrier_flags = 0;
+ uint32_t access_flags = 0;
+ if (p_post_barrier.has_flag(BARRIER_MASK_COMPUTE)) {
+ barrier_flags |= VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
+ access_flags |= VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT;
+ }
+ if (p_post_barrier.has_flag(BARRIER_MASK_RASTER)) {
+ barrier_flags |= VK_PIPELINE_STAGE_VERTEX_INPUT_BIT | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT;
+ access_flags |= VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_INDEX_READ_BIT | VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT | VK_ACCESS_INDIRECT_COMMAND_READ_BIT;
+ }
+ if (p_post_barrier.has_flag(BARRIER_MASK_TRANSFER)) {
+ barrier_flags |= VK_PIPELINE_STAGE_TRANSFER_BIT;
+ access_flags |= VK_ACCESS_TRANSFER_WRITE_BIT | VK_ACCESS_TRANSFER_READ_BIT;
+ }
+ _compute_list_add_barrier(p_post_barrier, barrier_flags, access_flags);
memdelete(compute_list);
compute_list = nullptr;
diff --git a/drivers/vulkan/rendering_device_vulkan.h b/drivers/vulkan/rendering_device_vulkan.h
index 91a09fa970..2ec1574955 100644
--- a/drivers/vulkan/rendering_device_vulkan.h
+++ b/drivers/vulkan/rendering_device_vulkan.h
@@ -954,6 +954,8 @@ class RenderingDeviceVulkan : public RenderingDevice {
ComputeList *compute_list = nullptr;
+ void _compute_list_add_barrier(BitField<BarrierMask> p_post_barrier, uint32_t p_barrier_flags, uint32_t p_access_flags);
+
/**************************/
/**** FRAME MANAGEMENT ****/
/**************************/
@@ -1082,6 +1084,7 @@ public:
/*****************/
virtual RID sampler_create(const SamplerState &p_state);
+ virtual bool sampler_is_format_supported_for_filter(DataFormat p_format, SamplerFilter p_sampler_filter) const;
/**********************/
/**** VERTEX ARRAY ****/
diff --git a/drivers/wasapi/audio_driver_wasapi.cpp b/drivers/wasapi/audio_driver_wasapi.cpp
index 805528b8c7..f877f78665 100644
--- a/drivers/wasapi/audio_driver_wasapi.cpp
+++ b/drivers/wasapi/audio_driver_wasapi.cpp
@@ -545,7 +545,7 @@ Error AudioDriverWASAPI::finish_input_device() {
}
Error AudioDriverWASAPI::init() {
- mix_rate = GLOBAL_GET("audio/driver/mix_rate");
+ mix_rate = _get_configured_mix_rate();
target_latency_ms = GLOBAL_GET("audio/driver/output_latency");
@@ -930,7 +930,9 @@ void AudioDriverWASAPI::unlock() {
void AudioDriverWASAPI::finish() {
exit_thread.set();
- thread.wait_to_finish();
+ if (thread.is_started()) {
+ thread.wait_to_finish();
+ }
finish_input_device();
finish_output_device();
diff --git a/drivers/windows/dir_access_windows.cpp b/drivers/windows/dir_access_windows.cpp
index 7b88bd8a95..88eb89656a 100644
--- a/drivers/windows/dir_access_windows.cpp
+++ b/drivers/windows/dir_access_windows.cpp
@@ -59,6 +59,14 @@ struct DirAccessWindowsPrivate {
WIN32_FIND_DATAW fu; //unicode version
};
+String DirAccessWindows::fix_path(String p_path) const {
+ String r_path = DirAccess::fix_path(p_path);
+ if (r_path.is_absolute_path() && !r_path.is_network_share_path() && r_path.length() > MAX_PATH) {
+ r_path = "\\\\?\\" + r_path.replace("/", "\\");
+ }
+ return r_path;
+}
+
// CreateFolderAsync
Error DirAccessWindows::list_dir_begin() {
@@ -158,6 +166,7 @@ Error DirAccessWindows::make_dir(String p_dir) {
p_dir = fix_path(p_dir);
if (p_dir.is_relative_path()) {
p_dir = current_dir.path_join(p_dir);
+ p_dir = fix_path(p_dir);
}
p_dir = p_dir.simplify_path().replace("/", "\\");
@@ -165,12 +174,6 @@ Error DirAccessWindows::make_dir(String p_dir) {
bool success;
int err;
- if (!p_dir.is_network_share_path()) {
- p_dir = "\\\\?\\" + p_dir;
- // Add "\\?\" to the path to extend max. path length past 248, if it's not a network share UNC path.
- // See https://msdn.microsoft.com/en-us/library/windows/desktop/aa363855(v=vs.85).aspx
- }
-
success = CreateDirectoryW((LPCWSTR)(p_dir.utf16().get_data()), nullptr);
err = GetLastError();
diff --git a/drivers/windows/dir_access_windows.h b/drivers/windows/dir_access_windows.h
index 9d91c22f7e..1e55917756 100644
--- a/drivers/windows/dir_access_windows.h
+++ b/drivers/windows/dir_access_windows.h
@@ -53,6 +53,9 @@ class DirAccessWindows : public DirAccess {
bool _cisdir = false;
bool _cishidden = false;
+protected:
+ virtual String fix_path(String p_path) const override;
+
public:
virtual Error list_dir_begin() override; ///< This starts dir listing
virtual String get_next() override;
diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp
index f36bbcc350..6e69743d4e 100644
--- a/drivers/windows/file_access_windows.cpp
+++ b/drivers/windows/file_access_windows.cpp
@@ -68,6 +68,14 @@ bool FileAccessWindows::is_path_invalid(const String &p_path) {
return invalid_files.has(fname);
}
+String FileAccessWindows::fix_path(const String &p_path) const {
+ String r_path = FileAccess::fix_path(p_path);
+ if (r_path.is_absolute_path() && !r_path.is_network_share_path() && r_path.length() > MAX_PATH) {
+ r_path = "\\\\?\\" + r_path.replace("/", "\\");
+ }
+ return r_path;
+}
+
Error FileAccessWindows::open_internal(const String &p_path, int p_mode_flags) {
if (is_path_invalid(p_path)) {
#ifdef DEBUG_ENABLED
diff --git a/drivers/windows/file_access_windows.h b/drivers/windows/file_access_windows.h
index 453f8d3b5f..13c881e562 100644
--- a/drivers/windows/file_access_windows.h
+++ b/drivers/windows/file_access_windows.h
@@ -54,6 +54,7 @@ class FileAccessWindows : public FileAccess {
static HashSet<String> invalid_files;
public:
+ virtual String fix_path(const String &p_path) const override;
virtual Error open_internal(const String &p_path, int p_mode_flags) override; ///< open a file
virtual bool is_open() const override; ///< true when file is open
diff --git a/drivers/xaudio2/audio_driver_xaudio2.cpp b/drivers/xaudio2/audio_driver_xaudio2.cpp
index 44ce01d4d7..22063c52d9 100644
--- a/drivers/xaudio2/audio_driver_xaudio2.cpp
+++ b/drivers/xaudio2/audio_driver_xaudio2.cpp
@@ -39,7 +39,8 @@ Error AudioDriverXAudio2::init() {
pcm_open = false;
samples_in = nullptr;
- mix_rate = GLOBAL_GET("audio/driver/mix_rate");
+ mix_rate = _get_configured_mix_rate();
+
// FIXME: speaker_mode seems unused in the Xaudio2 driver so far
speaker_mode = SPEAKER_MODE_STEREO;
channels = 2;
@@ -150,7 +151,9 @@ void AudioDriverXAudio2::unlock() {
void AudioDriverXAudio2::finish() {
exit_thread.set();
- thread.wait_to_finish();
+ if (thread.is_started()) {
+ thread.wait_to_finish();
+ }
if (source_voice) {
source_voice->Stop(0);
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp
index c6acf99872..4b3cf671d5 100644
--- a/editor/animation_track_editor.cpp
+++ b/editor/animation_track_editor.cpp
@@ -6084,7 +6084,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
Pair<real_t, Variant> keydata;
keydata.first = delta_t;
Vector3 v;
- animation->position_track_interpolate(i, delta_t, &v);
+ animation->try_position_track_interpolate(i, delta_t, &v);
keydata.second = v;
insert_queue_new.append(keydata);
}
@@ -6094,7 +6094,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
Pair<real_t, Variant> keydata;
keydata.first = delta_t;
Quaternion v;
- animation->rotation_track_interpolate(i, delta_t, &v);
+ animation->try_rotation_track_interpolate(i, delta_t, &v);
keydata.second = v;
insert_queue_new.append(keydata);
}
@@ -6104,7 +6104,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
Pair<real_t, Variant> keydata;
keydata.first = delta_t;
Vector3 v;
- animation->scale_track_interpolate(i, delta_t, &v);
+ animation->try_scale_track_interpolate(i, delta_t, &v);
keydata.second = v;
insert_queue_new.append(keydata);
}
@@ -6114,7 +6114,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
Pair<real_t, Variant> keydata;
keydata.first = delta_t;
float v;
- animation->blend_shape_track_interpolate(i, delta_t, &v);
+ animation->try_blend_shape_track_interpolate(i, delta_t, &v);
keydata.second = v;
insert_queue_new.append(keydata);
}
@@ -6760,7 +6760,7 @@ AnimationTrackEditor::AnimationTrackEditor() {
bake_fps->set_max(999);
bake_fps->set_step(1);
bake_fps->set_value(30); // Default
- bake_grid->add_child(memnew(Label(TTR("Pos/Rot/Scl3D Track:"))));
+ bake_grid->add_child(memnew(Label(TTR("3D Pos/Rot/Scl Track:"))));
bake_grid->add_child(bake_trs);
bake_grid->add_child(memnew(Label(TTR("Blendshape Track:"))));
bake_grid->add_child(bake_blendshape);
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index 61df3a977a..b188e1faca 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -902,6 +902,9 @@ void CodeTextEditor::_line_col_changed() {
sb.append(" : ");
sb.append(itos(positional_column + 1).lpad(3));
+ sb.append(" | ");
+ sb.append(text_editor->is_indent_using_spaces() ? "Spaces" : "Tabs");
+
line_and_col_txt->set_text(sb.as_string());
if (find_replace_bar) {
@@ -1142,115 +1145,6 @@ void CodeTextEditor::insert_final_newline() {
}
}
-void CodeTextEditor::convert_indent_to_spaces() {
- int indent_size = EDITOR_GET("text_editor/behavior/indent/size");
- String indent = "";
-
- for (int i = 0; i < indent_size; i++) {
- indent += " ";
- }
-
- Vector<int> cursor_columns;
- cursor_columns.resize(text_editor->get_caret_count());
- for (int c = 0; c < text_editor->get_caret_count(); c++) {
- cursor_columns.write[c] = text_editor->get_caret_column(c);
- }
-
- bool changed_indentation = false;
- for (int i = 0; i < text_editor->get_line_count(); i++) {
- String line = text_editor->get_line(i);
-
- if (line.length() <= 0) {
- continue;
- }
-
- int j = 0;
- while (j < line.length() && (line[j] == ' ' || line[j] == '\t')) {
- if (line[j] == '\t') {
- if (!changed_indentation) {
- text_editor->begin_complex_operation();
- changed_indentation = true;
- }
- for (int c = 0; c < text_editor->get_caret_count(); c++) {
- if (text_editor->get_caret_line(c) == i && text_editor->get_caret_column(c) > j) {
- cursor_columns.write[c] += indent_size - 1;
- }
- }
- line = line.left(j) + indent + line.substr(j + 1);
- }
- j++;
- }
- if (changed_indentation) {
- text_editor->set_line(i, line);
- }
- }
- if (changed_indentation) {
- for (int c = 0; c < text_editor->get_caret_count(); c++) {
- text_editor->set_caret_column(cursor_columns[c], c == 0, c);
- }
- text_editor->merge_overlapping_carets();
- text_editor->end_complex_operation();
- text_editor->queue_redraw();
- }
-}
-
-void CodeTextEditor::convert_indent_to_tabs() {
- int indent_size = EDITOR_GET("text_editor/behavior/indent/size");
- indent_size -= 1;
-
- Vector<int> cursor_columns;
- cursor_columns.resize(text_editor->get_caret_count());
- for (int c = 0; c < text_editor->get_caret_count(); c++) {
- cursor_columns.write[c] = text_editor->get_caret_column(c);
- }
-
- bool changed_indentation = false;
- for (int i = 0; i < text_editor->get_line_count(); i++) {
- String line = text_editor->get_line(i);
-
- if (line.length() <= 0) {
- continue;
- }
-
- int j = 0;
- int space_count = -1;
- while (j < line.length() && (line[j] == ' ' || line[j] == '\t')) {
- if (line[j] != '\t') {
- space_count++;
-
- if (space_count == indent_size) {
- if (!changed_indentation) {
- text_editor->begin_complex_operation();
- changed_indentation = true;
- }
- for (int c = 0; c < text_editor->get_caret_count(); c++) {
- if (text_editor->get_caret_line(c) == i && text_editor->get_caret_column(c) > j) {
- cursor_columns.write[c] -= indent_size;
- }
- }
- line = line.left(j - indent_size) + "\t" + line.substr(j + 1);
- j = 0;
- space_count = -1;
- }
- } else {
- space_count = -1;
- }
- j++;
- }
- if (changed_indentation) {
- text_editor->set_line(i, line);
- }
- }
- if (changed_indentation) {
- for (int c = 0; c < text_editor->get_caret_count(); c++) {
- text_editor->set_caret_column(cursor_columns[c], c == 0, c);
- }
- text_editor->merge_overlapping_carets();
- text_editor->end_complex_operation();
- text_editor->queue_redraw();
- }
-}
-
void CodeTextEditor::convert_case(CaseStyle p_case) {
if (!text_editor->has_selection()) {
return;
diff --git a/editor/code_editor.h b/editor/code_editor.h
index 343720637b..a83bb96771 100644
--- a/editor/code_editor.h
+++ b/editor/code_editor.h
@@ -222,9 +222,6 @@ public:
void trim_trailing_whitespace();
void insert_final_newline();
- void convert_indent_to_spaces();
- void convert_indent_to_tabs();
-
enum CaseStyle {
UPPER,
LOWER,
diff --git a/editor/debugger/debug_adapter/debug_adapter_parser.cpp b/editor/debugger/debug_adapter/debug_adapter_parser.cpp
index fc806ded5e..e3686a0217 100644
--- a/editor/debugger/debug_adapter/debug_adapter_parser.cpp
+++ b/editor/debugger/debug_adapter/debug_adapter_parser.cpp
@@ -32,9 +32,8 @@
#include "editor/debugger/editor_debugger_node.h"
#include "editor/debugger/script_editor_debugger.h"
-#include "editor/editor_node.h"
-#include "editor/editor_run_native.h"
#include "editor/export/editor_export_platform.h"
+#include "editor/gui/editor_run_bar.h"
#include "editor/plugins/script_editor_plugin.h"
void DebugAdapterParser::_bind_methods() {
@@ -162,7 +161,7 @@ Dictionary DebugAdapterParser::req_initialize(const Dictionary &p_params) const
Dictionary DebugAdapterParser::req_disconnect(const Dictionary &p_params) const {
if (!DebugAdapterProtocol::get_singleton()->get_current_peer()->attached) {
- EditorNode::get_singleton()->run_stop();
+ EditorRunBar::get_singleton()->stop_playing();
}
return prepare_success_response(p_params);
@@ -188,7 +187,7 @@ Dictionary DebugAdapterParser::req_launch(const Dictionary &p_params) const {
String platform_string = args.get("platform", "host");
if (platform_string == "host") {
- EditorNode::get_singleton()->run_play();
+ EditorRunBar::get_singleton()->play_main_scene();
} else {
int device = args.get("device", -1);
int idx = -1;
@@ -212,8 +211,8 @@ Dictionary DebugAdapterParser::req_launch(const Dictionary &p_params) const {
return prepare_error_response(p_params, DAP::ErrorType::UNKNOWN_PLATFORM);
}
- EditorNode *editor = EditorNode::get_singleton();
- Error err = platform_string == "android" ? editor->run_play_native(device * 10000 + idx) : editor->run_play_native(idx);
+ EditorRunBar *run_bar = EditorRunBar::get_singleton();
+ Error err = platform_string == "android" ? run_bar->start_native_device(device * 10000 + idx) : run_bar->start_native_device(idx);
if (err) {
if (err == ERR_INVALID_PARAMETER && platform_string == "android") {
return prepare_error_response(p_params, DAP::ErrorType::MISSING_DEVICE);
@@ -257,13 +256,13 @@ Dictionary DebugAdapterParser::req_restart(const Dictionary &p_params) const {
}
Dictionary DebugAdapterParser::req_terminate(const Dictionary &p_params) const {
- EditorNode::get_singleton()->run_stop();
+ EditorRunBar::get_singleton()->stop_playing();
return prepare_success_response(p_params);
}
Dictionary DebugAdapterParser::req_pause(const Dictionary &p_params) const {
- EditorNode::get_singleton()->get_pause_button()->set_pressed(true);
+ EditorRunBar::get_singleton()->get_pause_button()->set_pressed(true);
EditorDebuggerNode::get_singleton()->_paused();
DebugAdapterProtocol::get_singleton()->notify_stopped_paused();
@@ -272,7 +271,7 @@ Dictionary DebugAdapterParser::req_pause(const Dictionary &p_params) const {
}
Dictionary DebugAdapterParser::req_continue(const Dictionary &p_params) const {
- EditorNode::get_singleton()->get_pause_button()->set_pressed(false);
+ EditorRunBar::get_singleton()->get_pause_button()->set_pressed(false);
EditorDebuggerNode::get_singleton()->_paused();
DebugAdapterProtocol::get_singleton()->notify_continued();
diff --git a/editor/debugger/debug_adapter/debug_adapter_protocol.cpp b/editor/debugger/debug_adapter/debug_adapter_protocol.cpp
index f85163cd6a..26fb73570e 100644
--- a/editor/debugger/debug_adapter/debug_adapter_protocol.cpp
+++ b/editor/debugger/debug_adapter/debug_adapter_protocol.cpp
@@ -38,6 +38,7 @@
#include "editor/editor_log.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
+#include "editor/gui/editor_run_bar.h"
DebugAdapterProtocol *DebugAdapterProtocol::singleton = nullptr;
@@ -812,7 +813,7 @@ Array DebugAdapterProtocol::update_breakpoints(const String &p_path, const Array
}
void DebugAdapterProtocol::on_debug_paused() {
- if (EditorNode::get_singleton()->get_pause_button()->is_pressed()) {
+ if (EditorRunBar::get_singleton()->get_pause_button()->is_pressed()) {
notify_stopped_paused();
} else {
notify_continued();
@@ -1017,8 +1018,7 @@ DebugAdapterProtocol::DebugAdapterProtocol() {
reset_ids();
- EditorNode *node = EditorNode::get_singleton();
- node->get_pause_button()->connect("pressed", callable_mp(this, &DebugAdapterProtocol::on_debug_paused));
+ EditorRunBar::get_singleton()->get_pause_button()->connect("pressed", callable_mp(this, &DebugAdapterProtocol::on_debug_paused));
EditorDebuggerNode *debugger_node = EditorDebuggerNode::get_singleton();
debugger_node->connect("breakpoint_toggled", callable_mp(this, &DebugAdapterProtocol::on_debug_breakpoint_toggled));
diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp
index a368cacf56..7083640b24 100644
--- a/editor/debugger/editor_debugger_node.cpp
+++ b/editor/debugger/editor_debugger_node.cpp
@@ -37,6 +37,7 @@
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "editor/editor_undo_redo_manager.h"
+#include "editor/gui/editor_run_bar.h"
#include "editor/inspector_dock.h"
#include "editor/plugins/editor_debugger_plugin.h"
#include "editor/plugins/script_editor_plugin.h"
@@ -87,8 +88,7 @@ EditorDebuggerNode::EditorDebuggerNode() {
remote_scene_tree_timeout = EDITOR_DEF("debugger/remote_scene_tree_refresh_interval", 1.0);
inspect_edited_object_timeout = EDITOR_DEF("debugger/remote_inspect_refresh_interval", 0.2);
- EditorNode *editor = EditorNode::get_singleton();
- editor->get_pause_button()->connect("pressed", callable_mp(this, &EditorDebuggerNode::_paused));
+ EditorRunBar::get_singleton()->get_pause_button()->connect("pressed", callable_mp(this, &EditorDebuggerNode::_paused));
}
ScriptEditorDebugger *EditorDebuggerNode::_add_debugger() {
@@ -260,7 +260,7 @@ void EditorDebuggerNode::stop(bool p_force) {
server->stop();
EditorNode::get_log()->add_message("--- Debugging process stopped ---", EditorLog::MSG_TYPE_EDITOR);
- if (EditorNode::get_singleton()->is_movie_maker_enabled()) {
+ if (EditorRunBar::get_singleton()->is_movie_maker_enabled()) {
// Request attention in case the user was doing something else when movie recording is finished.
DisplayServer::get_singleton()->window_request_attention();
}
@@ -344,7 +344,7 @@ void EditorDebuggerNode::_notification(int p_what) {
}
}
- EditorNode::get_singleton()->get_pause_button()->set_disabled(false);
+ EditorRunBar::get_singleton()->get_pause_button()->set_disabled(false);
// Switch to remote tree view if so desired.
auto_switch_remote_scene_tree = (bool)EDITOR_GET("debugger/auto_switch_to_remote_scene_tree");
if (auto_switch_remote_scene_tree) {
@@ -413,8 +413,8 @@ void EditorDebuggerNode::_debugger_stopped(int p_id) {
}
});
if (!found) {
- EditorNode::get_singleton()->get_pause_button()->set_pressed(false);
- EditorNode::get_singleton()->get_pause_button()->set_disabled(true);
+ EditorRunBar::get_singleton()->get_pause_button()->set_pressed(false);
+ EditorRunBar::get_singleton()->get_pause_button()->set_disabled(true);
SceneTreeDock::get_singleton()->hide_remote_tree();
SceneTreeDock::get_singleton()->hide_tab_buttons();
EditorNode::get_singleton()->notify_all_debug_sessions_exited();
@@ -509,7 +509,7 @@ void EditorDebuggerNode::_update_debug_options() {
}
void EditorDebuggerNode::_paused() {
- const bool paused = EditorNode::get_singleton()->get_pause_button()->is_pressed();
+ const bool paused = EditorRunBar::get_singleton()->get_pause_button()->is_pressed();
_for_all(tabs, [&](ScriptEditorDebugger *dbg) {
if (paused && !dbg->is_breaked()) {
dbg->debug_break();
@@ -527,7 +527,7 @@ void EditorDebuggerNode::_breaked(bool p_breaked, bool p_can_debug, String p_mes
tabs->set_current_tab(p_debugger);
}
_break_state_changed();
- EditorNode::get_singleton()->get_pause_button()->set_pressed(p_breaked);
+ EditorRunBar::get_singleton()->get_pause_button()->set_pressed(p_breaked);
emit_signal(SNAME("breaked"), p_breaked, p_can_debug);
}
diff --git a/editor/directory_create_dialog.cpp b/editor/directory_create_dialog.cpp
new file mode 100644
index 0000000000..df860bab2c
--- /dev/null
+++ b/editor/directory_create_dialog.cpp
@@ -0,0 +1,172 @@
+/**************************************************************************/
+/* directory_create_dialog.cpp */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/**************************************************************************/
+
+#include "directory_create_dialog.h"
+
+#include "core/io/dir_access.h"
+#include "editor/editor_node.h"
+#include "editor/editor_scale.h"
+#include "scene/gui/box_container.h"
+#include "scene/gui/label.h"
+#include "scene/gui/line_edit.h"
+#include "scene/gui/panel_container.h"
+
+static String sanitize_input(const String &p_path) {
+ String path = p_path.strip_edges();
+ if (path.ends_with("/")) {
+ path = path.left(path.length() - 1);
+ }
+ return path;
+}
+
+String DirectoryCreateDialog::_validate_path(const String &p_path) const {
+ if (p_path.is_empty()) {
+ return TTR("Folder name cannot be empty.");
+ }
+
+ for (const String &part : p_path.split("/")) {
+ if (part.is_empty()) {
+ return TTR("Folder name cannot be empty.");
+ }
+ if (p_path.contains("\\") || p_path.contains(":") || p_path.contains("*") ||
+ p_path.contains("|") || p_path.contains(">") || p_path.ends_with(".") || p_path.ends_with(" ")) {
+ return TTR("Folder name contains invalid characters.");
+ }
+ }
+
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ da->change_dir(base_dir);
+ if (da->file_exists(p_path)) {
+ return TTR("File with that name already exists.");
+ }
+ if (da->dir_exists(p_path)) {
+ return TTR("Folder with that name already exists.");
+ }
+
+ return String();
+}
+
+void DirectoryCreateDialog::_on_dir_path_changed(const String &p_text) {
+ const String path = sanitize_input(p_text);
+ const String error = _validate_path(path);
+
+ if (error.is_empty()) {
+ status_label->add_theme_color_override("font_color", get_theme_color(SNAME("success_color"), SNAME("Editor")));
+
+ if (path.contains("/")) {
+ status_label->set_text(TTR("Using slashes in folder names will create subfolders recursively."));
+ } else {
+ status_label->set_text(TTR("Folder name is valid."));
+ }
+ } else {
+ status_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
+ status_label->set_text(error);
+ }
+
+ get_ok_button()->set_disabled(!error.is_empty());
+}
+
+void DirectoryCreateDialog::ok_pressed() {
+ const String path = sanitize_input(dir_path->get_text());
+
+ // The OK button should be disabled if the path is invalid, but just in case.
+ const String error = _validate_path(path);
+ ERR_FAIL_COND_MSG(!error.is_empty(), error);
+
+ Error err;
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+
+ err = da->change_dir(base_dir);
+ ERR_FAIL_COND_MSG(err != OK, "Cannot open directory '" + base_dir + "'.");
+
+ print_verbose("Making folder " + path + " in " + base_dir);
+ err = da->make_dir_recursive(path);
+
+ if (err == OK) {
+ emit_signal(SNAME("dir_created"));
+ } else {
+ EditorNode::get_singleton()->show_warning(TTR("Could not create folder."));
+ }
+ hide();
+}
+
+void DirectoryCreateDialog::_post_popup() {
+ ConfirmationDialog::_post_popup();
+ dir_path->grab_focus();
+}
+
+void DirectoryCreateDialog::config(const String &p_base_dir) {
+ base_dir = p_base_dir;
+ label->set_text(vformat(TTR("Create new folder in %s:"), base_dir));
+ dir_path->set_text("new folder");
+ dir_path->select_all();
+ _on_dir_path_changed(dir_path->get_text());
+}
+
+void DirectoryCreateDialog::_bind_methods() {
+ ADD_SIGNAL(MethodInfo("dir_created"));
+}
+
+void DirectoryCreateDialog::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_THEME_CHANGED: {
+ status_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree")));
+ } break;
+ }
+}
+
+DirectoryCreateDialog::DirectoryCreateDialog() {
+ set_title(TTR("Create Folder"));
+ set_min_size(Size2i(480, 0) * EDSCALE);
+
+ VBoxContainer *vb = memnew(VBoxContainer);
+ add_child(vb);
+
+ label = memnew(Label);
+ label->set_text_overrun_behavior(TextServer::OVERRUN_TRIM_WORD_ELLIPSIS);
+ vb->add_child(label);
+
+ dir_path = memnew(LineEdit);
+ dir_path->connect("text_changed", callable_mp(this, &DirectoryCreateDialog::_on_dir_path_changed));
+ vb->add_child(dir_path);
+ register_text_enter(dir_path);
+
+ Control *spacing = memnew(Control);
+ spacing->set_custom_minimum_size(Size2(0, 10 * EDSCALE));
+ vb->add_child(spacing);
+
+ status_panel = memnew(PanelContainer);
+ status_panel->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+ vb->add_child(status_panel);
+
+ status_label = memnew(Label);
+ status_label->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+ status_panel->add_child(status_label);
+}
diff --git a/editor/directory_create_dialog.h b/editor/directory_create_dialog.h
new file mode 100644
index 0000000000..e2601181da
--- /dev/null
+++ b/editor/directory_create_dialog.h
@@ -0,0 +1,68 @@
+/**************************************************************************/
+/* directory_create_dialog.h */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/**************************************************************************/
+
+#ifndef DIRECTORY_CREATE_DIALOG_H
+#define DIRECTORY_CREATE_DIALOG_H
+
+#include "scene/gui/dialogs.h"
+
+class Label;
+class LineEdit;
+class PanelContainer;
+
+class DirectoryCreateDialog : public ConfirmationDialog {
+ GDCLASS(DirectoryCreateDialog, ConfirmationDialog);
+
+ String base_dir;
+
+ Label *label = nullptr;
+ LineEdit *dir_path = nullptr;
+
+ PanelContainer *status_panel = nullptr;
+ Label *status_label = nullptr;
+
+ String _validate_path(const String &p_path) const;
+
+ void _on_dir_path_changed(const String &p_text);
+
+protected:
+ static void _bind_methods();
+ void _notification(int p_what);
+
+ virtual void ok_pressed() override;
+ virtual void _post_popup() override;
+
+public:
+ void config(const String &p_base_dir);
+
+ DirectoryCreateDialog();
+};
+
+#endif // DIRECTORY_CREATE_DIALOG_H
diff --git a/editor/doc_tools.cpp b/editor/doc_tools.cpp
index 110fa941af..7c9736413d 100644
--- a/editor/doc_tools.cpp
+++ b/editor/doc_tools.cpp
@@ -374,6 +374,11 @@ void DocTools::generate(bool p_basic_types) {
classes.pop_front();
continue;
}
+ if (ClassDB::get_api_type(name) != ClassDB::API_CORE && ClassDB::get_api_type(name) != ClassDB::API_EDITOR) {
+ print_verbose(vformat("Class '%s' belongs neither to core nor editor, skipping.", name));
+ classes.pop_front();
+ continue;
+ }
String cname = name;
// Property setters and getters do not get exposed as individual methods.
@@ -1367,10 +1372,7 @@ static void _write_string(Ref<FileAccess> f, int p_tablevel, const String &p_str
if (p_string.is_empty()) {
return;
}
- String tab;
- for (int i = 0; i < p_tablevel; i++) {
- tab += "\t";
- }
+ String tab = String("\t").repeat(p_tablevel);
f->store_string(tab + p_string + "\n");
}
diff --git a/editor/editor_command_palette.cpp b/editor/editor_command_palette.cpp
index 1c598277dd..eb35eddeb1 100644
--- a/editor/editor_command_palette.cpp
+++ b/editor/editor_command_palette.cpp
@@ -75,9 +75,15 @@ void EditorCommandPalette::_update_command_search(const String &search_text) {
r.shortcut_text = E.value.shortcut;
r.last_used = E.value.last_used;
- if (search_text.is_subsequence_ofn(r.display_name)) {
+ bool is_subsequence_of_key_name = search_text.is_subsequence_ofn(r.key_name);
+ bool is_subsequence_of_display_name = search_text.is_subsequence_ofn(r.display_name);
+
+ if (is_subsequence_of_key_name || is_subsequence_of_display_name) {
if (!search_text.is_empty()) {
- r.score = _score_path(search_text, r.display_name.to_lower());
+ float key_name_score = is_subsequence_of_key_name ? _score_path(search_text, r.key_name.to_lower()) : .0f;
+ float display_name_score = is_subsequence_of_display_name ? _score_path(search_text, r.display_name.to_lower()) : .0f;
+
+ r.score = MAX(key_name_score, display_name_score);
}
entries.push_back(r);
diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp
index 1421db42ec..753f54b807 100644
--- a/editor/editor_data.cpp
+++ b/editor/editor_data.cpp
@@ -622,7 +622,7 @@ void EditorData::remove_scene(int p_idx) {
}
if (!edited_scene[p_idx].path.is_empty()) {
- ScriptEditor::get_singleton()->close_builtin_scripts_from_scene(edited_scene[p_idx].path);
+ EditorNode::get_singleton()->emit_signal("scene_closed", edited_scene[p_idx].path);
}
undo_redo_manager->discard_history(edited_scene[p_idx].history_id);
@@ -713,6 +713,16 @@ int EditorData::get_edited_scene() const {
return current_edited_scene;
}
+int EditorData::get_edited_scene_from_path(const String &p_path) const {
+ for (int i = 0; i < edited_scene.size(); i++) {
+ if (edited_scene[i].path == p_path) {
+ return i;
+ }
+ }
+
+ return -1;
+}
+
void EditorData::set_edited_scene(int p_idx) {
ERR_FAIL_INDEX(p_idx, edited_scene.size());
current_edited_scene = p_idx;
diff --git a/editor/editor_data.h b/editor/editor_data.h
index 370963074c..d4a2f534cd 100644
--- a/editor/editor_data.h
+++ b/editor/editor_data.h
@@ -196,9 +196,11 @@ public:
void set_edited_scene(int p_idx);
void set_edited_scene_root(Node *p_root);
int get_edited_scene() const;
+ int get_edited_scene_from_path(const String &p_path) const;
Node *get_edited_scene_root(int p_idx = -1);
int get_edited_scene_count() const;
Vector<EditedScene> get_edited_scenes() const;
+
String get_scene_title(int p_idx, bool p_always_strip_extension = false) const;
String get_scene_path(int p_idx) const;
String get_scene_type(int p_idx) const;
@@ -211,6 +213,7 @@ public:
NodePath get_edited_scene_live_edit_root();
bool check_and_update_scene(int p_idx);
void move_edited_scene_to_index(int p_idx);
+
bool call_build();
void set_scene_as_saved(int p_idx);
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp
index 58080c08ae..0cdbddf4c4 100644
--- a/editor/editor_file_system.cpp
+++ b/editor/editor_file_system.cpp
@@ -1256,7 +1256,9 @@ void EditorFileSystem::_notification(int p_what) {
if (scanning_changes_done) {
set_process(false);
- thread_sources.wait_to_finish();
+ if (thread_sources.is_started()) {
+ thread_sources.wait_to_finish();
+ }
bool changed = _update_scan_actions();
_update_pending_script_classes();
if (changed) {
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index c2801e1188..dd2ee8c4ce 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -32,9 +32,9 @@
#include "core/core_constants.h"
#include "core/input/input.h"
+#include "core/object/script_language.h"
#include "core/os/keyboard.h"
#include "core/version.h"
-#include "core/version_generated.gen.h"
#include "doc_data_compressed.gen.h"
#include "editor/editor_node.h"
#include "editor/editor_paths.h"
@@ -45,6 +45,8 @@
#define CONTRIBUTE_URL vformat("%s/contributing/documentation/updating_the_class_reference.html", VERSION_DOCS_URL)
+// TODO: this is sometimes used directly as doc->something, other times as EditorHelp::get_doc_data(), which is thread-safe.
+// Might this be a problem?
DocTools *EditorHelp::doc = nullptr;
class DocCache : public Resource {
@@ -74,6 +76,55 @@ public:
void set_classes(const Array &p_classes) { classes = p_classes; }
};
+static bool _attempt_doc_load(const String &p_class) {
+ // Docgen always happens in the outer-most class: it also generates docs for inner classes.
+ String outer_class = p_class.get_slice(".", 0);
+ if (!ScriptServer::is_global_class(outer_class)) {
+ return false;
+ }
+
+ // ResourceLoader is used in order to have a script-agnostic way to load scripts.
+ // This forces GDScript to compile the code, which is unnecessary for docgen, but it's a good compromise right now.
+ Ref<Script> script = ResourceLoader::load(ScriptServer::get_global_class_path(outer_class), outer_class);
+ if (script.is_valid()) {
+ Vector<DocData::ClassDoc> docs = script->get_documentation();
+ for (int j = 0; j < docs.size(); j++) {
+ const DocData::ClassDoc &doc = docs.get(j);
+ EditorHelp::get_doc_data()->add_doc(doc);
+ }
+ return true;
+ }
+
+ return false;
+}
+
+// Removes unnecessary prefix from p_class_specifier when within the p_edited_class context
+static String _contextualize_class_specifier(const String &p_class_specifier, const String &p_edited_class) {
+ // If this is a completely different context than the current class, then keep full path
+ if (!p_class_specifier.begins_with(p_edited_class)) {
+ return p_class_specifier;
+ }
+
+ // Here equal length + begins_with from above implies p_class_specifier == p_edited_class :)
+ if (p_class_specifier.length() == p_edited_class.length()) {
+ int rfind = p_class_specifier.rfind(".");
+ if (rfind == -1) { // Single identifier
+ return p_class_specifier;
+ }
+ // Multiple specifiers: keep last one only
+ return p_class_specifier.substr(rfind + 1);
+ }
+
+ // They share a _name_ prefix but not a _class specifier_ prefix, e.g. Tree & TreeItem
+ // begins_with + lengths being different implies p_class_specifier.length() > p_edited_class.length() so this is safe
+ if (p_class_specifier[p_edited_class.length()] != '.') {
+ return p_class_specifier;
+ }
+
+ // Remove class specifier prefix
+ return p_class_specifier.substr(p_edited_class.length() + 1);
+}
+
void EditorHelp::_update_theme_item_cache() {
VBoxContainer::_update_theme_item_cache();
@@ -131,12 +182,13 @@ void EditorHelp::_class_list_select(const String &p_select) {
}
void EditorHelp::_class_desc_select(const String &p_select) {
- if (p_select.begins_with("$")) { //enum
+ if (p_select.begins_with("$")) { // enum
String select = p_select.substr(1, p_select.length());
String class_name;
- if (select.contains(".")) {
- class_name = select.get_slice(".", 0);
- select = select.get_slice(".", 1);
+ int rfind = select.rfind(".");
+ if (rfind != -1) {
+ class_name = select.substr(0, rfind);
+ select = select.substr(rfind + 1);
} else {
class_name = "@GlobalScope";
}
@@ -254,35 +306,35 @@ void EditorHelp::_add_type(const String &p_type, const String &p_enum) {
bool is_enum_type = !p_enum.is_empty();
bool can_ref = !p_type.contains("*") || is_enum_type;
- String t = p_type;
+ String link_t = p_type; // For links in metadata
+ String display_t = link_t; // For display purposes
if (is_enum_type) {
- if (p_enum.get_slice_count(".") > 1) {
- t = p_enum.get_slice(".", 1);
- } else {
- t = p_enum.get_slice(".", 0);
- }
+ link_t = p_enum; // The link for enums is always the full enum description
+ display_t = _contextualize_class_specifier(p_enum, edited_class);
+ } else {
+ display_t = _contextualize_class_specifier(p_type, edited_class);
}
class_desc->push_color(theme_cache.type_color);
bool add_array = false;
if (can_ref) {
- if (t.ends_with("[]")) {
+ if (link_t.ends_with("[]")) {
add_array = true;
- t = t.replace("[]", "");
+ link_t = link_t.replace("[]", "");
- class_desc->push_meta("#Array"); //class
+ class_desc->push_meta("#Array"); // class
class_desc->add_text("Array");
class_desc->pop();
class_desc->add_text("[");
}
if (is_enum_type) {
- class_desc->push_meta("$" + p_enum); //class
+ class_desc->push_meta("$" + link_t); // enum
} else {
- class_desc->push_meta("#" + t); //class
+ class_desc->push_meta("#" + link_t); // class
}
}
- class_desc->add_text(t);
+ class_desc->add_text(display_t);
if (can_ref) {
class_desc->pop(); // Pushed meta above.
if (add_array) {
@@ -339,7 +391,7 @@ String EditorHelp::_fix_constant(const String &p_constant) const {
class_desc->pop();
void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview) {
- method_line[p_method.name] = class_desc->get_paragraph_count() - 2; //gets overridden if description
+ method_line[p_method.name] = class_desc->get_paragraph_count() - 2; // Gets overridden if description
const bool is_vararg = p_method.qualifiers.contains("vararg");
@@ -353,8 +405,8 @@ void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview
_add_type(p_method.return_type, p_method.return_enum);
if (p_overview) {
- class_desc->pop(); //align
- class_desc->pop(); //cell
+ class_desc->pop(); // align
+ class_desc->pop(); // cell
class_desc->push_cell();
} else {
class_desc->add_text(" ");
@@ -369,7 +421,7 @@ void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview
class_desc->pop();
if (p_overview && !p_method.description.strip_edges().is_empty()) {
- class_desc->pop(); //meta
+ class_desc->pop(); // meta
}
class_desc->push_color(theme_cache.symbol_color);
@@ -448,7 +500,7 @@ void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview
}
if (p_overview) {
- class_desc->pop(); //cell
+ class_desc->pop(); // cell
}
}
@@ -489,8 +541,9 @@ void EditorHelp::_pop_code_font() {
class_desc->pop();
}
-Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) {
- if (!doc->class_list.has(p_class)) {
+Error EditorHelp::_goto_desc(const String &p_class) {
+ // If class doesn't have docs listed, attempt on-demand docgen
+ if (!doc->class_list.has(p_class) && !_attempt_doc_load(p_class)) {
return ERR_DOES_NOT_EXIST;
}
@@ -530,9 +583,9 @@ void EditorHelp::_update_method_list(const Vector<DocData::MethodDoc> p_methods)
if (any_previous && !m.is_empty()) {
class_desc->push_cell();
- class_desc->pop(); //cell
+ class_desc->pop(); // cell
class_desc->push_cell();
- class_desc->pop(); //cell
+ class_desc->pop(); // cell
}
String group_prefix;
@@ -550,9 +603,9 @@ void EditorHelp::_update_method_list(const Vector<DocData::MethodDoc> p_methods)
if (is_new_group && pass == 1) {
class_desc->push_cell();
- class_desc->pop(); //cell
+ class_desc->pop(); // cell
class_desc->push_cell();
- class_desc->pop(); //cell
+ class_desc->pop(); // cell
}
_add_method(m[i], true);
@@ -561,7 +614,7 @@ void EditorHelp::_update_method_list(const Vector<DocData::MethodDoc> p_methods)
any_previous = !m.is_empty();
}
- class_desc->pop(); //table
+ class_desc->pop(); // table
class_desc->pop();
_pop_code_font();
@@ -1197,7 +1250,7 @@ void EditorHelp::_update_doc() {
_add_text(cd.signals[i].arguments[j].name);
class_desc->add_text(": ");
- _add_type(cd.signals[i].arguments[j].type);
+ _add_type(cd.signals[i].arguments[j].type, cd.signals[i].arguments[j].enumeration);
if (!cd.signals[i].arguments[j].default_value.is_empty()) {
class_desc->push_color(theme_cache.symbol_color);
class_desc->add_text(" = ");
@@ -1768,7 +1821,6 @@ void EditorHelp::_request_help(const String &p_string) {
if (err == OK) {
EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT);
}
- //100 palabras
}
void EditorHelp::_help_callback(const String &p_topic) {
@@ -2179,7 +2231,7 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt, Control
tag_stack.push_front("font");
} else {
- p_rt->add_text("["); //ignore
+ p_rt->add_text("["); // ignore
pos = brk_pos + 1;
}
}
@@ -2202,16 +2254,18 @@ String EditorHelp::get_cache_full_path() {
}
static bool first_attempt = true;
-static List<StringName> classes_whitelist;
+
+static String _compute_doc_version_hash() {
+ return uitos(ClassDB::get_api_hash(ClassDB::API_CORE)) + "-" + uitos(ClassDB::get_api_hash(ClassDB::API_EDITOR));
+}
void EditorHelp::_load_doc_thread(void *p_udata) {
DEV_ASSERT(first_attempt);
Ref<DocCache> cache_res = ResourceLoader::load(get_cache_full_path());
- if (cache_res.is_valid() && cache_res->get_version_hash() == String(VERSION_HASH)) {
+ if (cache_res.is_valid() && cache_res->get_version_hash() == _compute_doc_version_hash()) {
for (int i = 0; i < cache_res->get_classes().size(); i++) {
doc->add_doc(DocData::ClassDoc::from_dict(cache_res->get_classes()[i]));
}
- classes_whitelist.clear();
} else {
// We have to go back to the main thread to start from scratch.
first_attempt = false;
@@ -2226,7 +2280,7 @@ void EditorHelp::_gen_doc_thread(void *p_udata) {
Ref<DocCache> cache_res;
cache_res.instantiate();
- cache_res->set_version_hash(VERSION_HASH);
+ cache_res->set_version_hash(_compute_doc_version_hash());
Array classes;
for (const KeyValue<String, DocData::ClassDoc> &E : doc->class_list) {
classes.push_back(DocData::ClassDoc::to_dict(E.value));
@@ -2249,9 +2303,6 @@ void EditorHelp::generate_doc(bool p_use_cache) {
DEV_ASSERT(first_attempt == (doc == nullptr));
if (!doc) {
- // Classes registered after this point should not have documentation generated.
- ClassDB::get_class_list(&classes_whitelist);
-
GDREGISTER_CLASS(DocCache);
doc = memnew(DocTools);
}
@@ -2265,22 +2316,6 @@ void EditorHelp::generate_doc(bool p_use_cache) {
} else {
print_verbose("Regenerating editor help cache");
- if (!first_attempt) {
- // Some classes that should not be exposed may have been registered by now. Unexpose them.
- // Arduous, but happens only when regenerating.
- List<StringName> current_classes;
- ClassDB::get_class_list(&current_classes);
- List<StringName>::Element *W = classes_whitelist.front();
- for (const StringName &name : current_classes) {
- if (W && W->get() == name) {
- W = W->next();
- } else {
- ClassDB::classes[name].exposed = false;
- }
- }
- }
- classes_whitelist.clear();
-
// Not doable on threads unfortunately, since it instantiates all sorts of classes to get default values.
doc->generate(true);
@@ -2328,9 +2363,9 @@ void EditorHelp::go_to_help(const String &p_help) {
_help_callback(p_help);
}
-void EditorHelp::go_to_class(const String &p_class, int p_scroll) {
+void EditorHelp::go_to_class(const String &p_class) {
_wait_for_thread();
- _goto_desc(p_class, p_scroll);
+ _goto_desc(p_class);
}
void EditorHelp::update_doc() {
@@ -2342,9 +2377,6 @@ void EditorHelp::update_doc() {
void EditorHelp::cleanup_doc() {
_wait_for_thread();
- if (doc_gen_use_threads) {
- thread.wait_to_finish();
- }
memdelete(doc);
}
@@ -2461,14 +2493,15 @@ void EditorHelpBit::_go_to_help(String p_what) {
}
void EditorHelpBit::_meta_clicked(String p_select) {
- if (p_select.begins_with("$")) { //enum
-
+ if (p_select.begins_with("$")) { // enum
String select = p_select.substr(1, p_select.length());
String class_name;
- if (select.contains(".")) {
- class_name = select.get_slice(".", 0);
+ int rfind = select.rfind(".");
+ if (rfind != -1) {
+ class_name = select.substr(0, rfind);
+ select = select.substr(rfind + 1);
} else {
- class_name = "@Global";
+ class_name = "@GlobalScope";
}
_go_to_help("class_enum:" + class_name + ":" + select);
return;
diff --git a/editor/editor_help.h b/editor/editor_help.h
index 01e91b4593..4175ece816 100644
--- a/editor/editor_help.h
+++ b/editor/editor_help.h
@@ -178,7 +178,7 @@ class EditorHelp : public VBoxContainer {
void _class_desc_resized(bool p_force_update_theme);
int display_margin = 0;
- Error _goto_desc(const String &p_class, int p_vscr = -1);
+ Error _goto_desc(const String &p_class);
//void _update_history_buttons();
void _update_method_list(const Vector<DocData::MethodDoc> p_methods);
void _update_method_descriptions(const DocData::ClassDoc p_classdoc, const Vector<DocData::MethodDoc> p_methods, const String &p_method_type);
@@ -210,7 +210,7 @@ public:
static String get_cache_full_path();
void go_to_help(const String &p_help);
- void go_to_class(const String &p_class, int p_scroll = 0);
+ void go_to_class(const String &p_class);
void update_doc();
Vector<Pair<String, int>> get_sections();
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index 31d66ba451..2b02818645 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -2783,7 +2783,9 @@ void EditorInspector::update_tree() {
// Update the docs reference and the label based on the script.
Vector<DocData::ClassDoc> docs = scr->get_documentation();
if (!docs.is_empty()) {
- doc_name = docs[0].name;
+ // The documentation of a GDScript's main class is at the end of the array.
+ // Hacky because this isn't necessarily always guaranteed.
+ doc_name = docs[docs.size() - 1].name;
}
if (script_name != StringName()) {
label = script_name;
@@ -3132,7 +3134,9 @@ void EditorInspector::update_tree() {
if (scr.is_valid()) {
Vector<DocData::ClassDoc> docs = scr->get_documentation();
if (!docs.is_empty()) {
- classname = docs[0].name;
+ // The documentation of a GDScript's main class is at the end of the array.
+ // Hacky because this isn't necessarily always guaranteed.
+ classname = docs[docs.size() - 1].name;
}
}
}
@@ -3437,6 +3441,16 @@ void EditorInspector::set_property_name_style(EditorPropertyNameProcessor::Style
update_tree();
}
+void EditorInspector::set_use_settings_name_style(bool p_enable) {
+ if (use_settings_name_style == p_enable) {
+ return;
+ }
+ use_settings_name_style = p_enable;
+ if (use_settings_name_style) {
+ set_property_name_style(EditorPropertyNameProcessor::get_singleton()->get_settings_style());
+ }
+}
+
void EditorInspector::set_autoclear(bool p_enable) {
autoclear = p_enable;
}
@@ -3969,7 +3983,20 @@ void EditorInspector::_notification(int p_what) {
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
_update_inspector_bg();
+ bool needs_update = false;
+
+ if (use_settings_name_style && EditorSettings::get_singleton()->check_changed_settings_in_group("interface/editor/localize_settings")) {
+ EditorPropertyNameProcessor::Style style = EditorPropertyNameProcessor::get_settings_style();
+ if (property_name_style != style) {
+ property_name_style = style;
+ needs_update = true;
+ }
+ }
if (EditorSettings::get_singleton()->check_changed_settings_in_group("interface/inspector")) {
+ needs_update = true;
+ }
+
+ if (needs_update) {
update_tree();
}
} break;
@@ -4154,4 +4181,7 @@ EditorInspector::EditorInspector() {
ED_SHORTCUT("property_editor/copy_value", TTR("Copy Value"), KeyModifierMask::CMD_OR_CTRL | Key::C);
ED_SHORTCUT("property_editor/paste_value", TTR("Paste Value"), KeyModifierMask::CMD_OR_CTRL | Key::V);
ED_SHORTCUT("property_editor/copy_property_path", TTR("Copy Property Path"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::C);
+
+ // `use_settings_name_style` is true by default, set the name style accordingly.
+ set_property_name_style(EditorPropertyNameProcessor::get_singleton()->get_settings_style());
}
diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h
index b3709e93f4..e9a4eaec30 100644
--- a/editor/editor_inspector.h
+++ b/editor/editor_inspector.h
@@ -465,6 +465,7 @@ class EditorInspector : public ScrollContainer {
bool hide_metadata = true;
bool use_doc_hints = false;
EditorPropertyNameProcessor::Style property_name_style = EditorPropertyNameProcessor::STYLE_CAPITALIZED;
+ bool use_settings_name_style = true;
bool use_filter = false;
bool autoclear = false;
bool use_folding = false;
@@ -570,6 +571,9 @@ public:
EditorPropertyNameProcessor::Style get_property_name_style() const;
void set_property_name_style(EditorPropertyNameProcessor::Style p_style);
+ // If true, the inspector will update its property name style according to the current editor settings.
+ void set_use_settings_name_style(bool p_enable);
+
void set_autoclear(bool p_enable);
void set_show_categories(bool p_show);
diff --git a/editor/editor_interface.cpp b/editor/editor_interface.cpp
index 99803fd82d..167a5a3dba 100644
--- a/editor/editor_interface.cpp
+++ b/editor/editor_interface.cpp
@@ -37,6 +37,7 @@
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/filesystem_dock.h"
+#include "editor/gui/editor_run_bar.h"
#include "editor/inspector_dock.h"
#include "main/main.h"
#include "scene/gui/box_container.h"
@@ -317,35 +318,35 @@ void EditorInterface::save_scene_as(const String &p_scene, bool p_with_preview)
// Scene playback.
void EditorInterface::play_main_scene() {
- EditorNode::get_singleton()->run_play();
+ EditorRunBar::get_singleton()->play_main_scene();
}
void EditorInterface::play_current_scene() {
- EditorNode::get_singleton()->run_play_current();
+ EditorRunBar::get_singleton()->play_current_scene();
}
void EditorInterface::play_custom_scene(const String &scene_path) {
- EditorNode::get_singleton()->run_play_custom(scene_path);
+ EditorRunBar::get_singleton()->play_custom_scene(scene_path);
}
void EditorInterface::stop_playing_scene() {
- EditorNode::get_singleton()->run_stop();
+ EditorRunBar::get_singleton()->stop_playing();
}
bool EditorInterface::is_playing_scene() const {
- return EditorNode::get_singleton()->is_run_playing();
+ return EditorRunBar::get_singleton()->is_playing();
}
String EditorInterface::get_playing_scene() const {
- return EditorNode::get_singleton()->get_run_playing_scene();
+ return EditorRunBar::get_singleton()->get_playing_scene();
}
void EditorInterface::set_movie_maker_enabled(bool p_enabled) {
- EditorNode::get_singleton()->set_movie_maker_enabled(p_enabled);
+ EditorRunBar::get_singleton()->set_movie_maker_enabled(p_enabled);
}
bool EditorInterface::is_movie_maker_enabled() const {
- return EditorNode::get_singleton()->is_movie_maker_enabled();
+ return EditorRunBar::get_singleton()->is_movie_maker_enabled();
}
// Base.
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index f2f1285799..864d45230a 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -53,6 +53,8 @@
#include "scene/gui/menu_button.h"
#include "scene/gui/panel.h"
#include "scene/gui/panel_container.h"
+#include "scene/gui/popup.h"
+#include "scene/gui/rich_text_label.h"
#include "scene/gui/split_container.h"
#include "scene/gui/tab_bar.h"
#include "scene/gui/tab_container.h"
@@ -99,6 +101,7 @@
#include "editor/fbx_importer_manager.h"
#include "editor/filesystem_dock.h"
#include "editor/gui/editor_file_dialog.h"
+#include "editor/gui/editor_run_bar.h"
#include "editor/gui/editor_title_bar.h"
#include "editor/gui/editor_toaster.h"
#include "editor/history_dock.h"
@@ -747,6 +750,9 @@ void EditorNode::_notification(int p_what) {
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
scene_tabs->set_tab_close_display_policy((TabBar::CloseButtonDisplayPolicy)EDITOR_GET("interface/scene_tabs/display_close_button").operator int());
+ FileDialog::set_default_show_hidden_files(EDITOR_GET("filesystem/file_dialog/show_hidden_files"));
+ EditorFileDialog::set_default_show_hidden_files(EDITOR_GET("filesystem/file_dialog/show_hidden_files"));
+ EditorFileDialog::set_default_display_mode((EditorFileDialog::DisplayMode)EDITOR_GET("filesystem/file_dialog/display_mode").operator int());
bool theme_changed =
EditorSettings::get_singleton()->check_changed_settings_in_group("interface/theme") ||
@@ -756,7 +762,9 @@ void EditorNode::_notification(int p_what) {
EditorSettings::get_singleton()->check_changed_settings_in_group("text_editor/theme") ||
EditorSettings::get_singleton()->check_changed_settings_in_group("text_editor/help/help") ||
EditorSettings::get_singleton()->check_changed_settings_in_group("filesystem/file_dialog/thumbnail_size") ||
- EditorSettings::get_singleton()->check_changed_settings_in_group("run/output/font_size");
+ EditorSettings::get_singleton()->check_changed_settings_in_group("run/output/font_size") ||
+ EditorSettings::get_singleton()->check_changed_settings_in_group("interface/touchscreen/increase_scrollbar_touch_area") ||
+ EditorSettings::get_singleton()->check_changed_settings_in_group("interface/touchscreen/scale_gizmo_handles");
if (theme_changed) {
theme = create_custom_theme(theme_base->get_theme());
@@ -802,20 +810,6 @@ void EditorNode::_notification(int p_what) {
_build_icon_type_cache();
- if (write_movie_button->is_pressed()) {
- launch_pad->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("LaunchPadMovieMode"), SNAME("EditorStyles")));
- write_movie_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("MovieWriterButtonPressed"), SNAME("EditorStyles")));
- } else {
- launch_pad->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("LaunchPadNormal"), SNAME("EditorStyles")));
- write_movie_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("MovieWriterButtonNormal"), SNAME("EditorStyles")));
- }
-
- play_button->set_icon(gui_base->get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons")));
- play_scene_button->set_icon(gui_base->get_theme_icon(SNAME("PlayScene"), SNAME("EditorIcons")));
- play_custom_scene_button->set_icon(gui_base->get_theme_icon(SNAME("PlayCustom"), SNAME("EditorIcons")));
- pause_button->set_icon(gui_base->get_theme_icon(SNAME("Pause"), SNAME("EditorIcons")));
- stop_button->set_icon(gui_base->get_theme_icon(SNAME("Stop"), SNAME("EditorIcons")));
-
prev_scene->set_icon(gui_base->get_theme_icon(SNAME("PrevScene"), SNAME("EditorIcons")));
distraction_free->set_icon(gui_base->get_theme_icon(SNAME("DistractionFree"), SNAME("EditorIcons")));
scene_tab_add->set_icon(gui_base->get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
@@ -1194,7 +1188,7 @@ void EditorNode::_vp_resized() {
}
void EditorNode::_titlebar_resized() {
- DisplayServer::get_singleton()->window_set_window_buttons_offset(Vector2i(menu_hb->get_global_position().y + menu_hb->get_size().y / 2, menu_hb->get_global_position().y + menu_hb->get_size().y / 2), DisplayServer::MAIN_WINDOW_ID);
+ DisplayServer::get_singleton()->window_set_window_buttons_offset(Vector2i(title_bar->get_global_position().y + title_bar->get_size().y / 2, title_bar->get_global_position().y + title_bar->get_size().y / 2), DisplayServer::MAIN_WINDOW_ID);
const Vector3i &margin = DisplayServer::get_singleton()->window_get_safe_title_margins(DisplayServer::MAIN_WINDOW_ID);
if (left_menu_spacer) {
int w = (gui_base->is_layout_rtl()) ? margin.y : margin.x;
@@ -1204,8 +1198,8 @@ void EditorNode::_titlebar_resized() {
int w = (gui_base->is_layout_rtl()) ? margin.x : margin.y;
right_menu_spacer->set_custom_minimum_size(Size2(w, 0));
}
- if (menu_hb) {
- menu_hb->set_custom_minimum_size(Size2(0, margin.z - menu_hb->get_global_position().y));
+ if (title_bar) {
+ title_bar->set_custom_minimum_size(Size2(0, margin.z - title_bar->get_global_position().y));
}
}
@@ -1814,7 +1808,7 @@ void EditorNode::_save_scene(String p_file, int idx) {
editor_data.apply_changes_in_editors();
List<Ref<AnimatedValuesBackup>> anim_backups;
_reset_animation_players(scene, &anim_backups);
- _save_default_environment();
+ save_default_environment();
_set_scene_metadata(p_file, idx);
@@ -1876,7 +1870,7 @@ void EditorNode::_save_scene(String p_file, int idx) {
}
void EditorNode::save_all_scenes() {
- _menu_option_confirm(RUN_STOP, true);
+ project_run_bar->stop_playing();
_save_all_scenes();
}
@@ -1890,11 +1884,33 @@ void EditorNode::save_scene_list(Vector<String> p_scene_filenames) {
}
}
+void EditorNode::save_before_run() {
+ current_menu_option = FILE_SAVE_AND_RUN;
+ _menu_option_confirm(FILE_SAVE_AS_SCENE, true);
+ file->set_title(TTR("Save scene before running..."));
+}
+
+void EditorNode::try_autosave() {
+ if (!bool(EDITOR_GET("run/auto_save/save_before_running"))) {
+ return;
+ }
+
+ if (unsaved_cache) {
+ Node *scene = editor_data.get_edited_scene_root();
+
+ if (scene && !scene->get_scene_file_path().is_empty()) { // 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);
+ editor_data.save_editor_external_data();
+}
+
void EditorNode::restart_editor() {
exiting = true;
- if (editor_run.get_status() != EditorRun::STATUS_STOP) {
- editor_run.stop();
+ if (project_run_bar->is_playing()) {
+ project_run_bar->stop_playing();
}
String to_reopen;
@@ -1942,7 +1958,7 @@ void EditorNode::_save_all_scenes() {
if (!all_saved) {
show_warning(TTR("Could not save one or more scenes!"), TTR("Save All Scenes"));
}
- _save_default_environment();
+ save_default_environment();
}
void EditorNode::_mark_unsaved_scenes() {
@@ -1982,11 +1998,7 @@ void EditorNode::_dialog_action(String p_file) {
ProjectSettings::get_singleton()->save();
// TODO: Would be nice to show the project manager opened with the highlighted field.
- if ((bool)pick_main_scene->get_meta("from_native", false)) {
- run_native->resume_run_native();
- } else {
- _run(false, ""); // Automatically run the project.
- }
+ project_run_bar->play_main_scene((bool)pick_main_scene->get_meta("from_native", false));
} break;
case FILE_CLOSE:
case SCENE_TAB_CLOSE:
@@ -2007,7 +2019,7 @@ void EditorNode::_dialog_action(String p_file) {
return;
}
- _save_default_environment();
+ save_default_environment();
_save_scene_with_preview(p_file, scene_idx);
_add_to_recent_scenes(p_file);
save_layout();
@@ -2021,9 +2033,9 @@ void EditorNode::_dialog_action(String p_file) {
case FILE_SAVE_AND_RUN: {
if (file->get_file_mode() == EditorFileDialog::FILE_MODE_SAVE_FILE) {
- _save_default_environment();
+ save_default_environment();
_save_scene_with_preview(p_file);
- _run(false, p_file);
+ project_run_bar->play_custom_scene(p_file);
}
} break;
@@ -2032,13 +2044,9 @@ void EditorNode::_dialog_action(String p_file) {
ProjectSettings::get_singleton()->save();
if (file->get_file_mode() == EditorFileDialog::FILE_MODE_SAVE_FILE) {
- _save_default_environment();
+ save_default_environment();
_save_scene_with_preview(p_file);
- if ((bool)pick_main_scene->get_meta("from_native", false)) {
- run_native->resume_run_native();
- } else {
- _run(false, p_file);
- }
+ project_run_bar->play_main_scene((bool)pick_main_scene->get_meta("from_native", false));
}
} break;
@@ -2250,7 +2258,7 @@ void EditorNode::push_item(Object *p_object, const String &p_property, bool p_in
_edit_current();
}
-void EditorNode::_save_default_environment() {
+void EditorNode::save_default_environment() {
Ref<Environment> fallback = get_tree()->get_root()->get_world_3d()->get_fallback_environment();
if (fallback.is_valid() && fallback->get_path().is_resource_file()) {
@@ -2496,157 +2504,6 @@ void EditorNode::_edit_current(bool p_skip_foreign) {
InspectorDock::get_singleton()->update(current_obj);
}
-void EditorNode::_write_movie_toggled(bool p_enabled) {
- if (p_enabled) {
- launch_pad->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("LaunchPadMovieMode"), SNAME("EditorStyles")));
- write_movie_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("MovieWriterButtonPressed"), SNAME("EditorStyles")));
- } else {
- launch_pad->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("LaunchPadNormal"), SNAME("EditorStyles")));
- write_movie_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("MovieWriterButtonNormal"), SNAME("EditorStyles")));
- }
-}
-
-void EditorNode::_run(bool p_current, const String &p_custom) {
- if (editor_run.get_status() == EditorRun::STATUS_PLAY) {
- play_button->set_pressed(!_playing_edited);
- play_scene_button->set_pressed(_playing_edited);
- return;
- }
-
- play_button->set_pressed(false);
- play_button->set_icon(gui_base->get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons")));
- play_scene_button->set_pressed(false);
- play_scene_button->set_icon(gui_base->get_theme_icon(SNAME("PlayScene"), SNAME("EditorIcons")));
- play_custom_scene_button->set_pressed(false);
- play_custom_scene_button->set_icon(gui_base->get_theme_icon(SNAME("PlayCustom"), SNAME("EditorIcons")));
-
- String write_movie_file;
- if (write_movie_button->is_pressed()) {
- if (p_current && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->has_meta("movie_file")) {
- // If the scene file has a movie_file metadata set, use this as file. Quick workaround if you want to have multiple scenes that write to multiple movies.
- write_movie_file = get_tree()->get_edited_scene_root()->get_meta("movie_file");
- } else {
- write_movie_file = GLOBAL_GET("editor/movie_writer/movie_file");
- }
- if (write_movie_file == String()) {
- show_accept(TTR("Movie Maker mode is enabled, but no movie file path has been specified.\nA default movie file path can be specified in the project settings under the Editor > Movie Writer category.\nAlternatively, for running single scenes, a `movie_file` string metadata can be added to the root node,\nspecifying the path to a movie file that will be used when recording that scene."), TTR("OK"));
- return;
- }
- }
-
- String run_filename;
-
- if ((p_current && p_custom.is_empty()) || (editor_data.get_edited_scene_root() && !p_custom.is_empty() && p_custom == editor_data.get_edited_scene_root()->get_scene_file_path())) {
- Node *scene = editor_data.get_edited_scene_root();
-
- if (!scene) {
- show_accept(TTR("There is no defined scene to run."), TTR("OK"));
- return;
- }
-
- if (scene->get_scene_file_path().is_empty()) {
- current_menu_option = FILE_SAVE_AND_RUN;
- _menu_option_confirm(FILE_SAVE_AS_SCENE, true);
- file->set_title(TTR("Save scene before running..."));
- return;
- }
-
- run_filename = scene->get_scene_file_path();
- } else if (!p_custom.is_empty()) {
- run_filename = p_custom;
- }
-
- if (run_filename.is_empty()) {
- // Evidently, run the scene.
- if (!ensure_main_scene(false)) {
- return;
- }
- run_filename = GLOBAL_DEF_BASIC("application/run/main_scene", "");
- }
-
- if (bool(EDITOR_GET("run/auto_save/save_before_running"))) {
- if (unsaved_cache) {
- Node *scene = editor_data.get_edited_scene_root();
-
- if (scene && !scene->get_scene_file_path().is_empty()) { // 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);
- editor_data.save_editor_external_data();
- }
-
- if (!call_build()) {
- return;
- }
-
- if (bool(EDITOR_GET("run/output/always_clear_output_on_play"))) {
- log->clear();
- }
-
- if (bool(EDITOR_GET("run/output/always_open_output_on_play"))) {
- make_bottom_panel_item_visible(log);
- }
-
- EditorDebuggerNode::get_singleton()->start();
- Error error = editor_run.run(run_filename, write_movie_file);
- if (error != OK) {
- EditorDebuggerNode::get_singleton()->stop();
- show_accept(TTR("Could not start subprocess(es)!"), TTR("OK"));
- return;
- }
-
- emit_signal(SNAME("play_pressed"));
- if (p_current) {
- run_current_filename = run_filename;
- play_scene_button->set_pressed(true);
- play_scene_button->set_icon(gui_base->get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")));
- play_scene_button->set_tooltip_text(TTR("Reload the played scene."));
- } else if (!p_custom.is_empty()) {
- run_custom_filename = p_custom;
- play_custom_scene_button->set_pressed(true);
- play_custom_scene_button->set_icon(gui_base->get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")));
- play_custom_scene_button->set_tooltip_text(TTR("Reload the played scene."));
- } else {
- play_button->set_pressed(true);
- play_button->set_icon(gui_base->get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")));
- play_button->set_tooltip_text(TTR("Reload the played scene."));
- }
- stop_button->set_disabled(false);
-
- _playing_edited = p_current;
-}
-
-void EditorNode::_run_native(const Ref<EditorExportPreset> &p_preset) {
- bool autosave = EDITOR_GET("run/auto_save/save_before_running");
- if (autosave) {
- _menu_option_confirm(FILE_SAVE_ALL_SCENES, false);
- }
- if (run_native->is_deploy_debug_remote_enabled()) {
- _menu_option_confirm(RUN_STOP, true);
-
- if (!call_build()) {
- return; // Build failed.
- }
-
- EditorDebuggerNode::get_singleton()->start(p_preset->get_platform()->get_debug_protocol());
- emit_signal(SNAME("play_pressed"));
- editor_run.run_native_notify();
- }
-}
-
-void EditorNode::_reset_play_buttons() {
- play_button->set_pressed(false);
- play_button->set_icon(gui_base->get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons")));
- play_button->set_tooltip_text(TTR("Play the project."));
- play_scene_button->set_pressed(false);
- play_scene_button->set_icon(gui_base->get_theme_icon(SNAME("PlayScene"), SNAME("EditorIcons")));
- play_scene_button->set_tooltip_text(TTR("Play the edited scene."));
- play_custom_scene_button->set_pressed(false);
- play_custom_scene_button->set_icon(gui_base->get_theme_icon(SNAME("PlayCustom"), SNAME("EditorIcons")));
- play_custom_scene_button->set_tooltip_text(TTR("Play a custom scene."));
-}
-
void EditorNode::_android_build_source_selected(const String &p_file) {
export_template_manager->install_android_template_from_file(p_file);
}
@@ -2813,6 +2670,10 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
_save_all_scenes();
} break;
+ case FILE_RUN_SCENE: {
+ project_run_bar->play_current_scene();
+ } break;
+
case FILE_EXPORT_PROJECT: {
project_export->popup_export();
} break;
@@ -2917,45 +2778,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
scene_tabs->set_current_tab(cur_idx);
} break;
- case RUN_PLAY: {
- run_play();
-
- } break;
- case RUN_PLAY_CUSTOM_SCENE: {
- if (run_custom_filename.is_empty() || editor_run.get_status() == EditorRun::STATUS_STOP) {
- _menu_option_confirm(RUN_STOP, true);
- quick_run->popup_dialog("PackedScene", true);
- quick_run->set_title(TTR("Quick Run Scene..."));
- play_custom_scene_button->set_pressed(false);
- } else {
- String last_custom_scene = run_custom_filename; // This is necessary to have a copy of the string.
- run_play_custom(last_custom_scene);
- }
-
- } break;
- case RUN_STOP: {
- if (editor_run.get_status() == EditorRun::STATUS_STOP) {
- break;
- }
-
- editor_run.stop();
- run_custom_filename.clear();
- run_current_filename.clear();
- stop_button->set_disabled(true);
- _reset_play_buttons();
-
- if (bool(EDITOR_GET("run/output/always_close_output_on_stop"))) {
- for (int i = 0; i < bottom_panel_items.size(); i++) {
- if (bottom_panel_items[i].control == log) {
- _bottom_panel_switch(false, i);
- break;
- }
- }
- }
- EditorDebuggerNode::get_singleton()->stop();
- emit_signal(SNAME("stop_pressed"));
-
- } break;
case FILE_SHOW_IN_FILESYSTEM: {
String path = editor_data.get_scene_path(editor_data.get_edited_scene());
@@ -2964,15 +2786,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
}
} break;
- case RUN_PLAY_SCENE: {
- if (run_current_filename.is_empty() || editor_run.get_status() == EditorRun::STATUS_STOP) {
- run_play_current();
- } else {
- String last_current_scene = run_current_filename; // This is necessary to have a copy of the string.
- run_play_custom(last_current_scene);
- }
-
- } break;
case RUN_SETTINGS: {
project_settings_editor->popup_project_settings();
} break;
@@ -2995,10 +2808,10 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
case RUN_USER_DATA_FOLDER: {
// Ensure_user_data_dir() to prevent the edge case: "Open User Data Folder" won't work after the project was renamed in ProjectSettingsEditor unless the project is saved.
OS::get_singleton()->ensure_user_data_dir();
- OS::get_singleton()->shell_open(String("file://") + OS::get_singleton()->get_user_data_dir());
+ OS::get_singleton()->shell_show_in_file_manager(OS::get_singleton()->get_user_data_dir(), true);
} break;
case FILE_EXPLORE_ANDROID_BUILD_TEMPLATES: {
- OS::get_singleton()->shell_open("file://" + ProjectSettings::get_singleton()->get_resource_path().path_join("android"));
+ OS::get_singleton()->shell_show_in_file_manager(ProjectSettings::get_singleton()->get_resource_path().path_join("android"), true);
} break;
case FILE_QUIT:
case RUN_PROJECT_MANAGER:
@@ -3070,10 +2883,10 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
editor_settings_dialog->popup_edit_settings();
} break;
case SETTINGS_EDITOR_DATA_FOLDER: {
- OS::get_singleton()->shell_open(String("file://") + EditorPaths::get_singleton()->get_data_dir());
+ OS::get_singleton()->shell_show_in_file_manager(EditorPaths::get_singleton()->get_data_dir(), true);
} break;
case SETTINGS_EDITOR_CONFIG_FOLDER: {
- OS::get_singleton()->shell_open(String("file://") + EditorPaths::get_singleton()->get_config_dir());
+ OS::get_singleton()->shell_show_in_file_manager(EditorPaths::get_singleton()->get_config_dir(), true);
} break;
case SETTINGS_MANAGE_EXPORT_TEMPLATES: {
export_template_manager->popup_manager();
@@ -3176,7 +2989,7 @@ void EditorNode::_screenshot(bool p_use_utc) {
NodePath path = String("user://") + name;
_save_screenshot(path);
if (EDITOR_GET("interface/editor/automatically_open_screenshots")) {
- OS::get_singleton()->shell_open(String("file://") + ProjectSettings::get_singleton()->globalize_path(path));
+ OS::get_singleton()->shell_show_in_file_manager(ProjectSettings::get_singleton()->globalize_path(path), true);
}
}
@@ -3296,12 +3109,12 @@ void EditorNode::_discard_changes(const String &p_str) {
_proceed_closing_scene_tabs();
} break;
case FILE_QUIT: {
- _menu_option_confirm(RUN_STOP, true);
+ project_run_bar->stop_playing();
_exit_editor(EXIT_SUCCESS);
} break;
case RUN_PROJECT_MANAGER: {
- _menu_option_confirm(RUN_STOP, true);
+ project_run_bar->stop_playing();
_exit_editor(EXIT_SUCCESS);
String exec = OS::get_singleton()->get_executable_path();
@@ -3584,14 +3397,6 @@ bool EditorNode::is_addon_plugin_enabled(const String &p_addon) const {
return addon_name_to_plugin.has("res://addons/" + p_addon + "/plugin.cfg");
}
-void EditorNode::set_movie_maker_enabled(bool p_enabled) {
- write_movie_button->set_pressed(p_enabled);
-}
-
-bool EditorNode::is_movie_maker_enabled() const {
- return write_movie_button->is_pressed();
-}
-
void EditorNode::_remove_edited_scene(bool p_change_tab) {
int new_index = editor_data.get_edited_scene();
int old_index = new_index;
@@ -4260,14 +4065,31 @@ void EditorNode::_quick_opened() {
}
}
-void EditorNode::_quick_run() {
- _run(false, quick_run->get_selected());
+void EditorNode::_project_run_started() {
+ if (bool(EDITOR_GET("run/output/always_clear_output_on_play"))) {
+ log->clear();
+ }
+
+ if (bool(EDITOR_GET("run/output/always_open_output_on_play"))) {
+ make_bottom_panel_item_visible(log);
+ }
+}
+
+void EditorNode::_project_run_stopped() {
+ if (!bool(EDITOR_GET("run/output/always_close_output_on_stop"))) {
+ return;
+ }
+
+ for (int i = 0; i < bottom_panel_items.size(); i++) {
+ if (bottom_panel_items[i].control == log) {
+ _bottom_panel_switch(false, i);
+ break;
+ }
+ }
}
void EditorNode::notify_all_debug_sessions_exited() {
- _menu_option_confirm(RUN_STOP, false);
- stop_button->set_pressed(false);
- editor_run.stop();
+ project_run_bar->stop_playing();
}
void EditorNode::add_io_error(const String &p_error) {
@@ -4305,13 +4127,12 @@ bool EditorNode::is_scene_in_use(const String &p_path) {
return false;
}
+OS::ProcessID EditorNode::has_child_process(OS::ProcessID p_pid) const {
+ return project_run_bar->has_child_process(p_pid);
+}
+
void EditorNode::stop_child_process(OS::ProcessID p_pid) {
- if (has_child_process(p_pid)) {
- editor_run.stop_child_process(p_pid);
- if (!editor_run.get_child_process_count()) { // All children stopped. Closing.
- _menu_option_confirm(RUN_STOP, false);
- }
- }
+ project_run_bar->stop_child_process(p_pid);
}
Ref<Script> EditorNode::get_object_custom_type_base(const Object *p_object) const {
@@ -5274,45 +5095,6 @@ bool EditorNode::ensure_main_scene(bool p_from_native) {
return true;
}
-Error EditorNode::run_play_native(int p_id) {
- return run_native->run_native(p_id);
-}
-
-void EditorNode::run_play() {
- _menu_option_confirm(RUN_STOP, true);
- _run(false);
-}
-
-void EditorNode::run_play_current() {
- _save_default_environment();
- _menu_option_confirm(RUN_STOP, true);
- _run(true);
-}
-
-void EditorNode::run_play_custom(const String &p_custom) {
- bool is_current = !run_current_filename.is_empty();
- _menu_option_confirm(RUN_STOP, true);
- _run(is_current, p_custom);
-}
-
-void EditorNode::run_stop() {
- _menu_option_confirm(RUN_STOP, false);
-}
-
-bool EditorNode::is_run_playing() const {
- EditorRun::Status status = editor_run.get_status();
- return (status == EditorRun::STATUS_PLAY || status == EditorRun::STATUS_PAUSED);
-}
-
-String EditorNode::get_run_playing_scene() const {
- String run_filename = editor_run.get_running_scene();
- if (run_filename.is_empty() && is_run_playing()) {
- run_filename = GLOBAL_GET("application/run/main_scene"); // Must be the main scene then.
- }
-
- return run_filename;
-}
-
void EditorNode::_immediate_dialog_confirmed() {
immediate_dialog_confirmed = true;
}
@@ -5533,7 +5315,7 @@ void EditorNode::_scene_tab_input(const Ref<InputEvent> &p_input) {
if (scene_tabs->get_hovered_tab() >= 0) {
scene_tabs_context_menu->add_separator();
scene_tabs_context_menu->add_item(TTR("Show in FileSystem"), FILE_SHOW_IN_FILESYSTEM);
- scene_tabs_context_menu->add_item(TTR("Play This Scene"), RUN_PLAY_SCENE);
+ scene_tabs_context_menu->add_item(TTR("Play This Scene"), FILE_RUN_SCENE);
scene_tabs_context_menu->add_separator();
scene_tabs_context_menu->add_shortcut(ED_GET_SHORTCUT("editor/close_scene"), FILE_CLOSE);
@@ -6546,14 +6328,13 @@ void EditorNode::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_gui_base"), &EditorNode::get_gui_base);
- ADD_SIGNAL(MethodInfo("play_pressed"));
- ADD_SIGNAL(MethodInfo("stop_pressed"));
ADD_SIGNAL(MethodInfo("request_help_search"));
ADD_SIGNAL(MethodInfo("script_add_function_request", PropertyInfo(Variant::OBJECT, "obj"), PropertyInfo(Variant::STRING, "function"), PropertyInfo(Variant::PACKED_STRING_ARRAY, "args")));
ADD_SIGNAL(MethodInfo("resource_saved", PropertyInfo(Variant::OBJECT, "obj")));
ADD_SIGNAL(MethodInfo("scene_saved", PropertyInfo(Variant::STRING, "path")));
ADD_SIGNAL(MethodInfo("project_settings_changed"));
ADD_SIGNAL(MethodInfo("scene_changed"));
+ ADD_SIGNAL(MethodInfo("scene_closed", PropertyInfo(Variant::STRING, "path")));
}
static Node *_resource_get_edited_scene() {
@@ -6931,8 +6712,8 @@ EditorNode::EditorNode() {
main_vbox->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT, Control::PRESET_MODE_MINSIZE, 8);
main_vbox->add_theme_constant_override("separation", 8 * EDSCALE);
- menu_hb = memnew(EditorTitleBar);
- main_vbox->add_child(menu_hb);
+ title_bar = memnew(EditorTitleBar);
+ main_vbox->add_child(title_bar);
left_l_hsplit = memnew(HSplitContainer);
main_vbox->add_child(left_l_hsplit);
@@ -7172,11 +6953,11 @@ EditorNode::EditorNode() {
// Add spacer to avoid other controls under window minimize/maximize/close buttons (left side).
left_menu_spacer = memnew(Control);
left_menu_spacer->set_mouse_filter(Control::MOUSE_FILTER_PASS);
- menu_hb->add_child(left_menu_spacer);
+ title_bar->add_child(left_menu_spacer);
}
main_menu = memnew(MenuBar);
- menu_hb->add_child(main_menu);
+ title_bar->add_child(main_menu);
main_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles")));
main_menu->set_flat(true);
@@ -7352,7 +7133,7 @@ EditorNode::EditorNode() {
HBoxContainer *left_spacer = memnew(HBoxContainer);
left_spacer->set_mouse_filter(Control::MOUSE_FILTER_PASS);
left_spacer->set_h_size_flags(Control::SIZE_EXPAND_FILL);
- menu_hb->add_child(left_spacer);
+ title_bar->add_child(left_spacer);
if (can_expand && global_menu) {
project_title = memnew(Label);
@@ -7367,7 +7148,7 @@ EditorNode::EditorNode() {
}
main_editor_button_hb = memnew(HBoxContainer);
- menu_hb->add_child(main_editor_button_hb);
+ title_bar->add_child(main_editor_button_hb);
// Options are added and handled by DebuggerEditorPlugin.
debug_menu = memnew(PopupMenu);
@@ -7452,104 +7233,15 @@ EditorNode::EditorNode() {
Control *right_spacer = memnew(Control);
right_spacer->set_mouse_filter(Control::MOUSE_FILTER_PASS);
right_spacer->set_h_size_flags(Control::SIZE_EXPAND_FILL);
- menu_hb->add_child(right_spacer);
-
- launch_pad = memnew(PanelContainer);
- launch_pad->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("LaunchPadNormal"), SNAME("EditorStyles")));
- menu_hb->add_child(launch_pad);
-
- HBoxContainer *launch_pad_hb = memnew(HBoxContainer);
- launch_pad->add_child(launch_pad_hb);
-
- play_button = memnew(Button);
- play_button->set_flat(true);
- launch_pad_hb->add_child(play_button);
- play_button->set_toggle_mode(true);
- play_button->set_focus_mode(Control::FOCUS_NONE);
- play_button->connect("pressed", callable_mp(this, &EditorNode::_menu_option).bind(RUN_PLAY));
- play_button->set_tooltip_text(TTR("Run the project's default scene."));
-
- ED_SHORTCUT_AND_COMMAND("editor/run_project", TTR("Run Project"), Key::F5);
- ED_SHORTCUT_OVERRIDE("editor/run_project", "macos", KeyModifierMask::META | Key::B);
- play_button->set_shortcut(ED_GET_SHORTCUT("editor/run_project"));
-
- pause_button = memnew(Button);
- pause_button->set_flat(true);
- pause_button->set_toggle_mode(true);
- pause_button->set_icon(gui_base->get_theme_icon(SNAME("Pause"), SNAME("EditorIcons")));
- pause_button->set_focus_mode(Control::FOCUS_NONE);
- pause_button->set_tooltip_text(TTR("Pause the running project's execution for debugging."));
- pause_button->set_disabled(true);
- launch_pad_hb->add_child(pause_button);
-
- ED_SHORTCUT("editor/pause_running_project", TTR("Pause Running Project"), Key::F7);
- ED_SHORTCUT_OVERRIDE("editor/pause_running_project", "macos", KeyModifierMask::META | KeyModifierMask::CTRL | Key::Y);
- pause_button->set_shortcut(ED_GET_SHORTCUT("editor/pause_running_project"));
-
- stop_button = memnew(Button);
- stop_button->set_flat(true);
- launch_pad_hb->add_child(stop_button);
- stop_button->set_focus_mode(Control::FOCUS_NONE);
- stop_button->set_icon(gui_base->get_theme_icon(SNAME("Stop"), SNAME("EditorIcons")));
- stop_button->connect("pressed", callable_mp(this, &EditorNode::_menu_option).bind(RUN_STOP));
- stop_button->set_tooltip_text(TTR("Stop the currently running project."));
- stop_button->set_disabled(true);
-
- ED_SHORTCUT("editor/stop_running_project", TTR("Stop Running Project"), Key::F8);
- ED_SHORTCUT_OVERRIDE("editor/stop_running_project", "macos", KeyModifierMask::META | Key::PERIOD);
- stop_button->set_shortcut(ED_GET_SHORTCUT("editor/stop_running_project"));
-
- run_native = memnew(EditorRunNative);
- launch_pad_hb->add_child(run_native);
- run_native->connect("native_run", callable_mp(this, &EditorNode::_run_native));
-
- play_scene_button = memnew(Button);
- play_scene_button->set_flat(true);
- launch_pad_hb->add_child(play_scene_button);
- play_scene_button->set_toggle_mode(true);
- play_scene_button->set_focus_mode(Control::FOCUS_NONE);
- play_scene_button->connect("pressed", callable_mp(this, &EditorNode::_menu_option).bind(RUN_PLAY_SCENE));
- play_scene_button->set_tooltip_text(TTR("Run the currently edited scene."));
-
- ED_SHORTCUT_AND_COMMAND("editor/run_current_scene", TTR("Run Current Scene"), Key::F6);
- ED_SHORTCUT_OVERRIDE("editor/run_current_scene", "macos", KeyModifierMask::META | Key::R);
- play_scene_button->set_shortcut(ED_GET_SHORTCUT("editor/run_current_scene"));
-
- play_custom_scene_button = memnew(Button);
- play_custom_scene_button->set_flat(true);
- launch_pad_hb->add_child(play_custom_scene_button);
- play_custom_scene_button->set_toggle_mode(true);
- play_custom_scene_button->set_focus_mode(Control::FOCUS_NONE);
- play_custom_scene_button->connect("pressed", callable_mp(this, &EditorNode::_menu_option).bind(RUN_PLAY_CUSTOM_SCENE));
- play_custom_scene_button->set_tooltip_text(TTR("Run a specific scene."));
-
- _reset_play_buttons();
-
- ED_SHORTCUT_AND_COMMAND("editor/run_specific_scene", TTR("Run Specific Scene"), KeyModifierMask::CTRL | KeyModifierMask::SHIFT | Key::F5);
- ED_SHORTCUT_OVERRIDE("editor/run_specific_scene", "macos", KeyModifierMask::META | KeyModifierMask::SHIFT | Key::R);
- play_custom_scene_button->set_shortcut(ED_GET_SHORTCUT("editor/run_specific_scene"));
-
- write_movie_panel = memnew(PanelContainer);
- write_movie_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("MovieWriterButtonNormal"), SNAME("EditorStyles")));
- launch_pad_hb->add_child(write_movie_panel);
-
- write_movie_button = memnew(Button);
- write_movie_button->set_flat(true);
- write_movie_button->set_toggle_mode(true);
- write_movie_panel->add_child(write_movie_button);
- write_movie_button->set_pressed(false);
- write_movie_button->set_icon(gui_base->get_theme_icon(SNAME("MainMovieWrite"), SNAME("EditorIcons")));
- write_movie_button->set_focus_mode(Control::FOCUS_NONE);
- write_movie_button->connect("toggled", callable_mp(this, &EditorNode::_write_movie_toggled));
- write_movie_button->set_tooltip_text(TTR("Enable Movie Maker mode.\nThe project will run at stable FPS and the visual and audio output will be recorded to a video file."));
-
- // This button behaves differently, so color it as such.
- write_movie_button->add_theme_color_override("icon_normal_color", Color(1, 1, 1, 0.7));
- write_movie_button->add_theme_color_override("icon_pressed_color", Color(0, 0, 0, 0.84));
- write_movie_button->add_theme_color_override("icon_hover_color", Color(1, 1, 1, 0.9));
+ title_bar->add_child(right_spacer);
+
+ project_run_bar = memnew(EditorRunBar);
+ title_bar->add_child(project_run_bar);
+ project_run_bar->connect("play_pressed", callable_mp(this, &EditorNode::_project_run_started));
+ project_run_bar->connect("stop_pressed", callable_mp(this, &EditorNode::_project_run_stopped));
HBoxContainer *right_menu_hb = memnew(HBoxContainer);
- menu_hb->add_child(right_menu_hb);
+ title_bar->add_child(right_menu_hb);
renderer = memnew(OptionButton);
renderer->set_visible(true);
@@ -7567,7 +7259,7 @@ EditorNode::EditorNode() {
// Add spacer to avoid other controls under the window minimize/maximize/close buttons (right side).
right_menu_spacer = memnew(Control);
right_menu_spacer->set_mouse_filter(Control::MOUSE_FILTER_PASS);
- menu_hb->add_child(right_menu_spacer);
+ title_bar->add_child(right_menu_spacer);
}
String current_renderer = GLOBAL_GET("rendering/renderer/rendering_method");
@@ -8004,10 +7696,6 @@ EditorNode::EditorNode() {
gui_base->add_child(quick_open);
quick_open->connect("quick_open", callable_mp(this, &EditorNode::_quick_opened));
- quick_run = memnew(EditorQuickOpen);
- gui_base->add_child(quick_run);
- quick_run->connect("quick_open", callable_mp(this, &EditorNode::_quick_run));
-
_update_recent_scenes();
set_process_shortcut_input(true);
@@ -8079,14 +7767,14 @@ EditorNode::EditorNode() {
screenshot_timer->set_owner(get_owner());
// Adjust spacers to center 2D / 3D / Script buttons.
- int max_w = MAX(launch_pad->get_minimum_size().x + right_menu_hb->get_minimum_size().x, main_menu->get_minimum_size().x);
+ int max_w = MAX(project_run_bar->get_minimum_size().x + right_menu_hb->get_minimum_size().x, main_menu->get_minimum_size().x);
left_spacer->set_custom_minimum_size(Size2(MAX(0, max_w - main_menu->get_minimum_size().x), 0));
- right_spacer->set_custom_minimum_size(Size2(MAX(0, max_w - launch_pad->get_minimum_size().x - right_menu_hb->get_minimum_size().x), 0));
+ right_spacer->set_custom_minimum_size(Size2(MAX(0, max_w - project_run_bar->get_minimum_size().x - right_menu_hb->get_minimum_size().x), 0));
// Extend menu bar to window title.
if (can_expand) {
DisplayServer::get_singleton()->window_set_flag(DisplayServer::WINDOW_FLAG_EXTEND_TO_TITLE, true, DisplayServer::MAIN_WINDOW_ID);
- menu_hb->set_can_move_window(true);
+ title_bar->set_can_move_window(true);
}
String exec = OS::get_singleton()->get_executable_path();
diff --git a/editor/editor_node.h b/editor/editor_node.h
index 831e2989f5..0003fee301 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -35,8 +35,6 @@
#include "editor/editor_data.h"
#include "editor/editor_folding.h"
#include "editor/editor_plugin.h"
-#include "editor/editor_run.h"
-#include "editor/export/editor_export.h"
typedef void (*EditorNodeInitCallback)();
typedef void (*EditorPluginInitializeCallback)();
@@ -59,6 +57,8 @@ class Node2D;
class OptionButton;
class Panel;
class PanelContainer;
+class PopupPanel;
+class RichTextLabel;
class SubViewport;
class TabBar;
class TabContainer;
@@ -92,6 +92,7 @@ class EditorQuickOpen;
class EditorPropertyResource;
class EditorResourcePreview;
class EditorResourceConversionPlugin;
+class EditorRunBar;
class EditorRunNative;
class EditorSelectionHistory;
class EditorSettingsDialog;
@@ -162,6 +163,7 @@ private:
FILE_SAVE_ALL_SCENES,
FILE_SAVE_AND_RUN,
FILE_SAVE_AND_RUN_MAIN_SCENE,
+ FILE_RUN_SCENE,
FILE_SHOW_IN_FILESYSTEM,
FILE_EXPORT_PROJECT,
FILE_EXPORT_MESH_LIBRARY,
@@ -188,11 +190,7 @@ private:
TOOLS_CUSTOM,
RESOURCE_SAVE,
RESOURCE_SAVE_AS,
- RUN_PLAY,
- RUN_STOP,
- RUN_PLAY_SCENE,
- RUN_PLAY_CUSTOM_SCENE,
RUN_SETTINGS,
RUN_USER_DATA_FOLDER,
RELOAD_CURRENT_PROJECT,
@@ -265,7 +263,6 @@ private:
EditorData editor_data;
EditorFolding editor_folding;
- EditorRun editor_run;
EditorSelectionHistory editor_history;
EditorCommandPalette *command_palette = nullptr;
@@ -277,9 +274,7 @@ private:
EditorPluginList *editor_plugins_force_over = nullptr;
EditorPluginList *editor_plugins_over = nullptr;
EditorQuickOpen *quick_open = nullptr;
- EditorQuickOpen *quick_run = nullptr;
EditorResourcePreview *resource_preview = nullptr;
- EditorRunNative *run_native = nullptr;
EditorSelection *editor_selection = nullptr;
EditorSettingsDialog *editor_settings_dialog = nullptr;
HistoryDock *history_dock = nullptr;
@@ -342,7 +337,8 @@ private:
Label *project_title = nullptr;
Control *left_menu_spacer = nullptr;
Control *right_menu_spacer = nullptr;
- EditorTitleBar *menu_hb = nullptr;
+ EditorTitleBar *title_bar = nullptr;
+ EditorRunBar *project_run_bar = nullptr;
VBoxContainer *main_screen_vbox = nullptr;
MenuBar *main_menu = nullptr;
PopupMenu *file_menu = nullptr;
@@ -357,15 +353,6 @@ private:
Button *search_button = nullptr;
TextureProgressBar *audio_vu = nullptr;
- PanelContainer *launch_pad = nullptr;
- Button *play_button = nullptr;
- Button *pause_button = nullptr;
- Button *stop_button = nullptr;
- Button *play_scene_button = nullptr;
- Button *play_custom_scene_button = nullptr;
- PanelContainer *write_movie_panel = nullptr;
- Button *write_movie_button = nullptr;
-
Timer *screenshot_timer = nullptr;
PluginConfigDialog *plugin_config_dialog = nullptr;
@@ -469,7 +456,6 @@ private:
bool scene_distraction_free = false;
bool script_distraction_free = false;
- bool _playing_edited = false;
bool changing_scene = false;
bool cmdline_export_mode = false;
bool convert_old = false;
@@ -496,9 +482,6 @@ private:
String external_file;
String open_navigate;
- String run_custom_filename;
- String run_current_filename;
-
DynamicFontImportSettings *fontdata_import_settings = nullptr;
SceneImportSettings *scene_import_settings = nullptr;
AudioStreamImportSettings *audio_stream_import_settings = nullptr;
@@ -600,14 +583,10 @@ private:
void _instantiate_request(const Vector<String> &p_files);
void _quick_opened();
- void _quick_run();
void _open_command_palette();
- void _write_movie_toggled(bool p_enabled);
-
- void _run(bool p_current = false, const String &p_custom = "");
- void _run_native(const Ref<EditorExportPreset> &p_preset);
- void _reset_play_buttons();
+ void _project_run_started();
+ void _project_run_stopped();
void _add_to_recent_scenes(const String &p_scene);
void _update_recent_scenes();
@@ -687,7 +666,6 @@ private:
void _inherit_imported(const String &p_action);
void _open_imported();
- void _save_default_environment();
void _update_update_spinner();
void _resources_changed(const Vector<String> &p_resources);
@@ -717,7 +695,6 @@ protected:
friend class FileSystemDock;
static void _bind_methods();
-
void _notification(int p_what);
int get_current_tab();
@@ -738,7 +715,7 @@ public:
static EditorData &get_editor_data() { return singleton->editor_data; }
static EditorFolding &get_editor_folding() { return singleton->editor_folding; }
- static EditorTitleBar *get_menu_hb() { return singleton->menu_hb; }
+ static EditorTitleBar *get_title_bar() { return singleton->title_bar; }
static VSplitContainer *get_top_split() { return singleton->top_split; }
static String adjust_scene_name_casing(const String &root_name);
@@ -789,9 +766,6 @@ public:
void set_addon_plugin_enabled(const String &p_addon, bool p_enabled, bool p_config_changed = false);
bool is_addon_plugin_enabled(const String &p_addon) const;
- void set_movie_maker_enabled(bool p_enabled);
- bool is_movie_maker_enabled() const;
-
void edit_node(Node *p_node);
void edit_resource(const Ref<Resource> &p_resource);
@@ -874,7 +848,7 @@ public:
void notify_all_debug_sessions_exited();
- OS::ProcessID has_child_process(OS::ProcessID p_pid) const { return editor_run.has_child_process(p_pid); }
+ OS::ProcessID has_child_process(OS::ProcessID p_pid) const;
void stop_child_process(OS::ProcessID p_pid);
Ref<Theme> get_editor_theme() const { return theme; }
@@ -908,6 +882,7 @@ public:
bool is_scene_in_use(const String &p_path);
void save_layout();
+ void save_default_environment();
void open_export_template_manager();
@@ -918,8 +893,6 @@ public:
bool is_exiting() const { return exiting; }
- Button *get_pause_button() { return pause_button; }
-
Button *add_bottom_panel_item(String p_text, Control *p_item);
void make_bottom_panel_item_visible(Control *p_item);
void raise_bottom_panel_item(Control *p_item);
@@ -937,6 +910,8 @@ public:
void save_all_scenes();
void save_scene_list(Vector<String> p_scene_filenames);
+ void save_before_run();
+ void try_autosave();
void restart_editor();
void notify_settings_changed();
@@ -958,14 +933,6 @@ public:
Vector<Ref<EditorResourceConversionPlugin>> find_resource_conversion_plugin(const Ref<Resource> &p_for_resource);
bool ensure_main_scene(bool p_from_native);
-
- Error run_play_native(int p_id);
- void run_play();
- void run_play_current();
- void run_play_custom(const String &p_custom);
- void run_stop();
- bool is_run_playing() const;
- String get_run_playing_scene() const;
};
struct EditorProgress {
diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp
index 8ac5e77d35..442524d579 100644
--- a/editor/editor_plugin.cpp
+++ b/editor/editor_plugin.cpp
@@ -94,7 +94,7 @@ void EditorPlugin::add_control_to_container(CustomControlContainer p_location, C
switch (p_location) {
case CONTAINER_TOOLBAR: {
- EditorNode::get_menu_hb()->add_child(p_control);
+ EditorNode::get_title_bar()->add_child(p_control);
} break;
case CONTAINER_SPATIAL_EDITOR_MENU: {
@@ -147,7 +147,7 @@ void EditorPlugin::remove_control_from_container(CustomControlContainer p_locati
switch (p_location) {
case CONTAINER_TOOLBAR: {
- EditorNode::get_menu_hb()->remove_child(p_control);
+ EditorNode::get_title_bar()->remove_child(p_control);
} break;
case CONTAINER_SPATIAL_EDITOR_MENU: {
diff --git a/editor/editor_plugin_settings.cpp b/editor/editor_plugin_settings.cpp
index 9bcb25e9c0..1e582992d1 100644
--- a/editor/editor_plugin_settings.cpp
+++ b/editor/editor_plugin_settings.cpp
@@ -32,6 +32,7 @@
#include "core/config/project_settings.h"
#include "core/io/config_file.h"
+#include "core/io/dir_access.h"
#include "core/io/file_access.h"
#include "core/os/main_loop.h"
#include "editor/editor_node.h"
diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp
index bb0434a1bf..3345f87973 100644
--- a/editor/editor_properties_array_dict.cpp
+++ b/editor/editor_properties_array_dict.cpp
@@ -203,7 +203,18 @@ void EditorPropertyArray::_property_changed(const String &p_property, Variant p_
index = p_property.get_slice("/", 1).to_int();
}
- Variant array = object->get_array().duplicate();
+ Variant array;
+ const Variant &original_array = object->get_array();
+
+ if (original_array.get_type() == Variant::ARRAY) {
+ // Needed to preserve type of TypedArrays in meta pointer properties.
+ Array temp;
+ temp.assign(original_array.duplicate());
+ array = temp;
+ } else {
+ array = original_array.duplicate();
+ }
+
array.set(index, p_value);
object->set_array(array);
emit_changed(get_edited_property(), array, "", true);
diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp
index cf88e42472..b090638c37 100644
--- a/editor/editor_run.cpp
+++ b/editor/editor_run.cpp
@@ -264,7 +264,7 @@ Error EditorRun::run(const String &p_scene, const String &p_write_movie) {
if (OS::get_singleton()->is_stdout_verbose()) {
print_line(vformat("Running: %s", exec));
for (const String &E : args) {
- print_line(" %s", E);
+ print_line(vformat(" %s", E));
}
}
diff --git a/editor/editor_run.h b/editor/editor_run.h
index 68c8742f79..bd6770ae3d 100644
--- a/editor/editor_run.h
+++ b/editor/editor_run.h
@@ -50,6 +50,7 @@ private:
public:
Status get_status() const;
String get_running_scene() const;
+
Error run(const String &p_scene, const String &p_write_movie = "");
void run_native_notify() { status = STATUS_PLAY; }
void stop();
diff --git a/editor/editor_run_native.cpp b/editor/editor_run_native.cpp
index 815d4fab9c..beccf0f2ec 100644
--- a/editor/editor_run_native.cpp
+++ b/editor/editor_run_native.cpp
@@ -33,6 +33,7 @@
#include "editor/editor_node.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
+#include "editor/export/editor_export.h"
#include "editor/export/editor_export_platform.h"
void EditorRunNative::_notification(int p_what) {
@@ -77,7 +78,7 @@ void EditorRunNative::_notification(int p_what) {
}
}
-Error EditorRunNative::run_native(int p_id) {
+Error EditorRunNative::start_run_native(int p_id) {
if (p_id < 0) {
return OK;
}
@@ -142,7 +143,7 @@ Error EditorRunNative::run_native(int p_id) {
}
void EditorRunNative::resume_run_native() {
- run_native(resume_id);
+ start_run_native(resume_id);
}
void EditorRunNative::_bind_methods() {
@@ -155,7 +156,7 @@ bool EditorRunNative::is_deploy_debug_remote_enabled() const {
EditorRunNative::EditorRunNative() {
remote_debug = memnew(MenuButton);
- remote_debug->get_popup()->connect("id_pressed", callable_mp(this, &EditorRunNative::run_native));
+ remote_debug->get_popup()->connect("id_pressed", callable_mp(this, &EditorRunNative::start_run_native));
remote_debug->set_tooltip_text(TTR("Remote Debug"));
remote_debug->set_disabled(true);
diff --git a/editor/editor_run_native.h b/editor/editor_run_native.h
index 2a5431e54b..f52a455bb2 100644
--- a/editor/editor_run_native.h
+++ b/editor/editor_run_native.h
@@ -52,11 +52,11 @@ protected:
void _notification(int p_what);
public:
- Error run_native(int p_id);
- bool is_deploy_debug_remote_enabled() const;
-
+ Error start_run_native(int p_id);
void resume_run_native();
+ bool is_deploy_debug_remote_enabled() const;
+
EditorRunNative();
};
diff --git a/editor/editor_run_script.cpp b/editor/editor_script.cpp
index a459943656..4e8c5ad8b5 100644
--- a/editor/editor_run_script.cpp
+++ b/editor/editor_script.cpp
@@ -1,5 +1,5 @@
/**************************************************************************/
-/* editor_run_script.cpp */
+/* editor_script.cpp */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,18 +28,18 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
-#include "editor_run_script.h"
+#include "editor_script.h"
#include "editor/editor_interface.h"
#include "editor/editor_node.h"
void EditorScript::add_root_node(Node *p_node) {
- if (!editor) {
+ if (!EditorNode::get_singleton()) {
EditorNode::add_io_error("EditorScript::add_root_node: " + TTR("Write your logic in the _run() method."));
return;
}
- if (editor->get_edited_scene()) {
+ if (EditorNode::get_singleton()->get_edited_scene()) {
EditorNode::add_io_error("EditorScript::add_root_node: " + TTR("There is an edited scene already."));
return;
}
@@ -47,36 +47,29 @@ void EditorScript::add_root_node(Node *p_node) {
//editor->set_edited_scene(p_node);
}
-EditorInterface *EditorScript::get_editor_interface() {
- return EditorInterface::get_singleton();
-}
-
-Node *EditorScript::get_scene() {
- if (!editor) {
+Node *EditorScript::get_scene() const {
+ if (!EditorNode::get_singleton()) {
EditorNode::add_io_error("EditorScript::get_scene: " + TTR("Write your logic in the _run() method."));
return nullptr;
}
- return editor->get_edited_scene();
+ return EditorNode::get_singleton()->get_edited_scene();
+}
+
+EditorInterface *EditorScript::get_editor_interface() const {
+ return EditorInterface::get_singleton();
}
-void EditorScript::_run() {
+void EditorScript::run() {
if (!GDVIRTUAL_CALL(_run)) {
EditorNode::add_io_error(TTR("Couldn't run editor script, did you forget to override the '_run' method?"));
}
}
-void EditorScript::set_editor(EditorNode *p_editor) {
- editor = p_editor;
-}
-
void EditorScript::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_root_node", "node"), &EditorScript::add_root_node);
ClassDB::bind_method(D_METHOD("get_scene"), &EditorScript::get_scene);
ClassDB::bind_method(D_METHOD("get_editor_interface"), &EditorScript::get_editor_interface);
- GDVIRTUAL_BIND(_run);
-}
-EditorScript::EditorScript() {
- editor = nullptr;
+ GDVIRTUAL_BIND(_run);
}
diff --git a/editor/editor_run_script.h b/editor/editor_script.h
index 8284d59110..d7c813261d 100644
--- a/editor/editor_run_script.h
+++ b/editor/editor_script.h
@@ -1,5 +1,5 @@
/**************************************************************************/
-/* editor_run_script.h */
+/* editor_script.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
-#ifndef EDITOR_RUN_SCRIPT_H
-#define EDITOR_RUN_SCRIPT_H
+#ifndef EDITOR_SCRIPT_H
+#define EDITOR_SCRIPT_H
#include "core/object/gdvirtual.gen.inc"
#include "core/object/ref_counted.h"
@@ -41,20 +41,19 @@ class EditorNode;
class EditorScript : public RefCounted {
GDCLASS(EditorScript, RefCounted);
- EditorNode *editor = nullptr;
-
protected:
static void _bind_methods();
+
GDVIRTUAL0(_run)
public:
void add_root_node(Node *p_node);
- Node *get_scene();
- EditorInterface *get_editor_interface();
- virtual void _run();
+ Node *get_scene() const;
+ EditorInterface *get_editor_interface() const;
+
+ virtual void run();
- void set_editor(EditorNode *p_editor);
- EditorScript();
+ EditorScript() {}
};
-#endif // EDITOR_RUN_SCRIPT_H
+#endif // EDITOR_SCRIPT_H
diff --git a/editor/editor_sectioned_inspector.cpp b/editor/editor_sectioned_inspector.cpp
index 8716a75efd..92aa74dd9d 100644
--- a/editor/editor_sectioned_inspector.cpp
+++ b/editor/editor_sectioned_inspector.cpp
@@ -310,16 +310,6 @@ void SectionedInspector::_search_changed(const String &p_what) {
update_category_list();
}
-void SectionedInspector::_notification(int p_what) {
- switch (p_what) {
- case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
- if (EditorSettings::get_singleton()->check_changed_settings_in_group("interface/editor/localize_settings")) {
- inspector->set_property_name_style(EditorPropertyNameProcessor::get_settings_style());
- }
- } break;
- }
-}
-
EditorInspector *SectionedInspector::get_inspector() {
return inspector;
}
@@ -353,7 +343,6 @@ SectionedInspector::SectionedInspector() :
inspector->set_v_size_flags(SIZE_EXPAND_FILL);
right_vb->add_child(inspector, true);
inspector->set_use_doc_hints(true);
- inspector->set_property_name_style(EditorPropertyNameProcessor::get_settings_style());
sections->connect("cell_selected", callable_mp(this, &SectionedInspector::_section_selected));
}
diff --git a/editor/editor_sectioned_inspector.h b/editor/editor_sectioned_inspector.h
index 0594ef486f..3c9eb78571 100644
--- a/editor/editor_sectioned_inspector.h
+++ b/editor/editor_sectioned_inspector.h
@@ -58,9 +58,6 @@ class SectionedInspector : public HSplitContainer {
void _search_changed(const String &p_what);
-protected:
- void _notification(int p_what);
-
public:
void register_search_box(LineEdit *p_box);
EditorInspector *get_inspector();
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 2cdce158b5..9577cd0e63 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -454,6 +454,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
// Inspector
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_RANGE, "interface/inspector/max_array_dictionary_items_per_page", 20, "10,100,1")
EDITOR_SETTING(Variant::BOOL, PROPERTY_HINT_NONE, "interface/inspector/show_low_level_opentype_features", false, "")
+ EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "interface/inspector/float_drag_speed", 5.0, "0.1,100,0.01")
// Theme
EDITOR_SETTING(Variant::STRING, PROPERTY_HINT_ENUM, "interface/theme/preset", "Default", "Default,Breeze Dark,Godot 2,Gray,Light,Solarized (Dark),Solarized (Light),Black (OLED),Custom")
@@ -476,6 +477,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
set_restart_if_changed("interface/touchscreen/enable_long_press_as_right_click", true);
EDITOR_SETTING(Variant::BOOL, PROPERTY_HINT_NONE, "interface/touchscreen/enable_pan_and_scale_gestures", has_touchscreen_ui, "")
set_restart_if_changed("interface/touchscreen/enable_pan_and_scale_gestures", true);
+ EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "interface/touchscreen/scale_gizmo_handles", has_touchscreen_ui ? 3 : 1, "1,5,1")
// Scene tabs
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "interface/scene_tabs/display_close_button", 1, "Never,If Tab Active,Always"); // TabBar::CloseButtonDisplayPolicy
@@ -695,7 +697,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_initial_set("editors/tiles_editor/grid_color", Color(1.0, 0.5, 0.2, 0.5));
// Polygon editor
- _initial_set("editors/polygon_editor/point_grab_radius", 8);
+ _initial_set("editors/polygon_editor/point_grab_radius", has_touchscreen_ui ? 32 : 8);
_initial_set("editors/polygon_editor/show_previous_outline", true);
// Animation
diff --git a/editor/editor_settings.h b/editor/editor_settings.h
index a21fb9fdfb..660a9501a2 100644
--- a/editor/editor_settings.h
+++ b/editor/editor_settings.h
@@ -31,14 +31,13 @@
#ifndef EDITOR_SETTINGS_H
#define EDITOR_SETTINGS_H
+#include "core/input/shortcut.h"
#include "core/io/config_file.h"
#include "core/io/resource.h"
#include "core/os/thread_safe.h"
#include "core/templates/rb_set.h"
class EditorPlugin;
-class InputEvent;
-class Shortcut;
class EditorSettings : public Resource {
GDCLASS(EditorSettings, Resource);
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp
index 32b6e9822a..1b5144af67 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -255,6 +255,28 @@ static Ref<ImageTexture> editor_generate_icon(int p_index, float p_scale, float
return ImageTexture::create_from_image(img);
}
+float get_gizmo_handle_scale(const String &gizmo_handle_name = "") {
+ const float scale_gizmo_handles_for_touch = EDITOR_GET("interface/touchscreen/scale_gizmo_handles");
+ if (scale_gizmo_handles_for_touch > 1.0f) {
+ // The names of the icons that require additional scaling.
+ static HashSet<StringName> gizmo_to_scale;
+ if (gizmo_to_scale.is_empty()) {
+ gizmo_to_scale.insert("EditorHandle");
+ gizmo_to_scale.insert("EditorHandleAdd");
+ gizmo_to_scale.insert("EditorHandleDisabled");
+ gizmo_to_scale.insert("EditorCurveHandle");
+ gizmo_to_scale.insert("EditorPathSharpHandle");
+ gizmo_to_scale.insert("EditorPathSmoothHandle");
+ }
+
+ if (gizmo_to_scale.has(gizmo_handle_name)) {
+ return EDSCALE * scale_gizmo_handles_for_touch;
+ }
+ }
+
+ return EDSCALE;
+}
+
void editor_register_and_generate_icons(Ref<Theme> p_theme, bool p_dark_theme, float p_icon_saturation, int p_thumb_size, bool p_only_thumbs = false) {
// Before we register the icons, we adjust their colors and saturation.
// Most icons follow the standard rules for color conversion to follow the editor
@@ -314,22 +336,23 @@ void editor_register_and_generate_icons(Ref<Theme> p_theme, bool p_dark_theme, f
for (int i = 0; i < editor_icons_count; i++) {
Ref<ImageTexture> icon;
- if (accent_color_icons.has(editor_icons_names[i])) {
- icon = editor_generate_icon(i, EDSCALE, 1.0, accent_color_map);
+ const String &editor_icon_name = editor_icons_names[i];
+ if (accent_color_icons.has(editor_icon_name)) {
+ icon = editor_generate_icon(i, get_gizmo_handle_scale(editor_icon_name), 1.0, accent_color_map);
} else {
float saturation = p_icon_saturation;
- if (saturation_exceptions.has(editor_icons_names[i])) {
+ if (saturation_exceptions.has(editor_icon_name)) {
saturation = 1.0;
}
- if (conversion_exceptions.has(editor_icons_names[i])) {
- icon = editor_generate_icon(i, EDSCALE, saturation);
+ if (conversion_exceptions.has(editor_icon_name)) {
+ icon = editor_generate_icon(i, get_gizmo_handle_scale(editor_icon_name), saturation);
} else {
- icon = editor_generate_icon(i, EDSCALE, saturation, color_conversion_map);
+ icon = editor_generate_icon(i, get_gizmo_handle_scale(editor_icon_name), saturation, color_conversion_map);
}
}
- p_theme->set_icon(editor_icons_names[i], SNAME("EditorIcons"), icon);
+ p_theme->set_icon(editor_icon_name, SNAME("EditorIcons"), icon);
}
}
@@ -395,6 +418,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
Color base_color = EDITOR_GET("interface/theme/base_color");
float contrast = EDITOR_GET("interface/theme/contrast");
bool increase_scrollbar_touch_area = EDITOR_GET("interface/touchscreen/increase_scrollbar_touch_area");
+ const float gizmo_handle_scale = EDITOR_GET("interface/touchscreen/scale_gizmo_handles");
bool draw_extra_borders = EDITOR_GET("interface/theme/draw_extra_borders");
float icon_saturation = EDITOR_GET("interface/theme/icon_saturation");
float relationship_line_opacity = EDITOR_GET("interface/theme/relationship_line_opacity");
@@ -594,6 +618,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_constant("class_icon_size", "Editor", 16 * EDSCALE);
theme->set_constant("dark_theme", "Editor", dark_theme);
theme->set_constant("color_picker_button_height", "Editor", 28 * EDSCALE);
+ theme->set_constant("gizmo_handle_scale", "Editor", gizmo_handle_scale);
// Register editor icons.
// If the settings are comparable to the old theme, then just copy them over.
@@ -609,8 +634,10 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
const bool prev_dark_theme = (bool)p_theme->get_constant(SNAME("dark_theme"), SNAME("Editor"));
const Color prev_accent_color = p_theme->get_color(SNAME("accent_color"), SNAME("Editor"));
const float prev_icon_saturation = p_theme->get_color(SNAME("icon_saturation"), SNAME("Editor")).r;
+ const float prev_gizmo_handle_scale = (float)p_theme->get_constant(SNAME("gizmo_handle_scale"), SNAME("Editor"));
keep_old_icons = (Math::is_equal_approx(prev_scale, EDSCALE) &&
+ Math::is_equal_approx(prev_gizmo_handle_scale, gizmo_handle_scale) &&
prev_dark_theme == dark_theme &&
prev_accent_color == accent_color &&
prev_icon_saturation == icon_saturation);
@@ -1604,6 +1631,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_stylebox("slider", "HSlider", make_flat_stylebox(dark_color_3, 0, default_margin_size / 2, 0, default_margin_size / 2, corner_width));
theme->set_stylebox("grabber_area", "HSlider", make_flat_stylebox(contrast_color_1, 0, default_margin_size / 2, 0, default_margin_size / 2, corner_width));
theme->set_stylebox("grabber_area_highlight", "HSlider", make_flat_stylebox(contrast_color_1, 0, default_margin_size / 2, 0, default_margin_size / 2));
+ theme->set_constant("center_grabber", "HSlider", 0);
theme->set_constant("grabber_offset", "HSlider", 0);
// VSlider
@@ -1612,6 +1640,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_stylebox("slider", "VSlider", make_flat_stylebox(dark_color_3, default_margin_size / 2, 0, default_margin_size / 2, 0, corner_width));
theme->set_stylebox("grabber_area", "VSlider", make_flat_stylebox(contrast_color_1, default_margin_size / 2, 0, default_margin_size / 2, 0, corner_width));
theme->set_stylebox("grabber_area_highlight", "VSlider", make_flat_stylebox(contrast_color_1, default_margin_size / 2, 0, default_margin_size / 2, 0));
+ theme->set_constant("center_grabber", "VSlider", 0);
theme->set_constant("grabber_offset", "VSlider", 0);
// RichTextLabel
@@ -1868,6 +1897,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_constant("sv_height", "ColorPicker", 256 * EDSCALE);
theme->set_constant("h_width", "ColorPicker", 30 * EDSCALE);
theme->set_constant("label_width", "ColorPicker", 10 * EDSCALE);
+ theme->set_constant("center_slider_grabbers", "ColorPicker", 1);
theme->set_icon("screen_picker", "ColorPicker", theme->get_icon(SNAME("ColorPick"), SNAME("EditorIcons")));
theme->set_icon("shape_circle", "ColorPicker", theme->get_icon(SNAME("PickerShapeCircle"), SNAME("EditorIcons")));
theme->set_icon("shape_rect", "ColorPicker", theme->get_icon(SNAME("PickerShapeRectangle"), SNAME("EditorIcons")));
diff --git a/editor/export/editor_export_platform.cpp b/editor/export/editor_export_platform.cpp
index 4e17379911..121088f27a 100644
--- a/editor/export/editor_export_platform.cpp
+++ b/editor/export/editor_export_platform.cpp
@@ -42,6 +42,7 @@
#include "editor/editor_paths.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
+#include "editor/export/editor_export.h"
#include "editor/plugins/script_editor_plugin.h"
#include "editor_export_plugin.h"
#include "scene/resources/packed_scene.h"
diff --git a/editor/export/export_template_manager.cpp b/editor/export/export_template_manager.cpp
index 725dc1d6bb..e551b0531a 100644
--- a/editor/export/export_template_manager.cpp
+++ b/editor/export/export_template_manager.cpp
@@ -620,7 +620,7 @@ void ExportTemplateManager::_installed_table_button_cbk(Object *p_item, int p_co
void ExportTemplateManager::_open_template_folder(const String &p_version) {
const String &templates_dir = EditorPaths::get_singleton()->get_export_templates_dir();
- OS::get_singleton()->shell_open("file://" + templates_dir.path_join(p_version));
+ OS::get_singleton()->shell_show_in_file_manager(templates_dir.path_join(p_version), true);
}
void ExportTemplateManager::popup_manager() {
diff --git a/editor/export/project_export.cpp b/editor/export/project_export.cpp
index 114d927c4d..de696b07b4 100644
--- a/editor/export/project_export.cpp
+++ b/editor/export/project_export.cpp
@@ -70,10 +70,6 @@ void ProjectExportDialog::_notification(int p_what) {
connect("confirmed", callable_mp(this, &ProjectExportDialog::_export_pck_zip));
_update_export_all();
} break;
-
- case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
- parameters->set_property_name_style(EditorPropertyNameProcessor::get_settings_style());
- } break;
}
}
@@ -833,14 +829,20 @@ bool ProjectExportDialog::_fill_tree(EditorFileSystemDirectory *p_dir, TreeItem
void ProjectExportDialog::_propagate_file_export_mode(TreeItem *p_item, EditorExportPreset::FileExportMode p_inherited_export_mode) {
EditorExportPreset::FileExportMode file_export_mode = (EditorExportPreset::FileExportMode)(int)p_item->get_metadata(1);
+ bool is_inherited = false;
if (file_export_mode == EditorExportPreset::MODE_FILE_NOT_CUSTOMIZED) {
file_export_mode = p_inherited_export_mode;
+ is_inherited = true;
}
if (file_export_mode == EditorExportPreset::MODE_FILE_NOT_CUSTOMIZED) {
p_item->set_text(1, "");
} else {
- p_item->set_text(1, file_mode_popup->get_item_text(file_mode_popup->get_item_index(file_export_mode)));
+ String text = file_mode_popup->get_item_text(file_mode_popup->get_item_index(file_export_mode));
+ if (is_inherited) {
+ text += " " + TTR("(Inherited)");
+ }
+ p_item->set_text(1, text);
}
for (int i = 0; i < p_item->get_child_count(); i++) {
@@ -1161,7 +1163,6 @@ ProjectExportDialog::ProjectExportDialog() {
sections->add_child(parameters);
parameters->set_name(TTR("Options"));
parameters->set_v_size_flags(Control::SIZE_EXPAND_FILL);
- parameters->set_property_name_style(EditorPropertyNameProcessor::get_settings_style());
parameters->set_use_doc_hints(true);
parameters->connect("property_edited", callable_mp(this, &ProjectExportDialog::_update_parameters));
EditorExport::get_singleton()->connect("export_presets_updated", callable_mp(this, &ProjectExportDialog::_force_update_current_preset_parameters));
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index 066e8cb84e..169e78c0f5 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -38,6 +38,7 @@
#include "core/os/os.h"
#include "core/templates/list.h"
#include "editor/create_dialog.h"
+#include "editor/directory_create_dialog.h"
#include "editor/editor_feature_profile.h"
#include "editor/editor_node.h"
#include "editor/editor_resource_preview.h"
@@ -1514,43 +1515,6 @@ void FileSystemDock::_save_scenes_after_move(const HashMap<String, String> &p_re
EditorNode::get_singleton()->save_scene_list(new_filenames);
}
-void FileSystemDock::_make_dir_confirm() {
- String dir_name = make_dir_dialog_text->get_text().strip_edges();
-
- if (dir_name.length() == 0) {
- EditorNode::get_singleton()->show_warning(TTR("No name provided."));
- return;
- } else if (dir_name.contains("/") || dir_name.contains("\\") || dir_name.contains(":") || dir_name.contains("*") ||
- dir_name.contains("|") || dir_name.contains(">") || dir_name.ends_with(".") || dir_name.ends_with(" ")) {
- EditorNode::get_singleton()->show_warning(TTR("Provided name contains invalid characters."));
- return;
- }
-
- String directory = path;
- if (!directory.ends_with("/")) {
- directory = directory.get_base_dir();
- }
-
- print_verbose("Making folder " + dir_name + " in " + directory);
- Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
- Error err = da->change_dir(directory);
- ERR_FAIL_COND_MSG(err != OK, "Cannot open directory '" + directory + "'.");
-
- if (da->dir_exists(dir_name)) {
- EditorNode::get_singleton()->show_warning(TTR("Could not create folder. File with that name already exists."));
- return;
- }
-
- err = da->make_dir(dir_name);
-
- if (err == OK) {
- print_verbose("FileSystem: calling rescan.");
- _rescan();
- } else {
- EditorNode::get_singleton()->show_warning(TTR("Could not create folder."));
- }
-}
-
void FileSystemDock::_make_scene_confirm() {
const String scene_path = make_scene_dialog->get_scene_path();
@@ -1881,11 +1845,8 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected
fpath = p_selected[0];
}
- if (!fpath.ends_with("/")) {
- fpath = fpath.get_base_dir();
- }
String dir = ProjectSettings::get_singleton()->globalize_path(fpath);
- OS::get_singleton()->shell_open(String("file://") + dir);
+ OS::get_singleton()->shell_show_in_file_manager(dir, true);
} break;
case FILE_OPEN_EXTERNAL: {
@@ -2108,10 +2069,12 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected
} break;
case FILE_NEW_FOLDER: {
- make_dir_dialog_text->set_text("new folder");
- make_dir_dialog_text->select_all();
- make_dir_dialog->popup_centered(Size2(250, 80) * EDSCALE);
- make_dir_dialog_text->grab_focus();
+ String directory = path;
+ if (!directory.ends_with("/")) {
+ directory = directory.get_base_dir();
+ }
+ make_dir_dialog->config(directory);
+ make_dir_dialog->popup_centered();
} break;
case FILE_NEW_SCENE: {
@@ -3352,16 +3315,9 @@ FileSystemDock::FileSystemDock() {
duplicate_dialog->register_text_enter(duplicate_dialog_text);
duplicate_dialog->connect("confirmed", callable_mp(this, &FileSystemDock::_duplicate_operation_confirm));
- make_dir_dialog = memnew(ConfirmationDialog);
- make_dir_dialog->set_title(TTR("Create Folder"));
- VBoxContainer *make_folder_dialog_vb = memnew(VBoxContainer);
- make_dir_dialog->add_child(make_folder_dialog_vb);
-
- make_dir_dialog_text = memnew(LineEdit);
- make_folder_dialog_vb->add_margin_child(TTR("Name:"), make_dir_dialog_text);
+ make_dir_dialog = memnew(DirectoryCreateDialog);
add_child(make_dir_dialog);
- make_dir_dialog->register_text_enter(make_dir_dialog_text);
- make_dir_dialog->connect("confirmed", callable_mp(this, &FileSystemDock::_make_dir_confirm));
+ make_dir_dialog->connect("dir_created", callable_mp(this, &FileSystemDock::_rescan));
make_scene_dialog = memnew(SceneCreateDialog);
add_child(make_scene_dialog);
diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h
index 7c67be44be..e47178d294 100644
--- a/editor/filesystem_dock.h
+++ b/editor/filesystem_dock.h
@@ -49,6 +49,7 @@ class LineEdit;
class ProgressBar;
class SceneCreateDialog;
class ShaderCreateDialog;
+class DirectoryCreateDialog;
class FileSystemDock : public VBoxContainer {
GDCLASS(FileSystemDock, VBoxContainer);
@@ -155,8 +156,7 @@ private:
LineEdit *rename_dialog_text = nullptr;
ConfirmationDialog *duplicate_dialog = nullptr;
LineEdit *duplicate_dialog_text = nullptr;
- ConfirmationDialog *make_dir_dialog = nullptr;
- LineEdit *make_dir_dialog_text = nullptr;
+ DirectoryCreateDialog *make_dir_dialog = nullptr;
ConfirmationDialog *overwrite_dialog = nullptr;
SceneCreateDialog *make_scene_dialog = nullptr;
ScriptCreateDialog *make_script_dialog = nullptr;
@@ -241,7 +241,6 @@ private:
void _folder_removed(String p_folder);
void _resource_created();
- void _make_dir_confirm();
void _make_scene_confirm();
void _rename_operation_confirm();
void _duplicate_operation_confirm();
diff --git a/editor/gui/editor_file_dialog.cpp b/editor/gui/editor_file_dialog.cpp
index 62e0520799..a7ddb984e0 100644
--- a/editor/gui/editor_file_dialog.cpp
+++ b/editor/gui/editor_file_dialog.cpp
@@ -713,11 +713,8 @@ void EditorFileDialog::_item_menu_id_pressed(int p_option) {
// Specific item was clicked. Open folders directly, or the folder containing a selected file.
Dictionary item_meta = item_list->get_item_metadata(idx);
path = ProjectSettings::get_singleton()->globalize_path(item_meta["path"]);
- if (!item_meta["dir"]) {
- path = path.get_base_dir();
- }
}
- OS::get_singleton()->shell_open(String("file://") + path);
+ OS::get_singleton()->shell_show_in_file_manager(path, true);
} break;
}
}
diff --git a/editor/gui/editor_run_bar.cpp b/editor/gui/editor_run_bar.cpp
new file mode 100644
index 0000000000..c226c1a2d6
--- /dev/null
+++ b/editor/gui/editor_run_bar.cpp
@@ -0,0 +1,444 @@
+/**************************************************************************/
+/* editor_run_bar.cpp */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/**************************************************************************/
+
+#include "editor_run_bar.h"
+
+#include "core/config/project_settings.h"
+#include "editor/debugger/editor_debugger_node.h"
+#include "editor/editor_command_palette.h"
+#include "editor/editor_node.h"
+#include "editor/editor_quick_open.h"
+#include "editor/editor_run_native.h"
+#include "editor/editor_settings.h"
+#include "scene/gui/box_container.h"
+#include "scene/gui/button.h"
+#include "scene/gui/panel_container.h"
+
+EditorRunBar *EditorRunBar::singleton = nullptr;
+
+void EditorRunBar::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_POSTINITIALIZE: {
+ _reset_play_buttons();
+ } break;
+
+ case NOTIFICATION_THEME_CHANGED: {
+ _update_play_buttons();
+ pause_button->set_icon(get_theme_icon(SNAME("Pause"), SNAME("EditorIcons")));
+ stop_button->set_icon(get_theme_icon(SNAME("Stop"), SNAME("EditorIcons")));
+
+ if (is_movie_maker_enabled()) {
+ main_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("LaunchPadMovieMode"), SNAME("EditorStyles")));
+ write_movie_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("MovieWriterButtonPressed"), SNAME("EditorStyles")));
+ } else {
+ main_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("LaunchPadNormal"), SNAME("EditorStyles")));
+ write_movie_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("MovieWriterButtonNormal"), SNAME("EditorStyles")));
+ }
+
+ write_movie_button->set_icon(get_theme_icon(SNAME("MainMovieWrite"), SNAME("EditorIcons")));
+ // This button behaves differently, so color it as such.
+ write_movie_button->add_theme_color_override("icon_normal_color", Color(1, 1, 1, 0.7));
+ write_movie_button->add_theme_color_override("icon_pressed_color", Color(0, 0, 0, 0.84));
+ write_movie_button->add_theme_color_override("icon_hover_color", Color(1, 1, 1, 0.9));
+ } break;
+ }
+}
+
+void EditorRunBar::_reset_play_buttons() {
+ play_button->set_pressed(false);
+ play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons")));
+ play_button->set_tooltip_text(TTR("Play the project."));
+
+ play_scene_button->set_pressed(false);
+ play_scene_button->set_icon(get_theme_icon(SNAME("PlayScene"), SNAME("EditorIcons")));
+ play_scene_button->set_tooltip_text(TTR("Play the edited scene."));
+
+ play_custom_scene_button->set_pressed(false);
+ play_custom_scene_button->set_icon(get_theme_icon(SNAME("PlayCustom"), SNAME("EditorIcons")));
+ play_custom_scene_button->set_tooltip_text(TTR("Play a custom scene."));
+}
+
+void EditorRunBar::_update_play_buttons() {
+ _reset_play_buttons();
+ if (!is_playing()) {
+ return;
+ }
+
+ Button *active_button = nullptr;
+ if (current_mode == RUN_CURRENT) {
+ active_button = play_scene_button;
+ } else if (current_mode == RUN_CUSTOM) {
+ active_button = play_custom_scene_button;
+ } else {
+ active_button = play_button;
+ }
+
+ if (active_button) {
+ active_button->set_pressed(true);
+ active_button->set_icon(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")));
+ active_button->set_tooltip_text(TTR("Reload the played scene."));
+ }
+}
+
+void EditorRunBar::_write_movie_toggled(bool p_enabled) {
+ if (p_enabled) {
+ add_theme_style_override("panel", get_theme_stylebox(SNAME("LaunchPadMovieMode"), SNAME("EditorStyles")));
+ write_movie_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("MovieWriterButtonPressed"), SNAME("EditorStyles")));
+ } else {
+ add_theme_style_override("panel", get_theme_stylebox(SNAME("LaunchPadNormal"), SNAME("EditorStyles")));
+ write_movie_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("MovieWriterButtonNormal"), SNAME("EditorStyles")));
+ }
+}
+
+void EditorRunBar::_quick_run_selected() {
+ play_custom_scene(quick_run->get_selected());
+}
+
+void EditorRunBar::_play_custom_pressed() {
+ if (editor_run.get_status() == EditorRun::STATUS_STOP || current_mode != RunMode::RUN_CUSTOM) {
+ stop_playing();
+
+ quick_run->popup_dialog("PackedScene", true);
+ quick_run->set_title(TTR("Quick Run Scene..."));
+ play_custom_scene_button->set_pressed(false);
+ } else {
+ // Reload if already running a custom scene.
+ String last_custom_scene = run_custom_filename; // This is necessary to have a copy of the string.
+ play_custom_scene(last_custom_scene);
+ }
+}
+
+void EditorRunBar::_play_current_pressed() {
+ if (editor_run.get_status() == EditorRun::STATUS_STOP || current_mode != RunMode::RUN_CURRENT) {
+ play_current_scene();
+ } else {
+ // Reload if already running the current scene.
+ play_current_scene(true);
+ }
+}
+
+void EditorRunBar::_run_scene(const String &p_scene_path) {
+ ERR_FAIL_COND_MSG(current_mode == RUN_CUSTOM && p_scene_path.is_empty(), "Attempting to run a custom scene with an empty path.");
+
+ if (editor_run.get_status() == EditorRun::STATUS_PLAY) {
+ return;
+ }
+
+ _reset_play_buttons();
+
+ String write_movie_file;
+ if (is_movie_maker_enabled()) {
+ if (current_mode == RUN_CURRENT) {
+ Node *scene_root = nullptr;
+ if (p_scene_path.is_empty()) {
+ scene_root = get_tree()->get_edited_scene_root();
+ } else {
+ int scene_index = EditorNode::get_editor_data().get_edited_scene_from_path(p_scene_path);
+ if (scene_index >= 0) {
+ scene_root = EditorNode::get_editor_data().get_edited_scene_root(scene_index);
+ }
+ }
+
+ if (scene_root && scene_root->has_meta("movie_file")) {
+ // If the scene file has a movie_file metadata set, use this as file.
+ // Quick workaround if you want to have multiple scenes that write to
+ // multiple movies.
+ write_movie_file = scene_root->get_meta("movie_file");
+ }
+ }
+
+ if (write_movie_file.is_empty()) {
+ write_movie_file = GLOBAL_GET("editor/movie_writer/movie_file");
+ }
+
+ if (write_movie_file.is_empty()) {
+ // TODO: Provide options to directly resolve the issue with a custom dialog.
+ EditorNode::get_singleton()->show_accept(TTR("Movie Maker mode is enabled, but no movie file path has been specified.\nA default movie file path can be specified in the project settings under the Editor > Movie Writer category.\nAlternatively, for running single scenes, a `movie_file` string metadata can be added to the root node,\nspecifying the path to a movie file that will be used when recording that scene."), TTR("OK"));
+ return;
+ }
+ }
+
+ String run_filename;
+ switch (current_mode) {
+ case RUN_CUSTOM: {
+ run_filename = p_scene_path;
+ run_custom_filename = run_filename;
+ } break;
+
+ case RUN_CURRENT: {
+ if (!p_scene_path.is_empty()) {
+ run_filename = p_scene_path;
+ run_current_filename = run_filename;
+ break;
+ }
+
+ Node *scene_root = get_tree()->get_edited_scene_root();
+ if (!scene_root) {
+ EditorNode::get_singleton()->show_accept(TTR("There is no defined scene to run."), TTR("OK"));
+ return;
+ }
+
+ if (scene_root->get_scene_file_path().is_empty()) {
+ EditorNode::get_singleton()->save_before_run();
+ return;
+ }
+
+ run_filename = scene_root->get_scene_file_path();
+ run_current_filename = run_filename;
+ } break;
+
+ default: {
+ if (!EditorNode::get_singleton()->ensure_main_scene(false)) {
+ return;
+ }
+
+ run_filename = GLOBAL_DEF_BASIC("application/run/main_scene", "");
+ } break;
+ }
+
+ EditorNode::get_singleton()->try_autosave();
+ if (!EditorNode::get_singleton()->call_build()) {
+ return;
+ }
+
+ EditorDebuggerNode::get_singleton()->start();
+ Error error = editor_run.run(run_filename, write_movie_file);
+ if (error != OK) {
+ EditorDebuggerNode::get_singleton()->stop();
+ EditorNode::get_singleton()->show_accept(TTR("Could not start subprocess(es)!"), TTR("OK"));
+ return;
+ }
+
+ _update_play_buttons();
+ stop_button->set_disabled(false);
+
+ emit_signal(SNAME("play_pressed"));
+}
+
+void EditorRunBar::_run_native(const Ref<EditorExportPreset> &p_preset) {
+ EditorNode::get_singleton()->try_autosave();
+
+ if (run_native->is_deploy_debug_remote_enabled()) {
+ stop_playing();
+
+ if (!EditorNode::get_singleton()->call_build()) {
+ return; // Build failed.
+ }
+
+ EditorDebuggerNode::get_singleton()->start(p_preset->get_platform()->get_debug_protocol());
+ emit_signal(SNAME("play_pressed"));
+ editor_run.run_native_notify();
+ }
+}
+
+void EditorRunBar::play_main_scene(bool p_from_native) {
+ if (p_from_native) {
+ run_native->resume_run_native();
+ } else {
+ stop_playing();
+
+ current_mode = RunMode::RUN_MAIN;
+ _run_scene();
+ }
+}
+
+void EditorRunBar::play_current_scene(bool p_reload) {
+ EditorNode::get_singleton()->save_default_environment();
+ stop_playing();
+
+ current_mode = RunMode::RUN_CURRENT;
+ if (p_reload) {
+ String last_current_scene = run_current_filename; // This is necessary to have a copy of the string.
+ _run_scene(last_current_scene);
+ } else {
+ _run_scene();
+ }
+}
+
+void EditorRunBar::play_custom_scene(const String &p_custom) {
+ stop_playing();
+
+ current_mode = RunMode::RUN_CUSTOM;
+ _run_scene(p_custom);
+}
+
+void EditorRunBar::stop_playing() {
+ if (editor_run.get_status() == EditorRun::STATUS_STOP) {
+ return;
+ }
+
+ current_mode = RunMode::STOPPED;
+ editor_run.stop();
+ EditorDebuggerNode::get_singleton()->stop();
+
+ run_custom_filename.clear();
+ run_current_filename.clear();
+ stop_button->set_pressed(false);
+ stop_button->set_disabled(true);
+ _reset_play_buttons();
+
+ emit_signal(SNAME("stop_pressed"));
+}
+
+bool EditorRunBar::is_playing() const {
+ EditorRun::Status status = editor_run.get_status();
+ return (status == EditorRun::STATUS_PLAY || status == EditorRun::STATUS_PAUSED);
+}
+
+String EditorRunBar::get_playing_scene() const {
+ String run_filename = editor_run.get_running_scene();
+ if (run_filename.is_empty() && is_playing()) {
+ run_filename = GLOBAL_GET("application/run/main_scene"); // Must be the main scene then.
+ }
+
+ return run_filename;
+}
+
+Error EditorRunBar::start_native_device(int p_device_id) {
+ return run_native->start_run_native(p_device_id);
+}
+
+OS::ProcessID EditorRunBar::has_child_process(OS::ProcessID p_pid) const {
+ return editor_run.has_child_process(p_pid);
+}
+
+void EditorRunBar::stop_child_process(OS::ProcessID p_pid) {
+ if (!has_child_process(p_pid)) {
+ return;
+ }
+
+ editor_run.stop_child_process(p_pid);
+ if (!editor_run.get_child_process_count()) { // All children stopped. Closing.
+ stop_playing();
+ }
+}
+
+void EditorRunBar::set_movie_maker_enabled(bool p_enabled) {
+ write_movie_button->set_pressed(p_enabled);
+}
+
+bool EditorRunBar::is_movie_maker_enabled() const {
+ return write_movie_button->is_pressed();
+}
+
+void EditorRunBar::_bind_methods() {
+ ADD_SIGNAL(MethodInfo("play_pressed"));
+ ADD_SIGNAL(MethodInfo("stop_pressed"));
+}
+
+EditorRunBar::EditorRunBar() {
+ singleton = this;
+
+ main_panel = memnew(PanelContainer);
+ add_child(main_panel);
+
+ HBoxContainer *main_hbox = memnew(HBoxContainer);
+ main_panel->add_child(main_hbox);
+
+ play_button = memnew(Button);
+ main_hbox->add_child(play_button);
+ play_button->set_flat(true);
+ play_button->set_toggle_mode(true);
+ play_button->set_focus_mode(Control::FOCUS_NONE);
+ play_button->set_tooltip_text(TTR("Run the project's default scene."));
+ play_button->connect("pressed", callable_mp(this, &EditorRunBar::play_main_scene).bind(false));
+
+ ED_SHORTCUT_AND_COMMAND("editor/run_project", TTR("Run Project"), Key::F5);
+ ED_SHORTCUT_OVERRIDE("editor/run_project", "macos", KeyModifierMask::META | Key::B);
+ play_button->set_shortcut(ED_GET_SHORTCUT("editor/run_project"));
+
+ pause_button = memnew(Button);
+ main_hbox->add_child(pause_button);
+ pause_button->set_flat(true);
+ pause_button->set_toggle_mode(true);
+ pause_button->set_focus_mode(Control::FOCUS_NONE);
+ pause_button->set_tooltip_text(TTR("Pause the running project's execution for debugging."));
+ pause_button->set_disabled(true);
+
+ ED_SHORTCUT("editor/pause_running_project", TTR("Pause Running Project"), Key::F7);
+ ED_SHORTCUT_OVERRIDE("editor/pause_running_project", "macos", KeyModifierMask::META | KeyModifierMask::CTRL | Key::Y);
+ pause_button->set_shortcut(ED_GET_SHORTCUT("editor/pause_running_project"));
+
+ stop_button = memnew(Button);
+ main_hbox->add_child(stop_button);
+ stop_button->set_flat(true);
+ stop_button->set_focus_mode(Control::FOCUS_NONE);
+ stop_button->set_tooltip_text(TTR("Stop the currently running project."));
+ stop_button->set_disabled(true);
+ stop_button->connect("pressed", callable_mp(this, &EditorRunBar::stop_playing));
+
+ ED_SHORTCUT("editor/stop_running_project", TTR("Stop Running Project"), Key::F8);
+ ED_SHORTCUT_OVERRIDE("editor/stop_running_project", "macos", KeyModifierMask::META | Key::PERIOD);
+ stop_button->set_shortcut(ED_GET_SHORTCUT("editor/stop_running_project"));
+
+ run_native = memnew(EditorRunNative);
+ main_hbox->add_child(run_native);
+ run_native->connect("native_run", callable_mp(this, &EditorRunBar::_run_native));
+
+ play_scene_button = memnew(Button);
+ main_hbox->add_child(play_scene_button);
+ play_scene_button->set_flat(true);
+ play_scene_button->set_toggle_mode(true);
+ play_scene_button->set_focus_mode(Control::FOCUS_NONE);
+ play_scene_button->set_tooltip_text(TTR("Run the currently edited scene."));
+ play_scene_button->connect("pressed", callable_mp(this, &EditorRunBar::_play_current_pressed));
+
+ ED_SHORTCUT_AND_COMMAND("editor/run_current_scene", TTR("Run Current Scene"), Key::F6);
+ ED_SHORTCUT_OVERRIDE("editor/run_current_scene", "macos", KeyModifierMask::META | Key::R);
+ play_scene_button->set_shortcut(ED_GET_SHORTCUT("editor/run_current_scene"));
+
+ play_custom_scene_button = memnew(Button);
+ main_hbox->add_child(play_custom_scene_button);
+ play_custom_scene_button->set_flat(true);
+ play_custom_scene_button->set_toggle_mode(true);
+ play_custom_scene_button->set_focus_mode(Control::FOCUS_NONE);
+ play_custom_scene_button->set_tooltip_text(TTR("Run a specific scene."));
+ play_custom_scene_button->connect("pressed", callable_mp(this, &EditorRunBar::_play_custom_pressed));
+
+ ED_SHORTCUT_AND_COMMAND("editor/run_specific_scene", TTR("Run Specific Scene"), KeyModifierMask::CTRL | KeyModifierMask::SHIFT | Key::F5);
+ ED_SHORTCUT_OVERRIDE("editor/run_specific_scene", "macos", KeyModifierMask::META | KeyModifierMask::SHIFT | Key::R);
+ play_custom_scene_button->set_shortcut(ED_GET_SHORTCUT("editor/run_specific_scene"));
+
+ write_movie_panel = memnew(PanelContainer);
+ main_hbox->add_child(write_movie_panel);
+
+ write_movie_button = memnew(Button);
+ write_movie_panel->add_child(write_movie_button);
+ write_movie_button->set_flat(true);
+ write_movie_button->set_toggle_mode(true);
+ write_movie_button->set_pressed(false);
+ write_movie_button->set_focus_mode(Control::FOCUS_NONE);
+ write_movie_button->set_tooltip_text(TTR("Enable Movie Maker mode.\nThe project will run at stable FPS and the visual and audio output will be recorded to a video file."));
+ write_movie_button->connect("toggled", callable_mp(this, &EditorRunBar::_write_movie_toggled));
+
+ quick_run = memnew(EditorQuickOpen);
+ add_child(quick_run);
+ quick_run->connect("quick_open", callable_mp(this, &EditorRunBar::_quick_run_selected));
+}
diff --git a/editor/gui/editor_run_bar.h b/editor/gui/editor_run_bar.h
new file mode 100644
index 0000000000..b7e7db2bd6
--- /dev/null
+++ b/editor/gui/editor_run_bar.h
@@ -0,0 +1,115 @@
+/**************************************************************************/
+/* editor_run_bar.h */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/**************************************************************************/
+
+#ifndef EDITOR_RUN_BAR_H
+#define EDITOR_RUN_BAR_H
+
+#include "editor/editor_run.h"
+#include "editor/export/editor_export.h"
+#include "scene/gui/margin_container.h"
+
+class Button;
+class EditorRunNative;
+class EditorQuickOpen;
+class PanelContainer;
+
+class EditorRunBar : public MarginContainer {
+ GDCLASS(EditorRunBar, MarginContainer);
+
+ static EditorRunBar *singleton;
+
+ enum RunMode {
+ STOPPED = 0,
+ RUN_MAIN,
+ RUN_CURRENT,
+ RUN_CUSTOM,
+ };
+
+ PanelContainer *main_panel = nullptr;
+
+ Button *play_button = nullptr;
+ Button *pause_button = nullptr;
+ Button *stop_button = nullptr;
+ Button *play_scene_button = nullptr;
+ Button *play_custom_scene_button = nullptr;
+
+ EditorRun editor_run;
+ EditorRunNative *run_native = nullptr;
+
+ PanelContainer *write_movie_panel = nullptr;
+ Button *write_movie_button = nullptr;
+
+ EditorQuickOpen *quick_run = nullptr;
+
+ RunMode current_mode = RunMode::STOPPED;
+ String run_custom_filename;
+ String run_current_filename;
+
+ void _reset_play_buttons();
+ void _update_play_buttons();
+
+ void _write_movie_toggled(bool p_enabled);
+ void _quick_run_selected();
+
+ void _play_current_pressed();
+ void _play_custom_pressed();
+
+ void _run_scene(const String &p_scene_path = "");
+ void _run_native(const Ref<EditorExportPreset> &p_preset);
+
+protected:
+ void _notification(int p_what);
+ static void _bind_methods();
+
+public:
+ static EditorRunBar *get_singleton() { return singleton; }
+
+ void play_main_scene(bool p_from_native = false);
+ void play_current_scene(bool p_reload = false);
+ void play_custom_scene(const String &p_custom);
+
+ void stop_playing();
+ bool is_playing() const;
+ String get_playing_scene() const;
+
+ Error start_native_device(int p_device_id);
+
+ OS::ProcessID has_child_process(OS::ProcessID p_pid) const;
+ void stop_child_process(OS::ProcessID p_pid);
+
+ void set_movie_maker_enabled(bool p_enabled);
+ bool is_movie_maker_enabled() const;
+
+ Button *get_pause_button() { return pause_button; }
+
+ EditorRunBar();
+};
+
+#endif // EDITOR_RUN_BAR_H
diff --git a/editor/gui/editor_spin_slider.cpp b/editor/gui/editor_spin_slider.cpp
index ecbf12fed8..6d02fcef1d 100644
--- a/editor/gui/editor_spin_slider.cpp
+++ b/editor/gui/editor_spin_slider.cpp
@@ -34,6 +34,7 @@
#include "core/math/expression.h"
#include "core/os/keyboard.h"
#include "editor/editor_scale.h"
+#include "editor/editor_settings.h"
String EditorSpinSlider::get_tooltip(const Point2 &p_pos) const {
if (grabber->is_visible()) {
@@ -103,7 +104,7 @@ void EditorSpinSlider::gui_input(const Ref<InputEvent> &p_event) {
if (mm->is_shift_pressed() && grabbing_spinner) {
diff_x *= 0.1;
}
- grabbing_spinner_dist_cache += diff_x;
+ grabbing_spinner_dist_cache += diff_x * grabbing_spinner_speed;
if (!grabbing_spinner && ABS(grabbing_spinner_dist_cache) > 4 * EDSCALE) {
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_CAPTURED);
@@ -439,7 +440,11 @@ void EditorSpinSlider::_draw_spin_slider() {
void EditorSpinSlider::_notification(int p_what) {
switch (p_what) {
- case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_ENTER_TREE: {
+ grabbing_spinner_speed = EditorSettings::get_singleton()->get("interface/inspector/float_drag_speed");
+ _update_value_input_stylebox();
+ } break;
+
case NOTIFICATION_THEME_CHANGED: {
_update_value_input_stylebox();
} break;
diff --git a/editor/gui/editor_spin_slider.h b/editor/gui/editor_spin_slider.h
index a4d810b18b..8c643157f1 100644
--- a/editor/gui/editor_spin_slider.h
+++ b/editor/gui/editor_spin_slider.h
@@ -60,6 +60,7 @@ class EditorSpinSlider : public Range {
bool read_only = false;
float grabbing_spinner_dist_cache = 0.0f;
+ float grabbing_spinner_speed = 0.0f;
Vector2 grabbing_spinner_mouse_pos;
double pre_grab_value = 0.0;
diff --git a/editor/icons/SnapDisable.svg b/editor/icons/SnapDisable.svg
new file mode 100644
index 0000000000..9bc0a6ad94
--- /dev/null
+++ b/editor/icons/SnapDisable.svg
@@ -0,0 +1 @@
+<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m11 7a4 4 0 0 0 -4 4v2h2v-2a2 2 0 0 1 2-2 2 2 0 0 1 2 2v2h2v-2a4 4 0 0 0 -4-4z" fill="#fff" fill-opacity=".68627"/><g fill="#e0e0e0"><path d="m4.1817443 1.9883112a.49892098.49907772 0 0 0 -.3478478.856731l2.1416536 2.1423264-2.1416536 2.1423263a.49892098.49907772 0 1 0 .7054536.7056752l2.1416536-2.1423263 2.1416535 2.1423263a.49892098.49907772 0 1 0 .7054536-.7056752l-2.1416536-2.1423263 2.1416536-2.1423264a.49892098.49907772 0 0 0 -.3624598-.8557329.49892098.49907772 0 0 0 -.3429739.1500975l-2.1416534 2.1423265-2.1416537-2.1423265a.49892098.49907772 0 0 0 -.3575908-.1510706z" fill-rule="evenodd" stroke-width=".498949"/><path d="m7 13v2h2v-2zm6 0v2h2v-2z"/></g></svg>
diff --git a/editor/import/dynamic_font_import_settings.cpp b/editor/import/dynamic_font_import_settings.cpp
index 65fc79a7a5..39e4ffbc16 100644
--- a/editor/import/dynamic_font_import_settings.cpp
+++ b/editor/import/dynamic_font_import_settings.cpp
@@ -928,15 +928,6 @@ void DynamicFontImportSettings::_notification(int p_what) {
add_var->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
label_warn->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor")));
} break;
-
- case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
- if (EditorSettings::get_singleton()->check_changed_settings_in_group("interface/editor/localize_settings")) {
- EditorPropertyNameProcessor::Style style = EditorPropertyNameProcessor::get_singleton()->get_settings_style();
- inspector_general->set_property_name_style(style);
- inspector_vars->set_property_name_style(style);
- inspector_text->set_property_name_style(style);
- }
- } break;
}
}
@@ -1342,7 +1333,6 @@ DynamicFontImportSettings::DynamicFontImportSettings() {
inspector_general->set_v_size_flags(Control::SIZE_EXPAND_FILL);
inspector_general->set_custom_minimum_size(Size2(300 * EDSCALE, 250 * EDSCALE));
inspector_general->connect("property_edited", callable_mp(this, &DynamicFontImportSettings::_main_prop_changed));
- inspector_general->set_property_name_style(EditorPropertyNameProcessor::get_singleton()->get_settings_style());
page1_hb->add_child(inspector_general);
// Page 2 layout: Configurations
@@ -1394,7 +1384,6 @@ DynamicFontImportSettings::DynamicFontImportSettings() {
inspector_vars = memnew(EditorInspector);
inspector_vars->set_v_size_flags(Control::SIZE_EXPAND_FILL);
inspector_vars->connect("property_edited", callable_mp(this, &DynamicFontImportSettings::_variation_changed));
- inspector_vars->set_property_name_style(EditorPropertyNameProcessor::get_singleton()->get_settings_style());
page2_side_vb->add_child(inspector_vars);
VBoxContainer *preload_pages_vb = memnew(VBoxContainer);
@@ -1470,7 +1459,6 @@ DynamicFontImportSettings::DynamicFontImportSettings() {
inspector_text->set_v_size_flags(Control::SIZE_EXPAND_FILL);
inspector_text->set_custom_minimum_size(Size2(300 * EDSCALE, 250 * EDSCALE));
inspector_text->connect("property_edited", callable_mp(this, &DynamicFontImportSettings::_change_text_opts));
- inspector_text->set_property_name_style(EditorPropertyNameProcessor::get_singleton()->get_settings_style());
page2_1_hb->add_child(inspector_text);
text_edit = memnew(TextEdit);
diff --git a/editor/import/post_import_plugin_skeleton_rest_fixer.cpp b/editor/import/post_import_plugin_skeleton_rest_fixer.cpp
index e105135c11..6214a2b70d 100644
--- a/editor/import/post_import_plugin_skeleton_rest_fixer.cpp
+++ b/editor/import/post_import_plugin_skeleton_rest_fixer.cpp
@@ -669,7 +669,7 @@ void PostImportPluginSkeletonRestFixer::internal_process(InternalImportCategory
StringName bn = skin->get_bind_name(i);
int bone_idx = src_skeleton->find_bone(bn);
if (bone_idx >= 0) {
- Transform3D new_rest = silhouette_diff[i] * src_skeleton->get_bone_global_rest(bone_idx);
+ Transform3D new_rest = silhouette_diff[bone_idx] * src_skeleton->get_bone_global_rest(bone_idx);
skin->set_bind_pose(i, new_rest.inverse() * ibm_diff[bone_idx]);
}
}
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index c052f92508..15bb504d8d 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -1455,22 +1455,22 @@ void ResourceImporterScene::_create_slices(AnimationPlayer *ap, Ref<Animation> a
if (kt > (from + 0.01) && k > 0) {
if (anim->track_get_type(j) == Animation::TYPE_POSITION_3D) {
Vector3 p;
- anim->position_track_interpolate(j, from, &p);
+ anim->try_position_track_interpolate(j, from, &p);
new_anim->position_track_insert_key(dtrack, 0, p);
} else if (anim->track_get_type(j) == Animation::TYPE_ROTATION_3D) {
Quaternion r;
- anim->rotation_track_interpolate(j, from, &r);
+ anim->try_rotation_track_interpolate(j, from, &r);
new_anim->rotation_track_insert_key(dtrack, 0, r);
} else if (anim->track_get_type(j) == Animation::TYPE_SCALE_3D) {
Vector3 s;
- anim->scale_track_interpolate(j, from, &s);
+ anim->try_scale_track_interpolate(j, from, &s);
new_anim->scale_track_insert_key(dtrack, 0, s);
} else if (anim->track_get_type(j) == Animation::TYPE_VALUE) {
Variant var = anim->value_track_interpolate(j, from);
new_anim->track_insert_key(dtrack, 0, var);
} else if (anim->track_get_type(j) == Animation::TYPE_BLEND_SHAPE) {
float interp;
- anim->blend_shape_track_interpolate(j, from, &interp);
+ anim->try_blend_shape_track_interpolate(j, from, &interp);
new_anim->blend_shape_track_insert_key(dtrack, 0, interp);
}
}
@@ -1501,22 +1501,22 @@ void ResourceImporterScene::_create_slices(AnimationPlayer *ap, Ref<Animation> a
if (dtrack != -1 && kt >= to) {
if (anim->track_get_type(j) == Animation::TYPE_POSITION_3D) {
Vector3 p;
- anim->position_track_interpolate(j, to, &p);
+ anim->try_position_track_interpolate(j, to, &p);
new_anim->position_track_insert_key(dtrack, to - from, p);
} else if (anim->track_get_type(j) == Animation::TYPE_ROTATION_3D) {
Quaternion r;
- anim->rotation_track_interpolate(j, to, &r);
+ anim->try_rotation_track_interpolate(j, to, &r);
new_anim->rotation_track_insert_key(dtrack, to - from, r);
} else if (anim->track_get_type(j) == Animation::TYPE_SCALE_3D) {
Vector3 s;
- anim->scale_track_interpolate(j, to, &s);
+ anim->try_scale_track_interpolate(j, to, &s);
new_anim->scale_track_insert_key(dtrack, to - from, s);
} else if (anim->track_get_type(j) == Animation::TYPE_VALUE) {
Variant var = anim->value_track_interpolate(j, to);
new_anim->track_insert_key(dtrack, to - from, var);
} else if (anim->track_get_type(j) == Animation::TYPE_BLEND_SHAPE) {
float interp;
- anim->blend_shape_track_interpolate(j, to, &interp);
+ anim->try_blend_shape_track_interpolate(j, to, &interp);
new_anim->blend_shape_track_insert_key(dtrack, to - from, interp);
}
}
@@ -1528,21 +1528,21 @@ void ResourceImporterScene::_create_slices(AnimationPlayer *ap, Ref<Animation> a
new_anim->track_set_path(dtrack, anim->track_get_path(j));
if (anim->track_get_type(j) == Animation::TYPE_POSITION_3D) {
Vector3 p;
- anim->position_track_interpolate(j, from, &p);
+ anim->try_position_track_interpolate(j, from, &p);
new_anim->position_track_insert_key(dtrack, 0, p);
- anim->position_track_interpolate(j, to, &p);
+ anim->try_position_track_interpolate(j, to, &p);
new_anim->position_track_insert_key(dtrack, to - from, p);
} else if (anim->track_get_type(j) == Animation::TYPE_ROTATION_3D) {
Quaternion r;
- anim->rotation_track_interpolate(j, from, &r);
+ anim->try_rotation_track_interpolate(j, from, &r);
new_anim->rotation_track_insert_key(dtrack, 0, r);
- anim->rotation_track_interpolate(j, to, &r);
+ anim->try_rotation_track_interpolate(j, to, &r);
new_anim->rotation_track_insert_key(dtrack, to - from, r);
} else if (anim->track_get_type(j) == Animation::TYPE_SCALE_3D) {
Vector3 s;
- anim->scale_track_interpolate(j, from, &s);
+ anim->try_scale_track_interpolate(j, from, &s);
new_anim->scale_track_insert_key(dtrack, 0, s);
- anim->scale_track_interpolate(j, to, &s);
+ anim->try_scale_track_interpolate(j, to, &s);
new_anim->scale_track_insert_key(dtrack, to - from, s);
} else if (anim->track_get_type(j) == Animation::TYPE_VALUE) {
Variant var = anim->value_track_interpolate(j, from);
@@ -1551,9 +1551,9 @@ void ResourceImporterScene::_create_slices(AnimationPlayer *ap, Ref<Animation> a
new_anim->track_insert_key(dtrack, to - from, to_var);
} else if (anim->track_get_type(j) == Animation::TYPE_BLEND_SHAPE) {
float interp;
- anim->blend_shape_track_interpolate(j, from, &interp);
+ anim->try_blend_shape_track_interpolate(j, from, &interp);
new_anim->blend_shape_track_insert_key(dtrack, 0, interp);
- anim->blend_shape_track_interpolate(j, to, &interp);
+ anim->try_blend_shape_track_interpolate(j, to, &interp);
new_anim->blend_shape_track_insert_key(dtrack, to - from, interp);
}
}
diff --git a/editor/import/scene_import_settings.cpp b/editor/import/scene_import_settings.cpp
index e7ba47e2a1..92d287c54f 100644
--- a/editor/import/scene_import_settings.cpp
+++ b/editor/import/scene_import_settings.cpp
@@ -1006,10 +1006,6 @@ void SceneImportSettings::_notification(int p_what) {
action_menu->add_theme_style_override("hover", get_theme_stylebox("hover", "Button"));
action_menu->add_theme_style_override("pressed", get_theme_stylebox("pressed", "Button"));
} break;
-
- case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
- inspector->set_property_name_style(EditorPropertyNameProcessor::get_settings_style());
- } break;
}
}
@@ -1410,7 +1406,6 @@ SceneImportSettings::SceneImportSettings() {
inspector = memnew(EditorInspector);
inspector->set_custom_minimum_size(Size2(300 * EDSCALE, 0));
- inspector->set_property_name_style(EditorPropertyNameProcessor::get_settings_style());
property_split->add_child(inspector);
diff --git a/editor/import_defaults_editor.cpp b/editor/import_defaults_editor.cpp
index 0e25468e1a..ebbea827c0 100644
--- a/editor/import_defaults_editor.cpp
+++ b/editor/import_defaults_editor.cpp
@@ -36,7 +36,6 @@
#include "editor/editor_autoload_settings.h"
#include "editor/editor_plugin_settings.h"
#include "editor/editor_sectioned_inspector.h"
-#include "editor/editor_settings.h"
#include "editor/localization_editor.h"
#include "editor/shader_globals_editor.h"
#include "scene/gui/center_container.h"
@@ -82,11 +81,6 @@ protected:
void ImportDefaultsEditor::_notification(int p_what) {
switch (p_what) {
- case NOTIFICATION_ENTER_TREE:
- case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
- inspector->set_property_name_style(EditorPropertyNameProcessor::get_settings_style());
- } break;
-
case NOTIFICATION_PREDELETE: {
inspector->edit(nullptr);
} break;
diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp
index b5680f2f2c..7b8b9cd7a4 100644
--- a/editor/import_dock.cpp
+++ b/editor/import_dock.cpp
@@ -565,7 +565,6 @@ void ImportDock::_notification(int p_what) {
switch (p_what) {
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
imported->add_theme_style_override("normal", get_theme_stylebox(SNAME("normal"), SNAME("LineEdit")));
- import_opts->set_property_name_style(EditorPropertyNameProcessor::get_settings_style());
} break;
case NOTIFICATION_ENTER_TREE: {
@@ -643,7 +642,6 @@ ImportDock::ImportDock() {
import_opts = memnew(EditorInspector);
content->add_child(import_opts);
import_opts->set_v_size_flags(SIZE_EXPAND_FILL);
- import_opts->set_property_name_style(EditorPropertyNameProcessor::get_settings_style());
import_opts->connect("property_edited", callable_mp(this, &ImportDock::_property_edited));
import_opts->connect("property_toggled", callable_mp(this, &ImportDock::_property_toggled));
diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp
index 2acc83cead..39ed7d869b 100644
--- a/editor/inspector_dock.cpp
+++ b/editor/inspector_dock.cpp
@@ -767,7 +767,8 @@ InspectorDock::InspectorDock(EditorData &p_editor_data) {
inspector->set_use_doc_hints(true);
inspector->set_hide_script(false);
inspector->set_hide_metadata(false);
- inspector->set_property_name_style(EditorPropertyNameProcessor::get_default_inspector_style());
+ inspector->set_use_settings_name_style(false);
+ inspector->set_property_name_style(property_name_style);
inspector->set_use_folding(!bool(EDITOR_GET("interface/inspector/disable_folding")));
inspector->register_text_enter(search);
diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp
index d9d057d0e8..1fdb1d4a6e 100644
--- a/editor/plugins/animation_player_editor_plugin.cpp
+++ b/editor/plugins/animation_player_editor_plugin.cpp
@@ -1607,7 +1607,7 @@ bool AnimationPlayerEditor::_validate_tracks(const Ref<Animation> p_anim) {
for (int j = 0; j < key_len; j++) {
Quaternion q;
p_anim->rotation_track_get_key(i, j, &q);
- ERR_BREAK_EDMSG(!q.is_normalized(), "AnimationPlayer: '" + player->get_name() + "', Animation: '" + player->get_current_animation() + "', rotation track: '" + p_anim->track_get_path(i) + "' contains unnormalized Quaternion key.");
+ ERR_BREAK_EDMSG(!q.is_normalized(), "AnimationPlayer: '" + player->get_name() + "', Animation: '" + player->get_current_animation() + "', 3D Rotation Track: '" + p_anim->track_get_path(i) + "' contains unnormalized Quaternion key.");
}
} else if (ttype == Animation::TYPE_VALUE) {
int key_len = p_anim->track_get_key_count(i);
@@ -1620,7 +1620,7 @@ bool AnimationPlayerEditor::_validate_tracks(const Ref<Animation> p_anim) {
Quaternion q = Quaternion(p_anim->track_get_key_value(i, j));
if (!q.is_normalized()) {
is_valid = false;
- ERR_BREAK_EDMSG(true, "AnimationPlayer: '" + player->get_name() + "', Animation: '" + player->get_current_animation() + "', value track: '" + p_anim->track_get_path(i) + "' contains unnormalized Quaternion key.");
+ ERR_BREAK_EDMSG(true, "AnimationPlayer: '" + player->get_name() + "', Animation: '" + player->get_current_animation() + "', Value Track: '" + p_anim->track_get_path(i) + "' contains unnormalized Quaternion key.");
}
}
} break;
@@ -1629,7 +1629,7 @@ bool AnimationPlayerEditor::_validate_tracks(const Ref<Animation> p_anim) {
Transform3D t = Transform3D(p_anim->track_get_key_value(i, j));
if (!t.basis.orthonormalized().is_rotation()) {
is_valid = false;
- ERR_BREAK_EDMSG(true, "AnimationPlayer: '" + player->get_name() + "', Animation: '" + player->get_current_animation() + "', value track: '" + p_anim->track_get_path(i) + "' contains corrupted basis (some axes are too close other axis or scaled by zero) Transform3D key.");
+ ERR_BREAK_EDMSG(true, "AnimationPlayer: '" + player->get_name() + "', Animation: '" + player->get_current_animation() + "', Value Track: '" + p_anim->track_get_path(i) + "' contains corrupted basis (some axes are too close other axis or scaled by zero) Transform3D key.");
}
}
} break;
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index eef1fea11b..f9ab37dce2 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -38,6 +38,7 @@
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/editor_undo_redo_manager.h"
+#include "editor/gui/editor_run_bar.h"
#include "editor/gui/editor_toaster.h"
#include "editor/gui/editor_zoom_widget.h"
#include "editor/plugins/animation_player_editor_plugin.h"
@@ -4975,8 +4976,8 @@ CanvasItemEditor::CanvasItemEditor() {
SceneTreeDock::get_singleton()->connect("node_created", callable_mp(this, &CanvasItemEditor::_node_created));
SceneTreeDock::get_singleton()->connect("add_node_used", callable_mp(this, &CanvasItemEditor::_reset_create_position));
- EditorNode::get_singleton()->call_deferred(SNAME("connect"), "play_pressed", callable_mp(this, &CanvasItemEditor::_update_override_camera_button).bind(true));
- EditorNode::get_singleton()->call_deferred(SNAME("connect"), "stop_pressed", callable_mp(this, &CanvasItemEditor::_update_override_camera_button).bind(false));
+ EditorRunBar::get_singleton()->call_deferred(SNAME("connect"), "play_pressed", callable_mp(this, &CanvasItemEditor::_update_override_camera_button).bind(true));
+ EditorRunBar::get_singleton()->call_deferred(SNAME("connect"), "stop_pressed", callable_mp(this, &CanvasItemEditor::_update_override_camera_button).bind(false));
// A fluid container for all toolbars.
HFlowContainer *main_flow = memnew(HFlowContainer);
diff --git a/editor/plugins/collision_shape_2d_editor_plugin.cpp b/editor/plugins/collision_shape_2d_editor_plugin.cpp
index 4afbb87197..22ce3e2d6e 100644
--- a/editor/plugins/collision_shape_2d_editor_plugin.cpp
+++ b/editor/plugins/collision_shape_2d_editor_plugin.cpp
@@ -33,6 +33,7 @@
#include "canvas_item_editor_plugin.h"
#include "core/os/keyboard.h"
#include "editor/editor_node.h"
+#include "editor/editor_settings.h"
#include "editor/editor_undo_redo_manager.h"
#include "scene/resources/capsule_shape_2d.h"
#include "scene/resources/circle_shape_2d.h"
@@ -42,6 +43,11 @@
#include "scene/resources/segment_shape_2d.h"
#include "scene/resources/separation_ray_shape_2d.h"
#include "scene/resources/world_boundary_shape_2d.h"
+#include "scene/scene_string_names.h"
+
+CollisionShape2DEditor::CollisionShape2DEditor() {
+ grab_threshold = EDITOR_GET("editors/polygon_editor/point_grab_radius");
+}
void CollisionShape2DEditor::_node_removed(Node *p_node) {
if (p_node == node) {
@@ -129,8 +135,6 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) {
} else if (idx == 1) {
capsule->set_height(parameter * 2);
}
-
- canvas_item_editor->update_viewport();
}
} break;
@@ -138,9 +142,6 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) {
case CIRCLE_SHAPE: {
Ref<CircleShape2D> circle = node->get_shape();
circle->set_radius(p_point.length());
-
- canvas_item_editor->update_viewport();
-
} break;
case CONCAVE_POLYGON_SHAPE: {
@@ -158,19 +159,13 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) {
} else {
world_boundary->set_normal(p_point.normalized());
}
-
- canvas_item_editor->update_viewport();
}
-
} break;
case SEPARATION_RAY_SHAPE: {
Ref<SeparationRayShape2D> ray = node->get_shape();
ray->set_length(Math::abs(p_point.y));
-
- canvas_item_editor->update_viewport();
-
} break;
case RECTANGLE_SHAPE: {
@@ -194,8 +189,6 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) {
pos += (size - (Point2)original) * 0.5 * RECT_HANDLES[idx] * 0.5;
node->set_global_position(original_transform.xform(pos));
}
-
- canvas_item_editor->update_viewport();
}
} break;
@@ -209,13 +202,9 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) {
} else if (idx == 1) {
seg->set_b(p_point);
}
-
- canvas_item_editor->update_viewport();
}
-
} break;
}
- node->get_shape()->notify_property_list_changed();
}
void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) {
@@ -233,10 +222,8 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) {
} else if (idx == 1) {
undo_redo->add_do_method(capsule.ptr(), "set_height", capsule->get_height());
}
- undo_redo->add_do_method(canvas_item_editor, "update_viewport");
undo_redo->add_undo_method(capsule.ptr(), "set_radius", values[0]);
undo_redo->add_undo_method(capsule.ptr(), "set_height", values[1]);
- undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
} break;
@@ -244,9 +231,7 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) {
Ref<CircleShape2D> circle = node->get_shape();
undo_redo->add_do_method(circle.ptr(), "set_radius", circle->get_radius());
- undo_redo->add_do_method(canvas_item_editor, "update_viewport");
undo_redo->add_undo_method(circle.ptr(), "set_radius", p_org);
- undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
} break;
@@ -263,14 +248,10 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) {
if (idx == 0) {
undo_redo->add_do_method(world_boundary.ptr(), "set_distance", world_boundary->get_distance());
- undo_redo->add_do_method(canvas_item_editor, "update_viewport");
undo_redo->add_undo_method(world_boundary.ptr(), "set_distance", p_org);
- undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
} else {
undo_redo->add_do_method(world_boundary.ptr(), "set_normal", world_boundary->get_normal());
- undo_redo->add_do_method(canvas_item_editor, "update_viewport");
undo_redo->add_undo_method(world_boundary.ptr(), "set_normal", p_org);
- undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
}
} break;
@@ -279,9 +260,7 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) {
Ref<SeparationRayShape2D> ray = node->get_shape();
undo_redo->add_do_method(ray.ptr(), "set_length", ray->get_length());
- undo_redo->add_do_method(canvas_item_editor, "update_viewport");
undo_redo->add_undo_method(ray.ptr(), "set_length", p_org);
- undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
} break;
@@ -290,10 +269,8 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) {
undo_redo->add_do_method(rect.ptr(), "set_size", rect->get_size());
undo_redo->add_do_method(node, "set_global_transform", node->get_global_transform());
- undo_redo->add_do_method(canvas_item_editor, "update_viewport");
undo_redo->add_undo_method(rect.ptr(), "set_size", p_org);
undo_redo->add_undo_method(node, "set_global_transform", original_transform);
- undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
} break;
@@ -301,14 +278,10 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) {
Ref<SegmentShape2D> seg = node->get_shape();
if (idx == 0) {
undo_redo->add_do_method(seg.ptr(), "set_a", seg->get_a());
- undo_redo->add_do_method(canvas_item_editor, "update_viewport");
undo_redo->add_undo_method(seg.ptr(), "set_a", p_org);
- undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
} else if (idx == 1) {
undo_redo->add_do_method(seg.ptr(), "set_b", seg->get_b());
- undo_redo->add_do_method(canvas_item_editor, "update_viewport");
undo_redo->add_undo_method(seg.ptr(), "set_b", p_org);
- undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
}
} break;
@@ -322,10 +295,6 @@ bool CollisionShape2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_e
return false;
}
- if (!node->get_shape().is_valid()) {
- return false;
- }
-
if (!node->is_visible_in_tree()) {
return false;
}
@@ -343,7 +312,7 @@ bool CollisionShape2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_e
if (mb->get_button_index() == MouseButton::LEFT) {
if (mb->is_pressed()) {
for (int i = 0; i < handles.size(); i++) {
- if (xform.xform(handles[i]).distance_to(gpoint) < 8) {
+ if (xform.xform(handles[i]).distance_to(gpoint) < grab_threshold) {
edit_handle = i;
break;
@@ -410,38 +379,44 @@ bool CollisionShape2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_e
return false;
}
-void CollisionShape2DEditor::_get_current_shape_type() {
+void CollisionShape2DEditor::_shape_changed() {
+ canvas_item_editor->update_viewport();
+
+ if (current_shape.is_valid()) {
+ current_shape->disconnect(SceneStringNames::get_singleton()->changed, callable_mp(canvas_item_editor, &CanvasItemEditor::update_viewport));
+ current_shape = Ref<Shape2D>();
+ shape_type = -1;
+ }
+
if (!node) {
return;
}
- Ref<Shape2D> s = node->get_shape();
+ current_shape = node->get_shape();
- if (!s.is_valid()) {
+ if (current_shape.is_valid()) {
+ current_shape->connect(SceneStringNames::get_singleton()->changed, callable_mp(canvas_item_editor, &CanvasItemEditor::update_viewport));
+ } else {
return;
}
- if (Object::cast_to<CapsuleShape2D>(*s)) {
+ if (Object::cast_to<CapsuleShape2D>(*current_shape)) {
shape_type = CAPSULE_SHAPE;
- } else if (Object::cast_to<CircleShape2D>(*s)) {
+ } else if (Object::cast_to<CircleShape2D>(*current_shape)) {
shape_type = CIRCLE_SHAPE;
- } else if (Object::cast_to<ConcavePolygonShape2D>(*s)) {
+ } else if (Object::cast_to<ConcavePolygonShape2D>(*current_shape)) {
shape_type = CONCAVE_POLYGON_SHAPE;
- } else if (Object::cast_to<ConvexPolygonShape2D>(*s)) {
+ } else if (Object::cast_to<ConvexPolygonShape2D>(*current_shape)) {
shape_type = CONVEX_POLYGON_SHAPE;
- } else if (Object::cast_to<WorldBoundaryShape2D>(*s)) {
+ } else if (Object::cast_to<WorldBoundaryShape2D>(*current_shape)) {
shape_type = WORLD_BOUNDARY_SHAPE;
- } else if (Object::cast_to<SeparationRayShape2D>(*s)) {
+ } else if (Object::cast_to<SeparationRayShape2D>(*current_shape)) {
shape_type = SEPARATION_RAY_SHAPE;
- } else if (Object::cast_to<RectangleShape2D>(*s)) {
+ } else if (Object::cast_to<RectangleShape2D>(*current_shape)) {
shape_type = RECTANGLE_SHAPE;
- } else if (Object::cast_to<SegmentShape2D>(*s)) {
+ } else if (Object::cast_to<SegmentShape2D>(*current_shape)) {
shape_type = SEGMENT_SHAPE;
- } else {
- shape_type = -1;
}
-
- canvas_item_editor->update_viewport();
}
void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
@@ -449,16 +424,10 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla
return;
}
- if (!node->get_shape().is_valid()) {
- return;
- }
-
if (!node->is_visible_in_tree()) {
return;
}
- _get_current_shape_type();
-
if (shape_type == -1) {
return;
}
@@ -472,7 +441,7 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla
switch (shape_type) {
case CAPSULE_SHAPE: {
- Ref<CapsuleShape2D> shape = node->get_shape();
+ Ref<CapsuleShape2D> shape = current_shape;
handles.resize(2);
float radius = shape->get_radius();
@@ -487,7 +456,7 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla
} break;
case CIRCLE_SHAPE: {
- Ref<CircleShape2D> shape = node->get_shape();
+ Ref<CircleShape2D> shape = current_shape;
handles.resize(1);
handles.write[0] = Point2(shape->get_radius(), 0);
@@ -503,7 +472,7 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla
} break;
case WORLD_BOUNDARY_SHAPE: {
- Ref<WorldBoundaryShape2D> shape = node->get_shape();
+ Ref<WorldBoundaryShape2D> shape = current_shape;
handles.resize(2);
handles.write[0] = shape->get_normal() * shape->get_distance();
@@ -515,7 +484,7 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla
} break;
case SEPARATION_RAY_SHAPE: {
- Ref<SeparationRayShape2D> shape = node->get_shape();
+ Ref<SeparationRayShape2D> shape = current_shape;
handles.resize(1);
handles.write[0] = Point2(0, shape->get_length());
@@ -525,7 +494,7 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla
} break;
case RECTANGLE_SHAPE: {
- Ref<RectangleShape2D> shape = node->get_shape();
+ Ref<RectangleShape2D> shape = current_shape;
handles.resize(8);
Vector2 ext = shape->get_size() / 2;
@@ -537,7 +506,7 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla
} break;
case SEGMENT_SHAPE: {
- Ref<SegmentShape2D> shape = node->get_shape();
+ Ref<SegmentShape2D> shape = current_shape;
handles.resize(2);
handles.write[0] = shape->get_a();
@@ -559,6 +528,18 @@ void CollisionShape2DEditor::_notification(int p_what) {
case NOTIFICATION_EXIT_TREE: {
get_tree()->disconnect("node_removed", callable_mp(this, &CollisionShape2DEditor::_node_removed));
} break;
+
+ case NOTIFICATION_PROCESS: {
+ if (node && node->get_shape() != current_shape) {
+ _shape_changed();
+ }
+ } break;
+
+ case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
+ if (EditorSettings::get_singleton()->check_changed_settings_in_group("editors/polygon_editor/point_grab_radius")) {
+ grab_threshold = EDITOR_GET("editors/polygon_editor/point_grab_radius");
+ }
+ } break;
}
}
@@ -569,36 +550,17 @@ void CollisionShape2DEditor::edit(Node *p_node) {
if (p_node) {
node = Object::cast_to<CollisionShape2D>(p_node);
-
- _get_current_shape_type();
-
+ set_process(true);
} else {
if (pressed) {
set_handle(edit_handle, original_point);
pressed = false;
}
-
edit_handle = -1;
- shape_type = -1;
-
node = nullptr;
+ set_process(false);
}
-
- canvas_item_editor->update_viewport();
-}
-
-void CollisionShape2DEditor::_bind_methods() {
- ClassDB::bind_method("_get_current_shape_type", &CollisionShape2DEditor::_get_current_shape_type);
-}
-
-CollisionShape2DEditor::CollisionShape2DEditor() {
- node = nullptr;
- canvas_item_editor = nullptr;
-
- edit_handle = -1;
- pressed = false;
-
- shape_type = 0;
+ _shape_changed();
}
void CollisionShape2DEditorPlugin::edit(Object *p_obj) {
diff --git a/editor/plugins/collision_shape_2d_editor_plugin.h b/editor/plugins/collision_shape_2d_editor_plugin.h
index 9c37b6cf9d..d58f5d511f 100644
--- a/editor/plugins/collision_shape_2d_editor_plugin.h
+++ b/editor/plugins/collision_shape_2d_editor_plugin.h
@@ -66,24 +66,26 @@ class CollisionShape2DEditor : public Control {
Vector<Point2> handles;
- int shape_type;
- int edit_handle;
- bool pressed;
+ int shape_type = -1;
+ int edit_handle = -1;
+ bool pressed = false;
+ real_t grab_threshold = 8;
Variant original;
Transform2D original_transform;
Vector2 original_point;
Point2 last_point;
+ Ref<Shape2D> current_shape;
+
Variant get_handle_value(int idx) const;
void set_handle(int idx, Point2 &p_point);
void commit_handle(int idx, Variant &p_org);
- void _get_current_shape_type();
+ void _shape_changed();
protected:
void _notification(int p_what);
void _node_removed(Node *p_node);
- static void _bind_methods();
public:
bool forward_canvas_gui_input(const Ref<InputEvent> &p_event);
diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp
index a7ec4bfe33..72cd1da9dd 100644
--- a/editor/plugins/curve_editor_plugin.cpp
+++ b/editor/plugins/curve_editor_plugin.cpp
@@ -39,6 +39,7 @@
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/editor_undo_redo_manager.h"
+#include "scene/gui/popup_menu.h"
CurveEditor::CurveEditor() {
_selected_point = -1;
@@ -48,6 +49,7 @@ CurveEditor::CurveEditor() {
_tangents_length = 40;
_dragging = false;
_has_undo_data = false;
+ _gizmo_handle_scale = EDITOR_GET("interface/touchscreen/scale_gizmo_handles");
set_focus_mode(FOCUS_ALL);
set_clip_contents(true);
@@ -104,6 +106,11 @@ void CurveEditor::_notification(int p_what) {
case NOTIFICATION_DRAW: {
_draw();
} break;
+ case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
+ if (EditorSettings::get_singleton()->check_changed_settings_in_group("interface/touchscreen/scale_gizmo_handles")) {
+ _gizmo_handle_scale = EDITOR_GET("interface/touchscreen/scale_gizmo_handles");
+ }
+ } break;
}
}
@@ -396,7 +403,7 @@ int CurveEditor::get_point_at(Vector2 pos) const {
}
const Curve &curve = **_curve_ref;
- const float true_hover_radius = Math::round(_hover_radius * EDSCALE);
+ const float true_hover_radius = Math::round(_hover_radius * _gizmo_handle_scale * EDSCALE);
const float r = true_hover_radius * true_hover_radius;
for (int i = 0; i < curve.get_point_count(); ++i) {
@@ -416,14 +423,14 @@ CurveEditor::TangentIndex CurveEditor::get_tangent_at(Vector2 pos) const {
if (_selected_point != 0) {
Vector2 control_pos = get_tangent_view_pos(_selected_point, TANGENT_LEFT);
- if (control_pos.distance_to(pos) < _hover_radius) {
+ if (control_pos.distance_to(pos) < _hover_radius * _gizmo_handle_scale) {
return TANGENT_LEFT;
}
}
if (_selected_point != _curve_ref->get_point_count() - 1) {
Vector2 control_pos = get_tangent_view_pos(_selected_point, TANGENT_RIGHT);
- if (control_pos.distance_to(pos) < _hover_radius) {
+ if (control_pos.distance_to(pos) < _hover_radius * _gizmo_handle_scale) {
return TANGENT_RIGHT;
}
}
@@ -561,7 +568,7 @@ Vector2 CurveEditor::get_tangent_view_pos(int i, TangentIndex tangent) const {
Vector2 point_pos = get_view_pos(_curve_ref->get_point_position(i));
Vector2 control_pos = get_view_pos(_curve_ref->get_point_position(i) + dir);
- return point_pos + Math::round(_tangents_length * EDSCALE) * (control_pos - point_pos).normalized();
+ return point_pos + Math::round(_tangents_length * _gizmo_handle_scale * EDSCALE) * (control_pos - point_pos).normalized();
}
Vector2 CurveEditor::get_view_pos(Vector2 world_pos) const {
@@ -706,13 +713,13 @@ void CurveEditor::_draw() {
if (i != 0) {
Vector2 control_pos = get_tangent_view_pos(i, TANGENT_LEFT);
draw_line(get_view_pos(pos), control_pos, tangent_color, Math::round(EDSCALE));
- draw_rect(Rect2(control_pos, Vector2(1, 1)).grow(Math::round(2 * EDSCALE)), tangent_color);
+ draw_rect(Rect2(control_pos, Vector2(1, 1)).grow(Math::round(2 * _gizmo_handle_scale * EDSCALE)), tangent_color);
}
if (i != curve.get_point_count() - 1) {
Vector2 control_pos = get_tangent_view_pos(i, TANGENT_RIGHT);
draw_line(get_view_pos(pos), control_pos, tangent_color, Math::round(EDSCALE));
- draw_rect(Rect2(control_pos, Vector2(1, 1)).grow(Math::round(2 * EDSCALE)), tangent_color);
+ draw_rect(Rect2(control_pos, Vector2(1, 1)).grow(Math::round(2 * _gizmo_handle_scale * EDSCALE)), tangent_color);
}
}
@@ -735,7 +742,7 @@ void CurveEditor::_draw() {
for (int i = 0; i < curve.get_point_count(); ++i) {
Vector2 pos = curve.get_point_position(i);
- draw_rect(Rect2(get_view_pos(pos), Vector2(1, 1)).grow(Math::round(3 * EDSCALE)), i == _selected_point ? selected_point_color : point_color);
+ draw_rect(Rect2(get_view_pos(pos), Vector2(1, 1)).grow(Math::round(3 * _gizmo_handle_scale * EDSCALE)), i == _selected_point ? selected_point_color : point_color);
// TODO Circles are prettier. Needs a fix! Or a texture
//draw_circle(pos, 2, point_color);
}
@@ -745,7 +752,7 @@ void CurveEditor::_draw() {
if (_hover_point != -1) {
const Color hover_color = line_color;
Vector2 pos = curve.get_point_position(_hover_point);
- draw_rect(Rect2(get_view_pos(pos), Vector2(1, 1)).grow(Math::round(_hover_radius * EDSCALE)), hover_color, false, Math::round(EDSCALE));
+ draw_rect(Rect2(get_view_pos(pos), Vector2(1, 1)).grow(Math::round(_hover_radius * _gizmo_handle_scale * EDSCALE)), hover_color, false, Math::round(EDSCALE));
}
// Help text
diff --git a/editor/plugins/curve_editor_plugin.h b/editor/plugins/curve_editor_plugin.h
index d5cc0cb66a..b0d666b847 100644
--- a/editor/plugins/curve_editor_plugin.h
+++ b/editor/plugins/curve_editor_plugin.h
@@ -36,6 +36,8 @@
#include "editor/editor_resource_preview.h"
#include "scene/resources/curve.h"
+class PopupMenu;
+
// Edits a y(x) curve
class CurveEditor : public Control {
GDCLASS(CurveEditor, Control);
@@ -115,6 +117,7 @@ private:
// Constant
float _hover_radius;
float _tangents_length;
+ float _gizmo_handle_scale = 1.0;
};
class EditorInspectorPluginCurve : public EditorInspectorPlugin {
diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp
index 328fe9b950..404711e074 100644
--- a/editor/plugins/material_editor_plugin.cpp
+++ b/editor/plugins/material_editor_plugin.cpp
@@ -42,6 +42,7 @@
#include "scene/gui/color_rect.h"
#include "scene/gui/subviewport_container.h"
#include "scene/gui/texture_button.h"
+#include "scene/main/viewport.h"
#include "scene/resources/fog_material.h"
#include "scene/resources/particle_process_material.h"
#include "scene/resources/sky_material.h"
@@ -163,9 +164,19 @@ void MaterialEditor::_button_pressed(Node *p_button) {
MaterialEditor::MaterialEditor() {
// canvas item
+ vc_2d = memnew(SubViewportContainer);
+ vc_2d->set_stretch(true);
+ add_child(vc_2d);
+ vc_2d->set_anchors_and_offsets_preset(PRESET_FULL_RECT);
+
+ viewport_2d = memnew(SubViewport);
+ vc_2d->add_child(viewport_2d);
+ viewport_2d->set_disable_input(true);
+ viewport_2d->set_transparent_background(true);
+
layout_2d = memnew(HBoxContainer);
layout_2d->set_alignment(BoxContainer::ALIGNMENT_CENTER);
- add_child(layout_2d);
+ viewport_2d->add_child(layout_2d);
layout_2d->set_anchors_and_offsets_preset(PRESET_FULL_RECT);
rect_instance = memnew(ColorRect);
diff --git a/editor/plugins/material_editor_plugin.h b/editor/plugins/material_editor_plugin.h
index deb1211c54..ac81bdc7c7 100644
--- a/editor/plugins/material_editor_plugin.h
+++ b/editor/plugins/material_editor_plugin.h
@@ -51,6 +51,8 @@ class MaterialEditor : public Control {
Vector2 rot;
+ SubViewportContainer *vc_2d = nullptr;
+ SubViewport *viewport_2d = nullptr;
HBoxContainer *layout_2d = nullptr;
ColorRect *rect_instance = nullptr;
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index 00382e1a18..a726ab09d5 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -40,6 +40,7 @@
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "editor/editor_undo_redo_manager.h"
+#include "editor/gui/editor_run_bar.h"
#include "editor/gui/editor_spin_slider.h"
#include "editor/plugins/animation_player_editor_plugin.h"
#include "editor/plugins/gizmos/audio_listener_3d_gizmo_plugin.h"
@@ -7518,8 +7519,8 @@ void Node3DEditor::_notification(int p_what) {
SceneTreeDock::get_singleton()->get_tree_editor()->connect("node_changed", callable_mp(this, &Node3DEditor::_refresh_menu_icons));
editor_selection->connect("selection_changed", callable_mp(this, &Node3DEditor::_selection_changed));
- EditorNode::get_singleton()->connect("stop_pressed", callable_mp(this, &Node3DEditor::_update_camera_override_button).bind(false));
- EditorNode::get_singleton()->connect("play_pressed", callable_mp(this, &Node3DEditor::_update_camera_override_button).bind(true));
+ EditorRunBar::get_singleton()->connect("stop_pressed", callable_mp(this, &Node3DEditor::_update_camera_override_button).bind(false));
+ EditorRunBar::get_singleton()->connect("play_pressed", callable_mp(this, &Node3DEditor::_update_camera_override_button).bind(true));
_update_preview_environment();
@@ -8577,9 +8578,11 @@ void fragment() {
sun_color->get_popup()->connect("about_to_popup", callable_mp(EditorNode::get_singleton(), &EditorNode::setup_color_picker).bind(sun_color->get_picker()));
sun_energy = memnew(EditorSpinSlider);
+ sun_energy->set_max(64.0);
+ sun_energy->set_min(0);
+ sun_energy->set_step(0.05);
sun_vb->add_margin_child(TTR("Sun Energy"), sun_energy);
sun_energy->connect("value_changed", callable_mp(this, &Node3DEditor::_preview_settings_changed).unbind(1));
- sun_energy->set_max(64.0);
sun_max_distance = memnew(EditorSpinSlider);
sun_vb->add_margin_child(TTR("Shadow Max Distance"), sun_max_distance);
@@ -8628,8 +8631,10 @@ void fragment() {
environ_ground_color->get_popup()->connect("about_to_popup", callable_mp(EditorNode::get_singleton(), &EditorNode::setup_color_picker).bind(environ_ground_color->get_picker()));
environ_vb->add_margin_child(TTR("Ground Color"), environ_ground_color);
environ_energy = memnew(EditorSpinSlider);
- environ_energy->connect("value_changed", callable_mp(this, &Node3DEditor::_preview_settings_changed).unbind(1));
environ_energy->set_max(8.0);
+ environ_energy->set_min(0);
+ environ_energy->set_step(0.05);
+ environ_energy->connect("value_changed", callable_mp(this, &Node3DEditor::_preview_settings_changed).unbind(1));
environ_vb->add_margin_child(TTR("Sky Energy"), environ_energy);
HBoxContainer *fx_vb = memnew(HBoxContainer);
fx_vb->set_h_size_flags(SIZE_EXPAND_FILL);
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 736826c231..c605844728 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -43,12 +43,13 @@
#include "editor/editor_help_search.h"
#include "editor/editor_node.h"
#include "editor/editor_paths.h"
-#include "editor/editor_run_script.h"
#include "editor/editor_scale.h"
+#include "editor/editor_script.h"
#include "editor/editor_settings.h"
#include "editor/filesystem_dock.h"
#include "editor/find_in_files.h"
#include "editor/gui/editor_file_dialog.h"
+#include "editor/gui/editor_run_bar.h"
#include "editor/inspector_dock.h"
#include "editor/node_dock.h"
#include "editor/plugins/shader_editor_plugin.h"
@@ -943,11 +944,7 @@ void ScriptEditor::_resave_scripts(const String &p_str) {
se->insert_final_newline();
if (convert_indent_on_save) {
- if (use_space_indentation) {
- se->convert_indent_to_spaces();
- } else {
- se->convert_indent_to_tabs();
- }
+ se->convert_indent();
}
Ref<TextFile> text_file = scr;
@@ -1298,11 +1295,7 @@ void ScriptEditor::_menu_option(int p_option) {
current->insert_final_newline();
if (convert_indent_on_save) {
- if (use_space_indentation) {
- current->convert_indent_to_spaces();
- } else {
- current->convert_indent_to_tabs();
- }
+ current->convert_indent();
}
Ref<Resource> resource = current->get_edited_resource();
@@ -1375,9 +1368,7 @@ void ScriptEditor::_menu_option(int p_option) {
Ref<EditorScript> es = memnew(EditorScript);
es->set_script(scr);
- es->set_editor(EditorNode::get_singleton());
-
- es->_run();
+ es->run();
} break;
case FILE_CLOSE: {
if (current->is_unsaved()) {
@@ -1592,7 +1583,7 @@ void ScriptEditor::_tab_changed(int p_which) {
void ScriptEditor::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- EditorNode::get_singleton()->connect("stop_pressed", callable_mp(this, &ScriptEditor::_editor_stop));
+ EditorRunBar::get_singleton()->connect("stop_pressed", callable_mp(this, &ScriptEditor::_editor_stop));
EditorNode::get_singleton()->connect("script_add_function_request", callable_mp(this, &ScriptEditor::_add_callback));
EditorNode::get_singleton()->connect("resource_saved", callable_mp(this, &ScriptEditor::_res_saved_callback));
EditorNode::get_singleton()->connect("scene_saved", callable_mp(this, &ScriptEditor::_scene_saved_callback));
@@ -1643,10 +1634,11 @@ void ScriptEditor::_notification(int p_what) {
get_tree()->connect("tree_changed", callable_mp(this, &ScriptEditor::_tree_changed));
InspectorDock::get_singleton()->connect("request_help", callable_mp(this, &ScriptEditor::_help_class_open));
EditorNode::get_singleton()->connect("request_help_search", callable_mp(this, &ScriptEditor::_help_search));
+ EditorNode::get_singleton()->connect("scene_closed", callable_mp(this, &ScriptEditor::_close_builtin_scripts_from_scene));
} break;
case NOTIFICATION_EXIT_TREE: {
- EditorNode::get_singleton()->disconnect("stop_pressed", callable_mp(this, &ScriptEditor::_editor_stop));
+ EditorRunBar::get_singleton()->disconnect("stop_pressed", callable_mp(this, &ScriptEditor::_editor_stop));
} break;
case NOTIFICATION_APPLICATION_FOCUS_IN: {
@@ -1677,7 +1669,7 @@ bool ScriptEditor::can_take_away_focus() const {
}
}
-void ScriptEditor::close_builtin_scripts_from_scene(const String &p_scene) {
+void ScriptEditor::_close_builtin_scripts_from_scene(const String &p_scene) {
for (int i = 0; i < tab_container->get_tab_count(); i++) {
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i));
@@ -1687,7 +1679,7 @@ void ScriptEditor::close_builtin_scripts_from_scene(const String &p_scene) {
continue;
}
- if (scr->is_built_in() && scr->get_path().begins_with(p_scene)) { //is an internal script and belongs to scene being closed
+ if (scr->is_built_in() && scr->get_path().begins_with(p_scene)) { // Is an internal script and belongs to scene being closed.
_close_tab(i, false);
i--;
}
@@ -2451,11 +2443,7 @@ void ScriptEditor::save_current_script() {
current->insert_final_newline();
if (convert_indent_on_save) {
- if (use_space_indentation) {
- current->convert_indent_to_spaces();
- } else {
- current->convert_indent_to_tabs();
- }
+ current->convert_indent();
}
Ref<Resource> resource = current->get_edited_resource();
@@ -2499,11 +2487,7 @@ void ScriptEditor::save_all_scripts() {
}
if (convert_indent_on_save) {
- if (use_space_indentation) {
- se->convert_indent_to_spaces();
- } else {
- se->convert_indent_to_tabs();
- }
+ se->convert_indent();
}
if (trim_trailing_whitespace_on_save) {
@@ -2730,7 +2714,6 @@ void ScriptEditor::_editor_settings_changed() {
trim_trailing_whitespace_on_save = EDITOR_GET("text_editor/behavior/files/trim_trailing_whitespace_on_save");
convert_indent_on_save = EDITOR_GET("text_editor/behavior/files/convert_indent_on_save");
- use_space_indentation = EDITOR_GET("text_editor/behavior/indent/type");
members_overview_enabled = EDITOR_GET("text_editor/script_list/show_members_overview");
help_overview_enabled = EDITOR_GET("text_editor/help/show_help_index");
@@ -3317,7 +3300,7 @@ void ScriptEditor::_help_class_open(const String &p_class) {
eh->set_name(p_class);
tab_container->add_child(eh);
_go_to_tab(tab_container->get_tab_count() - 1);
- eh->go_to_class(p_class, 0);
+ eh->go_to_class(p_class);
eh->connect("go_to_help", callable_mp(this, &ScriptEditor::_help_class_goto));
_add_recent_script(p_class);
_sort_list_on_update = true;
@@ -4081,7 +4064,6 @@ ScriptEditor::ScriptEditor() {
edit_pass = 0;
trim_trailing_whitespace_on_save = EDITOR_GET("text_editor/behavior/files/trim_trailing_whitespace_on_save");
convert_indent_on_save = EDITOR_GET("text_editor/behavior/files/convert_indent_on_save");
- use_space_indentation = EDITOR_GET("text_editor/behavior/indent/type");
ScriptServer::edit_request_func = _open_script_request;
diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h
index 7d2f5ad22a..5cbe56b68b 100644
--- a/editor/plugins/script_editor_plugin.h
+++ b/editor/plugins/script_editor_plugin.h
@@ -169,8 +169,7 @@ public:
virtual void clear_executing_line() = 0;
virtual void trim_trailing_whitespace() = 0;
virtual void insert_final_newline() = 0;
- virtual void convert_indent_to_spaces() = 0;
- virtual void convert_indent_to_tabs() = 0;
+ virtual void convert_indent() = 0;
virtual void ensure_focus() = 0;
virtual void tag_saved_version() = 0;
virtual void reload(bool p_soft) {}
@@ -390,7 +389,6 @@ class ScriptEditor : public PanelContainer {
bool open_textfile_after_create = true;
bool trim_trailing_whitespace_on_save;
- bool use_space_indentation;
bool convert_indent_on_save;
void _goto_script_line2(int p_line);
@@ -482,6 +480,7 @@ class ScriptEditor : public PanelContainer {
void _on_find_in_files_modified_files(PackedStringArray paths);
static void _open_script_request(const String &p_path);
+ void _close_builtin_scripts_from_scene(const String &p_scene);
static ScriptEditor *script_editor;
@@ -523,8 +522,6 @@ public:
void notify_script_close(const Ref<Script> &p_script);
void notify_script_changed(const Ref<Script> &p_script);
- void close_builtin_scripts_from_scene(const String &p_scene);
-
void goto_help(const String &p_desc) { _help_class_goto(p_desc); }
void update_doc(const String &p_name);
void clear_docs_from_script(const Ref<Script> &p_script);
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 837645310a..978f1f56a5 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -38,6 +38,7 @@
#include "editor/editor_node.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
+#include "scene/gui/rich_text_label.h"
#include "scene/gui/split_container.h"
void ConnectionInfoDialog::ok_pressed() {
@@ -377,12 +378,8 @@ void ScriptTextEditor::insert_final_newline() {
code_editor->insert_final_newline();
}
-void ScriptTextEditor::convert_indent_to_spaces() {
- code_editor->convert_indent_to_spaces();
-}
-
-void ScriptTextEditor::convert_indent_to_tabs() {
- code_editor->convert_indent_to_tabs();
+void ScriptTextEditor::convert_indent() {
+ code_editor->get_text_editor()->convert_indent();
}
void ScriptTextEditor::tag_saved_version() {
@@ -1281,10 +1278,12 @@ void ScriptTextEditor::_edit_option(int p_op) {
trim_trailing_whitespace();
} break;
case EDIT_CONVERT_INDENT_TO_SPACES: {
- convert_indent_to_spaces();
+ tx->set_indent_using_spaces(true);
+ convert_indent();
} break;
case EDIT_CONVERT_INDENT_TO_TABS: {
- convert_indent_to_tabs();
+ tx->set_indent_using_spaces(false);
+ convert_indent();
} break;
case EDIT_PICK_COLOR: {
color_panel->popup();
@@ -1804,20 +1803,26 @@ void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
int col = pos.x;
tx->set_move_caret_on_right_click_enabled(EDITOR_GET("text_editor/behavior/navigation/move_caret_on_right_click"));
+ int caret_clicked = -1;
if (tx->is_move_caret_on_right_click_enabled()) {
- tx->remove_secondary_carets();
if (tx->has_selection()) {
- int from_line = tx->get_selection_from_line();
- int to_line = tx->get_selection_to_line();
- int from_column = tx->get_selection_from_column();
- int to_column = tx->get_selection_to_column();
-
- if (row < from_line || row > to_line || (row == from_line && col < from_column) || (row == to_line && col > to_column)) {
- // Right click is outside the selected text
- tx->deselect();
+ for (int i = 0; i < tx->get_caret_count(); i++) {
+ int from_line = tx->get_selection_from_line(i);
+ int to_line = tx->get_selection_to_line(i);
+ int from_column = tx->get_selection_from_column(i);
+ int to_column = tx->get_selection_to_column(i);
+
+ if (row >= from_line && row <= to_line && (row != from_line || col >= from_column) && (row != to_line || col <= to_column)) {
+ // Right click in one of the selected text
+ caret_clicked = i;
+ break;
+ }
}
}
- if (!tx->has_selection()) {
+ if (!caret_clicked) {
+ tx->deselect();
+ tx->remove_secondary_carets();
+ caret_clicked = 0;
tx->set_caret_line(row, false, false);
tx->set_caret_column(col);
}
@@ -1825,10 +1830,10 @@ void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
String word_at_pos = tx->get_word_at_pos(local_pos);
if (word_at_pos.is_empty()) {
- word_at_pos = tx->get_word_under_caret(0);
+ word_at_pos = tx->get_word_under_caret(caret_clicked);
}
if (word_at_pos.is_empty()) {
- word_at_pos = tx->get_selected_text(0);
+ word_at_pos = tx->get_selected_text(caret_clicked);
}
bool has_color = (word_at_pos == "Color");
diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h
index 1b986401c2..5e167af51a 100644
--- a/editor/plugins/script_text_editor.h
+++ b/editor/plugins/script_text_editor.h
@@ -222,8 +222,7 @@ public:
virtual void ensure_focus() override;
virtual void trim_trailing_whitespace() override;
virtual void insert_final_newline() override;
- virtual void convert_indent_to_spaces() override;
- virtual void convert_indent_to_tabs() override;
+ virtual void convert_indent() override;
virtual void tag_saved_version() override;
virtual void goto_line(int p_line, bool p_with_error = false) override;
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index 49459a0ba0..5cb014e5c7 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -236,6 +236,26 @@ void ShaderEditorPlugin::_close_shader(int p_index) {
EditorUndoRedoManager::get_singleton()->clear_history(); // To prevent undo on deleted graphs.
}
+void ShaderEditorPlugin::_close_builtin_shaders_from_scene(const String &p_scene) {
+ for (uint32_t i = 0; i < edited_shaders.size();) {
+ Ref<Shader> &shader = edited_shaders[i].shader;
+ if (shader.is_valid()) {
+ if (shader->is_built_in() && shader->get_path().begins_with(p_scene)) {
+ _close_shader(i);
+ continue;
+ }
+ }
+ Ref<ShaderInclude> &include = edited_shaders[i].shader_inc;
+ if (include.is_valid()) {
+ if (include->is_built_in() && include->get_path().begins_with(p_scene)) {
+ _close_shader(i);
+ continue;
+ }
+ }
+ i++;
+ }
+}
+
void ShaderEditorPlugin::_resource_saved(Object *obj) {
// May have been renamed on save.
for (EditedShader &edited_shader : edited_shaders) {
@@ -430,6 +450,14 @@ void ShaderEditorPlugin::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
}
+void ShaderEditorPlugin::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_READY: {
+ EditorNode::get_singleton()->connect("scene_closed", callable_mp(this, &ShaderEditorPlugin::_close_builtin_shaders_from_scene));
+ } break;
+ }
+}
+
ShaderEditorPlugin::ShaderEditorPlugin() {
main_split = memnew(HSplitContainer);
diff --git a/editor/plugins/shader_editor_plugin.h b/editor/plugins/shader_editor_plugin.h
index 408d08ade0..299d5975d2 100644
--- a/editor/plugins/shader_editor_plugin.h
+++ b/editor/plugins/shader_editor_plugin.h
@@ -82,6 +82,7 @@ class ShaderEditorPlugin : public EditorPlugin {
void _menu_item_pressed(int p_index);
void _resource_saved(Object *obj);
void _close_shader(int p_index);
+ void _close_builtin_shaders_from_scene(const String &p_scene);
void _shader_created(Ref<Shader> p_shader);
void _shader_include_created(Ref<ShaderInclude> p_shader_inc);
@@ -92,6 +93,9 @@ class ShaderEditorPlugin : public EditorPlugin {
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);
+protected:
+ void _notification(int p_what);
+
public:
virtual String get_name() const override { return "Shader"; }
virtual void edit(Object *p_object) override;
diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp
index 174588b92e..7a76e4f989 100644
--- a/editor/plugins/text_editor.cpp
+++ b/editor/plugins/text_editor.cpp
@@ -288,12 +288,8 @@ void TextEditor::insert_final_newline() {
code_editor->insert_final_newline();
}
-void TextEditor::convert_indent_to_spaces() {
- code_editor->convert_indent_to_spaces();
-}
-
-void TextEditor::convert_indent_to_tabs() {
- code_editor->convert_indent_to_tabs();
+void TextEditor::convert_indent() {
+ code_editor->get_text_editor()->convert_indent();
}
void TextEditor::tag_saved_version() {
@@ -419,10 +415,12 @@ void TextEditor::_edit_option(int p_op) {
trim_trailing_whitespace();
} break;
case EDIT_CONVERT_INDENT_TO_SPACES: {
- convert_indent_to_spaces();
+ tx->set_indent_using_spaces(true);
+ convert_indent();
} break;
case EDIT_CONVERT_INDENT_TO_TABS: {
- convert_indent_to_tabs();
+ tx->set_indent_using_spaces(false);
+ convert_indent();
} break;
case EDIT_TO_UPPERCASE: {
_convert_case(CodeTextEditor::UPPER);
diff --git a/editor/plugins/text_editor.h b/editor/plugins/text_editor.h
index d9f5222e90..0c218e9e0c 100644
--- a/editor/plugins/text_editor.h
+++ b/editor/plugins/text_editor.h
@@ -131,8 +131,7 @@ public:
virtual void clear_executing_line() override;
virtual void trim_trailing_whitespace() override;
virtual void insert_final_newline() override;
- virtual void convert_indent_to_spaces() override;
- virtual void convert_indent_to_tabs() override;
+ virtual void convert_indent() override;
virtual void ensure_focus() override;
virtual void tag_saved_version() override;
virtual void update_settings() override;
diff --git a/editor/plugins/tiles/tile_data_editors.cpp b/editor/plugins/tiles/tile_data_editors.cpp
index 8327fa5762..ef805e6524 100644
--- a/editor/plugins/tiles/tile_data_editors.cpp
+++ b/editor/plugins/tiles/tile_data_editors.cpp
@@ -41,9 +41,12 @@
#include "editor/editor_settings.h"
#include "editor/editor_undo_redo_manager.h"
+#include "scene/gui/control.h"
+#include "scene/gui/label.h"
#include "scene/gui/menu_button.h"
#include "scene/gui/option_button.h"
#include "scene/gui/separator.h"
+#include "scene/gui/spin_box.h"
#ifdef DEBUG_ENABLED
#include "servers/navigation_server_3d.h"
@@ -168,6 +171,17 @@ void GenericTilePolygonEditor::_base_control_draw() {
base_control->draw_texture_rect_region(background_texture, Rect2(-background_region.size / 2 - background_offset, region_size), background_region, background_modulate, background_transpose);
}
+ // Draw grid.
+ if (current_snap_option == SNAP_GRID) {
+ Vector2 spacing = tile_size / snap_subdivision->get_value();
+ Vector2 offset = -tile_size / 2;
+
+ for (int i = 1; i < snap_subdivision->get_value(); i++) {
+ base_control->draw_line(Vector2(spacing.x * i, 0) + offset, Vector2(spacing.x * i, tile_size.y) + offset, Color(1, 1, 1, 0.33));
+ base_control->draw_line(Vector2(0, spacing.y * i) + offset, Vector2(tile_size.x, spacing.y * i) + offset, Color(1, 1, 1, 0.33));
+ }
+ }
+
// Draw the polygons.
for (const Vector<Vector2> &polygon : polygons) {
Color color = polygon_color;
@@ -195,9 +209,7 @@ void GenericTilePolygonEditor::_base_control_draw() {
Point2 in_creation_point = xform.affine_inverse().xform(base_control->get_local_mouse_position());
float in_creation_distance = grab_threshold * 2.0;
_snap_to_tile_shape(in_creation_point, in_creation_distance, grab_threshold / editor_zoom_widget->get_zoom());
- if (button_pixel_snap->is_pressed()) {
- _snap_to_half_pixel(in_creation_point);
- }
+ _snap_point(in_creation_point);
if (drag_type == DRAG_TYPE_CREATE_POINT && !in_creation_polygon.is_empty()) {
base_control->draw_line(in_creation_polygon[in_creation_polygon.size() - 1], in_creation_point, Color(1.0, 1.0, 1.0));
@@ -443,8 +455,20 @@ void GenericTilePolygonEditor::_snap_to_tile_shape(Point2 &r_point, float &r_cur
r_point = snapped_point;
}
-void GenericTilePolygonEditor::_snap_to_half_pixel(Point2 &r_point) {
- r_point = (r_point * 2).round() / 2.0;
+void GenericTilePolygonEditor::_snap_point(Point2 &r_point) {
+ switch (current_snap_option) {
+ case SNAP_NONE:
+ break;
+
+ case SNAP_HALF_PIXEL:
+ r_point = r_point.snapped(Vector2(0.5, 0.5));
+ break;
+
+ case SNAP_GRID: {
+ const Vector2 tile_size = tile_set->get_tile_size();
+ r_point = (r_point + tile_size / 2).snapped(tile_size / snap_subdivision->get_value()) - tile_size / 2;
+ } break;
+ }
}
void GenericTilePolygonEditor::_base_control_gui_input(Ref<InputEvent> p_event) {
@@ -475,9 +499,7 @@ void GenericTilePolygonEditor::_base_control_gui_input(Ref<InputEvent> p_event)
Point2 point = xform.affine_inverse().xform(mm->get_position());
float distance = grab_threshold * 2.0;
_snap_to_tile_shape(point, distance, grab_threshold / editor_zoom_widget->get_zoom());
- if (button_pixel_snap->is_pressed()) {
- _snap_to_half_pixel(point);
- }
+ _snap_point(point);
polygons[drag_polygon_index].write[drag_point_index] = point;
} else if (drag_type == DRAG_TYPE_PAN) {
panning += mm->get_position() - drag_last_pos;
@@ -592,9 +614,7 @@ void GenericTilePolygonEditor::_base_control_gui_input(Ref<InputEvent> p_event)
Point2 point = xform.affine_inverse().xform(mb->get_position());
float distance = grab_threshold * 2;
_snap_to_tile_shape(point, distance, grab_threshold / editor_zoom_widget->get_zoom());
- if (button_pixel_snap->is_pressed()) {
- _snap_to_half_pixel(point);
- }
+ _snap_point(point);
in_creation_polygon.push_back(point);
}
drag_type = DRAG_TYPE_NONE;
@@ -652,6 +672,19 @@ void GenericTilePolygonEditor::_base_control_gui_input(Ref<InputEvent> p_event)
}
}
+void GenericTilePolygonEditor::_set_snap_option(int p_index) {
+ current_snap_option = p_index;
+ button_pixel_snap->set_icon(button_pixel_snap->get_popup()->get_item_icon(p_index));
+ snap_subdivision->set_visible(p_index == SNAP_GRID);
+ base_control->queue_redraw();
+ _store_snap_options();
+}
+
+void GenericTilePolygonEditor::_store_snap_options() {
+ EditorSettings::get_singleton()->set_project_metadata("editor_metadata", "tile_snap_option", current_snap_option);
+ EditorSettings::get_singleton()->set_project_metadata("editor_metadata", "tile_snap_subdiv", snap_subdivision->get_value());
+}
+
void GenericTilePolygonEditor::set_use_undo_redo(bool p_use_undo_redo) {
use_undo_redo = p_use_undo_redo;
}
@@ -766,8 +799,11 @@ void GenericTilePolygonEditor::_notification(int p_what) {
button_edit->set_icon(get_theme_icon(SNAME("CurveEdit"), SNAME("EditorIcons")));
button_delete->set_icon(get_theme_icon(SNAME("CurveDelete"), SNAME("EditorIcons")));
button_center_view->set_icon(get_theme_icon(SNAME("CenterView"), SNAME("EditorIcons")));
- button_pixel_snap->set_icon(get_theme_icon(SNAME("Snap"), SNAME("EditorIcons")));
button_advanced_menu->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons")));
+ button_pixel_snap->get_popup()->set_item_icon(0, get_theme_icon(SNAME("SnapDisable"), SNAME("EditorIcons")));
+ button_pixel_snap->get_popup()->set_item_icon(1, get_theme_icon(SNAME("Snap"), SNAME("EditorIcons")));
+ button_pixel_snap->get_popup()->set_item_icon(2, get_theme_icon(SNAME("SnapGrid"), SNAME("EditorIcons")));
+ button_pixel_snap->set_icon(button_pixel_snap->get_popup()->get_item_icon(current_snap_option));
PopupMenu *p = button_advanced_menu->get_popup();
p->set_item_icon(p->get_item_index(ROTATE_RIGHT), get_theme_icon(SNAME("RotateRight"), SNAME("EditorIcons")));
@@ -833,12 +869,20 @@ GenericTilePolygonEditor::GenericTilePolygonEditor() {
toolbar->add_child(memnew(VSeparator));
- button_pixel_snap = memnew(Button);
- button_pixel_snap->set_flat(true);
- button_pixel_snap->set_toggle_mode(true);
- button_pixel_snap->set_pressed(true);
- button_pixel_snap->set_tooltip_text(TTR("Snap to half-pixel"));
+ button_pixel_snap = memnew(MenuButton);
toolbar->add_child(button_pixel_snap);
+ button_pixel_snap->set_flat(true);
+ button_pixel_snap->set_tooltip_text(TTR("Toggle Grid Snap"));
+ button_pixel_snap->get_popup()->add_item(TTR("Disable Snap"), SNAP_NONE);
+ button_pixel_snap->get_popup()->add_item(TTR("Half-Pixel Snap"), SNAP_HALF_PIXEL);
+ button_pixel_snap->get_popup()->add_item(TTR("Grid Snap"), SNAP_GRID);
+ button_pixel_snap->get_popup()->connect("index_pressed", callable_mp(this, &GenericTilePolygonEditor::_set_snap_option));
+
+ snap_subdivision = memnew(SpinBox);
+ toolbar->add_child(snap_subdivision);
+ snap_subdivision->get_line_edit()->add_theme_constant_override("minimum_character_width", 2);
+ snap_subdivision->set_min(1);
+ snap_subdivision->set_max(99);
Control *root = memnew(Control);
root->set_h_size_flags(Control::SIZE_EXPAND_FILL);
@@ -859,6 +903,8 @@ GenericTilePolygonEditor::GenericTilePolygonEditor() {
base_control->set_clip_contents(true);
base_control->set_focus_mode(Control::FOCUS_CLICK);
root->add_child(base_control);
+ snap_subdivision->connect("value_changed", callable_mp((CanvasItem *)base_control, &CanvasItem::queue_redraw).unbind(1));
+ snap_subdivision->connect("value_changed", callable_mp(this, &GenericTilePolygonEditor::_store_snap_options).unbind(1));
editor_zoom_widget = memnew(EditorZoomWidget);
editor_zoom_widget->set_position(Vector2(5, 5));
@@ -873,6 +919,9 @@ GenericTilePolygonEditor::GenericTilePolygonEditor() {
button_center_view->set_flat(true);
button_center_view->set_disabled(true);
root->add_child(button_center_view);
+
+ snap_subdivision->set_value_no_signal(EditorSettings::get_singleton()->get_project_metadata("editor_metadata", "tile_snap_subdiv", 4));
+ _set_snap_option(EditorSettings::get_singleton()->get_project_metadata("editor_metadata", "tile_snap_option", SNAP_NONE));
}
void TileDataDefaultEditor::_property_value_changed(StringName p_property, Variant p_value, StringName p_field) {
diff --git a/editor/plugins/tiles/tile_data_editors.h b/editor/plugins/tiles/tile_data_editors.h
index 1ebf30aecd..b3ecdb8cfb 100644
--- a/editor/plugins/tiles/tile_data_editors.h
+++ b/editor/plugins/tiles/tile_data_editors.h
@@ -36,10 +36,10 @@
#include "editor/editor_properties.h"
#include "scene/2d/tile_map.h"
#include "scene/gui/box_container.h"
-#include "scene/gui/control.h"
-#include "scene/gui/label.h"
class MenuButton;
+class SpinBox;
+class Label;
class EditorUndoRedoManager;
class TileDataEditor : public VBoxContainer {
@@ -120,9 +120,17 @@ private:
Button *button_create = nullptr;
Button *button_edit = nullptr;
Button *button_delete = nullptr;
- Button *button_pixel_snap = nullptr;
MenuButton *button_advanced_menu = nullptr;
+ enum Snap {
+ SNAP_NONE,
+ SNAP_HALF_PIXEL,
+ SNAP_GRID,
+ };
+ int current_snap_option = SNAP_HALF_PIXEL;
+ MenuButton *button_pixel_snap = nullptr;
+ SpinBox *snap_subdivision = nullptr;
+
Vector<Point2> in_creation_polygon;
Panel *panel = nullptr;
@@ -155,9 +163,11 @@ private:
void _advanced_menu_item_pressed(int p_item_pressed);
void _center_view();
void _base_control_gui_input(Ref<InputEvent> p_event);
+ void _set_snap_option(int p_index);
+ void _store_snap_options();
void _snap_to_tile_shape(Point2 &r_point, float &r_current_snapped_dist, float p_snap_dist);
- void _snap_to_half_pixel(Point2 &r_point);
+ void _snap_point(Point2 &r_point);
void _grab_polygon_point(Vector2 p_pos, const Transform2D &p_polygon_xform, int &r_polygon_index, int &r_point_index);
void _grab_polygon_segment_point(Vector2 p_pos, const Transform2D &p_polygon_xform, int &r_polygon_index, int &r_segment_index, Vector2 &r_point);
diff --git a/editor/plugins/tiles/tile_map_editor.cpp b/editor/plugins/tiles/tile_map_editor.cpp
index 55b5abf983..0a8ccdba1a 100644
--- a/editor/plugins/tiles/tile_map_editor.cpp
+++ b/editor/plugins/tiles/tile_map_editor.cpp
@@ -938,6 +938,20 @@ void TileMapEditorTilesPlugin::forward_canvas_draw_over_viewport(Control *p_over
}
}
}
+
+ Ref<Font> font = p_overlay->get_theme_font(SNAME("font"), SNAME("Label"));
+ int font_size = p_overlay->get_theme_font_size(SNAME("font_size"), SNAME("Label"));
+ Point2 msgpos = Point2(20 * EDSCALE, p_overlay->get_size().y - 20 * EDSCALE);
+
+ String text = tile_map->local_to_map(tile_map->get_local_mouse_position());
+ if (drag_type == DRAG_TYPE_RECT) {
+ Vector2i size = tile_map->local_to_map(tile_map->get_local_mouse_position()) - tile_map->local_to_map(drag_start_mouse_pos);
+ text += vformat(" %s (%dx%d)", TTR("Drawing Rect:"), ABS(size.x) + 1, ABS(size.y) + 1);
+ }
+
+ p_overlay->draw_string(font, msgpos + Point2(1, 1), text, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, Color(0, 0, 0, 0.8));
+ p_overlay->draw_string(font, msgpos + Point2(-1, -1), text, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, Color(0, 0, 0, 0.8));
+ p_overlay->draw_string(font, msgpos, text, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, Color(1, 1, 1, 1));
}
}
diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
index 42c296e825..a8c3b8e8d5 100644
--- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
+++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
@@ -34,7 +34,6 @@
#include "editor/editor_inspector.h"
#include "editor/editor_node.h"
-#include "editor/editor_property_name_processor.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/editor_undo_redo_manager.h"
@@ -2415,14 +2414,6 @@ void TileSetAtlasSourceEditor::_notification(int p_what) {
}
}
} break;
-
- case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
- if (EditorSettings::get_singleton()->check_changed_settings_in_group("interface/editor/localize_settings")) {
- EditorPropertyNameProcessor::Style style = EditorPropertyNameProcessor::get_singleton()->get_settings_style();
- atlas_source_inspector->set_property_name_style(style);
- tile_inspector->set_property_name_style(style);
- }
- } break;
}
}
@@ -2492,7 +2483,6 @@ TileSetAtlasSourceEditor::TileSetAtlasSourceEditor() {
tile_inspector->edit(tile_proxy_object);
tile_inspector->set_use_folding(true);
tile_inspector->connect("property_selected", callable_mp(this, &TileSetAtlasSourceEditor::_inspector_property_selected));
- tile_inspector->set_property_name_style(EditorPropertyNameProcessor::get_singleton()->get_settings_style());
middle_vbox_container->add_child(tile_inspector);
tile_inspector_no_tile_selected_label = memnew(Label);
@@ -2544,7 +2534,6 @@ TileSetAtlasSourceEditor::TileSetAtlasSourceEditor() {
atlas_source_inspector->set_v_size_flags(SIZE_EXPAND_FILL);
atlas_source_inspector->set_show_categories(true);
atlas_source_inspector->edit(atlas_source_proxy_object);
- atlas_source_inspector->set_property_name_style(EditorPropertyNameProcessor::get_singleton()->get_settings_style());
middle_vbox_container->add_child(atlas_source_inspector);
// -- Right side --
diff --git a/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp b/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp
index 9350467176..6908dd7c3b 100644
--- a/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp
+++ b/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp
@@ -32,7 +32,6 @@
#include "editor/editor_file_system.h"
#include "editor/editor_node.h"
-#include "editor/editor_property_name_processor.h"
#include "editor/editor_resource_preview.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
@@ -365,14 +364,6 @@ void TileSetScenesCollectionSourceEditor::_notification(int p_what) {
_update_scenes_list();
_update_action_buttons();
} break;
-
- case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
- if (EditorSettings::get_singleton()->check_changed_settings_in_group("interface/editor/localize_settings")) {
- EditorPropertyNameProcessor::Style style = EditorPropertyNameProcessor::get_singleton()->get_settings_style();
- scenes_collection_source_inspector->set_property_name_style(style);
- tile_inspector->set_property_name_style(style);
- }
- } break;
}
}
@@ -514,7 +505,6 @@ TileSetScenesCollectionSourceEditor::TileSetScenesCollectionSourceEditor() {
scenes_collection_source_inspector = memnew(EditorInspector);
scenes_collection_source_inspector->set_vertical_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED);
scenes_collection_source_inspector->edit(scenes_collection_source_proxy_object);
- scenes_collection_source_inspector->set_property_name_style(EditorPropertyNameProcessor::get_singleton()->get_settings_style());
middle_vbox_container->add_child(scenes_collection_source_inspector);
// Tile inspector.
@@ -531,7 +521,6 @@ TileSetScenesCollectionSourceEditor::TileSetScenesCollectionSourceEditor() {
tile_inspector->set_vertical_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED);
tile_inspector->edit(tile_proxy_object);
tile_inspector->set_use_folding(true);
- tile_inspector->set_property_name_style(EditorPropertyNameProcessor::get_singleton()->get_settings_style());
middle_vbox_container->add_child(tile_inspector);
// Scenes list.
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index b74324ff29..754533ab31 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -1209,13 +1209,19 @@ void VisualShaderEditor::clear_custom_types() {
}
}
-void VisualShaderEditor::add_custom_type(const String &p_name, const Ref<Script> &p_script, const String &p_description, int p_return_icon_type, const String &p_category, bool p_highend) {
+void VisualShaderEditor::add_custom_type(const String &p_name, const String &p_type, const Ref<Script> &p_script, const String &p_description, int p_return_icon_type, const String &p_category, bool p_highend) {
ERR_FAIL_COND(!p_name.is_valid_identifier());
- ERR_FAIL_COND(!p_script.is_valid());
+ ERR_FAIL_COND(p_type.is_empty() && !p_script.is_valid());
for (int i = 0; i < add_options.size(); i++) {
- if (add_options[i].is_custom) {
- if (add_options[i].script == p_script) {
+ const AddOption &op = add_options[i];
+
+ if (op.is_custom) {
+ if (!p_type.is_empty()) {
+ if (op.type == p_type) {
+ return;
+ }
+ } else if (op.script == p_script) {
return;
}
}
@@ -1223,12 +1229,14 @@ void VisualShaderEditor::add_custom_type(const String &p_name, const Ref<Script>
AddOption ao;
ao.name = p_name;
+ ao.type = p_type;
ao.script = p_script;
ao.return_type = p_return_icon_type;
ao.description = p_description;
ao.category = p_category;
ao.highend = p_highend;
ao.is_custom = true;
+ ao.is_native = !p_type.is_empty();
bool begin = false;
String root = p_category.split("/")[0];
@@ -1253,50 +1261,23 @@ void VisualShaderEditor::add_custom_type(const String &p_name, const Ref<Script>
Dictionary VisualShaderEditor::get_custom_node_data(Ref<VisualShaderNodeCustom> &p_custom_node) {
Dictionary dict;
dict["script"] = p_custom_node->get_script();
+ dict["name"] = p_custom_node->_get_name();
+ dict["description"] = p_custom_node->_get_description();
+ dict["return_icon_type"] = p_custom_node->_get_return_icon_type();
+ dict["highend"] = p_custom_node->_is_highend();
- String name;
- if (p_custom_node->has_method("_get_name")) {
- name = (String)p_custom_node->call("_get_name");
- } else {
- name = "Unnamed";
- }
- dict["name"] = name;
-
- String description = "";
- if (p_custom_node->has_method("_get_description")) {
- description = (String)p_custom_node->call("_get_description");
- }
- dict["description"] = description;
-
- int return_icon_type = -1;
- if (p_custom_node->has_method("_get_return_icon_type")) {
- return_icon_type = (int)p_custom_node->call("_get_return_icon_type");
- }
- dict["return_icon_type"] = return_icon_type;
-
- String category = "";
- if (p_custom_node->has_method("_get_category")) {
- category = (String)p_custom_node->call("_get_category");
- }
+ String category = p_custom_node->_get_category();
category = category.rstrip("/");
category = category.lstrip("/");
category = "Addons/" + category;
-
- String subcategory = "";
if (p_custom_node->has_method("_get_subcategory")) {
- subcategory = (String)p_custom_node->call("_get_subcategory");
- }
- if (!subcategory.is_empty()) {
- category += "/" + subcategory;
+ String subcategory = (String)p_custom_node->call("_get_subcategory");
+ if (!subcategory.is_empty()) {
+ category += "/" + subcategory;
+ }
}
dict["category"] = category;
- bool highend = false;
- if (p_custom_node->has_method("_is_highend")) {
- highend = (bool)p_custom_node->call("_is_highend");
- }
- dict["highend"] = highend;
-
return dict;
}
@@ -1333,7 +1314,7 @@ void VisualShaderEditor::_script_created(const Ref<Script> &p_script) {
ref->set_script(p_script);
Dictionary dict = get_custom_node_data(ref);
- add_custom_type(dict["name"], dict["script"], dict["description"], dict["return_icon_type"], dict["category"], dict["highend"]);
+ add_custom_type(dict["name"], String(), dict["script"], dict["description"], dict["return_icon_type"], dict["category"], dict["highend"]);
_update_options_menu();
}
@@ -1456,7 +1437,7 @@ void VisualShaderEditor::_update_custom_script(const Ref<Script> &p_script) {
}
if (!found_type) {
- add_custom_type(dict["name"], dict["script"], dict["description"], dict["return_icon_type"], dict["category"], dict["highend"]);
+ add_custom_type(dict["name"], String(), dict["script"], dict["description"], dict["return_icon_type"], dict["category"], dict["highend"]);
}
// To prevent updating options multiple times when multiple scripts are saved.
@@ -1595,29 +1576,60 @@ bool VisualShaderEditor::_is_available(int p_mode) {
void VisualShaderEditor::_update_nodes() {
clear_custom_types();
- List<StringName> class_list;
- ScriptServer::get_global_class_list(&class_list);
Dictionary added;
- for (int i = 0; i < class_list.size(); i++) {
- if (ScriptServer::get_global_class_native_base(class_list[i]) == "VisualShaderNodeCustom") {
- String script_path = ScriptServer::get_global_class_path(class_list[i]);
- Ref<Resource> res = ResourceLoader::load(script_path);
- ERR_FAIL_COND(res.is_null());
- ERR_FAIL_COND(!res->is_class("Script"));
- Ref<Script> scr = Ref<Script>(res);
-
- Ref<VisualShaderNodeCustom> ref;
- ref.instantiate();
- ref->set_script(scr);
- if (!ref->is_available(visual_shader->get_mode(), visual_shader->get_shader_type())) {
- continue;
+
+ // Add GDScript classes.
+ {
+ List<StringName> class_list;
+ ScriptServer::get_global_class_list(&class_list);
+
+ for (int i = 0; i < class_list.size(); i++) {
+ if (ScriptServer::get_global_class_native_base(class_list[i]) == "VisualShaderNodeCustom") {
+ String script_path = ScriptServer::get_global_class_path(class_list[i]);
+ Ref<Resource> res = ResourceLoader::load(script_path);
+ ERR_CONTINUE(res.is_null());
+ ERR_CONTINUE(!res->is_class("Script"));
+ Ref<Script> scr = Ref<Script>(res);
+
+ Ref<VisualShaderNodeCustom> ref;
+ ref.instantiate();
+ ref->set_script(scr);
+ if (!ref->is_available(visual_shader->get_mode(), visual_shader->get_shader_type())) {
+ continue;
+ }
+ Dictionary dict = get_custom_node_data(ref);
+ dict["type"] = String();
+
+ String key;
+ key = String(dict["category"]) + "/" + String(dict["name"]);
+
+ added[key] = dict;
}
- Dictionary dict = get_custom_node_data(ref);
+ }
+ }
- String key;
- key = String(dict["category"]) + "/" + String(dict["name"]);
+ // Add GDExtension classes.
+ {
+ List<StringName> class_list;
+ ClassDB::get_class_list(&class_list);
+
+ for (int i = 0; i < class_list.size(); i++) {
+ if (ClassDB::get_parent_class(class_list[i]) == "VisualShaderNodeCustom") {
+ Object *instance = ClassDB::instantiate(class_list[i]);
+ Ref<VisualShaderNodeCustom> ref = Object::cast_to<VisualShaderNodeCustom>(instance);
+ ERR_CONTINUE(ref.is_null());
+ if (!ref->is_available(visual_shader->get_mode(), visual_shader->get_shader_type())) {
+ continue;
+ }
+ Dictionary dict = get_custom_node_data(ref);
+ dict["type"] = class_list[i];
+ dict["script"] = Ref<Script>();
- added[key] = dict;
+ String key;
+ key = String(dict["category"]) + "/" + String(dict["name"]);
+
+ added[key] = dict;
+ }
}
}
@@ -1655,7 +1667,7 @@ void VisualShaderEditor::_update_nodes() {
const Dictionary &value = (Dictionary)added[key];
- add_custom_type(value["name"], value["script"], value["description"], value["return_icon_type"], value["category"], value["highend"]);
+ add_custom_type(value["name"], value["type"], value["script"], value["description"], value["return_icon_type"], value["category"], value["highend"]);
}
_update_options_menu();
@@ -3062,12 +3074,21 @@ void VisualShaderEditor::_add_node(int p_idx, const Vector<Variant> &p_ops, Stri
vsnode = Ref<VisualShaderNode>(vsn);
} else {
- ERR_FAIL_COND(add_options[p_idx].script.is_null());
- StringName base_type = add_options[p_idx].script->get_instance_base_type();
+ StringName base_type;
+ bool is_native = add_options[p_idx].is_native;
+
+ if (is_native) {
+ base_type = add_options[p_idx].type;
+ } else {
+ ERR_FAIL_COND(add_options[p_idx].script.is_null());
+ base_type = add_options[p_idx].script->get_instance_base_type();
+ }
VisualShaderNode *vsn = Object::cast_to<VisualShaderNode>(ClassDB::instantiate(base_type));
ERR_FAIL_COND(!vsn);
vsnode = Ref<VisualShaderNode>(vsn);
- vsnode->set_script(add_options[p_idx].script);
+ if (!is_native) {
+ vsnode->set_script(add_options[p_idx].script);
+ }
}
bool is_texture2d = (Object::cast_to<VisualShaderNodeTexture>(vsnode.ptr()) != nullptr);
diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h
index 21139fbddd..bdb23afa0f 100644
--- a/editor/plugins/visual_shader_editor_plugin.h
+++ b/editor/plugins/visual_shader_editor_plugin.h
@@ -310,6 +310,7 @@ class VisualShaderEditor : public VBoxContainer {
int func = 0;
bool highend = false;
bool is_custom = false;
+ bool is_native = false;
int temp_idx = 0;
AddOption(const String &p_name = String(), const String &p_category = String(), const String &p_type = String(), const String &p_description = String(), const Vector<Variant> &p_ops = Vector<Variant>(), int p_return_type = -1, int p_mode = -1, int p_func = -1, bool p_highend = false) {
@@ -527,9 +528,10 @@ public:
VisualShaderGraphPlugin *get_graph_plugin() { return graph_plugin.ptr(); }
void clear_custom_types();
- void add_custom_type(const String &p_name, const Ref<Script> &p_script, const String &p_description, int p_return_icon_type, const String &p_category, bool p_highend);
+ void add_custom_type(const String &p_name, const String &p_type, const Ref<Script> &p_script, const String &p_description, int p_return_icon_type, const String &p_category, bool p_highend);
Dictionary get_custom_node_data(Ref<VisualShaderNodeCustom> &p_custom_node);
+ void update_custom_type(const Ref<Resource> &p_resource);
virtual Size2 get_minimum_size() const override;
void edit(VisualShader *p_visual_shader);
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index 4dd2237b4f..9f9e321a9c 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -1829,7 +1829,7 @@ void ProjectList::_favorite_pressed(Node *p_hb) {
}
void ProjectList::_show_project(const String &p_path) {
- OS::get_singleton()->shell_open(String("file://") + p_path);
+ OS::get_singleton()->shell_show_in_file_manager(p_path, true);
}
void ProjectList::_bind_methods() {
@@ -2602,6 +2602,7 @@ ProjectManager::ProjectManager() {
DisplayServer::get_singleton()->window_set_title(VERSION_NAME + String(" - ") + TTR("Project Manager", "Application"));
EditorFileDialog::set_default_show_hidden_files(EDITOR_GET("filesystem/file_dialog/show_hidden_files"));
+ EditorFileDialog::set_default_display_mode((EditorFileDialog::DisplayMode)EDITOR_GET("filesystem/file_dialog/display_mode").operator int());
int swap_cancel_ok = EDITOR_GET("interface/editor/accept_dialog_cancel_ok_buttons");
if (swap_cancel_ok != 0) { // 0 is auto, set in register_scene based on DisplayServer.
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp
index 1cd863fb8a..95cf9496dc 100644
--- a/editor/project_settings_editor.cpp
+++ b/editor/project_settings_editor.cpp
@@ -36,6 +36,7 @@
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/editor_undo_redo_manager.h"
+#include "editor/export/editor_export.h"
#include "scene/gui/check_button.h"
#include "servers/movie_writer/movie_writer.h"
diff --git a/editor/register_editor_types.cpp b/editor/register_editor_types.cpp
index 724d435f68..0a63c40bf6 100644
--- a/editor/register_editor_types.cpp
+++ b/editor/register_editor_types.cpp
@@ -30,7 +30,6 @@
#include "register_editor_types.h"
-#include "editor/animation_track_editor.h"
#include "editor/debugger/debug_adapter/debug_adapter_server.h"
#include "editor/editor_command_palette.h"
#include "editor/editor_feature_profile.h"
@@ -40,11 +39,13 @@
#include "editor/editor_paths.h"
#include "editor/editor_resource_picker.h"
#include "editor/editor_resource_preview.h"
-#include "editor/editor_run_script.h"
+#include "editor/editor_script.h"
#include "editor/editor_settings.h"
#include "editor/editor_translation_parser.h"
#include "editor/editor_undo_redo_manager.h"
+#include "editor/export/editor_export_platform.h"
#include "editor/export/editor_export_platform_pc.h"
+#include "editor/export/editor_export_plugin.h"
#include "editor/filesystem_dock.h"
#include "editor/gui/editor_file_dialog.h"
#include "editor/gui/editor_spin_slider.h"
@@ -137,14 +138,15 @@ void register_editor_types() {
GDREGISTER_CLASS(EditorExportPlugin);
GDREGISTER_ABSTRACT_CLASS(EditorExportPlatform);
GDREGISTER_ABSTRACT_CLASS(EditorExportPlatformPC);
+
register_exporter_types();
+
GDREGISTER_CLASS(EditorResourceConversionPlugin);
GDREGISTER_CLASS(EditorSceneFormatImporter);
GDREGISTER_CLASS(EditorScenePostImportPlugin);
GDREGISTER_CLASS(EditorInspector);
GDREGISTER_CLASS(EditorInspectorPlugin);
GDREGISTER_CLASS(EditorProperty);
- GDREGISTER_CLASS(AnimationTrackEditPlugin);
GDREGISTER_CLASS(ScriptCreateDialog);
GDREGISTER_CLASS(EditorFeatureProfile);
GDREGISTER_CLASS(EditorSpinSlider);
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 968cd5ab23..9e231a41c3 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -53,6 +53,7 @@
#include "editor/plugins/script_editor_plugin.h"
#include "editor/reparent_dialog.h"
#include "editor/shader_create_dialog.h"
+#include "scene/gui/check_box.h"
#include "scene/main/window.h"
#include "scene/property_utils.h"
#include "scene/resources/packed_scene.h"
@@ -275,6 +276,8 @@ void SceneTreeDock::_replace_with_branch_scene(const String &p_file, Node *base)
return;
}
+ instantiated_scene->set_unique_name_in_owner(base->is_unique_name_in_owner());
+
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
undo_redo->create_action(TTR("Replace with Branch Scene"));
@@ -850,9 +853,10 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
break;
}
- if (p_confirm_override) {
+ bool allow_ask_delete_tracks = EDITOR_GET("docks/scene_tree/ask_before_deleting_related_animation_tracks").operator bool();
+ bool has_tracks_to_delete = allow_ask_delete_tracks && _has_tracks_to_delete(edited_scene, remove_list);
+ if (p_confirm_override && !has_tracks_to_delete) {
_delete_confirm();
-
} else {
String msg;
if (remove_list.size() > 1) {
@@ -863,18 +867,30 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
msg = vformat(any_children ? TTR("Delete %d nodes and any children?") : TTR("Delete %d nodes?"), remove_list.size());
} else {
- 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_scene_file_path().is_empty() && 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());
+ if (!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_scene_file_path().is_empty() && 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 {
+ msg = vformat(TTR("Delete node \"%s\"?"), node->get_name());
+ }
+ }
+
+ if (has_tracks_to_delete) {
+ if (!msg.is_empty()) {
+ msg += "\n";
+ }
+ msg += TTR("Some nodes are referenced by animation tracks.");
+ delete_tracks_checkbox->show();
} else {
- msg = vformat(TTR("Delete node \"%s\"?"), node->get_name());
+ delete_tracks_checkbox->hide();
}
}
- delete_dialog->set_text(msg);
+ delete_dialog_label->set_text(msg);
// Resize the dialog to its minimum size.
// This prevents the dialog from being too wide after displaying
@@ -1496,12 +1512,10 @@ void SceneTreeDock::_set_owners(Node *p_owner, const Array &p_nodes) {
void SceneTreeDock::_fill_path_renames(Vector<StringName> base_path, Vector<StringName> new_base_path, Node *p_node, HashMap<Node *, NodePath> *p_renames) {
base_path.push_back(p_node->get_name());
- if (new_base_path.size()) {
- new_base_path.push_back(p_node->get_name());
- }
NodePath new_path;
- if (new_base_path.size()) {
+ if (!new_base_path.is_empty()) {
+ new_base_path.push_back(p_node->get_name());
new_path = NodePath(new_base_path, true);
}
@@ -1512,6 +1526,43 @@ void SceneTreeDock::_fill_path_renames(Vector<StringName> base_path, Vector<Stri
}
}
+bool SceneTreeDock::_has_tracks_to_delete(Node *p_node, List<Node *> &p_to_delete) const {
+ AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(p_node);
+ if (ap) {
+ Node *root = ap->get_node(ap->get_root());
+ if (root && !p_to_delete.find(root)) {
+ List<StringName> anims;
+ ap->get_animation_list(&anims);
+
+ for (const StringName &E : anims) {
+ Ref<Animation> anim = ap->get_animation(E);
+ if (anim.is_null()) {
+ continue;
+ }
+
+ for (int i = 0; i < anim->get_track_count(); i++) {
+ NodePath track_np = anim->track_get_path(i);
+ Node *n = root->get_node_or_null(track_np);
+ if (n) {
+ for (const Node *F : p_to_delete) {
+ if (F == n || F->is_ancestor_of(n)) {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ for (int i = 0; i < p_node->get_child_count(); i++) {
+ if (_has_tracks_to_delete(p_node->get_child(i), p_to_delete)) {
+ return true;
+ }
+ }
+ return false;
+}
+
void SceneTreeDock::fill_path_renames(Node *p_node, Node *p_new_parent, HashMap<Node *, NodePath> *p_renames) {
Vector<StringName> base_path;
Node *n = p_node->get_parent();
@@ -1701,7 +1752,7 @@ void SceneTreeDock::perform_node_renames(Node *p_base, HashMap<Node *, NodePath>
HashMap<Node *, NodePath>::Iterator found_path = p_renames->find(n);
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
if (found_path) {
- if (found_path->value == NodePath()) {
+ if (found_path->value.is_empty()) {
//will be erased
int idx = 0;
@@ -2094,11 +2145,6 @@ void SceneTreeDock::_delete_confirm(bool p_cut) {
return;
}
- EditorNode::get_singleton()->hide_unused_editors(this);
-
- EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
- undo_redo->create_action(p_cut ? TTR("Cut Node(s)") : TTR("Remove Node(s)"), UndoRedo::MERGE_DISABLE, remove_list.front()->get());
-
bool entire_scene = false;
for (const Node *E : remove_list) {
@@ -2108,27 +2154,34 @@ void SceneTreeDock::_delete_confirm(bool p_cut) {
}
}
+ EditorNode::get_singleton()->hide_unused_editors(this);
+
+ EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
+ undo_redo->create_action(p_cut ? TTR("Cut Node(s)") : TTR("Remove Node(s)"), UndoRedo::MERGE_DISABLE, remove_list.front()->get());
+
if (entire_scene) {
undo_redo->add_do_method(EditorNode::get_singleton(), "set_edited_scene", (Object *)nullptr);
undo_redo->add_undo_method(EditorNode::get_singleton(), "set_edited_scene", edited_scene);
undo_redo->add_undo_method(edited_scene, "set_owner", edited_scene->get_owner());
undo_redo->add_undo_method(scene_tree, "update_tree");
undo_redo->add_undo_reference(edited_scene);
-
} else {
- remove_list.sort_custom<Node::Comparator>(); //sort nodes to keep positions
- HashMap<Node *, NodePath> path_renames;
+ if (delete_tracks_checkbox->is_pressed() || p_cut) {
+ remove_list.sort_custom<Node::Comparator>(); // Sort nodes to keep positions.
+ HashMap<Node *, NodePath> path_renames;
- //delete from animation
- for (Node *n : remove_list) {
- if (!n->is_inside_tree() || !n->get_parent()) {
- continue;
+ //delete from animation
+ for (Node *n : remove_list) {
+ if (!n->is_inside_tree() || !n->get_parent()) {
+ continue;
+ }
+
+ fill_path_renames(n, nullptr, &path_renames);
}
- fill_path_renames(n, nullptr, &path_renames);
+ perform_node_renames(nullptr, &path_renames);
}
- perform_node_renames(nullptr, &path_renames);
//delete for read
for (Node *n : remove_list) {
if (!n->is_inside_tree() || !n->get_parent()) {
@@ -3774,6 +3827,16 @@ SceneTreeDock::SceneTreeDock(Node *p_scene_root, EditorSelection *p_editor_selec
add_child(delete_dialog);
delete_dialog->connect("confirmed", callable_mp(this, &SceneTreeDock::_delete_confirm).bind(false));
+ VBoxContainer *vb = memnew(VBoxContainer);
+ delete_dialog->add_child(vb);
+
+ delete_dialog_label = memnew(Label);
+ vb->add_child(delete_dialog_label);
+
+ delete_tracks_checkbox = memnew(CheckBox(TTR("Delete Related Animation Tracks")));
+ delete_tracks_checkbox->set_pressed(true);
+ vb->add_child(delete_tracks_checkbox);
+
editable_instance_remove_dialog = memnew(ConfirmationDialog);
add_child(editable_instance_remove_dialog);
editable_instance_remove_dialog->connect("confirmed", callable_mp(this, &SceneTreeDock::_toggle_editable_children_from_selection));
@@ -3810,6 +3873,7 @@ SceneTreeDock::SceneTreeDock(Node *p_scene_root, EditorSelection *p_editor_selec
EDITOR_DEF("interface/editors/show_scene_tree_root_selection", true);
EDITOR_DEF("interface/editors/derive_script_globals_by_name", true);
+ EDITOR_DEF("docks/scene_tree/ask_before_deleting_related_animation_tracks", true);
EDITOR_DEF("_use_favorites_root_selection", false);
Resource::_update_configuration_warning = _update_configuration_warning;
diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h
index 75acb37973..e8a6686386 100644
--- a/editor/scene_tree_dock.h
+++ b/editor/scene_tree_dock.h
@@ -36,6 +36,7 @@
#include "scene/gui/box_container.h"
#include "scene/resources/animation.h"
+class CheckBox;
class EditorData;
class EditorSelection;
class EditorQuickOpen;
@@ -148,6 +149,8 @@ class SceneTreeDock : public VBoxContainer {
ShaderCreateDialog *shader_create_dialog = nullptr;
AcceptDialog *accept = nullptr;
ConfirmationDialog *delete_dialog = nullptr;
+ Label *delete_dialog_label = nullptr;
+ CheckBox *delete_tracks_checkbox = nullptr;
ConfirmationDialog *editable_instance_remove_dialog = nullptr;
ConfirmationDialog *placeholder_editable_instance_remove_dialog = nullptr;
@@ -213,6 +216,7 @@ class SceneTreeDock : public VBoxContainer {
void _shader_creation_closed();
void _delete_confirm(bool p_cut = false);
+ void _delete_dialog_closed();
void _toggle_editable_children_from_selection();
void _toggle_editable_children(Node *p_node);
@@ -234,6 +238,7 @@ class SceneTreeDock : public VBoxContainer {
void _update_script_button();
void _fill_path_renames(Vector<StringName> base_path, Vector<StringName> new_base_path, Node *p_node, HashMap<Node *, NodePath> *p_renames);
+ bool _has_tracks_to_delete(Node *p_node, List<Node *> &p_to_delete) const;
void _normalize_drop(Node *&to_node, int &to_pos, int p_type);
diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp
index f3f0e7308c..23272ab284 100644
--- a/editor/script_create_dialog.cpp
+++ b/editor/script_create_dialog.cpp
@@ -894,9 +894,9 @@ ScriptLanguage::ScriptTemplate ScriptCreateDialog::_parse_template(const ScriptL
if (line.begins_with("space-indent")) {
String indent_value = line.substr(17, -1).strip_edges();
if (indent_value.is_valid_int()) {
- space_indent = "";
- for (int i = 0; i < indent_value.to_int(); i++) {
- space_indent += " ";
+ int indent_size = indent_value.to_int();
+ if (indent_size >= 0) {
+ space_indent = String(" ").repeat(indent_size);
}
} else {
WARN_PRINT(vformat("Template meta-use_space_indent need to be a valid integer value. Found %s.", indent_value));
diff --git a/main/main.cpp b/main/main.cpp
index bc309219f4..5e0187cc7f 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -167,7 +167,7 @@ static bool project_manager = false;
static bool cmdline_tool = false;
static String locale;
static bool show_help = false;
-static bool auto_quit = false;
+static uint64_t quit_after = 0;
static OS::ProcessID editor_pid = 0;
#ifdef TOOLS_ENABLED
static bool found_project = false;
@@ -355,6 +355,7 @@ void Main::print_help(const char *p_binary) {
OS::get_singleton()->print(" --debug-server <uri> Start the editor debug server (<protocol>://<host/IP>[:<port>], e.g. tcp://127.0.0.1:6007)\n");
#endif
OS::get_singleton()->print(" --quit Quit after the first iteration.\n");
+ OS::get_singleton()->print(" --quit-after <int> Quit after the given number of iterations. Set to 0 to disable.\n");
OS::get_singleton()->print(" -l, --language <locale> Use a specific locale (<locale> being a two-letter code).\n");
OS::get_singleton()->print(" --path <directory> Path to a project (<directory> must contain a 'project.godot' file).\n");
OS::get_singleton()->print(" -u, --upwards Scan folders upwards for project.godot file.\n");
@@ -398,6 +399,7 @@ void Main::print_help(const char *p_binary) {
OS::get_singleton()->print(" --write-movie <file> Writes a video to the specified path (usually with .avi or .png extension).\n");
OS::get_singleton()->print(" --fixed-fps is forced when enabled, but it can be used to change movie FPS.\n");
OS::get_singleton()->print(" --disable-vsync can speed up movie writing but makes interaction more difficult.\n");
+ OS::get_singleton()->print(" --quit-after can be used to specify the number of frames to write.\n");
OS::get_singleton()->print("\n");
@@ -471,6 +473,8 @@ void Main::print_help(const char *p_binary) {
// The order is the same as in `Main::setup()`, only core and some editor types
// are initialized here. This also combines `Main::setup2()` initialization.
Error Main::test_setup() {
+ Thread::make_main_thread();
+
OS::get_singleton()->initialize();
engine = memnew(Engine);
@@ -680,6 +684,8 @@ int Main::test_entrypoint(int argc, char *argv[], bool &tests_need_run) {
*/
Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_phase) {
+ Thread::make_main_thread();
+
OS::get_singleton()->initialize();
engine = memnew(Engine);
@@ -1196,7 +1202,15 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
} else if (I->get() == "-u" || I->get() == "--upwards") { // scan folders upwards
upwards = true;
} else if (I->get() == "--quit") { // Auto quit at the end of the first main loop iteration
- auto_quit = true;
+ quit_after = 1;
+ } else if (I->get() == "--quit-after") { // Quit after the given number of iterations
+ if (I->next()) {
+ quit_after = I->next()->get().to_int();
+ N = I->next()->next();
+ } else {
+ OS::get_singleton()->print("Missing number of iterations, aborting.\n");
+ goto error;
+ }
} else if (I->get().ends_with("project.godot")) {
String path;
String file = I->get();
@@ -1876,6 +1890,8 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
engine->startup_benchmark_end_measure(); // core
+ Thread::release_main_thread(); // If setup2() is called from another thread, that one will become main thread, so preventively release this one.
+
if (p_second_phase) {
return setup2();
}
@@ -1941,7 +1957,9 @@ error:
return exit_code;
}
-Error Main::setup2(Thread::ID p_main_tid_override) {
+Error Main::setup2() {
+ Thread::make_main_thread(); // Make whatever thread call this the main thread.
+
// Print engine name and version
print_line(String(VERSION_NAME) + " v" + get_full_version_string() + " - " + String(VERSION_WEBSITE));
@@ -1962,10 +1980,6 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
initialize_modules(MODULE_INITIALIZATION_LEVEL_SERVERS);
GDExtensionManager::get_singleton()->initialize_extensions(GDExtension::INITIALIZATION_LEVEL_SERVERS);
- if (p_main_tid_override) {
- Thread::main_thread_id = p_main_tid_override;
- }
-
#ifdef TOOLS_ENABLED
if (editor || project_manager || cmdline_tool) {
EditorPaths::create();
@@ -3297,6 +3311,10 @@ bool Main::iteration() {
movie_writer->add_frame(vp_tex);
}
+ if ((quit_after > 0) && (Engine::get_singleton()->_process_frames >= quit_after)) {
+ exit = true;
+ }
+
if (fixed_fps != -1) {
return exit;
}
@@ -3320,7 +3338,7 @@ bool Main::iteration() {
}
#endif
- return exit || auto_quit;
+ return exit;
}
void Main::force_redraw() {
diff --git a/main/main.h b/main/main.h
index e345589f59..cc0655cd02 100644
--- a/main/main.h
+++ b/main/main.h
@@ -60,7 +60,7 @@ public:
static int test_entrypoint(int argc, char *argv[], bool &tests_need_run);
static Error setup(const char *execpath, int argc, char *argv[], bool p_second_phase = true);
- static Error setup2(Thread::ID p_main_tid_override = 0);
+ static Error setup2(); // The thread calling setup2() will effectively become the main thread.
static String get_rendering_driver_name();
#ifdef TESTS_ENABLED
static Error test_setup();
diff --git a/misc/hooks/pre-commit-make-rst b/misc/hooks/pre-commit-make-rst
index 7d115f1d13..3737272a6d 100755
--- a/misc/hooks/pre-commit-make-rst
+++ b/misc/hooks/pre-commit-make-rst
@@ -9,4 +9,4 @@ if [[ "$py_ver" != "3" ]]; then
PYTHON+=3
fi
-$PYTHON doc/tools/make_rst.py doc/classes modules --dry-run --color
+$PYTHON doc/tools/make_rst.py doc/classes modules platform --dry-run --color
diff --git a/misc/scripts/codespell.sh b/misc/scripts/codespell.sh
index 775d193a66..d15b6593f7 100755
--- a/misc/scripts/codespell.sh
+++ b/misc/scripts/codespell.sh
@@ -3,6 +3,6 @@ SKIP_LIST="./.*,./**/.*,./bin,./thirdparty,*.desktop,*.gen.*,*.po,*.pot,*.rc,./A
SKIP_LIST+="./core/input/gamecontrollerdb.txt,./core/string/locales.h,./editor/renames_map_3_to_4.cpp,./misc/scripts/codespell.sh,"
SKIP_LIST+="./platform/android/java/lib/src/com,./platform/web/node_modules,./platform/web/package-lock.json,"
-IGNORE_LIST="curvelinear,doubleclick,expct,findn,gird,hel,inout,lod,nd,numer,ot,te"
+IGNORE_LIST="curvelinear,doubleclick,expct,findn,gird,hel,inout,lod,nd,numer,ot,te,vai"
codespell -w -q 3 -S "${SKIP_LIST}" -L "${IGNORE_LIST}" --builtin "clear,rare,en-GB_to_en-US"
diff --git a/modules/csg/csg.cpp b/modules/csg/csg.cpp
index dee95d1ac5..0bd8e5d9ad 100644
--- a/modules/csg/csg.cpp
+++ b/modules/csg/csg.cpp
@@ -526,17 +526,19 @@ int CSGBrushOperation::MeshMerge::_create_bvh(FaceBVH *facebvhptr, FaceBVH **fac
return index;
}
-void CSGBrushOperation::MeshMerge::_add_distance(List<real_t> &r_intersectionsA, List<real_t> &r_intersectionsB, bool p_from_B, real_t p_distance) const {
- List<real_t> &intersections = p_from_B ? r_intersectionsB : r_intersectionsA;
+void CSGBrushOperation::MeshMerge::_add_distance(List<IntersectionDistance> &r_intersectionsA, List<IntersectionDistance> &r_intersectionsB, bool p_from_B, real_t p_distance_squared, bool p_is_conormal) const {
+ List<IntersectionDistance> &intersections = p_from_B ? r_intersectionsB : r_intersectionsA;
// Check if distance exists.
- for (const real_t E : intersections) {
- if (Math::is_equal_approx(E, p_distance)) {
+ for (const IntersectionDistance E : intersections) {
+ if (E.is_conormal == p_is_conormal && Math::is_equal_approx(E.distance_squared, p_distance_squared)) {
return;
}
}
-
- intersections.push_back(p_distance);
+ IntersectionDistance IntersectionDistance;
+ IntersectionDistance.is_conormal = p_is_conormal;
+ IntersectionDistance.distance_squared = p_distance_squared;
+ intersections.push_back(IntersectionDistance);
}
bool CSGBrushOperation::MeshMerge::_bvh_inside(FaceBVH *facebvhptr, int p_max_depth, int p_bvh_first, int p_face_idx) const {
@@ -561,8 +563,11 @@ bool CSGBrushOperation::MeshMerge::_bvh_inside(FaceBVH *facebvhptr, int p_max_de
VISITED_BIT_MASK = ~NODE_IDX_MASK
};
- List<real_t> intersectionsA;
- List<real_t> intersectionsB;
+ List<IntersectionDistance> intersectionsA;
+ List<IntersectionDistance> intersectionsB;
+
+ Intersection closest_intersection;
+ closest_intersection.found = false;
int level = 0;
int pos = p_bvh_first;
@@ -587,17 +592,61 @@ bool CSGBrushOperation::MeshMerge::_bvh_inside(FaceBVH *facebvhptr, int p_max_de
};
Vector3 current_normal = Plane(current_points[0], current_points[1], current_points[2]).normal;
Vector3 intersection_point;
-
// Check if faces are co-planar.
if (current_normal.is_equal_approx(face_normal) &&
is_point_in_triangle(face_center, current_points)) {
// Only add an intersection if not a B face.
if (!face.from_b) {
- _add_distance(intersectionsA, intersectionsB, current_face.from_b, 0);
+ _add_distance(intersectionsA, intersectionsB, current_face.from_b, 0, true);
}
} else if (ray_intersects_triangle(face_center, face_normal, current_points, CMP_EPSILON, intersection_point)) {
- real_t distance = face_center.distance_to(intersection_point);
- _add_distance(intersectionsA, intersectionsB, current_face.from_b, distance);
+ real_t distance_squared = face_center.distance_squared_to(intersection_point);
+ real_t inner = current_normal.dot(face_normal);
+ // If the faces are perpendicular, ignore this face.
+ // The triangles on the side should be intersected and result in the correct behavior.
+ if (!Math::is_zero_approx(inner)) {
+ _add_distance(intersectionsA, intersectionsB, current_face.from_b, distance_squared, inner > 0.0f);
+ }
+ }
+
+ if (face.from_b != current_face.from_b) {
+ if (current_normal.is_equal_approx(face_normal) &&
+ is_point_in_triangle(face_center, current_points)) {
+ // Only add an intersection if not a B face.
+ if (!face.from_b) {
+ closest_intersection.found = true;
+ closest_intersection.conormal = 1.0f;
+ closest_intersection.distance_squared = 0.0f;
+ closest_intersection.origin_angle = -FLT_MAX;
+ }
+ } else if (ray_intersects_triangle(face_center, face_normal, current_points, CMP_EPSILON, intersection_point)) {
+ Intersection potential_intersection;
+ potential_intersection.found = true;
+ potential_intersection.conormal = face_normal.dot(current_normal);
+ potential_intersection.distance_squared = face_center.distance_squared_to(intersection_point);
+ potential_intersection.origin_angle = Math::abs(potential_intersection.conormal);
+ real_t intersection_dist_from_face = face_normal.dot(intersection_point - face_center);
+ for (int i = 0; i < 3; i++) {
+ real_t point_dist_from_face = face_normal.dot(current_points[i] - face_center);
+ if (!Math::is_equal_approx(point_dist_from_face, intersection_dist_from_face) &&
+ point_dist_from_face < intersection_dist_from_face) {
+ potential_intersection.origin_angle = -potential_intersection.origin_angle;
+ break;
+ }
+ }
+ if (potential_intersection.conormal != 0.0f) {
+ if (!closest_intersection.found) {
+ closest_intersection = potential_intersection;
+ } else if (!Math::is_equal_approx(potential_intersection.distance_squared, closest_intersection.distance_squared) &&
+ potential_intersection.distance_squared < closest_intersection.distance_squared) {
+ closest_intersection = potential_intersection;
+ } else if (Math::is_equal_approx(potential_intersection.distance_squared, closest_intersection.distance_squared)) {
+ if (potential_intersection.origin_angle < closest_intersection.origin_angle) {
+ closest_intersection = potential_intersection;
+ }
+ }
+ }
+ }
}
}
@@ -652,8 +701,11 @@ bool CSGBrushOperation::MeshMerge::_bvh_inside(FaceBVH *facebvhptr, int p_max_de
}
}
- // Inside if face normal intersects other faces an odd number of times.
- return (intersectionsA.size() + intersectionsB.size()) & 1;
+ if (!closest_intersection.found) {
+ return false;
+ } else {
+ return closest_intersection.conormal > 0.0f;
+ }
}
void CSGBrushOperation::MeshMerge::mark_inside_faces() {
@@ -1016,6 +1068,8 @@ void CSGBrushOperation::Build2DFaces::_merge_faces(const Vector<int> &p_segment_
}
void CSGBrushOperation::Build2DFaces::_find_edge_intersections(const Vector2 p_segment_points[2], Vector<int> &r_segment_indices) {
+ LocalVector<Vector<Vector2>> processed_edges;
+
// For each face.
for (int face_idx = 0; face_idx < faces.size(); ++face_idx) {
Face2D face = faces[face_idx];
@@ -1027,17 +1081,32 @@ void CSGBrushOperation::Build2DFaces::_find_edge_intersections(const Vector2 p_s
// Check each edge.
for (int face_edge_idx = 0; face_edge_idx < 3; ++face_edge_idx) {
- Vector2 edge_points[2] = {
+ Vector<Vector2> edge_points_and_uvs = {
face_vertices[face_edge_idx].point,
- face_vertices[(face_edge_idx + 1) % 3].point
- };
- Vector2 edge_uvs[2] = {
+ face_vertices[(face_edge_idx + 1) % 3].point,
face_vertices[face_edge_idx].uv,
face_vertices[(face_edge_idx + 1) % 3].uv
};
- Vector2 intersection_point;
+
+ Vector2 edge_points[2] = {
+ edge_points_and_uvs[0],
+ edge_points_and_uvs[1],
+ };
+ Vector2 edge_uvs[2] = {
+ edge_points_and_uvs[2],
+ edge_points_and_uvs[3],
+ };
+
+ // Check if edge has already been processed.
+ if (processed_edges.find(edge_points_and_uvs) != -1) {
+ continue;
+ }
+
+ processed_edges.push_back(edge_points_and_uvs);
// First check if the ends of the segment are on the edge.
+ Vector2 intersection_point;
+
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);
diff --git a/modules/csg/csg.h b/modules/csg/csg.h
index 1513a01f9e..473a23e39f 100644
--- a/modules/csg/csg.h
+++ b/modules/csg/csg.h
@@ -135,6 +135,17 @@ struct CSGBrushOperation {
return h;
}
};
+ struct Intersection {
+ bool found = false;
+ real_t conormal = FLT_MAX;
+ real_t distance_squared = FLT_MAX;
+ real_t origin_angle = FLT_MAX;
+ };
+
+ struct IntersectionDistance {
+ bool is_conormal;
+ real_t distance_squared;
+ };
Vector<Vector3> points;
Vector<Face> faces;
@@ -143,7 +154,7 @@ struct CSGBrushOperation {
OAHashMap<VertexKey, int, VertexKeyHash> snap_cache;
float vertex_snap = 0.0;
- inline void _add_distance(List<real_t> &r_intersectionsA, List<real_t> &r_intersectionsB, bool p_from_B, real_t p_distance) const;
+ inline void _add_distance(List<IntersectionDistance> &r_intersectionsA, List<IntersectionDistance> &r_intersectionsB, bool p_from_B, real_t p_distance, bool p_is_conormal) const;
inline bool _bvh_inside(FaceBVH *facebvhptr, int p_max_depth, int p_bvh_first, int p_face_idx) const;
inline int _create_bvh(FaceBVH *facebvhptr, FaceBVH **facebvhptrptr, int p_from, int p_size, int p_depth, int &r_max_depth, int &r_max_alloc);
diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp
index afb8e62eea..ba0d49c993 100644
--- a/modules/csg/csg_shape.cpp
+++ b/modules/csg/csg_shape.cpp
@@ -653,7 +653,7 @@ void CSGShape3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_meshes"), &CSGShape3D::get_meshes);
ADD_PROPERTY(PropertyInfo(Variant::INT, "operation", PROPERTY_HINT_ENUM, "Union,Intersection,Subtraction"), "set_operation", "get_operation");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "snap", PROPERTY_HINT_RANGE, "0.0001,1,0.001,suffix:m"), "set_snap", "get_snap");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "snap", PROPERTY_HINT_RANGE, "0.000001,1,0.000001,suffix:m"), "set_snap", "get_snap");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "calculate_tangents"), "set_calculate_tangents", "is_calculating_tangents");
ADD_GROUP("Collision", "collision_");
diff --git a/modules/csg/doc_classes/CSGShape3D.xml b/modules/csg/doc_classes/CSGShape3D.xml
index e92bb05b51..cae30ed446 100644
--- a/modules/csg/doc_classes/CSGShape3D.xml
+++ b/modules/csg/doc_classes/CSGShape3D.xml
@@ -15,14 +15,14 @@
<return type="bool" />
<param index="0" name="layer_number" type="int" />
<description>
- Returns whether or not the specified layer of the [member collision_layer] is enabled, given a [code]layer_number[/code] between 1 and 32.
+ Returns whether or not the specified layer of the [member collision_layer] is enabled, given a [param layer_number] between 1 and 32.
</description>
</method>
<method name="get_collision_mask_value" qualifiers="const">
<return type="bool" />
<param index="0" name="layer_number" type="int" />
<description>
- Returns whether or not the specified layer of the [member collision_mask] is enabled, given a [code]layer_number[/code] between 1 and 32.
+ Returns whether or not the specified layer of the [member collision_mask] is enabled, given a [param layer_number] between 1 and 32.
</description>
</method>
<method name="get_meshes" qualifiers="const">
@@ -42,7 +42,7 @@
<param index="0" name="layer_number" type="int" />
<param index="1" name="value" type="bool" />
<description>
- Based on [code]value[/code], enables or disables the specified layer in the [member collision_layer], given a [code]layer_number[/code] between 1 and 32.
+ Based on [param value], enables or disables the specified layer in the [member collision_layer], given a [param layer_number] between 1 and 32.
</description>
</method>
<method name="set_collision_mask_value">
@@ -50,7 +50,7 @@
<param index="0" name="layer_number" type="int" />
<param index="1" name="value" type="bool" />
<description>
- Based on [code]value[/code], enables or disables the specified layer in the [member collision_mask], given a [code]layer_number[/code] between 1 and 32.
+ Based on [param value], enables or disables the specified layer in the [member collision_mask], given a [param layer_number] between 1 and 32.
</description>
</method>
</methods>
@@ -73,7 +73,7 @@
The operation that is performed on this shape. This is ignored for the first CSG child node as the operation is between this node and the previous child of this nodes parent.
</member>
<member name="snap" type="float" setter="set_snap" getter="get_snap" default="0.001">
- Snap makes the mesh snap to a given distance so that the faces of two meshes can be perfectly aligned. A lower value results in greater precision but may be harder to adjust.
+ Snap makes the mesh vertices snap to a given distance so that the faces of two meshes can be perfectly aligned. A lower value results in greater precision but may be harder to adjust.
</member>
<member name="use_collision" type="bool" setter="set_use_collision" getter="is_using_collision" default="false">
Adds a collision shape to the physics engine for our CSG shape. This will always act like a static body. Note that the collision shape is still active even if the CSG shape itself is hidden. See also [member collision_mask] and [member collision_priority].
diff --git a/modules/enet/doc_classes/ENetConnection.xml b/modules/enet/doc_classes/ENetConnection.xml
index 365d12bb7a..3c1f559b9f 100644
--- a/modules/enet/doc_classes/ENetConnection.xml
+++ b/modules/enet/doc_classes/ENetConnection.xml
@@ -24,7 +24,7 @@
<param index="1" name="packet" type="PackedByteArray" />
<param index="2" name="flags" type="int" />
<description>
- Queues a [code]packet[/code] to be sent to all peers associated with the host over the specified [code]channel[/code]. See [ENetPacketPeer] [code]FLAG_*[/code] constants for available packet flags.
+ Queues a [param packet] to be sent to all peers associated with the host over the specified [param channel]. See [ENetPacketPeer] [code]FLAG_*[/code] constants for available packet flags.
</description>
</method>
<method name="channel_limit">
@@ -50,7 +50,7 @@
<param index="2" name="channels" type="int" default="0" />
<param index="3" name="data" type="int" default="0" />
<description>
- Initiates a connection to a foreign [code]address[/code] using the specified [code]port[/code] and allocating the requested [code]channels[/code]. Optional [code]data[/code] can be passed during connection in the form of a 32 bit integer.
+ Initiates a connection to a foreign [param address] using the specified [param port] and allocating the requested [param channels]. Optional [param data] can be passed during connection in the form of a 32 bit integer.
[b]Note:[/b] You must call either [method create_host] or [method create_host_bound] before calling this method.
</description>
</method>
@@ -61,7 +61,7 @@
<param index="2" name="in_bandwidth" type="int" default="0" />
<param index="3" name="out_bandwidth" type="int" default="0" />
<description>
- Create an ENetHost that will allow up to [code]max_peers[/code] connected peers, each allocating up to [code]max_channels[/code] channels, optionally limiting bandwidth to [code]in_bandwidth[/code] and [code]out_bandwidth[/code].
+ Create an ENetHost that will allow up to [param max_peers] connected peers, each allocating up to [param max_channels] channels, optionally limiting bandwidth to [param in_bandwidth] and [param out_bandwidth].
</description>
</method>
<method name="create_host_bound">
@@ -73,7 +73,7 @@
<param index="4" name="in_bandwidth" type="int" default="0" />
<param index="5" name="out_bandwidth" type="int" default="0" />
<description>
- Create an ENetHost like [method create_host] which is also bound to the given [code]bind_address[/code] and [code]bind_port[/code].
+ Create an ENetHost like [method create_host] which is also bound to the given [param bind_address] and [param bind_port].
</description>
</method>
<method name="destroy">
@@ -87,7 +87,7 @@
<param index="0" name="hostname" type="String" />
<param index="1" name="client_options" type="TLSOptions" default="null" />
<description>
- Configure this ENetHost to use the custom Godot extension allowing DTLS encryption for ENet clients. Call this before [method connect_to_host] to have ENet connect using DTLS validating the server certificate against [code]hostname[/code]. You can pass the optional [param client_options] parameter to customize the trusted certification authorities, or disable the common name verification. See [method TLSOptions.client] and [method TLSOptions.client_unsafe].
+ Configure this ENetHost to use the custom Godot extension allowing DTLS encryption for ENet clients. Call this before [method connect_to_host] to have ENet connect using DTLS validating the server certificate against [param hostname]. You can pass the optional [param client_options] parameter to customize the trusted certification authorities, or disable the common name verification. See [method TLSOptions.client] and [method TLSOptions.client_unsafe].
</description>
</method>
<method name="dtls_server_setup">
diff --git a/modules/enet/doc_classes/ENetMultiplayerPeer.xml b/modules/enet/doc_classes/ENetMultiplayerPeer.xml
index 0e81244a1c..646cf37b55 100644
--- a/modules/enet/doc_classes/ENetMultiplayerPeer.xml
+++ b/modules/enet/doc_classes/ENetMultiplayerPeer.xml
@@ -17,8 +17,8 @@
<param index="0" name="peer_id" type="int" />
<param index="1" name="host" type="ENetConnection" />
<description>
- Add a new remote peer with the given [code]peer_id[/code] connected to the given [code]host[/code].
- [b]Note:[/b] The [code]host[/code] must have exactly one peer in the [constant ENetPacketPeer.STATE_CONNECTED] state.
+ Add a new remote peer with the given [param peer_id] connected to the given [param host].
+ [b]Note:[/b] The [param host] must have exactly one peer in the [constant ENetPacketPeer.STATE_CONNECTED] state.
</description>
</method>
<method name="create_client">
@@ -30,14 +30,14 @@
<param index="4" name="out_bandwidth" type="int" default="0" />
<param index="5" name="local_port" type="int" default="0" />
<description>
- Create client that connects to a server at [code]address[/code] using specified [code]port[/code]. The given address needs to be either a fully qualified domain name (e.g. [code]"www.example.com"[/code]) or an IP address in IPv4 or IPv6 format (e.g. [code]"192.168.1.1"[/code]). The [code]port[/code] is the port the server is listening on. The [code]channel_count[/code] parameter can be used to specify the number of ENet channels allocated for the connection. The [code]in_bandwidth[/code] and [code]out_bandwidth[/code] parameters can be used to limit the incoming and outgoing bandwidth to the given number of bytes per second. The default of 0 means unlimited bandwidth. Note that ENet will strategically drop packets on specific sides of a connection between peers to ensure the peer's bandwidth is not overwhelmed. The bandwidth parameters also determine the window size of a connection which limits the amount of reliable packets that may be in transit at any given time. Returns [constant OK] if a client was created, [constant ERR_ALREADY_IN_USE] if this ENetMultiplayerPeer instance already has an open connection (in which case you need to call [method MultiplayerPeer.close] first) or [constant ERR_CANT_CREATE] if the client could not be created. If [code]local_port[/code] is specified, the client will also listen to the given port; this is useful for some NAT traversal techniques.
+ Create client that connects to a server at [param address] using specified [param port]. The given address needs to be either a fully qualified domain name (e.g. [code]"www.example.com"[/code]) or an IP address in IPv4 or IPv6 format (e.g. [code]"192.168.1.1"[/code]). The [param port] is the port the server is listening on. The [param channel_count] parameter can be used to specify the number of ENet channels allocated for the connection. The [param in_bandwidth] and [param out_bandwidth] parameters can be used to limit the incoming and outgoing bandwidth to the given number of bytes per second. The default of 0 means unlimited bandwidth. Note that ENet will strategically drop packets on specific sides of a connection between peers to ensure the peer's bandwidth is not overwhelmed. The bandwidth parameters also determine the window size of a connection which limits the amount of reliable packets that may be in transit at any given time. Returns [constant OK] if a client was created, [constant ERR_ALREADY_IN_USE] if this ENetMultiplayerPeer instance already has an open connection (in which case you need to call [method MultiplayerPeer.close] first) or [constant ERR_CANT_CREATE] if the client could not be created. If [param local_port] is specified, the client will also listen to the given port; this is useful for some NAT traversal techniques.
</description>
</method>
<method name="create_mesh">
<return type="int" enum="Error" />
<param index="0" name="unique_id" type="int" />
<description>
- Initialize this [MultiplayerPeer] in mesh mode. The provided [code]unique_id[/code] will be used as the local peer network unique ID once assigned as the [member MultiplayerAPI.multiplayer_peer]. In the mesh configuration you will need to set up each new peer manually using [ENetConnection] before calling [method add_mesh_peer]. While this technique is more advanced, it allows for better control over the connection process (e.g. when dealing with NAT punch-through) and for better distribution of the network load (which would otherwise be more taxing on the server).
+ Initialize this [MultiplayerPeer] in mesh mode. The provided [param unique_id] will be used as the local peer network unique ID once assigned as the [member MultiplayerAPI.multiplayer_peer]. In the mesh configuration you will need to set up each new peer manually using [ENetConnection] before calling [method add_mesh_peer]. While this technique is more advanced, it allows for better control over the connection process (e.g. when dealing with NAT punch-through) and for better distribution of the network load (which would otherwise be more taxing on the server).
</description>
</method>
<method name="create_server">
@@ -48,14 +48,14 @@
<param index="3" name="in_bandwidth" type="int" default="0" />
<param index="4" name="out_bandwidth" type="int" default="0" />
<description>
- Create server that listens to connections via [code]port[/code]. The port needs to be an available, unused port between 0 and 65535. Note that ports below 1024 are privileged and may require elevated permissions depending on the platform. To change the interface the server listens on, use [method set_bind_ip]. The default IP is the wildcard [code]"*"[/code], which listens on all available interfaces. [code]max_clients[/code] is the maximum number of clients that are allowed at once, any number up to 4095 may be used, although the achievable number of simultaneous clients may be far lower and depends on the application. For additional details on the bandwidth parameters, see [method create_client]. Returns [constant OK] if a server was created, [constant ERR_ALREADY_IN_USE] if this ENetMultiplayerPeer instance already has an open connection (in which case you need to call [method MultiplayerPeer.close] first) or [constant ERR_CANT_CREATE] if the server could not be created.
+ Create server that listens to connections via [param port]. The port needs to be an available, unused port between 0 and 65535. Note that ports below 1024 are privileged and may require elevated permissions depending on the platform. To change the interface the server listens on, use [method set_bind_ip]. The default IP is the wildcard [code]"*"[/code], which listens on all available interfaces. [param max_clients] is the maximum number of clients that are allowed at once, any number up to 4095 may be used, although the achievable number of simultaneous clients may be far lower and depends on the application. For additional details on the bandwidth parameters, see [method create_client]. Returns [constant OK] if a server was created, [constant ERR_ALREADY_IN_USE] if this ENetMultiplayerPeer instance already has an open connection (in which case you need to call [method MultiplayerPeer.close] first) or [constant ERR_CANT_CREATE] if the server could not be created.
</description>
</method>
<method name="get_peer" qualifiers="const">
<return type="ENetPacketPeer" />
<param index="0" name="id" type="int" />
<description>
- Returns the [ENetPacketPeer] associated to the given [code]id[/code].
+ Returns the [ENetPacketPeer] associated to the given [param id].
</description>
</method>
<method name="set_bind_ip">
diff --git a/modules/enet/doc_classes/ENetPacketPeer.xml b/modules/enet/doc_classes/ENetPacketPeer.xml
index 9c7ee3c17d..0e531b0e89 100644
--- a/modules/enet/doc_classes/ENetPacketPeer.xml
+++ b/modules/enet/doc_classes/ENetPacketPeer.xml
@@ -40,7 +40,7 @@
<return type="float" />
<param index="0" name="statistic" type="int" enum="ENetPacketPeer.PeerStatistic" />
<description>
- Returns the requested [code]statistic[/code] for this peer. See [enum PeerStatistic].
+ Returns the requested [param statistic] for this peer. See [enum PeerStatistic].
</description>
</method>
<method name="is_active" qualifiers="const">
@@ -80,7 +80,7 @@
<return type="void" />
<param index="0" name="ping_interval" type="int" />
<description>
- Sets the [code]ping_interval[/code] in milliseconds at which pings will be sent to a peer. Pings are used both to monitor the liveness of the connection and also to dynamically adjust the throttle during periods of low traffic so that the throttle has reasonable responsiveness during traffic spikes. The default ping interval is [code]500[/code] milliseconds.
+ Sets the [param ping_interval] in milliseconds at which pings will be sent to a peer. Pings are used both to monitor the liveness of the connection and also to dynamically adjust the throttle during periods of low traffic so that the throttle has reasonable responsiveness during traffic spikes. The default ping interval is [code]500[/code] milliseconds.
</description>
</method>
<method name="reset">
@@ -95,7 +95,7 @@
<param index="1" name="packet" type="PackedByteArray" />
<param index="2" name="flags" type="int" />
<description>
- Queues a [code]packet[/code] to be sent over the specified [code]channel[/code]. See [code]FLAG_*[/code] constants for available packet flags.
+ Queues a [param packet] to be sent over the specified [param channel]. See [code]FLAG_*[/code] constants for available packet flags.
</description>
</method>
<method name="set_timeout">
@@ -105,7 +105,7 @@
<param index="2" name="timeout_max" type="int" />
<description>
Sets the timeout parameters for a peer. The timeout parameters control how and when a peer will timeout from a failure to acknowledge reliable traffic. Timeout values are expressed in milliseconds.
- The [code]timeout_limit[/code] is a factor that, multiplied by a value based on the average round trip time, will determine the timeout limit for a reliable packet. When that limit is reached, the timeout will be doubled, and the peer will be disconnected if that limit has reached [code]timeout_min[/code]. The [code]timeout_max[/code] parameter, on the other hand, defines a fixed timeout for which any packet must be acknowledged or the peer will be dropped.
+ The [param timeout] is a factor that, multiplied by a value based on the average round trip time, will determine the timeout limit for a reliable packet. When that limit is reached, the timeout will be doubled, and the peer will be disconnected if that limit has reached [param timeout_min]. The [param timeout_max] parameter, on the other hand, defines a fixed timeout for which any packet must be acknowledged or the peer will be dropped.
</description>
</method>
<method name="throttle_configure">
@@ -115,7 +115,7 @@
<param index="2" name="deceleration" type="int" />
<description>
Configures throttle parameter for a peer.
- Unreliable packets are dropped by ENet in response to the varying conditions of the Internet connection to the peer. The throttle represents a probability that an unreliable packet should not be dropped and thus sent by ENet to the peer. By measuring fluctuations in round trip times of reliable packets over the specified [code]interval[/code], ENet will either increase the probability by the amount specified in the [code]acceleration[/code] parameter, or decrease it by the amount specified in the [code]deceleration[/code] parameter (both are ratios to [constant PACKET_THROTTLE_SCALE]).
+ Unreliable packets are dropped by ENet in response to the varying conditions of the Internet connection to the peer. The throttle represents a probability that an unreliable packet should not be dropped and thus sent by ENet to the peer. By measuring fluctuations in round trip times of reliable packets over the specified [param interval], ENet will either increase the probability by the amount specified in the [param acceleration] parameter, or decrease it by the amount specified in the [param deceleration] parameter (both are ratios to [constant PACKET_THROTTLE_SCALE]).
When the throttle has a value of [constant PACKET_THROTTLE_SCALE], no unreliable packets are dropped by ENet, and so 100% of all unreliable packets will be sent.
When the throttle has a value of [code]0[/code], all unreliable packets are dropped by ENet, and so 0% of all unreliable packets will be sent.
Intermediate values for the throttle represent intermediate probabilities between 0% and 100% of unreliable packets being sent. The bandwidth limits of the local and foreign hosts are taken into account to determine a sensible limit for the throttle probability above which it should not raise even in the best of conditions.
diff --git a/modules/etcpak/image_compress_etcpak.cpp b/modules/etcpak/image_compress_etcpak.cpp
index 16a59d3880..14cce2686c 100644
--- a/modules/etcpak/image_compress_etcpak.cpp
+++ b/modules/etcpak/image_compress_etcpak.cpp
@@ -66,7 +66,7 @@ EtcpakType _determine_dxt_type(Image::UsedChannels p_channels) {
case Image::USED_CHANNELS_RG:
return EtcpakType::ETCPAK_TYPE_DXT5_RA_AS_RG;
case Image::USED_CHANNELS_RGB:
- return EtcpakType::ETCPAK_TYPE_DXT5;
+ return EtcpakType::ETCPAK_TYPE_DXT1;
case Image::USED_CHANNELS_RGBA:
return EtcpakType::ETCPAK_TYPE_DXT5;
default:
diff --git a/modules/freetype/SCsub b/modules/freetype/SCsub
index 0b86bc569f..421f200f1a 100644
--- a/modules/freetype/SCsub
+++ b/modules/freetype/SCsub
@@ -59,25 +59,7 @@ if env["builtin_freetype"]:
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
if env["brotli"]:
- thirdparty_brotli_dir = "#thirdparty/brotli/"
- thirdparty_brotli_sources = [
- "common/constants.c",
- "common/context.c",
- "common/dictionary.c",
- "common/platform.c",
- "common/shared_dictionary.c",
- "common/transform.c",
- "dec/bit_reader.c",
- "dec/decode.c",
- "dec/huffman.c",
- "dec/state.c",
- ]
- thirdparty_sources += [thirdparty_brotli_dir + file for file in thirdparty_brotli_sources]
env_freetype.Append(CPPDEFINES=["FT_CONFIG_OPTION_USE_BROTLI"])
- env_freetype.Prepend(CPPPATH=[thirdparty_brotli_dir + "include"])
-
- if env.get("use_ubsan") or env.get("use_asan") or env.get("use_tsan") or env.get("use_lsan") or env.get("use_msan"):
- env_freetype.Append(CPPDEFINES=["BROTLI_BUILD_PORTABLE"])
if env["platform"] == "uwp":
# Include header for UWP to fix build issues
diff --git a/modules/freetype/config.py b/modules/freetype/config.py
index c0586d5536..d22f9454ed 100644
--- a/modules/freetype/config.py
+++ b/modules/freetype/config.py
@@ -2,13 +2,5 @@ def can_build(env, platform):
return True
-def get_opts(platform):
- from SCons.Variables import BoolVariable
-
- return [
- BoolVariable("brotli", "Enable Brotli decompressor for WOFF2 fonts support", True),
- ]
-
-
def configure(env):
pass
diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml
index 1234abc62e..0e51230cd0 100644
--- a/modules/gdscript/doc_classes/@GDScript.xml
+++ b/modules/gdscript/doc_classes/@GDScript.xml
@@ -139,7 +139,7 @@
print(is_instance_of(a, MyClass))
print(is_instance_of(a, MyClass.InnerClass))
[/codeblock]
- [b]Note:[/b] If [param value] and/or [param type] are freed objects (see [method @GlobalScope.is_instance_valid]), or [param type] is not one of the above options, this method will raise an runtime error.
+ [b]Note:[/b] If [param value] and/or [param type] are freed objects (see [method @GlobalScope.is_instance_valid]), or [param type] is not one of the above options, this method will raise a runtime error.
See also [method @GlobalScope.typeof], [method type_exists], [method Array.is_same_typed] (and other [Array] methods).
</description>
</method>
@@ -227,8 +227,8 @@
To iterate over an [Array] backwards, use:
[codeblock]
var array = [3, 6, 9]
- for i in range(array.size(), 0, -1):
- print(array[i - 1])
+ for i in range(array.size() - 1, -1, -1):
+ print(array[i])
[/codeblock]
Output:
[codeblock]
@@ -609,7 +609,7 @@
<param index="3" name="transfer_channel" type="int" default="0" />
<description>
Mark the following method for remote procedure calls. See [url=$DOCS_URL/tutorials/networking/high_level_multiplayer.html]High-level multiplayer[/url].
- The order of [code]mode[/code], [code]sync[/code] and [code]transfer_mode[/code] does not matter and all arguments can be omitted, but [code]transfer_channel[/code] always has to be the last argument. The accepted values for [code]mode[/code] are [code]"any_peer"[/code] or [code]"authority"[/code], for [code]sync[/code] are [code]"call_remote"[/code] or [code]"call_local"[/code] and for [code]transfer_mode[/code] are [code]"unreliable"[/code], [code]"unreliable_ordered"[/code] or [code]"reliable"[/code].
+ The order of [param mode], [param sync] and [param transfer_mode] does not matter and all arguments can be omitted, but [param transfer_channel] always has to be the last argument. The accepted values for [param mode] are [code]"any_peer"[/code] or [code]"authority"[/code], for [param sync] are [code]"call_remote"[/code] or [code]"call_local"[/code] and for [param transfer_mode] are [code]"unreliable"[/code], [code]"unreliable_ordered"[/code] or [code]"reliable"[/code].
[codeblock]
@rpc
func fn(): pass
@@ -622,6 +622,12 @@
[/codeblock]
</description>
</annotation>
+ <annotation name="@static_unload">
+ <return type="void" />
+ <description>
+ Make a script with static variables to not persist after all references are lost. If the script is loaded again the static variables will revert to their default values.
+ </description>
+ </annotation>
<annotation name="@tool">
<return type="void" />
<description>
diff --git a/modules/gdscript/editor/gdscript_docgen.cpp b/modules/gdscript/editor/gdscript_docgen.cpp
new file mode 100644
index 0000000000..451af996ec
--- /dev/null
+++ b/modules/gdscript/editor/gdscript_docgen.cpp
@@ -0,0 +1,271 @@
+/**************************************************************************/
+/* gdscript_docgen.cpp */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/**************************************************************************/
+
+#include "gdscript_docgen.h"
+#include "../gdscript.h"
+
+using GDP = GDScriptParser;
+using GDType = GDP::DataType;
+
+static String _get_script_path(const String &p_path) {
+ return vformat(R"("%s")", p_path.get_slice("://", 1));
+}
+
+static String _get_class_name(const GDP::ClassNode &p_class) {
+ const GDP::ClassNode *curr_class = &p_class;
+ if (!curr_class->identifier) { // All inner classes have a identifier, so this is the outer class
+ return _get_script_path(curr_class->fqcn);
+ }
+
+ String full_name = curr_class->identifier->name;
+ while (curr_class->outer) {
+ curr_class = curr_class->outer;
+ if (!curr_class->identifier) { // All inner classes have a identifier, so this is the outer class
+ return vformat("%s.%s", _get_script_path(curr_class->fqcn), full_name);
+ }
+ full_name = vformat("%s.%s", curr_class->identifier->name, full_name);
+ }
+ return full_name;
+}
+
+static PropertyInfo _property_info_from_datatype(const GDType &p_type) {
+ PropertyInfo pi;
+ pi.type = p_type.builtin_type;
+ if (p_type.kind == GDType::CLASS) {
+ pi.class_name = _get_class_name(*p_type.class_type);
+ } else if (p_type.kind == GDType::ENUM && p_type.enum_type != StringName()) {
+ pi.type = Variant::INT; // Only int types are recognized as enums by the EditorHelp
+ pi.usage |= PROPERTY_USAGE_CLASS_IS_ENUM;
+ // Replace :: from enum's use of fully qualified class names with regular .
+ pi.class_name = String(p_type.native_type).replace("::", ".");
+ } else if (p_type.kind == GDType::NATIVE) {
+ pi.class_name = p_type.native_type;
+ }
+ return pi;
+}
+
+void GDScriptDocGen::generate_docs(GDScript *p_script, const GDP::ClassNode *p_class) {
+ p_script->_clear_doc();
+
+ DocData::ClassDoc &doc = p_script->doc;
+
+ doc.script_path = _get_script_path(p_script->get_script_path());
+ if (p_script->name.is_empty()) {
+ doc.name = doc.script_path;
+ } else {
+ doc.name = p_script->name;
+ }
+
+ if (p_script->_owner) {
+ doc.name = p_script->_owner->doc.name + "." + doc.name;
+ doc.script_path = doc.script_path + "." + doc.name;
+ }
+
+ doc.is_script_doc = true;
+
+ if (p_script->base.is_valid() && p_script->base->is_valid()) {
+ if (!p_script->base->doc.name.is_empty()) {
+ doc.inherits = p_script->base->doc.name;
+ } else {
+ doc.inherits = p_script->base->get_instance_base_type();
+ }
+ } else if (p_script->native.is_valid()) {
+ doc.inherits = p_script->native->get_name();
+ }
+
+ doc.brief_description = p_class->doc_brief_description;
+ doc.description = p_class->doc_description;
+ for (const Pair<String, String> &p : p_class->doc_tutorials) {
+ DocData::TutorialDoc td;
+ td.title = p.first;
+ td.link = p.second;
+ doc.tutorials.append(td);
+ }
+
+ for (const GDP::ClassNode::Member &member : p_class->members) {
+ switch (member.type) {
+ case GDP::ClassNode::Member::CLASS: {
+ const GDP::ClassNode *inner_class = member.m_class;
+ const StringName &class_name = inner_class->identifier->name;
+
+ p_script->member_lines[class_name] = inner_class->start_line;
+
+ // Recursively generate inner class docs
+ // Needs inner GDScripts to exist: previously generated in GDScriptCompiler::make_scripts()
+ GDScriptDocGen::generate_docs(*p_script->subclasses[class_name], inner_class);
+ } break;
+
+ case GDP::ClassNode::Member::CONSTANT: {
+ const GDP::ConstantNode *m_const = member.constant;
+ const StringName &const_name = member.constant->identifier->name;
+
+ p_script->member_lines[const_name] = m_const->start_line;
+
+ DocData::ConstantDoc const_doc;
+ DocData::constant_doc_from_variant(const_doc, const_name, m_const->initializer->reduced_value, m_const->doc_description);
+ doc.constants.push_back(const_doc);
+ } break;
+
+ case GDP::ClassNode::Member::FUNCTION: {
+ const GDP::FunctionNode *m_func = member.function;
+ const StringName &func_name = m_func->identifier->name;
+
+ p_script->member_lines[func_name] = m_func->start_line;
+
+ MethodInfo mi;
+ mi.name = func_name;
+
+ if (m_func->return_type) {
+ mi.return_val = _property_info_from_datatype(m_func->return_type->get_datatype());
+ }
+ for (const GDScriptParser::ParameterNode *p : m_func->parameters) {
+ PropertyInfo pi = _property_info_from_datatype(p->get_datatype());
+ pi.name = p->identifier->name;
+ mi.arguments.push_back(pi);
+ }
+
+ DocData::MethodDoc method_doc;
+ DocData::method_doc_from_methodinfo(method_doc, mi, m_func->doc_description);
+ doc.methods.push_back(method_doc);
+ } break;
+
+ case GDP::ClassNode::Member::SIGNAL: {
+ const GDP::SignalNode *m_signal = member.signal;
+ const StringName &signal_name = m_signal->identifier->name;
+
+ p_script->member_lines[signal_name] = m_signal->start_line;
+
+ MethodInfo mi;
+ mi.name = signal_name;
+ for (const GDScriptParser::ParameterNode *p : m_signal->parameters) {
+ PropertyInfo pi = _property_info_from_datatype(p->get_datatype());
+ pi.name = p->identifier->name;
+ mi.arguments.push_back(pi);
+ }
+
+ DocData::MethodDoc signal_doc;
+ DocData::signal_doc_from_methodinfo(signal_doc, mi, m_signal->doc_description);
+ doc.signals.push_back(signal_doc);
+ } break;
+
+ case GDP::ClassNode::Member::VARIABLE: {
+ const GDP::VariableNode *m_var = member.variable;
+ const StringName &var_name = m_var->identifier->name;
+
+ p_script->member_lines[var_name] = m_var->start_line;
+
+ DocData::PropertyDoc prop_doc;
+
+ prop_doc.name = var_name;
+ prop_doc.description = m_var->doc_description;
+
+ GDType dt = m_var->get_datatype();
+ switch (dt.kind) {
+ case GDType::CLASS:
+ prop_doc.type = _get_class_name(*dt.class_type);
+ break;
+ case GDType::VARIANT:
+ prop_doc.type = "Variant";
+ break;
+ case GDType::ENUM:
+ prop_doc.type = Variant::get_type_name(dt.builtin_type);
+ // Replace :: from enum's use of fully qualified class names with regular .
+ prop_doc.enumeration = String(dt.native_type).replace("::", ".");
+ break;
+ case GDType::NATIVE:;
+ prop_doc.type = dt.native_type;
+ break;
+ case GDType::BUILTIN:
+ prop_doc.type = Variant::get_type_name(dt.builtin_type);
+ break;
+ default:
+ // SCRIPT: can be preload()'d and perhaps used as types directly?
+ // RESOLVING & UNRESOLVED should never happen since docgen requires analyzing w/o errors
+ break;
+ }
+
+ if (m_var->property == GDP::VariableNode::PROP_SETGET) {
+ if (m_var->setter_pointer != nullptr) {
+ prop_doc.setter = m_var->setter_pointer->name;
+ }
+ if (m_var->getter_pointer != nullptr) {
+ prop_doc.getter = m_var->getter_pointer->name;
+ }
+ }
+
+ if (m_var->initializer && m_var->initializer->is_constant) {
+ prop_doc.default_value = m_var->initializer->reduced_value.get_construct_string().replace("\n", "");
+ }
+
+ prop_doc.overridden = false;
+
+ doc.properties.push_back(prop_doc);
+ } break;
+
+ case GDP::ClassNode::Member::ENUM: {
+ const GDP::EnumNode *m_enum = member.m_enum;
+ StringName name = m_enum->identifier->name;
+
+ p_script->member_lines[name] = m_enum->start_line;
+
+ for (const GDP::EnumNode::Value &val : m_enum->values) {
+ DocData::ConstantDoc const_doc;
+ const_doc.name = val.identifier->name;
+ const_doc.value = String(Variant(val.value));
+ const_doc.description = val.doc_description;
+ const_doc.enumeration = name;
+
+ doc.enums[const_doc.name] = const_doc.description;
+ doc.constants.push_back(const_doc);
+ }
+
+ } break;
+
+ case GDP::ClassNode::Member::ENUM_VALUE: {
+ const GDP::EnumNode::Value &m_enum_val = member.enum_value;
+ const StringName &name = m_enum_val.identifier->name;
+
+ p_script->member_lines[name] = m_enum_val.identifier->start_line;
+
+ DocData::ConstantDoc constant_doc;
+ constant_doc.enumeration = "@unnamed_enums";
+ DocData::constant_doc_from_variant(constant_doc, name, m_enum_val.value, m_enum_val.doc_description);
+ doc.constants.push_back(constant_doc);
+ } break;
+ case GDP::ClassNode::Member::GROUP:
+ case GDP::ClassNode::Member::UNDEFINED:
+ default:
+ break;
+ }
+ }
+
+ // Add doc to the outer-most class.
+ p_script->_add_doc(doc);
+}
diff --git a/modules/gdscript/editor/gdscript_docgen.h b/modules/gdscript/editor/gdscript_docgen.h
new file mode 100644
index 0000000000..bb3647196a
--- /dev/null
+++ b/modules/gdscript/editor/gdscript_docgen.h
@@ -0,0 +1,42 @@
+/**************************************************************************/
+/* gdscript_docgen.h */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/**************************************************************************/
+
+#ifndef GDSCRIPT_DOCGEN_H
+#define GDSCRIPT_DOCGEN_H
+
+#include "../gdscript_parser.h"
+#include "core/doc_data.h"
+
+class GDScriptDocGen {
+public:
+ static void generate_docs(GDScript *p_script, const GDScriptParser::ClassNode *p_class);
+};
+
+#endif // GDSCRIPT_DOCGEN_H
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp
index 2646c1ad15..d0790aba25 100644
--- a/modules/gdscript/gdscript.cpp
+++ b/modules/gdscript/gdscript.cpp
@@ -52,6 +52,7 @@
#ifdef TOOLS_ENABLED
#include "editor/editor_paths.h"
+#include "editor/gdscript_docgen.h"
#endif
///////////////////////////
@@ -340,12 +341,11 @@ void GDScript::_get_script_property_list(List<PropertyInfo> *r_list, bool p_incl
r_list->push_back(E);
}
- props.clear();
-
if (!p_include_base) {
break;
}
+ props.clear();
sptr = sptr->_base;
}
}
@@ -461,9 +461,9 @@ void GDScript::_update_exports_values(HashMap<StringName, Variant> &values, List
}
void GDScript::_add_doc(const DocData::ClassDoc &p_inner_class) {
- if (_owner) {
+ if (_owner) { // Only the top-level class stores doc info
_owner->_add_doc(p_inner_class);
- } else {
+ } else { // Remove old docs, add new
for (int i = 0; i < docs.size(); i++) {
if (docs[i].name == p_inner_class.name) {
docs.remove_at(i);
@@ -478,167 +478,6 @@ void GDScript::_clear_doc() {
docs.clear();
doc = DocData::ClassDoc();
}
-
-void GDScript::_update_doc() {
- _clear_doc();
-
- doc.script_path = vformat(R"("%s")", get_script_path().get_slice("://", 1));
- if (!name.is_empty()) {
- doc.name = name;
- } else {
- doc.name = doc.script_path;
- }
-
- if (_owner) {
- doc.name = _owner->doc.name + "." + doc.name;
- doc.script_path = doc.script_path + "." + doc.name;
- }
-
- doc.is_script_doc = true;
-
- if (base.is_valid() && base->is_valid()) {
- if (!base->doc.name.is_empty()) {
- doc.inherits = base->doc.name;
- } else {
- doc.inherits = base->get_instance_base_type();
- }
- } else if (native.is_valid()) {
- doc.inherits = native->get_name();
- }
-
- doc.brief_description = doc_brief_description;
- doc.description = doc_description;
- doc.tutorials = doc_tutorials;
-
- for (const KeyValue<String, DocData::EnumDoc> &E : doc_enums) {
- if (!E.value.description.is_empty()) {
- doc.enums[E.key] = E.value.description;
- }
- }
-
- List<MethodInfo> methods;
- _get_script_method_list(&methods, false);
- for (int i = 0; i < methods.size(); i++) {
- // Ignore internal methods.
- if (methods[i].name[0] == '@') {
- continue;
- }
-
- DocData::MethodDoc method_doc;
- const String &class_name = methods[i].name;
- if (member_functions.has(class_name)) {
- GDScriptFunction *fn = member_functions[class_name];
-
- // Change class name if return type is script reference.
- GDScriptDataType return_type = fn->get_return_type();
- if (return_type.kind == GDScriptDataType::GDSCRIPT) {
- methods[i].return_val.class_name = _get_gdscript_reference_class_name(Object::cast_to<GDScript>(return_type.script_type));
- }
-
- // Change class name if argument is script reference.
- for (int j = 0; j < fn->get_argument_count(); j++) {
- GDScriptDataType arg_type = fn->get_argument_type(j);
- if (arg_type.kind == GDScriptDataType::GDSCRIPT) {
- methods[i].arguments[j].class_name = _get_gdscript_reference_class_name(Object::cast_to<GDScript>(arg_type.script_type));
- }
- }
- }
- if (doc_functions.has(methods[i].name)) {
- DocData::method_doc_from_methodinfo(method_doc, methods[i], doc_functions[methods[i].name]);
- } else {
- DocData::method_doc_from_methodinfo(method_doc, methods[i], String());
- }
- doc.methods.push_back(method_doc);
- }
-
- List<PropertyInfo> props;
- _get_script_property_list(&props, false);
- for (int i = 0; i < props.size(); i++) {
- if (props[i].usage & PROPERTY_USAGE_CATEGORY || props[i].usage & PROPERTY_USAGE_GROUP || props[i].usage & PROPERTY_USAGE_SUBGROUP) {
- continue;
- }
- ScriptMemberInfo scr_member_info;
- scr_member_info.propinfo = props[i];
- scr_member_info.propinfo.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
- if (member_indices.has(props[i].name)) {
- const MemberInfo &mi = member_indices[props[i].name];
- scr_member_info.setter = mi.setter;
- scr_member_info.getter = mi.getter;
- if (mi.data_type.kind == GDScriptDataType::GDSCRIPT) {
- scr_member_info.propinfo.class_name = _get_gdscript_reference_class_name(
- Object::cast_to<GDScript>(mi.data_type.script_type));
- }
- }
- if (member_default_values.has(props[i].name)) {
- scr_member_info.has_default_value = true;
- scr_member_info.default_value = member_default_values[props[i].name];
- }
- if (doc_variables.has(props[i].name)) {
- scr_member_info.doc_string = doc_variables[props[i].name];
- }
-
- DocData::PropertyDoc prop_doc;
- DocData::property_doc_from_scriptmemberinfo(prop_doc, scr_member_info);
- doc.properties.push_back(prop_doc);
- }
-
- List<MethodInfo> signals;
- _get_script_signal_list(&signals, false);
- for (int i = 0; i < signals.size(); i++) {
- DocData::MethodDoc signal_doc;
- if (doc_signals.has(signals[i].name)) {
- DocData::signal_doc_from_methodinfo(signal_doc, signals[i], doc_signals[signals[i].name]);
- } else {
- DocData::signal_doc_from_methodinfo(signal_doc, signals[i], String());
- }
- doc.signals.push_back(signal_doc);
- }
-
- for (const KeyValue<StringName, Variant> &E : constants) {
- if (subclasses.has(E.key)) {
- continue;
- }
-
- // Enums.
- bool is_enum = false;
- if (E.value.get_type() == Variant::DICTIONARY) {
- if (doc_enums.has(E.key)) {
- is_enum = true;
- for (int i = 0; i < doc_enums[E.key].values.size(); i++) {
- doc_enums[E.key].values.write[i].enumeration = E.key;
- doc.constants.push_back(doc_enums[E.key].values[i]);
- }
- }
- }
- if (!is_enum && doc_enums.has("@unnamed_enums")) {
- for (int i = 0; i < doc_enums["@unnamed_enums"].values.size(); i++) {
- if (E.key == doc_enums["@unnamed_enums"].values[i].name) {
- is_enum = true;
- DocData::ConstantDoc constant_doc;
- constant_doc.enumeration = "@unnamed_enums";
- DocData::constant_doc_from_variant(constant_doc, E.key, E.value, doc_enums["@unnamed_enums"].values[i].description);
- doc.constants.push_back(constant_doc);
- break;
- }
- }
- }
- if (!is_enum) {
- DocData::ConstantDoc constant_doc;
- String const_description;
- if (doc_constants.has(E.key)) {
- const_description = doc_constants[E.key];
- }
- DocData::constant_doc_from_variant(constant_doc, E.key, E.value, const_description);
- doc.constants.push_back(constant_doc);
- }
- }
-
- for (KeyValue<StringName, Ref<GDScript>> &E : subclasses) {
- E.value->_update_doc();
- }
-
- _add_doc(doc);
-}
#endif
bool GDScript::_update_exports(bool *r_err, bool p_recursive_call, PlaceHolderScriptInstance *p_instance_to_update) {
@@ -812,6 +651,49 @@ String GDScript::_get_debug_path() const {
}
}
+Error GDScript::_static_init() {
+ if (static_initializer) {
+ Callable::CallError call_err;
+ static_initializer->call(nullptr, nullptr, 0, call_err);
+ if (call_err.error != Callable::CallError::CALL_OK) {
+ return ERR_CANT_CREATE;
+ }
+ }
+ Error err = OK;
+ for (KeyValue<StringName, Ref<GDScript>> &inner : subclasses) {
+ err = inner.value->_static_init();
+ if (err) {
+ break;
+ }
+ }
+ return err;
+}
+
+#ifdef TOOLS_ENABLED
+
+void GDScript::_save_old_static_data() {
+ old_static_variables_indices = static_variables_indices;
+ old_static_variables = static_variables;
+ for (KeyValue<StringName, Ref<GDScript>> &inner : subclasses) {
+ inner.value->_save_old_static_data();
+ }
+}
+
+void GDScript::_restore_old_static_data() {
+ for (KeyValue<StringName, MemberInfo> &E : old_static_variables_indices) {
+ if (static_variables_indices.has(E.key)) {
+ static_variables.write[static_variables_indices[E.key].index] = old_static_variables[E.value.index];
+ }
+ }
+ old_static_variables_indices.clear();
+ old_static_variables.clear();
+ for (KeyValue<StringName, Ref<GDScript>> &inner : subclasses) {
+ inner.value->_restore_old_static_data();
+ }
+}
+
+#endif
+
Error GDScript::reload(bool p_keep_state) {
if (reloading) {
return OK;
@@ -857,6 +739,14 @@ Error GDScript::reload(bool p_keep_state) {
}
}
+ bool can_run = ScriptServer::is_scripting_enabled() || is_tool();
+
+#ifdef TOOLS_ENABLED
+ if (p_keep_state && can_run && is_valid()) {
+ _save_old_static_data();
+ }
+#endif
+
valid = false;
GDScriptParser parser;
Error err = parser.parse(source, path, false);
@@ -887,7 +777,7 @@ Error GDScript::reload(bool p_keep_state) {
return ERR_PARSE_ERROR;
}
- bool can_run = ScriptServer::is_scripting_enabled() || parser.is_tool();
+ can_run = ScriptServer::is_scripting_enabled() || parser.is_tool();
GDScriptCompiler compiler;
err = compiler.compile(&parser, this, p_keep_state);
@@ -905,6 +795,13 @@ Error GDScript::reload(bool p_keep_state) {
return err;
}
}
+
+#ifdef TOOLS_ENABLED
+ // Done after compilation because it needs the GDScript object's inner class GDScript objects,
+ // which are made by calling make_scripts() within compiler.compile() above.
+ GDScriptDocGen::generate_docs(this, parser.get_tree());
+#endif
+
#ifdef DEBUG_ENABLED
for (const GDScriptWarning &warning : parser.get_warnings()) {
if (EngineDebugger::is_active()) {
@@ -914,6 +811,19 @@ Error GDScript::reload(bool p_keep_state) {
}
#endif
+ if (can_run) {
+ err = _static_init();
+ if (err) {
+ return err;
+ }
+ }
+
+#ifdef TOOLS_ENABLED
+ if (can_run && p_keep_state) {
+ _restore_old_static_data();
+ }
+#endif
+
reloading = false;
return OK;
}
@@ -942,6 +852,10 @@ const Variant GDScript::get_rpc_config() const {
return rpc_config;
}
+void GDScript::unload_static() const {
+ GDScriptCache::remove_script(fully_qualified_name);
+}
+
Variant GDScript::callp(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
GDScript *top = this;
while (top) {
@@ -978,6 +892,19 @@ bool GDScript::_get(const StringName &p_name, Variant &r_ret) const {
return true;
}
}
+
+ {
+ HashMap<StringName, MemberInfo>::ConstIterator E = static_variables_indices.find(p_name);
+ if (E) {
+ if (E->value.getter) {
+ Callable::CallError ce;
+ r_ret = const_cast<GDScript *>(this)->callp(E->value.getter, nullptr, 0, ce);
+ return true;
+ }
+ r_ret = static_variables[E->value.index];
+ return true;
+ }
+ }
top = top->_base;
}
@@ -995,7 +922,32 @@ bool GDScript::_set(const StringName &p_name, const Variant &p_value) {
set_source_code(p_value);
reload();
} else {
- return false;
+ const GDScript *top = this;
+ while (top) {
+ HashMap<StringName, MemberInfo>::ConstIterator E = static_variables_indices.find(p_name);
+ if (E) {
+ const GDScript::MemberInfo *member = &E->value;
+ Variant value = p_value;
+ if (member->data_type.has_type && !member->data_type.is_type(value)) {
+ const Variant *args = &p_value;
+ Callable::CallError err;
+ Variant::construct(member->data_type.builtin_type, value, &args, 1, err);
+ if (err.error != Callable::CallError::CALL_OK || !member->data_type.is_type(value)) {
+ return false;
+ }
+ }
+ if (member->setter) {
+ const Variant *args = &value;
+ Callable::CallError err;
+ callp(member->setter, &args, 1, err);
+ return err.error == Callable::CallError::CALL_OK;
+ } else {
+ static_variables.write[member->index] = value;
+ return true;
+ }
+ }
+ top = top->_base;
+ }
}
return true;
@@ -1266,7 +1218,6 @@ void GDScript::_get_script_signal_list(List<MethodInfo> *r_list, bool p_include_
else if (base_cache.is_valid()) {
base_cache->get_script_signal_list(r_list);
}
-
#endif
}
@@ -1448,6 +1399,13 @@ void GDScript::clear(GDScript::ClearData *p_clear_data) {
E.value.data_type.script_type_ref = Ref<Script>();
}
+ for (KeyValue<StringName, GDScript::MemberInfo> &E : static_variables_indices) {
+ clear_data->scripts.insert(E.value.data_type.script_type_ref);
+ E.value.data_type.script_type_ref = Ref<Script>();
+ }
+ static_variables.clear();
+ static_variables_indices.clear();
+
if (implicit_initializer) {
clear_data->functions.insert(implicit_initializer);
implicit_initializer = nullptr;
@@ -1458,6 +1416,11 @@ void GDScript::clear(GDScript::ClearData *p_clear_data) {
implicit_ready = nullptr;
}
+ if (static_initializer) {
+ clear_data->functions.insert(static_initializer);
+ static_initializer = nullptr;
+ }
+
_save_orphaned_subclasses(clear_data);
#ifdef TOOLS_ENABLED
@@ -1512,10 +1475,6 @@ GDScript::~GDScript() {
GDScriptLanguage::get_singleton()->script_list.remove(&script_list);
}
-
- if (GDScriptCache::singleton) { // Cache may have been already destroyed at engine shutdown.
- GDScriptCache::remove_script(get_path());
- }
}
//////////////////////////////
@@ -2546,6 +2505,7 @@ GDScriptLanguage::GDScriptLanguage() {
ERR_FAIL_COND(singleton);
singleton = this;
strings._init = StaticCString::create("_init");
+ strings._static_init = StaticCString::create("_static_init");
strings._notification = StaticCString::create("_notification");
strings._set = StaticCString::create("_set");
strings._get = StaticCString::create("_get");
diff --git a/modules/gdscript/gdscript.h b/modules/gdscript/gdscript.h
index 0117ed40ab..60bd9eef53 100644
--- a/modules/gdscript/gdscript.h
+++ b/modules/gdscript/gdscript.h
@@ -83,6 +83,7 @@ class GDScript : public Script {
friend class GDScriptFunction;
friend class GDScriptAnalyzer;
friend class GDScriptCompiler;
+ friend class GDScriptDocGen;
friend class GDScriptLanguage;
friend struct GDScriptUtilityFunctionsDefinitions;
@@ -93,6 +94,8 @@ class GDScript : public Script {
HashSet<StringName> members; //members are just indices to the instantiated script.
HashMap<StringName, Variant> constants;
+ HashMap<StringName, MemberInfo> static_variables_indices;
+ Vector<Variant> static_variables;
HashMap<StringName, GDScriptFunction *> member_functions;
HashMap<StringName, MemberInfo> member_indices; //members are just indices to the instantiated script.
HashMap<StringName, Ref<GDScript>> subclasses;
@@ -101,6 +104,12 @@ class GDScript : public Script {
#ifdef TOOLS_ENABLED
+ // For static data storage during hot-reloading.
+ HashMap<StringName, MemberInfo> old_static_variables_indices;
+ Vector<Variant> old_static_variables;
+ void _save_old_static_data();
+ void _restore_old_static_data();
+
HashMap<StringName, int> member_lines;
HashMap<StringName, Variant> member_default_values;
List<PropertyInfo> members_cache;
@@ -113,16 +122,7 @@ class GDScript : public Script {
DocData::ClassDoc doc;
Vector<DocData::ClassDoc> docs;
- String doc_brief_description;
- String doc_description;
- Vector<DocData::TutorialDoc> doc_tutorials;
- HashMap<String, String> doc_functions;
- HashMap<String, String> doc_variables;
- HashMap<String, String> doc_constants;
- HashMap<String, String> doc_signals;
- HashMap<String, DocData::EnumDoc> doc_enums;
void _clear_doc();
- void _update_doc();
void _add_doc(const DocData::ClassDoc &p_inner_class);
#endif
@@ -131,6 +131,9 @@ class GDScript : public Script {
GDScriptFunction *implicit_initializer = nullptr;
GDScriptFunction *initializer = nullptr; //direct pointer to new , faster to locate
GDScriptFunction *implicit_ready = nullptr;
+ GDScriptFunction *static_initializer = nullptr;
+
+ Error _static_init();
int subclass_count = 0;
RBSet<Object *> instances;
@@ -276,6 +279,8 @@ public:
virtual const Variant get_rpc_config() const override;
+ void unload_static() const;
+
#ifdef TOOLS_ENABLED
virtual bool is_placeholder_fallback_enabled() const override { return placeholder_fallback_enabled; }
#endif
@@ -447,6 +452,7 @@ public:
struct {
StringName _init;
+ StringName _static_init;
StringName _notification;
StringName _set;
StringName _get;
diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp
index aa91f8fe8d..c8cdac3702 100644
--- a/modules/gdscript/gdscript_analyzer.cpp
+++ b/modules/gdscript/gdscript_analyzer.cpp
@@ -879,6 +879,8 @@ void GDScriptAnalyzer::resolve_class_member(GDScriptParser::ClassNode *p_class,
#endif
switch (member.type) {
case GDScriptParser::ClassNode::Member::VARIABLE: {
+ bool previous_static_context = static_context;
+ static_context = member.variable->is_static;
check_class_member_name_conflict(p_class, member.variable->identifier->name, member.variable);
member.variable->set_datatype(resolving_datatype);
resolve_variable(member.variable, false);
@@ -890,6 +892,7 @@ void GDScriptAnalyzer::resolve_class_member(GDScriptParser::ClassNode *p_class,
E->apply(parser, member.variable);
}
}
+ static_context = previous_static_context;
#ifdef DEBUG_ENABLED
if (member.variable->exported && member.variable->onready) {
parser->push_warning(member.variable, GDScriptWarning::ONREADY_WITH_EXPORT);
@@ -897,7 +900,7 @@ void GDScriptAnalyzer::resolve_class_member(GDScriptParser::ClassNode *p_class,
if (member.variable->initializer) {
// Check if it is call to get_node() on self (using shorthand $ or not), so we can check if @onready is needed.
// This could be improved by traversing the expression fully and checking the presence of get_node at any level.
- if (!member.variable->onready && member.variable->initializer && (member.variable->initializer->type == GDScriptParser::Node::GET_NODE || member.variable->initializer->type == GDScriptParser::Node::CALL || member.variable->initializer->type == GDScriptParser::Node::CAST)) {
+ if (!member.variable->is_static && !member.variable->onready && member.variable->initializer && (member.variable->initializer->type == GDScriptParser::Node::GET_NODE || member.variable->initializer->type == GDScriptParser::Node::CALL || member.variable->initializer->type == GDScriptParser::Node::CAST)) {
GDScriptParser::Node *expr = member.variable->initializer;
if (expr->type == GDScriptParser::Node::CAST) {
expr = static_cast<GDScriptParser::CastNode *>(expr)->operand;
@@ -1082,6 +1085,10 @@ void GDScriptAnalyzer::resolve_class_interface(GDScriptParser::ClassNode *p_clas
p_source = p_class;
}
+#ifdef DEBUG_ENABLED
+ bool has_static_data = p_class->has_static_data;
+#endif
+
if (!p_class->resolved_interface) {
if (!parser->has_class(p_class)) {
String script_path = p_class->get_datatype().script_path;
@@ -1124,7 +1131,29 @@ void GDScriptAnalyzer::resolve_class_interface(GDScriptParser::ClassNode *p_clas
for (int i = 0; i < p_class->members.size(); i++) {
resolve_class_member(p_class, i);
+
+#ifdef DEBUG_ENABLED
+ if (!has_static_data) {
+ GDScriptParser::ClassNode::Member member = p_class->members[i];
+ if (member.type == GDScriptParser::ClassNode::Member::CLASS) {
+ has_static_data = member.m_class->has_static_data;
+ }
+ }
+#endif
+ }
+
+#ifdef DEBUG_ENABLED
+ if (!has_static_data && p_class->annotated_static_unload) {
+ GDScriptParser::Node *static_unload = nullptr;
+ for (GDScriptParser::AnnotationNode *node : p_class->annotations) {
+ if (node->name == "@static_unload") {
+ static_unload = node;
+ break;
+ }
+ }
+ parser->push_warning(static_unload ? static_unload : p_class, GDScriptWarning::REDUNDANT_STATIC_UNLOAD);
}
+#endif
}
}
@@ -1499,6 +1528,8 @@ void GDScriptAnalyzer::resolve_function_signature(GDScriptParser::FunctionNode *
GDScriptParser::FunctionNode *previous_function = parser->current_function;
parser->current_function = p_function;
+ bool previous_static_context = static_context;
+ static_context = p_function->is_static;
GDScriptParser::DataType prev_datatype = p_function->get_datatype();
@@ -1514,7 +1545,11 @@ void GDScriptAnalyzer::resolve_function_signature(GDScriptParser::FunctionNode *
resolve_parameter(p_function->parameters[i]);
#ifdef DEBUG_ENABLED
if (p_function->parameters[i]->usages == 0 && !String(p_function->parameters[i]->identifier->name).begins_with("_")) {
- parser->push_warning(p_function->parameters[i]->identifier, GDScriptWarning::UNUSED_PARAMETER, function_name, p_function->parameters[i]->identifier->name);
+ String visible_name = function_name;
+ if (function_name == StringName()) {
+ visible_name = p_is_lambda ? "<anonymous lambda>" : "<unknown function>";
+ }
+ parser->push_warning(p_function->parameters[i]->identifier, GDScriptWarning::UNUSED_PARAMETER, visible_name, p_function->parameters[i]->identifier->name);
}
is_shadowing(p_function->parameters[i]->identifier, "function parameter");
#endif // DEBUG_ENABLED
@@ -1542,6 +1577,18 @@ void GDScriptAnalyzer::resolve_function_signature(GDScriptParser::FunctionNode *
push_error("Constructor cannot have an explicit return type.", p_function->return_type);
}
}
+ } else if (!p_is_lambda && function_name == GDScriptLanguage::get_singleton()->strings._static_init) {
+ // Static constructor.
+ GDScriptParser::DataType return_type;
+ return_type.kind = GDScriptParser::DataType::BUILTIN;
+ return_type.builtin_type = Variant::NIL;
+ p_function->set_datatype(return_type);
+ if (p_function->return_type) {
+ GDScriptParser::DataType declared_return = resolve_datatype(p_function->return_type);
+ if (declared_return.kind != GDScriptParser::DataType::BUILTIN || declared_return.builtin_type != Variant::NIL) {
+ push_error("Static constructor cannot have an explicit return type.", p_function->return_type);
+ }
+ }
} else {
if (p_function->return_type != nullptr) {
p_function->set_datatype(type_from_metatype(resolve_datatype(p_function->return_type)));
@@ -1625,6 +1672,7 @@ void GDScriptAnalyzer::resolve_function_signature(GDScriptParser::FunctionNode *
parser->ignored_warnings = previously_ignored_warnings;
#endif
parser->current_function = previous_function;
+ static_context = previous_static_context;
}
void GDScriptAnalyzer::resolve_function_body(GDScriptParser::FunctionNode *p_function, bool p_is_lambda) {
@@ -2027,7 +2075,7 @@ void GDScriptAnalyzer::resolve_assert(GDScriptParser::AssertNode *p_assert) {
if (p_assert->condition->is_constant) {
if (p_assert->condition->reduced_value.booleanize()) {
parser->push_warning(p_assert->condition, GDScriptWarning::ASSERT_ALWAYS_TRUE);
- } else {
+ } else if (!(p_assert->condition->type == GDScriptParser::Node::LITERAL && static_cast<GDScriptParser::LiteralNode *>(p_assert->condition)->value.get_type() == Variant::BOOL)) {
parser->push_warning(p_assert->condition, GDScriptWarning::ASSERT_ALWAYS_FALSE);
}
}
@@ -3050,13 +3098,17 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a
base_type.is_meta_type = false;
}
- if (is_self && parser->current_function != nullptr && parser->current_function->is_static && !is_static) {
- // Get the parent function above any lambda.
- GDScriptParser::FunctionNode *parent_function = parser->current_function;
- while (parent_function->source_lambda) {
- parent_function = parent_function->source_lambda->parent_function;
+ if (is_self && static_context && !is_static) {
+ if (parser->current_function) {
+ // Get the parent function above any lambda.
+ GDScriptParser::FunctionNode *parent_function = parser->current_function;
+ while (parent_function->source_lambda) {
+ parent_function = parent_function->source_lambda->parent_function;
+ }
+ push_error(vformat(R"*(Cannot call non-static function "%s()" from static function "%s()".)*", p_call->function_name, parent_function->identifier->name), p_call);
+ } else {
+ push_error(vformat(R"*(Cannot call non-static function "%s()" for static variable initializer.)*", p_call->function_name), p_call);
}
- push_error(vformat(R"*(Cannot call non-static function "%s()" from static function "%s()".)*", p_call->function_name, parent_function->identifier->name), p_call);
} else if (!is_self && base_type.is_meta_type && !is_static) {
base_type.is_meta_type = false; // For `to_string()`.
push_error(vformat(R"*(Cannot call non-static function "%s()" on the class "%s" directly. Make an instance instead.)*", p_call->function_name, base_type.to_string()), p_call);
@@ -3073,7 +3125,7 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a
parser->push_warning(p_call, GDScriptWarning::RETURN_VALUE_DISCARDED, p_call->function_name);
}
- if (is_static && !base_type.is_meta_type && !(is_self && parser->current_function != nullptr && parser->current_function->is_static)) {
+ if (is_static && !is_constructor && !base_type.is_meta_type && !(is_self && static_context)) {
String caller_type = String(base_type.native_type);
if (caller_type.is_empty()) {
@@ -3125,7 +3177,7 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a
String base_name = is_self && !p_call->is_super ? "self" : base_type.to_string();
#ifdef SUGGEST_GODOT4_RENAMES
String rename_hint = String();
- if (GLOBAL_GET(GDScriptWarning::get_settings_path_from_code(GDScriptWarning::Code::RENAMED_IN_GD4_HINT)).booleanize()) {
+ if (GLOBAL_GET(GDScriptWarning::get_settings_path_from_code(GDScriptWarning::Code::RENAMED_IN_GODOT_4_HINT)).booleanize()) {
const char *renamed_function_name = check_for_renamed_identifier(p_call->function_name, p_call->type);
if (renamed_function_name) {
rename_hint = " " + vformat(R"(Did you mean to use "%s"?)", String(renamed_function_name) + "()");
@@ -3326,7 +3378,7 @@ void GDScriptAnalyzer::reduce_identifier_from_base(GDScriptParser::IdentifierNod
} else if (base.is_hard_type()) {
#ifdef SUGGEST_GODOT4_RENAMES
String rename_hint = String();
- if (GLOBAL_GET(GDScriptWarning::get_settings_path_from_code(GDScriptWarning::Code::RENAMED_IN_GD4_HINT)).booleanize()) {
+ if (GLOBAL_GET(GDScriptWarning::get_settings_path_from_code(GDScriptWarning::Code::RENAMED_IN_GODOT_4_HINT)).booleanize()) {
const char *renamed_identifier_name = check_for_renamed_identifier(name, p_identifier->type);
if (renamed_identifier_name) {
rename_hint = " " + vformat(R"(Did you mean to use "%s"?)", renamed_identifier_name);
@@ -3366,7 +3418,7 @@ void GDScriptAnalyzer::reduce_identifier_from_base(GDScriptParser::IdentifierNod
if (base.is_hard_type()) {
#ifdef SUGGEST_GODOT4_RENAMES
String rename_hint = String();
- if (GLOBAL_GET(GDScriptWarning::get_settings_path_from_code(GDScriptWarning::Code::RENAMED_IN_GD4_HINT)).booleanize()) {
+ if (GLOBAL_GET(GDScriptWarning::get_settings_path_from_code(GDScriptWarning::Code::RENAMED_IN_GODOT_4_HINT)).booleanize()) {
const char *renamed_identifier_name = check_for_renamed_identifier(name, p_identifier->type);
if (renamed_identifier_name) {
rename_hint = " " + vformat(R"(Did you mean to use "%s"?)", renamed_identifier_name);
@@ -3428,9 +3480,9 @@ void GDScriptAnalyzer::reduce_identifier_from_base(GDScriptParser::IdentifierNod
}
case GDScriptParser::ClassNode::Member::VARIABLE: {
- if (is_base && !base.is_meta_type) {
+ if (is_base && (!base.is_meta_type || member.variable->is_static)) {
p_identifier->set_datatype(member.get_datatype());
- p_identifier->source = GDScriptParser::IdentifierNode::MEMBER_VARIABLE;
+ p_identifier->source = member.variable->is_static ? GDScriptParser::IdentifierNode::STATIC_VARIABLE : GDScriptParser::IdentifierNode::MEMBER_VARIABLE;
p_identifier->variable_source = member.variable;
member.variable->usages += 1;
return;
@@ -3572,6 +3624,7 @@ void GDScriptAnalyzer::reduce_identifier(GDScriptParser::IdentifierNode *p_ident
mark_lambda_use_self();
p_identifier->variable_source->usages++;
[[fallthrough]];
+ case GDScriptParser::IdentifierNode::STATIC_VARIABLE:
case GDScriptParser::IdentifierNode::LOCAL_VARIABLE:
p_identifier->set_datatype(p_identifier->variable_source->get_datatype());
found_source = true;
@@ -3602,13 +3655,17 @@ void GDScriptAnalyzer::reduce_identifier(GDScriptParser::IdentifierNode *p_ident
if (found_source) {
bool source_is_variable = p_identifier->source == GDScriptParser::IdentifierNode::MEMBER_VARIABLE || p_identifier->source == GDScriptParser::IdentifierNode::INHERITED_VARIABLE;
bool source_is_signal = p_identifier->source == GDScriptParser::IdentifierNode::MEMBER_SIGNAL;
- if ((source_is_variable || source_is_signal) && parser->current_function && parser->current_function->is_static) {
- // Get the parent function above any lambda.
- GDScriptParser::FunctionNode *parent_function = parser->current_function;
- while (parent_function->source_lambda) {
- parent_function = parent_function->source_lambda->parent_function;
+ if ((source_is_variable || source_is_signal) && static_context) {
+ if (parser->current_function) {
+ // Get the parent function above any lambda.
+ GDScriptParser::FunctionNode *parent_function = parser->current_function;
+ while (parent_function->source_lambda) {
+ parent_function = parent_function->source_lambda->parent_function;
+ }
+ push_error(vformat(R"*(Cannot access %s "%s" from the static function "%s()".)*", source_is_signal ? "signal" : "instance variable", p_identifier->name, parent_function->identifier->name), p_identifier);
+ } else {
+ push_error(vformat(R"*(Cannot access %s "%s" for a static variable initializer.)*", source_is_signal ? "signal" : "instance variable", p_identifier->name), p_identifier);
}
- push_error(vformat(R"*(Cannot access %s "%s" from the static function "%s()".)*", source_is_signal ? "signal" : "instance variable", p_identifier->name, parent_function->identifier->name), p_identifier);
}
if (!lambda_stack.is_empty()) {
@@ -3750,7 +3807,7 @@ void GDScriptAnalyzer::reduce_identifier(GDScriptParser::IdentifierNode *p_ident
} else {
#ifdef SUGGEST_GODOT4_RENAMES
String rename_hint = String();
- if (GLOBAL_GET(GDScriptWarning::get_settings_path_from_code(GDScriptWarning::Code::RENAMED_IN_GD4_HINT)).booleanize()) {
+ if (GLOBAL_GET(GDScriptWarning::get_settings_path_from_code(GDScriptWarning::Code::RENAMED_IN_GODOT_4_HINT)).booleanize()) {
const char *renamed_identifier_name = check_for_renamed_identifier(name, p_identifier->type);
if (renamed_identifier_name) {
rename_hint = " " + vformat(R"(Did you mean to use "%s"?)", renamed_identifier_name);
diff --git a/modules/gdscript/gdscript_analyzer.h b/modules/gdscript/gdscript_analyzer.h
index 5902035bcd..0c7bf4125b 100644
--- a/modules/gdscript/gdscript_analyzer.h
+++ b/modules/gdscript/gdscript_analyzer.h
@@ -43,6 +43,7 @@ class GDScriptAnalyzer {
const GDScriptParser::EnumNode *current_enum = nullptr;
List<GDScriptParser::LambdaNode *> lambda_stack;
+ bool static_context = false;
// Tests for detecting invalid overloading of script members
static _FORCE_INLINE_ bool has_member_name_conflict_in_script_class(const StringName &p_name, const GDScriptParser::ClassNode *p_current_class_node, const GDScriptParser::Node *p_member);
diff --git a/modules/gdscript/gdscript_byte_codegen.cpp b/modules/gdscript/gdscript_byte_codegen.cpp
index d6f21d297a..1414075ba8 100644
--- a/modules/gdscript/gdscript_byte_codegen.cpp
+++ b/modules/gdscript/gdscript_byte_codegen.cpp
@@ -69,56 +69,52 @@ uint32_t GDScriptByteCodeGenerator::add_or_get_name(const StringName &p_name) {
uint32_t GDScriptByteCodeGenerator::add_temporary(const GDScriptDataType &p_type) {
Variant::Type temp_type = Variant::NIL;
- if (p_type.has_type) {
- if (p_type.kind == GDScriptDataType::BUILTIN) {
- switch (p_type.builtin_type) {
- case Variant::NIL:
- case Variant::BOOL:
- case Variant::INT:
- case Variant::FLOAT:
- case Variant::STRING:
- case Variant::VECTOR2:
- case Variant::VECTOR2I:
- case Variant::RECT2:
- case Variant::RECT2I:
- case Variant::VECTOR3:
- case Variant::VECTOR3I:
- case Variant::TRANSFORM2D:
- case Variant::VECTOR4:
- case Variant::VECTOR4I:
- case Variant::PLANE:
- case Variant::QUATERNION:
- case Variant::AABB:
- case Variant::BASIS:
- case Variant::TRANSFORM3D:
- case Variant::PROJECTION:
- case Variant::COLOR:
- case Variant::STRING_NAME:
- case Variant::NODE_PATH:
- case Variant::RID:
- case Variant::OBJECT:
- case Variant::CALLABLE:
- case Variant::SIGNAL:
- case Variant::DICTIONARY:
- case Variant::ARRAY:
- temp_type = p_type.builtin_type;
- break;
- case Variant::PACKED_BYTE_ARRAY:
- case Variant::PACKED_INT32_ARRAY:
- case Variant::PACKED_INT64_ARRAY:
- case Variant::PACKED_FLOAT32_ARRAY:
- case Variant::PACKED_FLOAT64_ARRAY:
- case Variant::PACKED_STRING_ARRAY:
- case Variant::PACKED_VECTOR2_ARRAY:
- case Variant::PACKED_VECTOR3_ARRAY:
- case Variant::PACKED_COLOR_ARRAY:
- case Variant::VARIANT_MAX:
- // Packed arrays are reference counted, so we don't use the pool for them.
- temp_type = Variant::NIL;
- break;
- }
- } else {
- temp_type = Variant::OBJECT;
+ if (p_type.has_type && p_type.kind == GDScriptDataType::BUILTIN) {
+ switch (p_type.builtin_type) {
+ case Variant::NIL:
+ case Variant::BOOL:
+ case Variant::INT:
+ case Variant::FLOAT:
+ case Variant::STRING:
+ case Variant::VECTOR2:
+ case Variant::VECTOR2I:
+ case Variant::RECT2:
+ case Variant::RECT2I:
+ case Variant::VECTOR3:
+ case Variant::VECTOR3I:
+ case Variant::TRANSFORM2D:
+ case Variant::VECTOR4:
+ case Variant::VECTOR4I:
+ case Variant::PLANE:
+ case Variant::QUATERNION:
+ case Variant::AABB:
+ case Variant::BASIS:
+ case Variant::TRANSFORM3D:
+ case Variant::PROJECTION:
+ case Variant::COLOR:
+ case Variant::STRING_NAME:
+ case Variant::NODE_PATH:
+ case Variant::RID:
+ case Variant::CALLABLE:
+ case Variant::SIGNAL:
+ temp_type = p_type.builtin_type;
+ break;
+ case Variant::OBJECT:
+ case Variant::DICTIONARY:
+ case Variant::ARRAY:
+ case Variant::PACKED_BYTE_ARRAY:
+ case Variant::PACKED_INT32_ARRAY:
+ case Variant::PACKED_INT64_ARRAY:
+ case Variant::PACKED_FLOAT32_ARRAY:
+ case Variant::PACKED_FLOAT64_ARRAY:
+ case Variant::PACKED_STRING_ARRAY:
+ case Variant::PACKED_VECTOR2_ARRAY:
+ case Variant::PACKED_VECTOR3_ARRAY:
+ case Variant::PACKED_COLOR_ARRAY:
+ case Variant::VARIANT_MAX:
+ // Arrays, dictionaries, and objects are reference counted, so we don't use the pool for them.
+ temp_type = Variant::NIL;
+ break;
}
}
@@ -143,10 +139,12 @@ void GDScriptByteCodeGenerator::pop_temporary() {
ERR_FAIL_COND(used_temporaries.is_empty());
int slot_idx = used_temporaries.back()->get();
const StackSlot &slot = temporaries[slot_idx];
- if (slot.type == Variant::OBJECT) {
+ if (slot.type == Variant::NIL) {
// Avoid keeping in the stack long-lived references to objects,
// which may prevent RefCounted objects from being freed.
- write_assign_false(Address(Address::TEMPORARY, slot_idx));
+ // However, the cleanup will be performed an the end of the
+ // statement, to allow object references to survive chaining.
+ temporaries_pending_clear.push_back(slot_idx);
}
temporaries_pool[slot.type].push_back(slot_idx);
used_temporaries.pop_back();
@@ -1756,6 +1754,23 @@ void GDScriptByteCodeGenerator::end_block() {
pop_stack_identifiers();
}
+void GDScriptByteCodeGenerator::clean_temporaries() {
+ List<int>::Element *E = temporaries_pending_clear.front();
+ while (E) {
+ // The temporary may have been re-used as something else than an object
+ // since it was added to the list. In that case, there's no need to clear it.
+ int slot_idx = E->get();
+ const StackSlot &slot = temporaries[slot_idx];
+ if (slot.type == Variant::NIL) {
+ write_assign_false(Address(Address::TEMPORARY, slot_idx));
+ }
+
+ List<int>::Element *next = E->next();
+ E->erase();
+ E = next;
+ }
+}
+
GDScriptByteCodeGenerator::~GDScriptByteCodeGenerator() {
if (!ended && function != nullptr) {
memdelete(function);
diff --git a/modules/gdscript/gdscript_byte_codegen.h b/modules/gdscript/gdscript_byte_codegen.h
index dc05de9fc6..fc684e4d8f 100644
--- a/modules/gdscript/gdscript_byte_codegen.h
+++ b/modules/gdscript/gdscript_byte_codegen.h
@@ -88,6 +88,7 @@ class GDScriptByteCodeGenerator : public GDScriptCodeGenerator {
Vector<StackSlot> locals;
Vector<StackSlot> temporaries;
List<int> used_temporaries;
+ List<int> temporaries_pending_clear;
RBMap<Variant::Type, List<int>> temporaries_pool;
List<GDScriptFunction::StackDebug> stack_debug;
@@ -365,6 +366,8 @@ class GDScriptByteCodeGenerator : public GDScriptCodeGenerator {
return p_address.address | (GDScriptFunction::ADDR_TYPE_MEMBER << GDScriptFunction::ADDR_BITS);
case Address::CONSTANT:
return p_address.address | (GDScriptFunction::ADDR_TYPE_CONSTANT << GDScriptFunction::ADDR_BITS);
+ case Address::STATIC_VARIABLE:
+ return p_address.address | (GDScriptFunction::ADDR_TYPE_STATIC_VAR << GDScriptFunction::ADDR_BITS);
case Address::LOCAL_VARIABLE:
case Address::FUNCTION_PARAMETER:
return p_address.address | (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS);
@@ -463,6 +466,7 @@ public:
virtual uint32_t add_or_get_name(const StringName &p_name) override;
virtual uint32_t add_temporary(const GDScriptDataType &p_type) override;
virtual void pop_temporary() override;
+ virtual void clean_temporaries() override;
virtual void start_parameters() override;
virtual void end_parameters() override;
diff --git a/modules/gdscript/gdscript_cache.cpp b/modules/gdscript/gdscript_cache.cpp
index a009e8e0a8..126fccbbf0 100644
--- a/modules/gdscript/gdscript_cache.cpp
+++ b/modules/gdscript/gdscript_cache.cpp
@@ -342,6 +342,16 @@ Error GDScriptCache::finish_compiling(const String &p_owner) {
return err;
}
+void GDScriptCache::add_static_script(Ref<GDScript> p_script) {
+ ERR_FAIL_COND_MSG(p_script.is_null(), "Trying to cache empty script as static.");
+ ERR_FAIL_COND_MSG(!p_script->is_valid(), "Trying to cache non-compiled script as static.");
+ singleton->static_gdscript_cache[p_script->get_fully_qualified_name()] = p_script;
+}
+
+void GDScriptCache::remove_static_script(const String &p_fqcn) {
+ singleton->static_gdscript_cache.erase(p_fqcn);
+}
+
Ref<PackedScene> GDScriptCache::get_packed_scene(const String &p_path, Error &r_error, const String &p_owner) {
MutexLock lock(singleton->mutex);
diff --git a/modules/gdscript/gdscript_cache.h b/modules/gdscript/gdscript_cache.h
index c7f40f6e82..28266a1c0b 100644
--- a/modules/gdscript/gdscript_cache.h
+++ b/modules/gdscript/gdscript_cache.h
@@ -78,6 +78,7 @@ class GDScriptCache {
HashMap<String, GDScriptParserRef *> parser_map;
HashMap<String, Ref<GDScript>> shallow_gdscript_cache;
HashMap<String, Ref<GDScript>> full_gdscript_cache;
+ HashMap<String, Ref<GDScript>> static_gdscript_cache;
HashMap<String, HashSet<String>> dependencies;
HashMap<String, Ref<PackedScene>> packed_scene_cache;
HashMap<String, HashSet<String>> packed_scene_dependencies;
@@ -101,6 +102,8 @@ public:
static Ref<GDScript> get_full_script(const String &p_path, Error &r_error, const String &p_owner = String(), bool p_update_from_disk = false);
static Ref<GDScript> get_cached_script(const String &p_path);
static Error finish_compiling(const String &p_owner);
+ static void add_static_script(Ref<GDScript> p_script);
+ static void remove_static_script(const String &p_fqcn);
static Ref<PackedScene> get_packed_scene(const String &p_path, Error &r_error, const String &p_owner = "");
static void clear_unreferenced_packed_scenes();
diff --git a/modules/gdscript/gdscript_codegen.h b/modules/gdscript/gdscript_codegen.h
index 7847ab28c7..dbc2466393 100644
--- a/modules/gdscript/gdscript_codegen.h
+++ b/modules/gdscript/gdscript_codegen.h
@@ -44,6 +44,7 @@ public:
CLASS,
MEMBER,
CONSTANT,
+ STATIC_VARIABLE,
LOCAL_VARIABLE,
FUNCTION_PARAMETER,
TEMPORARY,
@@ -72,6 +73,7 @@ public:
virtual uint32_t add_or_get_name(const StringName &p_name) = 0;
virtual uint32_t add_temporary(const GDScriptDataType &p_type) = 0;
virtual void pop_temporary() = 0;
+ virtual void clean_temporaries() = 0;
virtual void start_parameters() = 0;
virtual void end_parameters() = 0;
diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp
index 5413eadf60..327e24ef11 100644
--- a/modules/gdscript/gdscript_compiler.cpp
+++ b/modules/gdscript/gdscript_compiler.cpp
@@ -254,13 +254,29 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
gen->write_call_self(temp, codegen.script->member_indices[identifier].getter, args);
return temp;
} else {
- // No getter or inside getter: direct member access.,
+ // No getter or inside getter: direct member access.
int idx = codegen.script->member_indices[identifier].index;
return GDScriptCodeGenerator::Address(GDScriptCodeGenerator::Address::MEMBER, idx, codegen.script->get_member_type(identifier));
}
}
}
+ // Try static variables.
+ if (codegen.script->static_variables_indices.has(identifier)) {
+ if (codegen.script->static_variables_indices[identifier].getter != StringName() && codegen.script->static_variables_indices[identifier].getter != codegen.function_name) {
+ // Perform getter.
+ GDScriptCodeGenerator::Address temp = codegen.add_temporary(codegen.script->static_variables_indices[identifier].data_type);
+ GDScriptCodeGenerator::Address class_addr(GDScriptCodeGenerator::Address::CLASS);
+ Vector<GDScriptCodeGenerator::Address> args; // No argument needed.
+ gen->write_call(temp, class_addr, codegen.script->static_variables_indices[identifier].getter, args);
+ return temp;
+ } else {
+ // No getter or inside getter: direct variable access.
+ int idx = codegen.script->static_variables_indices[identifier].index;
+ return GDScriptCodeGenerator::Address(GDScriptCodeGenerator::Address::STATIC_VARIABLE, idx, codegen.script->static_variables_indices[identifier].data_type);
+ }
+ }
+
// Try class constants.
{
GDScript *owner = codegen.script;
@@ -563,7 +579,7 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
// Not exact arguments, but still can use method bind call.
gen->write_call_method_bind(result, self, method, arguments);
}
- } else if ((codegen.function_node && codegen.function_node->is_static) || call->function_name == "new") {
+ } else if (codegen.is_static || (codegen.function_node && codegen.function_node->is_static) || call->function_name == "new") {
GDScriptCodeGenerator::Address self;
self.mode = GDScriptCodeGenerator::Address::CLASS;
if (is_awaited) {
@@ -909,6 +925,7 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
bool is_member_property = false;
bool member_property_has_setter = false;
bool member_property_is_in_setter = false;
+ bool is_static = false;
StringName member_property_setter_function;
List<const GDScriptParser::SubscriptNode *> chain;
@@ -925,14 +942,16 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
StringName var_name = identifier->name;
if (_is_class_member_property(codegen, var_name)) {
assign_class_member_property = var_name;
- } else if (!_is_local_or_parameter(codegen, var_name) && codegen.script->member_indices.has(var_name)) {
+ } else if (!_is_local_or_parameter(codegen, var_name) && (codegen.script->member_indices.has(var_name) || codegen.script->static_variables_indices.has(var_name))) {
is_member_property = true;
- member_property_setter_function = codegen.script->member_indices[var_name].setter;
+ is_static = codegen.script->static_variables_indices.has(var_name);
+ const GDScript::MemberInfo &minfo = is_static ? codegen.script->static_variables_indices[var_name] : codegen.script->member_indices[var_name];
+ member_property_setter_function = minfo.setter;
member_property_has_setter = member_property_setter_function != StringName();
member_property_is_in_setter = member_property_has_setter && member_property_setter_function == codegen.function_name;
- target_member_property.mode = GDScriptCodeGenerator::Address::MEMBER;
- target_member_property.address = codegen.script->member_indices[var_name].index;
- target_member_property.type = codegen.script->member_indices[var_name].data_type;
+ target_member_property.mode = is_static ? GDScriptCodeGenerator::Address::STATIC_VARIABLE : GDScriptCodeGenerator::Address::MEMBER;
+ target_member_property.address = minfo.index;
+ target_member_property.type = minfo.data_type;
}
}
break;
@@ -1085,7 +1104,8 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
if (member_property_has_setter && !member_property_is_in_setter) {
Vector<GDScriptCodeGenerator::Address> args;
args.push_back(assigned);
- gen->write_call(GDScriptCodeGenerator::Address(), GDScriptCodeGenerator::Address(GDScriptCodeGenerator::Address::SELF), member_property_setter_function, args);
+ GDScriptCodeGenerator::Address self = is_static ? GDScriptCodeGenerator::Address(GDScriptCodeGenerator::Address::CLASS) : GDScriptCodeGenerator::Address(GDScriptCodeGenerator::Address::SELF);
+ gen->write_call(GDScriptCodeGenerator::Address(), self, member_property_setter_function, args);
} else {
gen->write_assign(target_member_property, assigned);
}
@@ -1134,16 +1154,19 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
bool is_member = false;
bool has_setter = false;
bool is_in_setter = false;
+ bool is_static = false;
StringName setter_function;
StringName var_name = static_cast<const GDScriptParser::IdentifierNode *>(assignment->assignee)->name;
- if (!_is_local_or_parameter(codegen, var_name) && codegen.script->member_indices.has(var_name)) {
+ if (!_is_local_or_parameter(codegen, var_name) && (codegen.script->member_indices.has(var_name) || codegen.script->static_variables_indices.has(var_name))) {
is_member = true;
- setter_function = codegen.script->member_indices[var_name].setter;
+ is_static = codegen.script->static_variables_indices.has(var_name);
+ GDScript::MemberInfo &minfo = is_static ? codegen.script->static_variables_indices[var_name] : codegen.script->member_indices[var_name];
+ setter_function = minfo.setter;
has_setter = setter_function != StringName();
is_in_setter = has_setter && setter_function == codegen.function_name;
- member.mode = GDScriptCodeGenerator::Address::MEMBER;
- member.address = codegen.script->member_indices[var_name].index;
- member.type = codegen.script->member_indices[var_name].data_type;
+ member.mode = is_static ? GDScriptCodeGenerator::Address::STATIC_VARIABLE : GDScriptCodeGenerator::Address::MEMBER;
+ member.address = minfo.index;
+ member.type = minfo.data_type;
}
GDScriptCodeGenerator::Address target;
@@ -1165,18 +1188,8 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
bool has_operation = assignment->operation != GDScriptParser::AssignmentNode::OP_NONE;
if (has_operation) {
// Perform operation.
- GDScriptCodeGenerator::Address og_value = _parse_expression(codegen, r_error, assignment->assignee);
-
- if (!has_setter && !assignment->use_conversion_assign) {
- // If there's nothing special about the assignment, perform the assignment as part of the operator
- gen->write_binary_operator(target, assignment->variant_op, og_value, assigned_value);
- if (assigned_value.mode == GDScriptCodeGenerator::Address::TEMPORARY) {
- gen->pop_temporary(); // Pop assigned value if not done before.
- }
- return GDScriptCodeGenerator::Address();
- }
-
GDScriptCodeGenerator::Address op_result = codegen.add_temporary(_gdtype_from_datatype(assignment->get_datatype(), codegen.script));
+ 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;
@@ -1665,6 +1678,7 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Sui
Error err = OK;
GDScriptCodeGenerator *gen = codegen.generator;
+ gen->clean_temporaries();
codegen.start_block();
if (p_add_locals) {
@@ -1967,6 +1981,8 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Sui
}
} break;
}
+
+ gen->clean_temporaries();
}
codegen.end_block();
@@ -2008,6 +2024,7 @@ GDScriptFunction *GDScriptCompiler::_parse_function(Error &r_error, GDScript *p_
}
codegen.function_name = func_name;
+ codegen.is_static = is_static;
codegen.generator->write_start(p_script, func_name, is_static, rpc_config, return_type);
int optional_parameters = 0;
@@ -2031,7 +2048,7 @@ GDScriptFunction *GDScriptCompiler::_parse_function(Error &r_error, GDScript *p_
bool is_implicit_ready = !p_func && p_for_ready;
if (!p_for_lambda && is_implicit_initializer) {
- // Initialize the default values for type variables before anything.
+ // Initialize the default values for typed variables before anything.
// This avoids crashes if they are accessed with validated calls before being properly initialized.
// It may happen with out-of-order access or with `@onready` variables.
for (const GDScriptParser::ClassNode::Member &member : p_class->members) {
@@ -2040,6 +2057,10 @@ GDScriptFunction *GDScriptCompiler::_parse_function(Error &r_error, GDScript *p_
}
const GDScriptParser::VariableNode *field = member.variable;
+ if (field->is_static) {
+ continue;
+ }
+
GDScriptDataType field_type = _gdtype_from_datatype(field->get_datatype(), codegen.script);
GDScriptCodeGenerator::Address dst_address(GDScriptCodeGenerator::Address::MEMBER, codegen.script->member_indices[field->identifier->name].index, field_type);
@@ -2063,6 +2084,10 @@ GDScriptFunction *GDScriptCompiler::_parse_function(Error &r_error, GDScript *p_
continue;
}
const GDScriptParser::VariableNode *field = p_class->members[i].variable;
+ if (field->is_static) {
+ continue;
+ }
+
if (field->onready != is_implicit_ready) {
// Only initialize in @implicit_ready.
continue;
@@ -2152,12 +2177,6 @@ GDScriptFunction *GDScriptCompiler::_parse_function(Error &r_error, GDScript *p_
if (p_func) {
codegen.generator->set_initial_line(p_func->start_line);
-#ifdef TOOLS_ENABLED
- if (!p_for_lambda) {
- p_script->member_lines[func_name] = p_func->start_line;
- p_script->doc_functions[func_name] = p_func->doc_description;
- }
-#endif
} else {
codegen.generator->set_initial_line(0);
}
@@ -2196,6 +2215,135 @@ GDScriptFunction *GDScriptCompiler::_parse_function(Error &r_error, GDScript *p_
return gd_function;
}
+GDScriptFunction *GDScriptCompiler::_make_static_initializer(Error &r_error, GDScript *p_script, const GDScriptParser::ClassNode *p_class) {
+ r_error = OK;
+ CodeGen codegen;
+ codegen.generator = memnew(GDScriptByteCodeGenerator);
+
+ codegen.class_node = p_class;
+ codegen.script = p_script;
+
+ StringName func_name = SNAME("@static_initializer");
+ bool is_static = true;
+ Variant rpc_config;
+ GDScriptDataType return_type;
+ return_type.has_type = true;
+ return_type.kind = GDScriptDataType::BUILTIN;
+ return_type.builtin_type = Variant::NIL;
+
+ codegen.function_name = func_name;
+ codegen.is_static = is_static;
+ codegen.generator->write_start(p_script, func_name, is_static, rpc_config, return_type);
+
+ GDScriptCodeGenerator::Address class_addr(GDScriptCodeGenerator::Address::CLASS);
+
+ // Initialize the default values for typed variables before anything.
+ // This avoids crashes if they are accessed with validated calls before being properly initialized.
+ // It may happen with out-of-order access or with `@onready` variables.
+ for (const GDScriptParser::ClassNode::Member &member : p_class->members) {
+ if (member.type != GDScriptParser::ClassNode::Member::VARIABLE) {
+ continue;
+ }
+
+ const GDScriptParser::VariableNode *field = member.variable;
+ if (!field->is_static) {
+ continue;
+ }
+
+ GDScriptDataType field_type = _gdtype_from_datatype(field->get_datatype(), codegen.script);
+
+ if (field_type.has_type) {
+ codegen.generator->write_newline(field->start_line);
+
+ if (field_type.has_container_element_type()) {
+ GDScriptCodeGenerator::Address temp = codegen.add_temporary(field_type);
+ codegen.generator->write_construct_typed_array(temp, field_type.get_container_element_type(), Vector<GDScriptCodeGenerator::Address>());
+ codegen.generator->write_set_named(class_addr, field->identifier->name, temp);
+ codegen.generator->pop_temporary();
+
+ } else if (field_type.kind == GDScriptDataType::BUILTIN) {
+ GDScriptCodeGenerator::Address temp = codegen.add_temporary(field_type);
+ codegen.generator->write_construct(temp, field_type.builtin_type, Vector<GDScriptCodeGenerator::Address>());
+ codegen.generator->write_set_named(class_addr, field->identifier->name, temp);
+ codegen.generator->pop_temporary();
+ }
+ // The `else` branch is for objects, in such case we leave it as `null`.
+ }
+ }
+
+ for (int i = 0; i < p_class->members.size(); i++) {
+ // Initialize static fields.
+ if (p_class->members[i].type != GDScriptParser::ClassNode::Member::VARIABLE) {
+ continue;
+ }
+ const GDScriptParser::VariableNode *field = p_class->members[i].variable;
+ if (!field->is_static) {
+ continue;
+ }
+
+ GDScriptDataType field_type = _gdtype_from_datatype(field->get_datatype(), codegen.script);
+
+ if (field->initializer) {
+ // Emit proper line change.
+ codegen.generator->write_newline(field->initializer->start_line);
+
+ GDScriptCodeGenerator::Address src_address = _parse_expression(codegen, r_error, field->initializer, false, true);
+ if (r_error) {
+ memdelete(codegen.generator);
+ return nullptr;
+ }
+
+ GDScriptCodeGenerator::Address temp = codegen.add_temporary(field_type);
+ if (field->use_conversion_assign) {
+ codegen.generator->write_assign_with_conversion(temp, src_address);
+ } else {
+ codegen.generator->write_assign(temp, src_address);
+ }
+ if (src_address.mode == GDScriptCodeGenerator::Address::TEMPORARY) {
+ codegen.generator->pop_temporary();
+ }
+
+ codegen.generator->write_set_named(class_addr, field->identifier->name, temp);
+ codegen.generator->pop_temporary();
+ }
+ }
+
+ if (p_script->has_method(GDScriptLanguage::get_singleton()->strings._static_init)) {
+ codegen.generator->write_newline(p_class->start_line);
+ codegen.generator->write_call(GDScriptCodeGenerator::Address(), class_addr, GDScriptLanguage::get_singleton()->strings._static_init, Vector<GDScriptCodeGenerator::Address>());
+ }
+
+#ifdef DEBUG_ENABLED
+ if (EngineDebugger::is_active()) {
+ String signature;
+ // Path.
+ if (!p_script->get_script_path().is_empty()) {
+ signature += p_script->get_script_path();
+ }
+ // Location.
+ signature += "::0";
+
+ // Function and class.
+
+ if (p_class->identifier) {
+ signature += "::" + String(p_class->identifier->name) + "." + String(func_name);
+ } else {
+ signature += "::" + String(func_name);
+ }
+
+ codegen.generator->set_signature(signature);
+ }
+#endif
+
+ codegen.generator->set_initial_line(p_class->start_line);
+
+ GDScriptFunction *gd_function = codegen.generator->write_end();
+
+ memdelete(codegen.generator);
+
+ return gd_function;
+}
+
Error GDScriptCompiler::_parse_setter_getter(GDScript *p_script, const GDScriptParser::ClassNode *p_class, const GDScriptParser::VariableNode *p_variable, bool p_is_setter) {
Error err = OK;
@@ -2226,23 +2374,6 @@ Error GDScriptCompiler::_populate_class_members(GDScript *p_script, const GDScri
parsing_classes.insert(p_script);
p_script->clearing = true;
-#ifdef TOOLS_ENABLED
- p_script->doc_functions.clear();
- p_script->doc_variables.clear();
- p_script->doc_constants.clear();
- p_script->doc_enums.clear();
- p_script->doc_signals.clear();
- p_script->doc_tutorials.clear();
-
- p_script->doc_brief_description = p_class->doc_brief_description;
- p_script->doc_description = p_class->doc_description;
- for (int i = 0; i < p_class->doc_tutorials.size(); i++) {
- DocData::TutorialDoc td;
- td.title = p_class->doc_tutorials[i].first;
- td.link = p_class->doc_tutorials[i].second;
- p_script->doc_tutorials.append(td);
- }
-#endif
p_script->native = Ref<GDScriptNativeClass>();
p_script->base = Ref<GDScript>();
@@ -2266,19 +2397,28 @@ Error GDScriptCompiler::_populate_class_members(GDScript *p_script, const GDScri
}
member_functions.clear();
+ p_script->static_variables.clear();
+
if (p_script->implicit_initializer) {
memdelete(p_script->implicit_initializer);
}
if (p_script->implicit_ready) {
memdelete(p_script->implicit_ready);
}
+ if (p_script->static_initializer) {
+ memdelete(p_script->static_initializer);
+ }
+
p_script->member_functions.clear();
p_script->member_indices.clear();
p_script->member_info.clear();
+ p_script->static_variables_indices.clear();
+ p_script->static_variables.clear();
p_script->_signals.clear();
p_script->initializer = nullptr;
p_script->implicit_initializer = nullptr;
p_script->implicit_ready = nullptr;
+ p_script->static_initializer = nullptr;
p_script->clearing = false;
@@ -2386,13 +2526,15 @@ Error GDScriptCompiler::_populate_class_members(GDScript *p_script, const GDScri
} else {
prop_info.usage = PROPERTY_USAGE_SCRIPT_VARIABLE;
}
-#ifdef TOOLS_ENABLED
- p_script->doc_variables[name] = variable->doc_description;
-#endif
- p_script->member_info[name] = prop_info;
- p_script->member_indices[name] = minfo;
- p_script->members.insert(name);
+ if (variable->is_static) {
+ minfo.index = p_script->static_variables_indices.size();
+ p_script->static_variables_indices[name] = minfo;
+ } else {
+ p_script->member_info[name] = prop_info;
+ p_script->member_indices[name] = minfo;
+ p_script->members.insert(name);
+ }
#ifdef TOOLS_ENABLED
if (variable->initializer != nullptr && variable->initializer->is_constant) {
@@ -2401,7 +2543,6 @@ Error GDScriptCompiler::_populate_class_members(GDScript *p_script, const GDScri
} else {
p_script->member_default_values.erase(name);
}
- p_script->member_lines[name] = variable->start_line;
#endif
} break;
@@ -2410,12 +2551,6 @@ Error GDScriptCompiler::_populate_class_members(GDScript *p_script, const GDScri
StringName name = constant->identifier->name;
p_script->constants.insert(name, constant->initializer->reduced_value);
-#ifdef TOOLS_ENABLED
- p_script->member_lines[name] = constant->start_line;
- if (!constant->doc_description.is_empty()) {
- p_script->doc_constants[name] = constant->doc_description;
- }
-#endif
} break;
case GDScriptParser::ClassNode::Member::ENUM_VALUE: {
@@ -2423,18 +2558,6 @@ Error GDScriptCompiler::_populate_class_members(GDScript *p_script, const GDScri
StringName name = enum_value.identifier->name;
p_script->constants.insert(name, enum_value.value);
-#ifdef TOOLS_ENABLED
- p_script->member_lines[name] = enum_value.identifier->start_line;
- if (!p_script->doc_enums.has("@unnamed_enums")) {
- p_script->doc_enums["@unnamed_enums"] = DocData::EnumDoc();
- p_script->doc_enums["@unnamed_enums"].name = "@unnamed_enums";
- }
- DocData::ConstantDoc const_doc;
- const_doc.name = enum_value.identifier->name;
- const_doc.value = Variant(enum_value.value).operator String(); // TODO-DOC: enum value currently is int.
- const_doc.description = enum_value.doc_description;
- p_script->doc_enums["@unnamed_enums"].values.push_back(const_doc);
-#endif
} break;
case GDScriptParser::ClassNode::Member::SIGNAL: {
@@ -2447,11 +2570,6 @@ Error GDScriptCompiler::_populate_class_members(GDScript *p_script, const GDScri
parameters_names.write[j] = signal->parameters[j]->identifier->name;
}
p_script->_signals[name] = parameters_names;
-#ifdef TOOLS_ENABLED
- if (!signal->doc_description.is_empty()) {
- p_script->doc_signals[name] = signal->doc_description;
- }
-#endif
} break;
case GDScriptParser::ClassNode::Member::ENUM: {
@@ -2459,19 +2577,6 @@ Error GDScriptCompiler::_populate_class_members(GDScript *p_script, const GDScri
StringName name = enum_n->identifier->name;
p_script->constants.insert(name, enum_n->dictionary);
-#ifdef TOOLS_ENABLED
- p_script->member_lines[name] = enum_n->start_line;
- p_script->doc_enums[name] = DocData::EnumDoc();
- p_script->doc_enums[name].name = name;
- p_script->doc_enums[name].description = enum_n->doc_description;
- for (int j = 0; j < enum_n->values.size(); j++) {
- DocData::ConstantDoc const_doc;
- const_doc.name = enum_n->values[j].identifier->name;
- const_doc.value = Variant(enum_n->values[j].value).operator String();
- const_doc.description = enum_n->values[j].doc_description;
- p_script->doc_enums[name].values.push_back(const_doc);
- }
-#endif
} break;
case GDScriptParser::ClassNode::Member::GROUP: {
@@ -2497,6 +2602,8 @@ Error GDScriptCompiler::_populate_class_members(GDScript *p_script, const GDScri
}
}
+ p_script->static_variables.resize(p_script->static_variables_indices.size());
+
parsed_classes.insert(p_script);
parsing_classes.erase(p_script);
@@ -2519,9 +2626,6 @@ Error GDScriptCompiler::_populate_class_members(GDScript *p_script, const GDScri
}
}
-#ifdef TOOLS_ENABLED
- p_script->member_lines[name] = inner_class->start_line;
-#endif
p_script->constants.insert(name, subclass); //once parsed, goes to the list of constants
}
@@ -2576,6 +2680,15 @@ Error GDScriptCompiler::_compile_class(GDScript *p_script, const GDScriptParser:
}
}
+ if (p_class->has_static_data) {
+ Error err = OK;
+ GDScriptFunction *func = _make_static_initializer(err, p_script, p_class);
+ p_script->static_initializer = func;
+ if (err) {
+ return err;
+ }
+ }
+
#ifdef DEBUG_ENABLED
//validate instances if keeping state
@@ -2614,7 +2727,7 @@ Error GDScriptCompiler::_compile_class(GDScript *p_script, const GDScriptParser:
//well, tough luck, not gonna do anything here
}
}
-#endif
+#endif // TOOLS_ENABLED
} else {
GDScriptInstance *gi = static_cast<GDScriptInstance *>(si);
gi->reload_members();
@@ -2623,7 +2736,9 @@ Error GDScriptCompiler::_compile_class(GDScript *p_script, const GDScriptParser:
E = N;
}
}
-#endif
+#endif //DEBUG_ENABLED
+
+ has_static_data = p_class->has_static_data;
for (int i = 0; i < p_class->members.size(); i++) {
if (p_class->members[i].type != GDScriptParser::ClassNode::Member::CLASS) {
@@ -2637,6 +2752,8 @@ Error GDScriptCompiler::_compile_class(GDScript *p_script, const GDScriptParser:
if (err) {
return err;
}
+
+ has_static_data = has_static_data || inner_class->has_static_data;
}
p_script->_init_rpc_methods_properties();
@@ -2723,9 +2840,9 @@ Error GDScriptCompiler::compile(const GDScriptParser *p_parser, GDScript *p_scri
return err;
}
-#ifdef TOOLS_ENABLED
- p_script->_update_doc();
-#endif
+ if (has_static_data && !root->annotated_static_unload) {
+ GDScriptCache::add_static_script(p_script);
+ }
return GDScriptCache::finish_compiling(main_script->get_path());
}
diff --git a/modules/gdscript/gdscript_compiler.h b/modules/gdscript/gdscript_compiler.h
index 5328c17c73..2d15d461fb 100644
--- a/modules/gdscript/gdscript_compiler.h
+++ b/modules/gdscript/gdscript_compiler.h
@@ -52,6 +52,7 @@ class GDScriptCompiler {
HashMap<StringName, GDScriptCodeGenerator::Address> parameters;
HashMap<StringName, GDScriptCodeGenerator::Address> locals;
List<HashMap<StringName, GDScriptCodeGenerator::Address>> locals_stack;
+ bool is_static = false;
GDScriptCodeGenerator::Address add_local(const StringName &p_name, const GDScriptDataType &p_type) {
uint32_t addr = generator->add_local(p_name, p_type);
@@ -130,6 +131,7 @@ class GDScriptCompiler {
void _add_locals_in_block(CodeGen &codegen, const GDScriptParser::SuiteNode *p_block);
Error _parse_block(CodeGen &codegen, const GDScriptParser::SuiteNode *p_block, bool p_add_locals = true);
GDScriptFunction *_parse_function(Error &r_error, GDScript *p_script, const GDScriptParser::ClassNode *p_class, const GDScriptParser::FunctionNode *p_func, bool p_for_ready = false, bool p_for_lambda = false);
+ GDScriptFunction *_make_static_initializer(Error &r_error, GDScript *p_script, const GDScriptParser::ClassNode *p_class);
Error _parse_setter_getter(GDScript *p_script, const GDScriptParser::ClassNode *p_class, const GDScriptParser::VariableNode *p_variable, bool p_is_setter);
Error _populate_class_members(GDScript *p_script, const GDScriptParser::ClassNode *p_class, bool p_keep_state);
Error _compile_class(GDScript *p_script, const GDScriptParser::ClassNode *p_class, bool p_keep_state);
@@ -138,6 +140,7 @@ class GDScriptCompiler {
StringName source;
String error;
GDScriptParser::ExpressionNode *awaited_node = nullptr;
+ bool has_static_data = false;
public:
static void convert_to_initializer_type(Variant &p_variant, const GDScriptParser::VariableNode *p_node);
diff --git a/modules/gdscript/gdscript_disassembler.cpp b/modules/gdscript/gdscript_disassembler.cpp
index 0acc03be3d..45ad8792d9 100644
--- a/modules/gdscript/gdscript_disassembler.cpp
+++ b/modules/gdscript/gdscript_disassembler.cpp
@@ -851,7 +851,7 @@ void GDScriptFunction::disassemble(const Vector<String> &p_code_lines) const {
}
text += ")";
- incr = 3 + captures_count;
+ incr = 4 + captures_count;
} break;
case OPCODE_CREATE_SELF_LAMBDA: {
int instr_var_args = _code_ptr[++ip];
@@ -871,7 +871,7 @@ void GDScriptFunction::disassemble(const Vector<String> &p_code_lines) const {
}
text += ")";
- incr = 3 + captures_count;
+ incr = 4 + captures_count;
} break;
case OPCODE_JUMP: {
text += "jump ";
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index be33c7c591..829567d734 100644
--- a/modules/gdscript/gdscript_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -2992,6 +2992,15 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
List<MethodInfo> virtual_methods;
ClassDB::get_virtual_methods(class_name, &virtual_methods);
+
+ {
+ // Not truly a virtual method, but can also be "overridden".
+ MethodInfo static_init("_static_init");
+ static_init.return_val.type = Variant::NIL;
+ static_init.flags |= METHOD_FLAG_STATIC | METHOD_FLAG_VIRTUAL;
+ virtual_methods.push_back(static_init);
+ }
+
for (const MethodInfo &mi : virtual_methods) {
String method_hint = mi.name;
if (method_hint.contains(":")) {
@@ -3089,12 +3098,7 @@ String GDScriptLanguage::_get_indentation() const {
if (use_space_indentation) {
int indent_size = EDITOR_GET("text_editor/behavior/indent/size");
-
- String space_indent = "";
- for (int i = 0; i < indent_size; i++) {
- space_indent += " ";
- }
- return space_indent;
+ return String(" ").repeat(indent_size);
}
}
#endif
@@ -3141,12 +3145,7 @@ void GDScriptLanguage::auto_indent_code(String &p_code, int p_from_line, int p_t
}
if (i >= p_from_line) {
- l = "";
- for (int j = 0; j < indent_stack.size(); j++) {
- l += indent;
- }
- l += st;
-
+ l = indent.repeat(indent_stack.size()) + st;
} else if (i > p_to_line) {
break;
}
diff --git a/modules/gdscript/gdscript_function.h b/modules/gdscript/gdscript_function.h
index 1a5e9eef53..390e562e6f 100644
--- a/modules/gdscript/gdscript_function.h
+++ b/modules/gdscript/gdscript_function.h
@@ -409,7 +409,8 @@ public:
ADDR_TYPE_STACK = 0,
ADDR_TYPE_CONSTANT = 1,
ADDR_TYPE_MEMBER = 2,
- ADDR_TYPE_MAX = 3,
+ ADDR_TYPE_STATIC_VAR = 3,
+ ADDR_TYPE_MAX = 4,
};
enum FixedAddresses {
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index bcc116cda2..d3529154cf 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -81,6 +81,8 @@ GDScriptParser::GDScriptParser() {
// TODO: Should this be static?
register_annotation(MethodInfo("@tool"), AnnotationInfo::SCRIPT, &GDScriptParser::tool_annotation);
register_annotation(MethodInfo("@icon", PropertyInfo(Variant::STRING, "icon_path")), AnnotationInfo::SCRIPT, &GDScriptParser::icon_annotation);
+ register_annotation(MethodInfo("@static_unload"), AnnotationInfo::SCRIPT, &GDScriptParser::static_unload_annotation);
+
register_annotation(MethodInfo("@onready"), AnnotationInfo::VARIABLE, &GDScriptParser::onready_annotation);
// Export annotations.
register_annotation(MethodInfo("@export"), AnnotationInfo::VARIABLE, &GDScriptParser::export_annotations<PROPERTY_HINT_NONE, Variant::NIL>);
@@ -623,7 +625,7 @@ bool GDScriptParser::has_class(const GDScriptParser::ClassNode *p_class) const {
return false;
}
-GDScriptParser::ClassNode *GDScriptParser::parse_class() {
+GDScriptParser::ClassNode *GDScriptParser::parse_class(bool p_is_static) {
ClassNode *n_class = alloc_node<ClassNode>();
ClassNode *previous_class = current_class;
@@ -724,7 +726,7 @@ void GDScriptParser::parse_extends() {
}
template <class T>
-void GDScriptParser::parse_class_member(T *(GDScriptParser::*p_parse_function)(), AnnotationInfo::TargetKind p_target, const String &p_member_kind) {
+void GDScriptParser::parse_class_member(T *(GDScriptParser::*p_parse_function)(bool), AnnotationInfo::TargetKind p_target, const String &p_member_kind, bool p_is_static) {
advance();
#ifdef TOOLS_ENABLED
@@ -749,7 +751,7 @@ void GDScriptParser::parse_class_member(T *(GDScriptParser::*p_parse_function)()
#endif // TOOLS_ENABLED
}
- T *member = (this->*p_parse_function)();
+ T *member = (this->*p_parse_function)(p_is_static);
if (member == nullptr) {
return;
}
@@ -761,7 +763,11 @@ void GDScriptParser::parse_class_member(T *(GDScriptParser::*p_parse_function)()
#ifdef TOOLS_ENABLED
// Consume doc comments.
class_doc_line = MIN(class_doc_line, doc_comment_line - 1);
- if (has_comment(doc_comment_line)) {
+
+ // Check whether current line has a doc comment
+ if (has_comment(previous.start_line, true)) {
+ member->doc_description = get_doc_comment(previous.start_line, true);
+ } else if (has_comment(doc_comment_line, true)) {
if constexpr (std::is_same_v<T, ClassNode>) {
get_class_doc_comment(doc_comment_line, member->doc_brief_description, member->doc_description, member->doc_tutorials, true);
} else {
@@ -799,10 +805,15 @@ void GDScriptParser::parse_class_member(T *(GDScriptParser::*p_parse_function)()
void GDScriptParser::parse_class_body(bool p_is_multiline) {
bool class_end = false;
+ bool next_is_static = false;
while (!class_end && !is_at_end()) {
- switch (current.type) {
+ GDScriptTokenizer::Token token = current;
+ switch (token.type) {
case GDScriptTokenizer::Token::VAR:
- parse_class_member(&GDScriptParser::parse_variable, AnnotationInfo::VARIABLE, "variable");
+ parse_class_member(&GDScriptParser::parse_variable, AnnotationInfo::VARIABLE, "variable", next_is_static);
+ if (next_is_static) {
+ current_class->has_static_data = true;
+ }
break;
case GDScriptTokenizer::Token::CONST:
parse_class_member(&GDScriptParser::parse_constant, AnnotationInfo::CONSTANT, "constant");
@@ -810,9 +821,8 @@ void GDScriptParser::parse_class_body(bool p_is_multiline) {
case GDScriptTokenizer::Token::SIGNAL:
parse_class_member(&GDScriptParser::parse_signal, AnnotationInfo::SIGNAL, "signal");
break;
- case GDScriptTokenizer::Token::STATIC:
case GDScriptTokenizer::Token::FUNC:
- parse_class_member(&GDScriptParser::parse_function, AnnotationInfo::FUNCTION, "function");
+ parse_class_member(&GDScriptParser::parse_function, AnnotationInfo::FUNCTION, "function", next_is_static);
break;
case GDScriptTokenizer::Token::CLASS:
parse_class_member(&GDScriptParser::parse_class, AnnotationInfo::CLASS, "class");
@@ -820,6 +830,13 @@ void GDScriptParser::parse_class_body(bool p_is_multiline) {
case GDScriptTokenizer::Token::ENUM:
parse_class_member(&GDScriptParser::parse_enum, AnnotationInfo::NONE, "enum");
break;
+ case GDScriptTokenizer::Token::STATIC: {
+ advance();
+ next_is_static = true;
+ if (!check(GDScriptTokenizer::Token::FUNC) && !check(GDScriptTokenizer::Token::VAR)) {
+ push_error(R"(Expected "func" or "var" after "static".)");
+ }
+ } break;
case GDScriptTokenizer::Token::ANNOTATION: {
advance();
@@ -866,6 +883,9 @@ void GDScriptParser::parse_class_body(bool p_is_multiline) {
advance();
break;
}
+ if (token.type != GDScriptTokenizer::Token::STATIC) {
+ next_is_static = false;
+ }
if (panic_mode) {
synchronize();
}
@@ -875,11 +895,11 @@ void GDScriptParser::parse_class_body(bool p_is_multiline) {
}
}
-GDScriptParser::VariableNode *GDScriptParser::parse_variable() {
- return parse_variable(true);
+GDScriptParser::VariableNode *GDScriptParser::parse_variable(bool p_is_static) {
+ return parse_variable(p_is_static, true);
}
-GDScriptParser::VariableNode *GDScriptParser::parse_variable(bool p_allow_property) {
+GDScriptParser::VariableNode *GDScriptParser::parse_variable(bool p_is_static, bool p_allow_property) {
VariableNode *variable = alloc_node<VariableNode>();
if (!consume(GDScriptTokenizer::Token::IDENTIFIER, R"(Expected variable name after "var".)")) {
@@ -889,6 +909,7 @@ GDScriptParser::VariableNode *GDScriptParser::parse_variable(bool p_allow_proper
variable->identifier = parse_identifier();
variable->export_info.name = variable->identifier->name;
+ variable->is_static = p_is_static;
if (match(GDScriptTokenizer::Token::COLON)) {
if (check(GDScriptTokenizer::Token::NEWLINE)) {
@@ -1032,6 +1053,7 @@ void GDScriptParser::parse_property_setter(VariableNode *p_variable) {
complete_extents(identifier);
identifier->name = "@" + p_variable->identifier->name + "_setter";
function->identifier = identifier;
+ function->is_static = p_variable->is_static;
consume(GDScriptTokenizer::Token::PARENTHESIS_OPEN, R"(Expected "(" after "set".)");
@@ -1083,6 +1105,7 @@ void GDScriptParser::parse_property_getter(VariableNode *p_variable) {
complete_extents(identifier);
identifier->name = "@" + p_variable->identifier->name + "_getter";
function->identifier = identifier;
+ function->is_static = p_variable->is_static;
FunctionNode *previous_function = current_function;
current_function = function;
@@ -1107,7 +1130,7 @@ void GDScriptParser::parse_property_getter(VariableNode *p_variable) {
}
}
-GDScriptParser::ConstantNode *GDScriptParser::parse_constant() {
+GDScriptParser::ConstantNode *GDScriptParser::parse_constant(bool p_is_static) {
ConstantNode *constant = alloc_node<ConstantNode>();
if (!consume(GDScriptTokenizer::Token::IDENTIFIER, R"(Expected constant name after "const".)")) {
@@ -1174,7 +1197,7 @@ GDScriptParser::ParameterNode *GDScriptParser::parse_parameter() {
return parameter;
}
-GDScriptParser::SignalNode *GDScriptParser::parse_signal() {
+GDScriptParser::SignalNode *GDScriptParser::parse_signal(bool p_is_static) {
SignalNode *signal = alloc_node<SignalNode>();
if (!consume(GDScriptTokenizer::Token::IDENTIFIER, R"(Expected signal name after "signal".)")) {
@@ -1219,7 +1242,7 @@ GDScriptParser::SignalNode *GDScriptParser::parse_signal() {
return signal;
}
-GDScriptParser::EnumNode *GDScriptParser::parse_enum() {
+GDScriptParser::EnumNode *GDScriptParser::parse_enum(bool p_is_static) {
EnumNode *enum_node = alloc_node<EnumNode>();
bool named = false;
@@ -1368,23 +1391,23 @@ void GDScriptParser::parse_function_signature(FunctionNode *p_function, SuiteNod
}
}
+ if (!p_function->source_lambda && p_function->identifier && p_function->identifier->name == GDScriptLanguage::get_singleton()->strings._static_init) {
+ if (!p_function->is_static) {
+ push_error(R"(Static constructor must be declared static.)");
+ }
+ if (p_function->parameters.size() != 0) {
+ push_error(R"(Static constructor cannot have parameters.)");
+ }
+ current_class->has_static_data = true;
+ }
+
// TODO: Improve token consumption so it synchronizes to a statement boundary. This way we can get into the function body with unrecognized tokens.
consume(GDScriptTokenizer::Token::COLON, vformat(R"(Expected ":" after %s declaration.)", p_type));
}
-GDScriptParser::FunctionNode *GDScriptParser::parse_function() {
+GDScriptParser::FunctionNode *GDScriptParser::parse_function(bool p_is_static) {
FunctionNode *function = alloc_node<FunctionNode>();
- bool _static = false;
- if (previous.type == GDScriptTokenizer::Token::STATIC) {
- // TODO: Improve message if user uses "static" with "var" or "const"
- if (!consume(GDScriptTokenizer::Token::FUNC, R"(Expected "func" after "static".)")) {
- complete_extents(function);
- return nullptr;
- }
- _static = true;
- }
-
make_completion_context(COMPLETION_OVERRIDE_METHOD, function);
if (!consume(GDScriptTokenizer::Token::IDENTIFIER, R"(Expected function name after "func".)")) {
@@ -1396,7 +1419,7 @@ GDScriptParser::FunctionNode *GDScriptParser::parse_function() {
current_function = function;
function->identifier = parse_identifier();
- function->is_static = _static;
+ function->is_static = p_is_static;
SuiteNode *body = alloc_node<SuiteNode>();
SuiteNode *previous_suite = current_suite;
@@ -1608,11 +1631,11 @@ GDScriptParser::Node *GDScriptParser::parse_statement() {
break;
case GDScriptTokenizer::Token::VAR:
advance();
- result = parse_variable();
+ result = parse_variable(false, false);
break;
case GDScriptTokenizer::Token::CONST:
advance();
- result = parse_constant();
+ result = parse_constant(false);
break;
case GDScriptTokenizer::Token::IF:
advance();
@@ -1642,7 +1665,7 @@ GDScriptParser::Node *GDScriptParser::parse_statement() {
advance();
ReturnNode *n_return = alloc_node<ReturnNode>();
if (!is_statement_end()) {
- if (current_function && current_function->identifier->name == GDScriptLanguage::get_singleton()->strings._init) {
+ if (current_function && (current_function->identifier->name == GDScriptLanguage::get_singleton()->strings._init || current_function->identifier->name == GDScriptLanguage::get_singleton()->strings._static_init)) {
push_error(R"(Constructor cannot return a value.)");
}
n_return->return_value = parse_expression(false);
@@ -3296,8 +3319,15 @@ static bool _in_codeblock(String p_line, bool p_already_in, int *r_block_begins
}
}
-bool GDScriptParser::has_comment(int p_line) {
- return tokenizer.get_comments().has(p_line);
+bool GDScriptParser::has_comment(int p_line, bool p_must_be_doc) {
+ bool has_comment = tokenizer.get_comments().has(p_line);
+ // If there are no comments or if we don't care whether the comment
+ // is a docstring, we have our result.
+ if (!p_must_be_doc || !has_comment) {
+ return has_comment;
+ }
+
+ return tokenizer.get_comments()[p_line].comment.begins_with("##");
}
String GDScriptParser::get_doc_comment(int p_line, bool p_single_line) {
@@ -4090,6 +4120,17 @@ bool GDScriptParser::rpc_annotation(const AnnotationNode *p_annotation, Node *p_
return true;
}
+bool GDScriptParser::static_unload_annotation(const AnnotationNode *p_annotation, Node *p_target) {
+ ERR_FAIL_COND_V_MSG(p_target->type != Node::CLASS, false, vformat(R"("%s" annotation can only be applied to classes.)", p_annotation->name));
+ ClassNode *p_class = static_cast<ClassNode *>(p_target);
+ if (p_class->annotated_static_unload) {
+ push_error(vformat(R"("%s" annotation can only be used once per script.)", p_annotation->name), p_annotation);
+ return false;
+ }
+ p_class->annotated_static_unload = true;
+ return true;
+}
+
GDScriptParser::DataType GDScriptParser::SuiteNode::Local::get_datatype() const {
switch (type) {
case CONSTANT:
diff --git a/modules/gdscript/gdscript_parser.h b/modules/gdscript/gdscript_parser.h
index 29841ab060..8f0265510f 100644
--- a/modules/gdscript/gdscript_parser.h
+++ b/modules/gdscript/gdscript_parser.h
@@ -709,6 +709,8 @@ public:
ClassNode *outer = nullptr;
bool extends_used = false;
bool onready_used = false;
+ bool has_static_data = false;
+ bool annotated_static_unload = false;
String extends_path;
Vector<IdentifierNode *> extends; // List for indexing: extends A.B.C
DataType base_type;
@@ -847,6 +849,7 @@ public:
LOCAL_BIND, // Pattern bind.
MEMBER_SIGNAL,
MEMBER_VARIABLE,
+ STATIC_VARIABLE,
MEMBER_CONSTANT,
INHERITED_VARIABLE,
};
@@ -1202,6 +1205,7 @@ public:
bool onready = false;
PropertyInfo export_info;
int assignments = 0;
+ bool is_static = false;
#ifdef TOOLS_ENABLED
String doc_description;
#endif // TOOLS_ENABLED
@@ -1405,16 +1409,16 @@ private:
// Main blocks.
void parse_program();
- ClassNode *parse_class();
+ ClassNode *parse_class(bool p_is_static);
void parse_class_name();
void parse_extends();
void parse_class_body(bool p_is_multiline);
template <class T>
- void parse_class_member(T *(GDScriptParser::*p_parse_function)(), AnnotationInfo::TargetKind p_target, const String &p_member_kind);
- SignalNode *parse_signal();
- EnumNode *parse_enum();
+ void parse_class_member(T *(GDScriptParser::*p_parse_function)(bool), AnnotationInfo::TargetKind p_target, const String &p_member_kind, bool p_is_static = false);
+ SignalNode *parse_signal(bool p_is_static);
+ EnumNode *parse_enum(bool p_is_static);
ParameterNode *parse_parameter();
- FunctionNode *parse_function();
+ FunctionNode *parse_function(bool p_is_static);
void parse_function_signature(FunctionNode *p_function, SuiteNode *p_body, const String &p_type);
SuiteNode *parse_suite(const String &p_context, SuiteNode *p_suite = nullptr, bool p_for_lambda = false);
// Annotations
@@ -1431,14 +1435,15 @@ private:
bool export_group_annotations(const AnnotationNode *p_annotation, Node *p_target);
bool warning_annotations(const AnnotationNode *p_annotation, Node *p_target);
bool rpc_annotation(const AnnotationNode *p_annotation, Node *p_target);
+ bool static_unload_annotation(const AnnotationNode *p_annotation, Node *p_target);
// Statements.
Node *parse_statement();
- VariableNode *parse_variable();
- VariableNode *parse_variable(bool p_allow_property);
+ VariableNode *parse_variable(bool p_is_static);
+ VariableNode *parse_variable(bool p_is_static, bool p_allow_property);
VariableNode *parse_property(VariableNode *p_variable, bool p_need_indent);
void parse_property_getter(VariableNode *p_variable);
void parse_property_setter(VariableNode *p_variable);
- ConstantNode *parse_constant();
+ ConstantNode *parse_constant(bool p_is_static);
AssertNode *parse_assert();
BreakNode *parse_break();
ContinueNode *parse_continue();
@@ -1480,7 +1485,7 @@ private:
#ifdef TOOLS_ENABLED
// Doc comments.
int class_doc_line = 0x7FFFFFFF;
- bool has_comment(int p_line);
+ bool has_comment(int p_line, bool p_must_be_doc = false);
String get_doc_comment(int p_line, bool p_single_line = false);
void get_class_doc_comment(int p_line, String &p_brief, String &p_desc, Vector<Pair<String, String>> &p_tutorials, bool p_inner_class);
#endif // TOOLS_ENABLED
diff --git a/modules/gdscript/gdscript_vm.cpp b/modules/gdscript/gdscript_vm.cpp
index 83d2ed6010..bebf34cbb3 100644
--- a/modules/gdscript/gdscript_vm.cpp
+++ b/modules/gdscript/gdscript_vm.cpp
@@ -680,10 +680,10 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
bool awaited = false;
#endif
#ifdef DEBUG_ENABLED
- int variant_address_limits[ADDR_TYPE_MAX] = { _stack_size, _constant_count, p_instance ? p_instance->members.size() : 0 };
+ int variant_address_limits[ADDR_TYPE_MAX] = { _stack_size, _constant_count, p_instance ? p_instance->members.size() : 0, script->static_variables.size() };
#endif
- Variant *variant_addresses[ADDR_TYPE_MAX] = { stack, _constants_ptr, p_instance ? p_instance->members.ptrw() : nullptr };
+ Variant *variant_addresses[ADDR_TYPE_MAX] = { stack, _constants_ptr, p_instance ? p_instance->members.ptrw() : nullptr, script->static_variables.ptrw() };
#ifdef DEBUG_ENABLED
OPCODE_WHILE(ip < _code_size) {
@@ -774,7 +774,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
bool result = false;
if (value->get_type() == Variant::ARRAY) {
Array *array = VariantInternal::get_array(value);
- result = array->get_typed_builtin() == ((uint32_t)builtin_type) && array->get_typed_class_name() == native_type && array->get_typed_script() == *script_type && array->get_typed_class_name() == native_type;
+ result = array->get_typed_builtin() == ((uint32_t)builtin_type) && array->get_typed_class_name() == native_type && array->get_typed_script() == *script_type;
}
*dst = result;
@@ -1252,7 +1252,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
Array *array = VariantInternal::get_array(src);
- if (array->get_typed_builtin() != ((uint32_t)builtin_type) || array->get_typed_class_name() != native_type || array->get_typed_script() != *script_type || array->get_typed_class_name() != native_type) {
+ if (array->get_typed_builtin() != ((uint32_t)builtin_type) || array->get_typed_class_name() != native_type || array->get_typed_script() != *script_type) {
#ifdef DEBUG_ENABLED
err_text = vformat(R"(Trying to assign an array of type "%s" to a variable of type "Array[%s]".)",
_get_var_type(src), _get_element_type(builtin_type, native_type, *script_type));
@@ -1651,10 +1651,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
bool was_freed = false;
Object *obj = ret->get_validated_object_with_check(was_freed);
- if (was_freed) {
- err_text = "Got a freed object as a result of the call.";
- OPCODE_BREAK;
- }
if (obj && obj->is_class_ptr(GDScriptFunctionState::get_class_ptr_static())) {
err_text = R"(Trying to call an async function without "await".)";
OPCODE_BREAK;
@@ -2583,7 +2579,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
Array *array = VariantInternal::get_array(r);
- if (array->get_typed_builtin() != ((uint32_t)builtin_type) || array->get_typed_class_name() != native_type || array->get_typed_script() != *script_type || array->get_typed_class_name() != native_type) {
+ if (array->get_typed_builtin() != ((uint32_t)builtin_type) || array->get_typed_class_name() != native_type || array->get_typed_script() != *script_type) {
#ifdef DEBUG_ENABLED
err_text = vformat(R"(Trying to return an array of type "%s" where expected return type is "Array[%s]".)",
_get_var_type(r), _get_element_type(builtin_type, native_type, *script_type));
@@ -3572,8 +3568,9 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
//error
// function, file, line, error, explanation
String err_file;
- if (p_instance && ObjectDB::get_instance(p_instance->owner_id) != nullptr && p_instance->script->is_valid() && !p_instance->script->path.is_empty()) {
- err_file = p_instance->script->path;
+ bool instance_valid_with_script = p_instance && ObjectDB::get_instance(p_instance->owner_id) != nullptr && p_instance->script->is_valid();
+ if (instance_valid_with_script && !get_script()->path.is_empty()) {
+ err_file = get_script()->path;
} else if (script) {
err_file = script->path;
}
@@ -3581,7 +3578,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
err_file = "<built-in>";
}
String err_func = name;
- if (p_instance && ObjectDB::get_instance(p_instance->owner_id) != nullptr && p_instance->script->is_valid() && !p_instance->script->name.is_empty()) {
+ if (instance_valid_with_script && !p_instance->script->name.is_empty()) {
err_func = p_instance->script->name + "." + err_func;
}
int err_line = line;
diff --git a/modules/gdscript/gdscript_warning.cpp b/modules/gdscript/gdscript_warning.cpp
index 0cb8e3a2af..8de78d2b9a 100644
--- a/modules/gdscript/gdscript_warning.cpp
+++ b/modules/gdscript/gdscript_warning.cpp
@@ -38,153 +38,115 @@ String GDScriptWarning::get_message() const {
#define CHECK_SYMBOLS(m_amount) ERR_FAIL_COND_V(symbols.size() < m_amount, String());
switch (code) {
- case UNASSIGNED_VARIABLE_OP_ASSIGN: {
+ case UNASSIGNED_VARIABLE:
CHECK_SYMBOLS(1);
- return "Using assignment with operation but the variable '" + symbols[0] + "' was not previously assigned a value.";
- } break;
- case UNASSIGNED_VARIABLE: {
+ return vformat(R"(The variable "%s" was used but never assigned a value.)", symbols[0]);
+ case UNASSIGNED_VARIABLE_OP_ASSIGN:
CHECK_SYMBOLS(1);
- return "The variable '" + symbols[0] + "' was used but never assigned a value.";
- } break;
- case UNUSED_VARIABLE: {
+ return vformat(R"(Using assignment with operation but the variable "%s" was not previously assigned a value.)", symbols[0]);
+ case UNUSED_VARIABLE:
CHECK_SYMBOLS(1);
- return "The local variable '" + symbols[0] + "' is declared but never used in the block. If this is intended, prefix it with an underscore: '_" + symbols[0] + "'";
- } break;
- case UNUSED_LOCAL_CONSTANT: {
+ return vformat(R"(The local variable "%s" is declared but never used in the block. If this is intended, prefix it with an underscore: "_%s".)", symbols[0], symbols[0]);
+ case UNUSED_LOCAL_CONSTANT:
CHECK_SYMBOLS(1);
- return "The local constant '" + symbols[0] + "' is declared but never used in the block. If this is intended, prefix it with an underscore: '_" + symbols[0] + "'";
- } break;
- case SHADOWED_VARIABLE: {
+ return vformat(R"(The local constant "%s" is declared but never used in the block. If this is intended, prefix it with an underscore: "_%s".)", symbols[0], symbols[0]);
+ case UNUSED_PRIVATE_CLASS_VARIABLE:
+ CHECK_SYMBOLS(1);
+ return vformat(R"(The class variable "%s" is declared but never used in the script.)", symbols[0]);
+ case UNUSED_PARAMETER:
+ CHECK_SYMBOLS(2);
+ return vformat(R"*(The parameter "%s" is never used in the function "%s()". If this is intended, prefix it with an underscore: "_%s".)*", symbols[1], symbols[0], symbols[1]);
+ case UNUSED_SIGNAL:
+ CHECK_SYMBOLS(1);
+ return vformat(R"(The signal "%s" is declared but never emitted.)", symbols[0]);
+ case SHADOWED_VARIABLE:
CHECK_SYMBOLS(4);
return vformat(R"(The local %s "%s" is shadowing an already-declared %s at line %s.)", symbols[0], symbols[1], symbols[2], symbols[3]);
- } break;
- case SHADOWED_VARIABLE_BASE_CLASS: {
+ case SHADOWED_VARIABLE_BASE_CLASS:
CHECK_SYMBOLS(4);
return vformat(R"(The local %s "%s" is shadowing an already-declared %s at the base class "%s".)", symbols[0], symbols[1], symbols[2], symbols[3]);
- } break;
- case UNUSED_PRIVATE_CLASS_VARIABLE: {
- CHECK_SYMBOLS(1);
- return "The class variable '" + symbols[0] + "' is declared but never used in the script.";
- } break;
- case UNUSED_PARAMETER: {
- CHECK_SYMBOLS(2);
- return "The parameter '" + symbols[1] + "' is never used in the function '" + symbols[0] + "'. If this is intended, prefix it with an underscore: '_" + symbols[1] + "'";
- } break;
- case UNREACHABLE_CODE: {
+ case SHADOWED_GLOBAL_IDENTIFIER:
+ CHECK_SYMBOLS(3);
+ return vformat(R"(The %s "%s" has the same name as a %s.)", symbols[0], symbols[1], symbols[2]);
+ case UNREACHABLE_CODE:
CHECK_SYMBOLS(1);
- return "Unreachable code (statement after return) in function '" + symbols[0] + "()'.";
- } break;
- case UNREACHABLE_PATTERN: {
+ return vformat(R"*(Unreachable code (statement after return) in function "%s()".)*", symbols[0]);
+ case UNREACHABLE_PATTERN:
return "Unreachable pattern (pattern after wildcard or bind).";
- } break;
- case STANDALONE_EXPRESSION: {
+ case STANDALONE_EXPRESSION:
return "Standalone expression (the line has no effect).";
- } break;
- case NARROWING_CONVERSION: {
- return "Narrowing conversion (float is converted to int and loses precision).";
- } break;
- case INCOMPATIBLE_TERNARY: {
+ case STANDALONE_TERNARY:
+ return "Standalone ternary conditional operator: the return value is being discarded.";
+ case INCOMPATIBLE_TERNARY:
return "Values of the ternary conditional are not mutually compatible.";
- } break;
- case UNUSED_SIGNAL: {
- CHECK_SYMBOLS(1);
- return "The signal '" + symbols[0] + "' is declared but never emitted.";
- } break;
- case RETURN_VALUE_DISCARDED: {
- CHECK_SYMBOLS(1);
- return "The function '" + symbols[0] + "()' returns a value that will be discarded if not used.";
- } break;
- case PROPERTY_USED_AS_FUNCTION: {
+ case PROPERTY_USED_AS_FUNCTION:
CHECK_SYMBOLS(2);
- return "The method '" + symbols[0] + "()' was not found in base '" + symbols[1] + "' but there's a property with the same name. Did you mean to access it?";
- } break;
- case CONSTANT_USED_AS_FUNCTION: {
+ return vformat(R"*(The method "%s()" was not found in base "%s" but there's a property with the same name. Did you mean to access it?)*", symbols[0], symbols[1]);
+ case CONSTANT_USED_AS_FUNCTION:
CHECK_SYMBOLS(2);
- return "The method '" + symbols[0] + "()' was not found in base '" + symbols[1] + "' but there's a constant with the same name. Did you mean to access it?";
- } break;
- case FUNCTION_USED_AS_PROPERTY: {
+ return vformat(R"*(The method "%s()" was not found in base "%s" but there's a constant with the same name. Did you mean to access it?)*", symbols[0], symbols[1]);
+ case FUNCTION_USED_AS_PROPERTY:
CHECK_SYMBOLS(2);
- return "The property '" + symbols[0] + "' was not found in base '" + symbols[1] + "' but there's a method with the same name. Did you mean to call it?";
- } break;
- case INTEGER_DIVISION: {
- return "Integer division, decimal part will be discarded.";
- } break;
- case UNSAFE_PROPERTY_ACCESS: {
+ return vformat(R"(The property "%s" was not found in base "%s" but there's a method with the same name. Did you mean to call it?)", symbols[0], symbols[1]);
+ case UNSAFE_PROPERTY_ACCESS:
CHECK_SYMBOLS(2);
- return "The property '" + symbols[0] + "' is not present on the inferred type '" + symbols[1] + "' (but may be present on a subtype).";
- } break;
- case UNSAFE_METHOD_ACCESS: {
+ return vformat(R"(The property "%s" is not present on the inferred type "%s" (but may be present on a subtype).)", symbols[0], symbols[1]);
+ case UNSAFE_METHOD_ACCESS:
CHECK_SYMBOLS(2);
- return "The method '" + symbols[0] + "' is not present on the inferred type '" + symbols[1] + "' (but may be present on a subtype).";
- } break;
- case UNSAFE_CAST: {
+ return vformat(R"*(The method "%s()" is not present on the inferred type "%s" (but may be present on a subtype).)*", symbols[0], symbols[1]);
+ case UNSAFE_CAST:
CHECK_SYMBOLS(1);
- return "The value is cast to '" + symbols[0] + "' but has an unknown type.";
- } break;
- case UNSAFE_CALL_ARGUMENT: {
+ return vformat(R"(The value is cast to "%s" but has an unknown type.)", symbols[0]);
+ case UNSAFE_CALL_ARGUMENT:
CHECK_SYMBOLS(4);
- return "The argument '" + symbols[0] + "' of the function '" + symbols[1] + "' requires a the subtype '" + symbols[2] + "' but the supertype '" + symbols[3] + "' was provided";
- } break;
- case UNSAFE_VOID_RETURN: {
+ return vformat(R"*(The argument %s of the function "%s()" requires a the subtype "%s" but the supertype "%s" was provided.)*", symbols[0], symbols[1], symbols[2], symbols[3]);
+ case UNSAFE_VOID_RETURN:
CHECK_SYMBOLS(2);
- return "The method '" + symbols[0] + "()' returns 'void' but it's trying to return a call to '" + symbols[1] + "()' that can't be ensured to also be 'void'.";
- } break;
- case DEPRECATED_KEYWORD: {
+ return vformat(R"*(The method "%s()" returns "void" but it's trying to return a call to "%s()" that can't be ensured to also be "void".)*", symbols[0], symbols[1]);
+ case RETURN_VALUE_DISCARDED:
+ CHECK_SYMBOLS(1);
+ return vformat(R"*(The function "%s()" returns a value that will be discarded if not used.)*", symbols[0]);
+ case STATIC_CALLED_ON_INSTANCE:
CHECK_SYMBOLS(2);
- return "The '" + symbols[0] + "' keyword is deprecated and will be removed in a future release, please replace its uses by '" + symbols[1] + "'.";
- } break;
- case STANDALONE_TERNARY: {
- return "Standalone ternary conditional operator: the return value is being discarded.";
- }
- case ASSERT_ALWAYS_TRUE: {
+ return vformat(R"*(The function "%s()" is a static function but was called from an instance. Instead, it should be directly called from the type: "%s.%s()".)*", symbols[0], symbols[1], symbols[0]);
+ case REDUNDANT_STATIC_UNLOAD:
+ return R"(The "@static_unload" annotation is redundant because the file does not have a class with static variables.)";
+ case REDUNDANT_AWAIT:
+ return R"("await" keyword not needed in this case, because the expression isn't a coroutine nor a signal.)";
+ case ASSERT_ALWAYS_TRUE:
return "Assert statement is redundant because the expression is always true.";
- }
- case ASSERT_ALWAYS_FALSE: {
+ case ASSERT_ALWAYS_FALSE:
return "Assert statement will raise an error because the expression is always false.";
- }
- case REDUNDANT_AWAIT: {
- return R"("await" keyword not needed in this case, because the expression isn't a coroutine nor a signal.)";
- }
- case EMPTY_FILE: {
- return "Empty script file.";
- }
- case SHADOWED_GLOBAL_IDENTIFIER: {
- CHECK_SYMBOLS(3);
- return vformat(R"(The %s '%s' has the same name as a %s.)", symbols[0], symbols[1], symbols[2]);
- }
- case INT_AS_ENUM_WITHOUT_CAST: {
+ case INTEGER_DIVISION:
+ return "Integer division, decimal part will be discarded.";
+ case NARROWING_CONVERSION:
+ return "Narrowing conversion (float is converted to int and loses precision).";
+ case INT_AS_ENUM_WITHOUT_CAST:
return "Integer used when an enum value is expected. If this is intended cast the integer to the enum type.";
- }
- case INT_AS_ENUM_WITHOUT_MATCH: {
+ case INT_AS_ENUM_WITHOUT_MATCH:
CHECK_SYMBOLS(3);
return vformat(R"(Cannot %s %s as Enum "%s": no enum member has matching value.)", symbols[0], symbols[1], symbols[2]);
- } break;
- case STATIC_CALLED_ON_INSTANCE: {
+ case EMPTY_FILE:
+ return "Empty script file.";
+ case DEPRECATED_KEYWORD:
CHECK_SYMBOLS(2);
- return vformat(R"(The function '%s()' is a static function but was called from an instance. Instead, it should be directly called from the type: '%s.%s()'.)", symbols[0], symbols[1], symbols[0]);
- }
- case CONFUSABLE_IDENTIFIER: {
+ return vformat(R"(The "%s" keyword is deprecated and will be removed in a future release, please replace its uses by "%s".)", symbols[0], symbols[1]);
+ case RENAMED_IN_GODOT_4_HINT:
+ break; // Renamed identifier hint is taken care of by the GDScriptAnalyzer. No message needed here.
+ case CONFUSABLE_IDENTIFIER:
CHECK_SYMBOLS(1);
return vformat(R"(The identifier "%s" has misleading characters and might be confused with something else.)", symbols[0]);
- }
- case RENAMED_IN_GD4_HINT: {
- break; // Renamed identifier hint is taken care of by the GDScriptAnalyzer. No message needed here.
- }
- case INFERENCE_ON_VARIANT: {
+ case INFERENCE_ON_VARIANT:
CHECK_SYMBOLS(1);
return vformat("The %s type is being inferred from a Variant value, so it will be typed as Variant.", symbols[0]);
- }
- case NATIVE_METHOD_OVERRIDE: {
+ case NATIVE_METHOD_OVERRIDE:
CHECK_SYMBOLS(2);
- return vformat(R"(The method "%s" overrides a method from native class "%s". This won't be called by the engine and may not work as expected.)", symbols[0], symbols[1]);
- }
- case GET_NODE_DEFAULT_WITHOUT_ONREADY: {
+ return vformat(R"*(The method "%s()" overrides a method from native class "%s". This won't be called by the engine and may not work as expected.)*", symbols[0], symbols[1]);
+ case GET_NODE_DEFAULT_WITHOUT_ONREADY:
CHECK_SYMBOLS(1);
return vformat(R"*(The default value is using "%s" which won't return nodes in the scene tree before "_ready()" is called. Use the "@onready" annotation to solve this.)*", symbols[0]);
- }
- case ONREADY_WITH_EXPORT: {
+ case ONREADY_WITH_EXPORT:
return R"("@onready" will set the default value after "@export" takes effect and will override it.)";
- }
case WARNING_MAX:
break; // Can't happen, but silences warning
}
@@ -200,7 +162,7 @@ int GDScriptWarning::get_default_value(Code p_code) {
PropertyInfo GDScriptWarning::get_property_info(Code p_code) {
// Making this a separate function in case a warning needs different PropertyInfo in the future.
- if (p_code == Code::RENAMED_IN_GD4_HINT) {
+ if (p_code == Code::RENAMED_IN_GODOT_4_HINT) {
return PropertyInfo(Variant::BOOL, get_settings_path_from_code(p_code));
}
return PropertyInfo(Variant::INT, get_settings_path_from_code(p_code), PROPERTY_HINT_ENUM, "Ignore,Warn,Error");
@@ -218,38 +180,39 @@ String GDScriptWarning::get_name_from_code(Code p_code) {
"UNASSIGNED_VARIABLE_OP_ASSIGN",
"UNUSED_VARIABLE",
"UNUSED_LOCAL_CONSTANT",
- "SHADOWED_VARIABLE",
- "SHADOWED_VARIABLE_BASE_CLASS",
"UNUSED_PRIVATE_CLASS_VARIABLE",
"UNUSED_PARAMETER",
+ "UNUSED_SIGNAL",
+ "SHADOWED_VARIABLE",
+ "SHADOWED_VARIABLE_BASE_CLASS",
+ "SHADOWED_GLOBAL_IDENTIFIER",
"UNREACHABLE_CODE",
"UNREACHABLE_PATTERN",
"STANDALONE_EXPRESSION",
- "NARROWING_CONVERSION",
+ "STANDALONE_TERNARY",
"INCOMPATIBLE_TERNARY",
- "UNUSED_SIGNAL",
- "RETURN_VALUE_DISCARDED",
"PROPERTY_USED_AS_FUNCTION",
"CONSTANT_USED_AS_FUNCTION",
"FUNCTION_USED_AS_PROPERTY",
- "INTEGER_DIVISION",
"UNSAFE_PROPERTY_ACCESS",
"UNSAFE_METHOD_ACCESS",
"UNSAFE_CAST",
"UNSAFE_CALL_ARGUMENT",
"UNSAFE_VOID_RETURN",
- "DEPRECATED_KEYWORD",
- "STANDALONE_TERNARY",
+ "RETURN_VALUE_DISCARDED",
+ "STATIC_CALLED_ON_INSTANCE",
+ "REDUNDANT_STATIC_UNLOAD",
+ "REDUNDANT_AWAIT",
"ASSERT_ALWAYS_TRUE",
"ASSERT_ALWAYS_FALSE",
- "REDUNDANT_AWAIT",
- "EMPTY_FILE",
- "SHADOWED_GLOBAL_IDENTIFIER",
+ "INTEGER_DIVISION",
+ "NARROWING_CONVERSION",
"INT_AS_ENUM_WITHOUT_CAST",
"INT_AS_ENUM_WITHOUT_MATCH",
- "STATIC_CALLED_ON_INSTANCE",
- "CONFUSABLE_IDENTIFIER",
+ "EMPTY_FILE",
+ "DEPRECATED_KEYWORD",
"RENAMED_IN_GODOT_4_HINT",
+ "CONFUSABLE_IDENTIFIER",
"INFERENCE_ON_VARIANT",
"NATIVE_METHOD_OVERRIDE",
"GET_NODE_DEFAULT_WITHOUT_ONREADY",
diff --git a/modules/gdscript/gdscript_warning.h b/modules/gdscript/gdscript_warning.h
index f0123c518c..ae6207fcdc 100644
--- a/modules/gdscript/gdscript_warning.h
+++ b/modules/gdscript/gdscript_warning.h
@@ -50,38 +50,39 @@ public:
UNASSIGNED_VARIABLE_OP_ASSIGN, // Variable never assigned but used in an assignment operation (+=, *=, etc).
UNUSED_VARIABLE, // Local variable is declared but never used.
UNUSED_LOCAL_CONSTANT, // Local constant is declared but never used.
- SHADOWED_VARIABLE, // Variable name shadowed by other variable in same class.
- SHADOWED_VARIABLE_BASE_CLASS, // Variable name shadowed by other variable in some base class.
UNUSED_PRIVATE_CLASS_VARIABLE, // Class variable is declared private ("_" prefix) but never used in the file.
UNUSED_PARAMETER, // Function parameter is never used.
+ UNUSED_SIGNAL, // Signal is defined but never emitted.
+ SHADOWED_VARIABLE, // Variable name shadowed by other variable in same class.
+ SHADOWED_VARIABLE_BASE_CLASS, // Variable name shadowed by other variable in some base class.
+ SHADOWED_GLOBAL_IDENTIFIER, // A global class or function has the same name as variable.
UNREACHABLE_CODE, // Code after a return statement.
UNREACHABLE_PATTERN, // Pattern in a match statement after a catch all pattern (wildcard or bind).
STANDALONE_EXPRESSION, // Expression not assigned to a variable.
- NARROWING_CONVERSION, // Float value into an integer slot, precision is lost.
+ STANDALONE_TERNARY, // Return value of ternary expression is discarded.
INCOMPATIBLE_TERNARY, // Possible values of a ternary if are not mutually compatible.
- UNUSED_SIGNAL, // Signal is defined but never emitted.
- RETURN_VALUE_DISCARDED, // Function call returns something but the value isn't used.
PROPERTY_USED_AS_FUNCTION, // Function not found, but there's a property with the same name.
CONSTANT_USED_AS_FUNCTION, // Function not found, but there's a constant with the same name.
FUNCTION_USED_AS_PROPERTY, // Property not found, but there's a function with the same name.
- INTEGER_DIVISION, // Integer divide by integer, decimal part is discarded.
UNSAFE_PROPERTY_ACCESS, // Property not found in the detected type (but can be in subtypes).
UNSAFE_METHOD_ACCESS, // Function not found in the detected type (but can be in subtypes).
UNSAFE_CAST, // Cast used in an unknown type.
- UNSAFE_CALL_ARGUMENT, // Function call argument is of a supertype of the require argument.
+ UNSAFE_CALL_ARGUMENT, // Function call argument is of a supertype of the required type.
UNSAFE_VOID_RETURN, // Function returns void but returned a call to a function that can't be type checked.
- DEPRECATED_KEYWORD, // The keyword is deprecated and should be replaced.
- STANDALONE_TERNARY, // Return value of ternary expression is discarded.
+ RETURN_VALUE_DISCARDED, // Function call returns something but the value isn't used.
+ STATIC_CALLED_ON_INSTANCE, // A static method was called on an instance of a class instead of on the class itself.
+ REDUNDANT_STATIC_UNLOAD, // The `@static_unload` annotation is used but the class does not have static data.
+ REDUNDANT_AWAIT, // await is used but expression is synchronous (not a signal nor a coroutine).
ASSERT_ALWAYS_TRUE, // Expression for assert argument is always true.
ASSERT_ALWAYS_FALSE, // Expression for assert argument is always false.
- REDUNDANT_AWAIT, // await is used but expression is synchronous (not a signal nor a coroutine).
- EMPTY_FILE, // A script file is empty.
- SHADOWED_GLOBAL_IDENTIFIER, // A global class or function has the same name as variable.
+ INTEGER_DIVISION, // Integer divide by integer, decimal part is discarded.
+ NARROWING_CONVERSION, // Float value into an integer slot, precision is lost.
INT_AS_ENUM_WITHOUT_CAST, // An integer value was used as an enum value without casting.
INT_AS_ENUM_WITHOUT_MATCH, // An integer value was used as an enum value without matching enum member.
- STATIC_CALLED_ON_INSTANCE, // A static method was called on an instance of a class instead of on the class itself.
+ EMPTY_FILE, // A script file is empty.
+ DEPRECATED_KEYWORD, // The keyword is deprecated and should be replaced.
+ RENAMED_IN_GODOT_4_HINT, // A variable or function that could not be found has been renamed in Godot 4.
CONFUSABLE_IDENTIFIER, // The identifier contains misleading characters that can be confused. E.g. "usеr" (has Cyrillic "е" instead of Latin "e").
- RENAMED_IN_GD4_HINT, // A variable or function that could not be found has been renamed in Godot 4
INFERENCE_ON_VARIANT, // The declaration uses type inference but the value is typed as Variant.
NATIVE_METHOD_OVERRIDE, // The script method overrides a native one, this may not work as intended.
GET_NODE_DEFAULT_WITHOUT_ONREADY, // A class variable uses `get_node()` (or the `$` notation) as its default value, but does not use the @onready annotation.
@@ -94,38 +95,39 @@ public:
WARN, // UNASSIGNED_VARIABLE_OP_ASSIGN
WARN, // UNUSED_VARIABLE
WARN, // UNUSED_LOCAL_CONSTANT
- WARN, // SHADOWED_VARIABLE
- WARN, // SHADOWED_VARIABLE_BASE_CLASS
WARN, // UNUSED_PRIVATE_CLASS_VARIABLE
WARN, // UNUSED_PARAMETER
+ WARN, // UNUSED_SIGNAL
+ WARN, // SHADOWED_VARIABLE
+ WARN, // SHADOWED_VARIABLE_BASE_CLASS
+ WARN, // SHADOWED_GLOBAL_IDENTIFIER
WARN, // UNREACHABLE_CODE
WARN, // UNREACHABLE_PATTERN
WARN, // STANDALONE_EXPRESSION
- WARN, // NARROWING_CONVERSION
+ WARN, // STANDALONE_TERNARY
WARN, // INCOMPATIBLE_TERNARY
- WARN, // UNUSED_SIGNAL
- IGNORE, // RETURN_VALUE_DISCARDED // Too spammy by default on common cases (connect, Tween, etc.).
WARN, // PROPERTY_USED_AS_FUNCTION
WARN, // CONSTANT_USED_AS_FUNCTION
WARN, // FUNCTION_USED_AS_PROPERTY
- WARN, // INTEGER_DIVISION
IGNORE, // UNSAFE_PROPERTY_ACCESS // Too common in untyped scenarios.
IGNORE, // UNSAFE_METHOD_ACCESS // Too common in untyped scenarios.
IGNORE, // UNSAFE_CAST // Too common in untyped scenarios.
IGNORE, // UNSAFE_CALL_ARGUMENT // Too common in untyped scenarios.
WARN, // UNSAFE_VOID_RETURN
- WARN, // DEPRECATED_KEYWORD
- WARN, // STANDALONE_TERNARY
+ IGNORE, // RETURN_VALUE_DISCARDED // Too spammy by default on common cases (connect, Tween, etc.).
+ WARN, // STATIC_CALLED_ON_INSTANCE
+ WARN, // REDUNDANT_STATIC_UNLOAD
+ WARN, // REDUNDANT_AWAIT
WARN, // ASSERT_ALWAYS_TRUE
WARN, // ASSERT_ALWAYS_FALSE
- WARN, // REDUNDANT_AWAIT
- WARN, // EMPTY_FILE
- WARN, // SHADOWED_GLOBAL_IDENTIFIER
+ WARN, // INTEGER_DIVISION
+ WARN, // NARROWING_CONVERSION
WARN, // INT_AS_ENUM_WITHOUT_CAST
WARN, // INT_AS_ENUM_WITHOUT_MATCH
- WARN, // STATIC_CALLED_ON_INSTANCE
+ WARN, // EMPTY_FILE
+ WARN, // DEPRECATED_KEYWORD
+ WARN, // RENAMED_IN_GODOT_4_HINT
WARN, // CONFUSABLE_IDENTIFIER
- WARN, // RENAMED_IN_GD4_HINT
ERROR, // INFERENCE_ON_VARIANT // Most likely done by accident, usually inference is trying for a particular type.
ERROR, // NATIVE_METHOD_OVERRIDE // May not work as expected.
ERROR, // GET_NODE_DEFAULT_WITHOUT_ONREADY // May not work as expected.
diff --git a/modules/gdscript/tests/gdscript_test_runner.cpp b/modules/gdscript/tests/gdscript_test_runner.cpp
index 57405aa1ce..b8448d16c2 100644
--- a/modules/gdscript/tests/gdscript_test_runner.cpp
+++ b/modules/gdscript/tests/gdscript_test_runner.cpp
@@ -350,13 +350,13 @@ void GDScriptTestRunner::handle_cmdline() {
for (List<String>::Element *E = cmdline_args.front(); E; E = E->next()) {
String &cmd = E->get();
if (cmd == "--gdscript-generate-tests") {
- if (E->next() == nullptr) {
- ERR_PRINT("Needed a path for the test files.");
- exit(-1);
+ String path;
+ if (E->next()) {
+ path = E->next()->get();
+ } else {
+ path = "modules/gdscript/tests/scripts";
}
- const String &path = E->next()->get();
-
GDScriptTestRunner runner(path, false, cmdline_args.find("--print-filenames") != nullptr);
bool completed = runner.generate_outputs();
@@ -566,6 +566,14 @@ GDScriptTest::TestResult GDScriptTest::execute_test_code(bool p_is_generating) {
ERR_FAIL_V_MSG(result, "\nCould not find test function on: '" + source_file + "'");
}
+ // Setup output handlers.
+ ErrorHandlerData error_data(&result, this);
+
+ _print_handler.userdata = &result;
+ _error_handler.userdata = &error_data;
+ add_print_handler(&_print_handler);
+ add_error_handler(&_error_handler);
+
script->reload();
// Create object instance for test.
@@ -577,14 +585,6 @@ GDScriptTest::TestResult GDScriptTest::execute_test_code(bool p_is_generating) {
obj->set_script(script);
GDScriptInstance *instance = static_cast<GDScriptInstance *>(obj->get_script_instance());
- // Setup output handlers.
- ErrorHandlerData error_data(&result, this);
-
- _print_handler.userdata = &result;
- _error_handler.userdata = &error_data;
- add_print_handler(&_print_handler);
- add_error_handler(&_error_handler);
-
// Call test function.
Callable::CallError call_err;
instance->callp(GDScriptTestRunner::test_function_name, nullptr, 0, call_err);
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/static_constructor_with_return_type.gd b/modules/gdscript/tests/scripts/analyzer/errors/static_constructor_with_return_type.gd
new file mode 100644
index 0000000000..3dac751ba9
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/static_constructor_with_return_type.gd
@@ -0,0 +1,5 @@
+static func _static_init() -> int:
+ print("static init")
+
+func test():
+ print("done")
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/static_constructor_with_return_type.out b/modules/gdscript/tests/scripts/analyzer/errors/static_constructor_with_return_type.out
new file mode 100644
index 0000000000..42294b7afb
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/static_constructor_with_return_type.out
@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+Static constructor cannot have an explicit return type.
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_non_static_call.gd b/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_non_static_call.gd
new file mode 100644
index 0000000000..1ae814ea34
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_non_static_call.gd
@@ -0,0 +1,9 @@
+@static_unload
+
+func non_static():
+ return "non static"
+
+static var static_var = non_static()
+
+func test():
+ print("does not run")
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_non_static_call.out b/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_non_static_call.out
new file mode 100644
index 0000000000..f1e9ec34f2
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_non_static_call.out
@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+Cannot call non-static function "non_static()" for static variable initializer.
diff --git a/modules/gdscript/tests/scripts/analyzer/features/allow_void_function_to_return_void.out b/modules/gdscript/tests/scripts/analyzer/features/allow_void_function_to_return_void.out
index 7c0416371f..f49d93620f 100644
--- a/modules/gdscript/tests/scripts/analyzer/features/allow_void_function_to_return_void.out
+++ b/modules/gdscript/tests/scripts/analyzer/features/allow_void_function_to_return_void.out
@@ -2,7 +2,7 @@ GDTEST_OK
>> WARNING
>> Line: 20
>> UNSAFE_VOID_RETURN
->> The method 'return_side_effect()' returns 'void' but it's trying to return a call to 'side_effect()' that can't be ensured to also be 'void'.
+>> The method "return_side_effect()" returns "void" but it's trying to return a call to "side_effect()" that can't be ensured to also be "void".
hello
effect
effect
diff --git a/modules/gdscript/tests/scripts/analyzer/features/assert_literal_false.gd b/modules/gdscript/tests/scripts/analyzer/features/assert_literal_false.gd
new file mode 100644
index 0000000000..d6c3cfc50e
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/assert_literal_false.gd
@@ -0,0 +1,6 @@
+func test():
+ var never: Variant = false
+ if never:
+ assert(false)
+ assert(false, 'message')
+ print('ok')
diff --git a/modules/gdscript/tests/scripts/analyzer/features/assert_literal_false.out b/modules/gdscript/tests/scripts/analyzer/features/assert_literal_false.out
new file mode 100644
index 0000000000..1b47ed10dc
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/assert_literal_false.out
@@ -0,0 +1,2 @@
+GDTEST_OK
+ok
diff --git a/modules/gdscript/tests/scripts/analyzer/features/auto_inferred_type_dont_error.out b/modules/gdscript/tests/scripts/analyzer/features/auto_inferred_type_dont_error.out
index 481016138a..22cd5d3a17 100644
--- a/modules/gdscript/tests/scripts/analyzer/features/auto_inferred_type_dont_error.out
+++ b/modules/gdscript/tests/scripts/analyzer/features/auto_inferred_type_dont_error.out
@@ -2,5 +2,5 @@ GDTEST_OK
>> WARNING
>> Line: 6
>> UNSAFE_METHOD_ACCESS
->> The method 'free' is not present on the inferred type 'Variant' (but may be present on a subtype).
+>> The method "free()" is not present on the inferred type "Variant" (but may be present on a subtype).
Ok
diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/lambda_unused_arg.out b/modules/gdscript/tests/scripts/analyzer/warnings/lambda_unused_arg.out
index 32e230fc80..fe6083c329 100644
--- a/modules/gdscript/tests/scripts/analyzer/warnings/lambda_unused_arg.out
+++ b/modules/gdscript/tests/scripts/analyzer/warnings/lambda_unused_arg.out
@@ -2,4 +2,4 @@ GDTEST_OK
>> WARNING
>> Line: 2
>> UNUSED_PARAMETER
->> The parameter 'unused' is never used in the function ''. If this is intended, prefix it with an underscore: '_unused'
+>> The parameter "unused" is never used in the function "<anonymous lambda>()". If this is intended, prefix it with an underscore: "_unused".
diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/overriding_native_method.out b/modules/gdscript/tests/scripts/analyzer/warnings/overriding_native_method.out
index 793faa05d4..c76950179d 100644
--- a/modules/gdscript/tests/scripts/analyzer/warnings/overriding_native_method.out
+++ b/modules/gdscript/tests/scripts/analyzer/warnings/overriding_native_method.out
@@ -2,5 +2,5 @@ GDTEST_OK
>> WARNING
>> Line: 4
>> NATIVE_METHOD_OVERRIDE
->> The method "get" overrides a method from native class "Object". This won't be called by the engine and may not work as expected.
+>> The method "get()" overrides a method from native class "Object". This won't be called by the engine and may not work as expected.
warn
diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/shadowning.out b/modules/gdscript/tests/scripts/analyzer/warnings/shadowning.out
index 9d0e567534..8467697a96 100644
--- a/modules/gdscript/tests/scripts/analyzer/warnings/shadowning.out
+++ b/modules/gdscript/tests/scripts/analyzer/warnings/shadowning.out
@@ -2,19 +2,19 @@ GDTEST_OK
>> WARNING
>> Line: 5
>> SHADOWED_GLOBAL_IDENTIFIER
->> The variable 'Array' has the same name as a built-in type.
+>> The variable "Array" has the same name as a built-in type.
>> WARNING
>> Line: 6
>> SHADOWED_GLOBAL_IDENTIFIER
->> The variable 'Node' has the same name as a global class.
+>> The variable "Node" has the same name as a global class.
>> WARNING
>> Line: 7
>> SHADOWED_GLOBAL_IDENTIFIER
->> The variable 'is_same' has the same name as a built-in function.
+>> The variable "is_same" has the same name as a built-in function.
>> WARNING
>> Line: 8
>> SHADOWED_GLOBAL_IDENTIFIER
->> The variable 'sqrt' has the same name as a built-in function.
+>> The variable "sqrt" has the same name as a built-in function.
>> WARNING
>> Line: 9
>> SHADOWED_VARIABLE
diff --git a/modules/gdscript/tests/scripts/parser/errors/static_constructor_not_static.gd b/modules/gdscript/tests/scripts/parser/errors/static_constructor_not_static.gd
new file mode 100644
index 0000000000..cbfa1f314f
--- /dev/null
+++ b/modules/gdscript/tests/scripts/parser/errors/static_constructor_not_static.gd
@@ -0,0 +1,5 @@
+func _static_init():
+ print("static init")
+
+func test():
+ print("done")
diff --git a/modules/gdscript/tests/scripts/parser/errors/static_constructor_not_static.out b/modules/gdscript/tests/scripts/parser/errors/static_constructor_not_static.out
new file mode 100644
index 0000000000..b2b8711e96
--- /dev/null
+++ b/modules/gdscript/tests/scripts/parser/errors/static_constructor_not_static.out
@@ -0,0 +1,2 @@
+GDTEST_PARSER_ERROR
+Static constructor must be declared static.
diff --git a/modules/gdscript/tests/scripts/parser/errors/static_constructor_returning_something.gd b/modules/gdscript/tests/scripts/parser/errors/static_constructor_returning_something.gd
new file mode 100644
index 0000000000..711243f822
--- /dev/null
+++ b/modules/gdscript/tests/scripts/parser/errors/static_constructor_returning_something.gd
@@ -0,0 +1,6 @@
+static func _static_init():
+ print("static init")
+ return true
+
+func test():
+ print("done")
diff --git a/modules/gdscript/tests/scripts/parser/errors/static_constructor_returning_something.out b/modules/gdscript/tests/scripts/parser/errors/static_constructor_returning_something.out
new file mode 100644
index 0000000000..a034850e86
--- /dev/null
+++ b/modules/gdscript/tests/scripts/parser/errors/static_constructor_returning_something.out
@@ -0,0 +1,2 @@
+GDTEST_PARSER_ERROR
+Constructor cannot return a value.
diff --git a/modules/gdscript/tests/scripts/parser/features/constants.out b/modules/gdscript/tests/scripts/parser/features/constants.out
index 6093e4a6ca..7ec33470d3 100644
--- a/modules/gdscript/tests/scripts/parser/features/constants.out
+++ b/modules/gdscript/tests/scripts/parser/features/constants.out
@@ -2,32 +2,32 @@ GDTEST_OK
>> WARNING
>> Line: 2
>> UNUSED_LOCAL_CONSTANT
->> The local constant '_TEST' is declared but never used in the block. If this is intended, prefix it with an underscore: '__TEST'
+>> The local constant "_TEST" is declared but never used in the block. If this is intended, prefix it with an underscore: "__TEST".
>> WARNING
>> Line: 3
>> UNUSED_LOCAL_CONSTANT
->> The local constant '_STRING' is declared but never used in the block. If this is intended, prefix it with an underscore: '__STRING'
+>> The local constant "_STRING" is declared but never used in the block. If this is intended, prefix it with an underscore: "__STRING".
>> WARNING
>> Line: 4
>> UNUSED_LOCAL_CONSTANT
->> The local constant '_VECTOR' is declared but never used in the block. If this is intended, prefix it with an underscore: '__VECTOR'
+>> The local constant "_VECTOR" is declared but never used in the block. If this is intended, prefix it with an underscore: "__VECTOR".
>> WARNING
>> Line: 5
>> UNUSED_LOCAL_CONSTANT
->> The local constant '_ARRAY' is declared but never used in the block. If this is intended, prefix it with an underscore: '__ARRAY'
+>> The local constant "_ARRAY" is declared but never used in the block. If this is intended, prefix it with an underscore: "__ARRAY".
>> WARNING
>> Line: 6
>> UNUSED_LOCAL_CONSTANT
->> The local constant '_DICTIONARY' is declared but never used in the block. If this is intended, prefix it with an underscore: '__DICTIONARY'
+>> The local constant "_DICTIONARY" is declared but never used in the block. If this is intended, prefix it with an underscore: "__DICTIONARY".
>> WARNING
>> Line: 9
>> UNUSED_LOCAL_CONSTANT
->> The local constant '_HELLO' is declared but never used in the block. If this is intended, prefix it with an underscore: '__HELLO'
+>> The local constant "_HELLO" is declared but never used in the block. If this is intended, prefix it with an underscore: "__HELLO".
>> WARNING
>> Line: 10
>> UNUSED_LOCAL_CONSTANT
->> The local constant '_INFINITY' is declared but never used in the block. If this is intended, prefix it with an underscore: '__INFINITY'
+>> The local constant "_INFINITY" is declared but never used in the block. If this is intended, prefix it with an underscore: "__INFINITY".
>> WARNING
>> Line: 11
>> UNUSED_LOCAL_CONSTANT
->> The local constant '_NOT_A_NUMBER' is declared but never used in the block. If this is intended, prefix it with an underscore: '__NOT_A_NUMBER'
+>> The local constant "_NOT_A_NUMBER" is declared but never used in the block. If this is intended, prefix it with an underscore: "__NOT_A_NUMBER".
diff --git a/modules/gdscript/tests/scripts/parser/features/match_bind_unused.out b/modules/gdscript/tests/scripts/parser/features/match_bind_unused.out
index 057c1b11e5..44d29cb82d 100644
--- a/modules/gdscript/tests/scripts/parser/features/match_bind_unused.out
+++ b/modules/gdscript/tests/scripts/parser/features/match_bind_unused.out
@@ -2,5 +2,5 @@ GDTEST_OK
>> WARNING
>> Line: 9
>> UNUSED_VARIABLE
->> The local variable 'value' is declared but never used in the block. If this is intended, prefix it with an underscore: '_value'
+>> The local variable "value" is declared but never used in the block. If this is intended, prefix it with an underscore: "_value".
value
diff --git a/modules/gdscript/tests/scripts/parser/features/static_typing.out b/modules/gdscript/tests/scripts/parser/features/static_typing.out
index 207d90fef1..40a8f97416 100644
--- a/modules/gdscript/tests/scripts/parser/features/static_typing.out
+++ b/modules/gdscript/tests/scripts/parser/features/static_typing.out
@@ -2,20 +2,20 @@ GDTEST_OK
>> WARNING
>> Line: 11
>> UNUSED_LOCAL_CONSTANT
->> The local constant '_INTEGER' is declared but never used in the block. If this is intended, prefix it with an underscore: '__INTEGER'
+>> The local constant "_INTEGER" is declared but never used in the block. If this is intended, prefix it with an underscore: "__INTEGER".
>> WARNING
>> Line: 12
>> UNUSED_LOCAL_CONSTANT
->> The local constant '_INTEGER_REDUNDANT_TYPED' is declared but never used in the block. If this is intended, prefix it with an underscore: '__INTEGER_REDUNDANT_TYPED'
+>> The local constant "_INTEGER_REDUNDANT_TYPED" is declared but never used in the block. If this is intended, prefix it with an underscore: "__INTEGER_REDUNDANT_TYPED".
>> WARNING
>> Line: 13
>> UNUSED_LOCAL_CONSTANT
->> The local constant '_INTEGER_REDUNDANT_TYPED2' is declared but never used in the block. If this is intended, prefix it with an underscore: '__INTEGER_REDUNDANT_TYPED2'
+>> The local constant "_INTEGER_REDUNDANT_TYPED2" is declared but never used in the block. If this is intended, prefix it with an underscore: "__INTEGER_REDUNDANT_TYPED2".
>> WARNING
>> Line: 14
>> UNUSED_LOCAL_CONSTANT
->> The local constant '_INTEGER_REDUNDANT_INFERRED' is declared but never used in the block. If this is intended, prefix it with an underscore: '__INTEGER_REDUNDANT_INFERRED'
+>> The local constant "_INTEGER_REDUNDANT_INFERRED" is declared but never used in the block. If this is intended, prefix it with an underscore: "__INTEGER_REDUNDANT_INFERRED".
>> WARNING
>> Line: 15
>> UNUSED_LOCAL_CONSTANT
->> The local constant '_INTEGER_REDUNDANT_INFERRED2' is declared but never used in the block. If this is intended, prefix it with an underscore: '__INTEGER_REDUNDANT_INFERRED2'
+>> The local constant "_INTEGER_REDUNDANT_INFERRED2" is declared but never used in the block. If this is intended, prefix it with an underscore: "__INTEGER_REDUNDANT_INFERRED2".
diff --git a/modules/gdscript/tests/scripts/parser/warnings/return_value_discarded.out b/modules/gdscript/tests/scripts/parser/warnings/return_value_discarded.out
index e89bb9226f..f2db4e9307 100644
--- a/modules/gdscript/tests/scripts/parser/warnings/return_value_discarded.out
+++ b/modules/gdscript/tests/scripts/parser/warnings/return_value_discarded.out
@@ -2,4 +2,4 @@ GDTEST_OK
>> WARNING
>> Line: 6
>> RETURN_VALUE_DISCARDED
->> The function 'i_return_int()' returns a value that will be discarded if not used.
+>> The function "i_return_int()" returns a value that will be discarded if not used.
diff --git a/modules/gdscript/tests/scripts/parser/warnings/shadowed_constant.out b/modules/gdscript/tests/scripts/parser/warnings/shadowed_constant.out
index 9c9417e11d..75fa01f928 100644
--- a/modules/gdscript/tests/scripts/parser/warnings/shadowed_constant.out
+++ b/modules/gdscript/tests/scripts/parser/warnings/shadowed_constant.out
@@ -2,7 +2,7 @@ GDTEST_OK
>> WARNING
>> Line: 8
>> UNUSED_LOCAL_CONSTANT
->> The local constant 'TEST' is declared but never used in the block. If this is intended, prefix it with an underscore: '_TEST'
+>> The local constant "TEST" is declared but never used in the block. If this is intended, prefix it with an underscore: "_TEST".
>> WARNING
>> Line: 8
>> SHADOWED_VARIABLE
diff --git a/modules/gdscript/tests/scripts/parser/warnings/shadowed_global_identifier.out b/modules/gdscript/tests/scripts/parser/warnings/shadowed_global_identifier.out
index c613140eb8..75a02c5d3c 100644
--- a/modules/gdscript/tests/scripts/parser/warnings/shadowed_global_identifier.out
+++ b/modules/gdscript/tests/scripts/parser/warnings/shadowed_global_identifier.out
@@ -2,8 +2,8 @@ GDTEST_OK
>> WARNING
>> Line: 2
>> UNUSED_VARIABLE
->> The local variable 'abs' is declared but never used in the block. If this is intended, prefix it with an underscore: '_abs'
+>> The local variable "abs" is declared but never used in the block. If this is intended, prefix it with an underscore: "_abs".
>> WARNING
>> Line: 2
>> SHADOWED_GLOBAL_IDENTIFIER
->> The variable 'abs' has the same name as a built-in function.
+>> The variable "abs" has the same name as a built-in function.
diff --git a/modules/gdscript/tests/scripts/parser/warnings/shadowed_variable_class.out b/modules/gdscript/tests/scripts/parser/warnings/shadowed_variable_class.out
index 82e467b368..aab27e78e2 100644
--- a/modules/gdscript/tests/scripts/parser/warnings/shadowed_variable_class.out
+++ b/modules/gdscript/tests/scripts/parser/warnings/shadowed_variable_class.out
@@ -2,7 +2,7 @@ GDTEST_OK
>> WARNING
>> Line: 8
>> UNUSED_VARIABLE
->> The local variable 'foo' is declared but never used in the block. If this is intended, prefix it with an underscore: '_foo'
+>> The local variable "foo" is declared but never used in the block. If this is intended, prefix it with an underscore: "_foo".
>> WARNING
>> Line: 8
>> SHADOWED_VARIABLE
diff --git a/modules/gdscript/tests/scripts/parser/warnings/shadowed_variable_function.out b/modules/gdscript/tests/scripts/parser/warnings/shadowed_variable_function.out
index 26ce0465b1..e3cd358126 100644
--- a/modules/gdscript/tests/scripts/parser/warnings/shadowed_variable_function.out
+++ b/modules/gdscript/tests/scripts/parser/warnings/shadowed_variable_function.out
@@ -2,7 +2,7 @@ GDTEST_OK
>> WARNING
>> Line: 2
>> UNUSED_VARIABLE
->> The local variable 'test' is declared but never used in the block. If this is intended, prefix it with an underscore: '_test'
+>> The local variable "test" is declared but never used in the block. If this is intended, prefix it with an underscore: "_test".
>> WARNING
>> Line: 2
>> SHADOWED_VARIABLE
diff --git a/modules/gdscript/tests/scripts/parser/warnings/static_called_on_instance.out b/modules/gdscript/tests/scripts/parser/warnings/static_called_on_instance.out
index 3933a35178..77994ce9ba 100644
--- a/modules/gdscript/tests/scripts/parser/warnings/static_called_on_instance.out
+++ b/modules/gdscript/tests/scripts/parser/warnings/static_called_on_instance.out
@@ -2,6 +2,6 @@ GDTEST_OK
>> WARNING
>> Line: 11
>> STATIC_CALLED_ON_INSTANCE
->> The function 'num_uint64()' is a static function but was called from an instance. Instead, it should be directly called from the type: 'String.num_uint64()'.
+>> The function "num_uint64()" is a static function but was called from an instance. Instead, it should be directly called from the type: "String.num_uint64()".
8589934592
8589934592
diff --git a/modules/gdscript/tests/scripts/parser/warnings/unassigned_variable.out b/modules/gdscript/tests/scripts/parser/warnings/unassigned_variable.out
index cf14502e9a..10f89be132 100644
--- a/modules/gdscript/tests/scripts/parser/warnings/unassigned_variable.out
+++ b/modules/gdscript/tests/scripts/parser/warnings/unassigned_variable.out
@@ -2,4 +2,4 @@ GDTEST_OK
>> WARNING
>> Line: 2
>> UNASSIGNED_VARIABLE
->> The variable '__' was used but never assigned a value.
+>> The variable "__" was used but never assigned a value.
diff --git a/modules/gdscript/tests/scripts/parser/warnings/unassigned_variable_op_assign.out b/modules/gdscript/tests/scripts/parser/warnings/unassigned_variable_op_assign.out
index ba55a4e0f8..4fc91487f2 100644
--- a/modules/gdscript/tests/scripts/parser/warnings/unassigned_variable_op_assign.out
+++ b/modules/gdscript/tests/scripts/parser/warnings/unassigned_variable_op_assign.out
@@ -2,4 +2,4 @@ GDTEST_OK
>> WARNING
>> Line: 4
>> UNASSIGNED_VARIABLE_OP_ASSIGN
->> Using assignment with operation but the variable '__' was not previously assigned a value.
+>> Using assignment with operation but the variable "__" was not previously assigned a value.
diff --git a/modules/gdscript/tests/scripts/parser/warnings/unreachable_code_after_return.out b/modules/gdscript/tests/scripts/parser/warnings/unreachable_code_after_return.out
index 9316abd5eb..f67dbdcd03 100644
--- a/modules/gdscript/tests/scripts/parser/warnings/unreachable_code_after_return.out
+++ b/modules/gdscript/tests/scripts/parser/warnings/unreachable_code_after_return.out
@@ -2,4 +2,4 @@ GDTEST_OK
>> WARNING
>> Line: 7
>> UNREACHABLE_CODE
->> Unreachable code (statement after return) in function 'test()'.
+>> Unreachable code (statement after return) in function "test()".
diff --git a/modules/gdscript/tests/scripts/parser/warnings/unused_argument.out b/modules/gdscript/tests/scripts/parser/warnings/unused_argument.out
index 92f3308f85..3a03406f92 100644
--- a/modules/gdscript/tests/scripts/parser/warnings/unused_argument.out
+++ b/modules/gdscript/tests/scripts/parser/warnings/unused_argument.out
@@ -2,4 +2,4 @@ GDTEST_OK
>> WARNING
>> Line: 2
>> UNUSED_PARAMETER
->> The parameter 'p_arg2' is never used in the function 'function_with_unused_argument'. If this is intended, prefix it with an underscore: '_p_arg2'
+>> The parameter "p_arg2" is never used in the function "function_with_unused_argument()". If this is intended, prefix it with an underscore: "_p_arg2".
diff --git a/modules/gdscript/tests/scripts/parser/warnings/unused_variable.out b/modules/gdscript/tests/scripts/parser/warnings/unused_variable.out
index 270e0e69c0..b9b3968473 100644
--- a/modules/gdscript/tests/scripts/parser/warnings/unused_variable.out
+++ b/modules/gdscript/tests/scripts/parser/warnings/unused_variable.out
@@ -2,4 +2,4 @@ GDTEST_OK
>> WARNING
>> Line: 2
>> UNUSED_VARIABLE
->> The local variable 'unused' is declared but never used in the block. If this is intended, prefix it with an underscore: '_unused'
+>> The local variable "unused" is declared but never used in the block. If this is intended, prefix it with an underscore: "_unused".
diff --git a/modules/gdscript/tests/scripts/runtime/features/assign_operator.gd b/modules/gdscript/tests/scripts/runtime/features/assign_operator.gd
new file mode 100644
index 0000000000..2a9fe851ef
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/assign_operator.gd
@@ -0,0 +1,31 @@
+# https://github.com/godotengine/godot/issues/75832
+
+@warning_ignore("narrowing_conversion")
+func test():
+ var hf := 2.0
+ var sf = 2.0
+
+ var i := 2
+ i *= hf
+ i *= sf
+ i *= 2.0
+ print(i)
+ var v2 := Vector2i(1, 2)
+ v2 *= hf
+ v2 *= sf
+ v2 *= 2.0
+ print(v2)
+ var v3 := Vector3i(1, 2, 3)
+ v3 *= hf
+ v3 *= sf
+ v3 *= 2.0
+ print(v3)
+ var v4 := Vector4i(1, 2, 3, 4)
+ v4 *= hf
+ v4 *= sf
+ v4 *= 2.0
+ print(v4)
+
+ var arr := [1, 2, 3]
+ arr += [4, 5]
+ print(arr)
diff --git a/modules/gdscript/tests/scripts/runtime/features/assign_operator.out b/modules/gdscript/tests/scripts/runtime/features/assign_operator.out
new file mode 100644
index 0000000000..bfcfc1dff5
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/assign_operator.out
@@ -0,0 +1,6 @@
+GDTEST_OK
+16
+(8, 16)
+(8, 16, 24)
+(8, 16, 24, 32)
+[1, 2, 3, 4, 5]
diff --git a/modules/gdscript/tests/scripts/runtime/features/getter_with_freed_object.gd b/modules/gdscript/tests/scripts/runtime/features/getter_with_freed_object.gd
new file mode 100644
index 0000000000..a2d09bf7d3
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/getter_with_freed_object.gd
@@ -0,0 +1,15 @@
+# https://github.com/godotengine/godot/issues/68184
+
+var node: Node:
+ get:
+ return node
+ set(n):
+ node = n
+
+
+func test():
+ node = Node.new()
+ node.free()
+
+ if !is_instance_valid(node):
+ print("It is freed")
diff --git a/modules/gdscript/tests/scripts/runtime/features/getter_with_freed_object.out b/modules/gdscript/tests/scripts/runtime/features/getter_with_freed_object.out
new file mode 100644
index 0000000000..b380f593d9
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/getter_with_freed_object.out
@@ -0,0 +1,2 @@
+GDTEST_OK
+It is freed
diff --git a/modules/gdscript/tests/scripts/runtime/features/static_constructor.gd b/modules/gdscript/tests/scripts/runtime/features/static_constructor.gd
new file mode 100644
index 0000000000..e08f77df12
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/static_constructor.gd
@@ -0,0 +1,13 @@
+@static_unload
+
+static var foo = "bar"
+
+static func _static_init():
+ print("static init called")
+ prints("foo is", foo)
+
+func test():
+ var _lambda = func _static_init():
+ print("lambda does not conflict with static constructor")
+
+ print("done")
diff --git a/modules/gdscript/tests/scripts/runtime/features/static_constructor.out b/modules/gdscript/tests/scripts/runtime/features/static_constructor.out
new file mode 100644
index 0000000000..7f72a0ac2c
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/static_constructor.out
@@ -0,0 +1,4 @@
+GDTEST_OK
+static init called
+foo is bar
+done
diff --git a/modules/gdscript/tests/scripts/runtime/features/static_variables.gd b/modules/gdscript/tests/scripts/runtime/features/static_variables.gd
new file mode 100644
index 0000000000..e193312381
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/static_variables.gd
@@ -0,0 +1,56 @@
+@static_unload
+
+static var perm := 0
+
+static var prop := "Hello!":
+ get: return prop + " suffix"
+ set(value): prop = "prefix " + str(value)
+
+static func get_data():
+ return "data"
+
+static var data = get_data()
+
+class Inner:
+ static var prop := "inner"
+ static func _static_init() -> void:
+ prints("Inner._static_init", prop)
+
+ class InnerInner:
+ static var prop := "inner inner"
+ static func _static_init() -> void:
+ prints("InnerInner._static_init", prop)
+
+func test():
+ prints("data:", data)
+
+ prints("perm:", perm)
+ prints("prop:", prop)
+
+ perm = 1
+ prop = "World!"
+
+ prints("perm:", perm)
+ prints("prop:", prop)
+
+ print("other.perm:", StaticVariablesOther.perm)
+ print("other.prop:", StaticVariablesOther.prop)
+
+ StaticVariablesOther.perm = 2
+ StaticVariablesOther.prop = "foo"
+
+ print("other.perm:", StaticVariablesOther.perm)
+ print("other.prop:", StaticVariablesOther.prop)
+
+ @warning_ignore("unsafe_method_access")
+ var path = get_script().get_path().get_base_dir()
+ var other = load(path + "/static_variables_load.gd")
+
+ print("load.perm:", other.perm)
+ print("load.prop:", other.prop)
+
+ other.perm = 3
+ other.prop = "bar"
+
+ print("load.perm:", other.perm)
+ print("load.prop:", other.prop)
diff --git a/modules/gdscript/tests/scripts/runtime/features/static_variables.out b/modules/gdscript/tests/scripts/runtime/features/static_variables.out
new file mode 100644
index 0000000000..d2491aef5e
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/static_variables.out
@@ -0,0 +1,16 @@
+GDTEST_OK
+Inner._static_init inner
+InnerInner._static_init inner inner
+data: data
+perm: 0
+prop: prefix Hello! suffix
+perm: 1
+prop: prefix World! suffix
+other.perm:0
+other.prop:prefix Hello! suffix
+other.perm:2
+other.prop:prefix foo suffix
+load.perm:0
+load.prop:prefix Hello! suffix
+load.perm:3
+load.prop:prefix bar suffix
diff --git a/modules/gdscript/tests/scripts/runtime/features/static_variables_load.gd b/modules/gdscript/tests/scripts/runtime/features/static_variables_load.gd
new file mode 100644
index 0000000000..8913b02756
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/static_variables_load.gd
@@ -0,0 +1,10 @@
+@static_unload
+
+static var perm := 0
+
+static var prop := "Hello!":
+ get: return prop + " suffix"
+ set(value): prop = "prefix " + str(value)
+
+func test():
+ print("ok")
diff --git a/modules/gdscript/tests/scripts/runtime/features/static_variables_load.out b/modules/gdscript/tests/scripts/runtime/features/static_variables_load.out
new file mode 100644
index 0000000000..1b47ed10dc
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/static_variables_load.out
@@ -0,0 +1,2 @@
+GDTEST_OK
+ok
diff --git a/modules/gdscript/tests/scripts/runtime/features/static_variables_other.gd b/modules/gdscript/tests/scripts/runtime/features/static_variables_other.gd
new file mode 100644
index 0000000000..7a3b0acca6
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/static_variables_other.gd
@@ -0,0 +1,11 @@
+@static_unload
+class_name StaticVariablesOther
+
+static var perm := 0
+
+static var prop := "Hello!":
+ get: return prop + " suffix"
+ set(value): prop = "prefix " + str(value)
+
+func test():
+ print("ok")
diff --git a/modules/gdscript/tests/scripts/runtime/features/static_variables_other.out b/modules/gdscript/tests/scripts/runtime/features/static_variables_other.out
new file mode 100644
index 0000000000..1b47ed10dc
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/static_variables_other.out
@@ -0,0 +1,2 @@
+GDTEST_OK
+ok
diff --git a/modules/gltf/config.py b/modules/gltf/config.py
index 130c06d264..36cf053aa1 100644
--- a/modules/gltf/config.py
+++ b/modules/gltf/config.py
@@ -15,12 +15,14 @@ def get_doc_classes():
"GLTFAnimation",
"GLTFBufferView",
"GLTFCamera",
+ "GLTFCollider",
"GLTFDocument",
"GLTFDocumentExtension",
"GLTFDocumentExtensionConvertImporterMesh",
"GLTFLight",
"GLTFMesh",
"GLTFNode",
+ "GLTFPhysicsBody",
"GLTFSkeleton",
"GLTFSkin",
"GLTFSpecGloss",
diff --git a/modules/gltf/doc_classes/GLTFCollider.xml b/modules/gltf/doc_classes/GLTFCollider.xml
new file mode 100644
index 0000000000..cd397df398
--- /dev/null
+++ b/modules/gltf/doc_classes/GLTFCollider.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="GLTFCollider" inherits="Resource" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
+ <brief_description>
+ Represents a GLTF collider.
+ </brief_description>
+ <description>
+ Represents a collider as defined by the [code]OMI_collider[/code] GLTF extension. This class is an intermediary between the GLTF data and Godot's nodes, and it's abstracted in a way that allows adding support for different GLTF physics extensions in the future.
+ </description>
+ <tutorials>
+ <link title="OMI_collider GLTF extension">https://github.com/omigroup/gltf-extensions/tree/main/extensions/2.0/OMI_collider</link>
+ </tutorials>
+ <methods>
+ <method name="from_dictionary" qualifiers="static">
+ <return type="GLTFCollider" />
+ <param index="0" name="dictionary" type="Dictionary" />
+ <description>
+ Creates a new GLTFCollider instance by parsing the given [Dictionary].
+ </description>
+ </method>
+ <method name="from_node" qualifiers="static">
+ <return type="GLTFCollider" />
+ <param index="0" name="collider_node" type="CollisionShape3D" />
+ <description>
+ Create a new GLTFCollider instance from the given Godot [CollisionShape3D] node.
+ </description>
+ </method>
+ <method name="to_dictionary" qualifiers="const">
+ <return type="Dictionary" />
+ <description>
+ Serializes this GLTFCollider instance into a [Dictionary].
+ </description>
+ </method>
+ <method name="to_node">
+ <return type="CollisionShape3D" />
+ <param index="0" name="cache_shapes" type="bool" default="false" />
+ <description>
+ Converts this GLTFCollider instance into a Godot [CollisionShape3D] node.
+ </description>
+ </method>
+ </methods>
+ <members>
+ <member name="height" type="float" setter="set_height" getter="get_height" default="2.0">
+ The height of the collider, in meters. This is only used when the collider type is "capsule" or "cylinder". This value should not be negative, and for "capsule" it should be at least twice the radius.
+ </member>
+ <member name="importer_mesh" type="ImporterMesh" setter="set_importer_mesh" getter="get_importer_mesh">
+ The [ImporterMesh] resource of the collider. This is only used when the collider type is "hull" (convex hull) or "trimesh" (concave trimesh).
+ </member>
+ <member name="is_trigger" type="bool" setter="set_is_trigger" getter="get_is_trigger" default="false">
+ If [code]true[/code], indicates that this collider is a trigger. For Godot, this means that the collider should be a child of an Area3D node.
+ This is the only variable not used in the [method to_node] method, it's intended to be used alongside when deciding where to add the generated node as a child.
+ </member>
+ <member name="mesh_index" type="int" setter="set_mesh_index" getter="get_mesh_index" default="-1">
+ The index of the collider's mesh in the GLTF file. This is only used when the collider type is "hull" (convex hull) or "trimesh" (concave trimesh).
+ </member>
+ <member name="radius" type="float" setter="set_radius" getter="get_radius" default="0.5">
+ The radius of the collider, in meters. This is only used when the collider type is "capsule", "cylinder", or "sphere". This value should not be negative.
+ </member>
+ <member name="shape_type" type="String" setter="set_shape_type" getter="get_shape_type" default="&quot;&quot;">
+ The type of shape this collider represents. Valid values are "box", "capsule", "cylinder", "sphere", "hull", and "trimesh".
+ </member>
+ <member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3(1, 1, 1)">
+ The size of the collider, in meters. This is only used when the collider type is "box", and it represents the "diameter" of the box. This value should not be negative.
+ </member>
+ </members>
+</class>
diff --git a/modules/gltf/doc_classes/GLTFPhysicsBody.xml b/modules/gltf/doc_classes/GLTFPhysicsBody.xml
new file mode 100644
index 0000000000..054bd2fc85
--- /dev/null
+++ b/modules/gltf/doc_classes/GLTFPhysicsBody.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="GLTFPhysicsBody" inherits="Resource" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
+ <brief_description>
+ Represents a GLTF physics body.
+ </brief_description>
+ <description>
+ Represents a physics body as defined by the [code]OMI_physics_body[/code] GLTF extension. This class is an intermediary between the GLTF data and Godot's nodes, and it's abstracted in a way that allows adding support for different GLTF physics extensions in the future.
+ </description>
+ <tutorials>
+ <link title="OMI_physics_body GLTF extension">https://github.com/omigroup/gltf-extensions/tree/main/extensions/2.0/OMI_physics_body</link>
+ </tutorials>
+ <methods>
+ <method name="from_dictionary" qualifiers="static">
+ <return type="GLTFPhysicsBody" />
+ <param index="0" name="dictionary" type="Dictionary" />
+ <description>
+ Creates a new GLTFPhysicsBody instance by parsing the given [Dictionary].
+ </description>
+ </method>
+ <method name="from_node" qualifiers="static">
+ <return type="GLTFPhysicsBody" />
+ <param index="0" name="body_node" type="CollisionObject3D" />
+ <description>
+ Create a new GLTFPhysicsBody instance from the given Godot [CollisionObject3D] node.
+ </description>
+ </method>
+ <method name="to_dictionary" qualifiers="const">
+ <return type="Dictionary" />
+ <description>
+ Serializes this GLTFPhysicsBody instance into a [Dictionary].
+ </description>
+ </method>
+ <method name="to_node" qualifiers="const">
+ <return type="CollisionObject3D" />
+ <description>
+ Converts this GLTFPhysicsBody instance into a Godot [CollisionObject3D] node.
+ </description>
+ </method>
+ </methods>
+ <members>
+ <member name="angular_velocity" type="Vector3" setter="set_angular_velocity" getter="get_angular_velocity" default="Vector3(0, 0, 0)">
+ The angular velocity of the physics body, in radians per second. This is only used when the body type is "rigid" or "vehicle".
+ </member>
+ <member name="body_type" type="String" setter="set_body_type" getter="get_body_type" default="&quot;static&quot;">
+ The type of the body. Valid values are "static", "kinematic", "character", "rigid", "vehicle", and "trigger".
+ </member>
+ <member name="inertia" type="Vector3" setter="set_inertia" getter="get_inertia" default="Vector3(0, 0, 0)">
+ The principle axes of the inertia tensor of the physics body, in kilogram meter squared (kg⋅m²). This is only used when the body type is "rigid" or "vehicle".
+ This is written to and read from the GLTF file as a 3x3 matrix, but is exposed as a Vector3 since Godot only supports principal axis inertia values. When converted to a Godot [RigidBody3D] node, if this value is zero, then the inertia will be calculated automatically.
+ </member>
+ <member name="linear_velocity" type="Vector3" setter="set_linear_velocity" getter="get_linear_velocity" default="Vector3(0, 0, 0)">
+ The linear velocity of the physics body, in meters per second. This is only used when the body type is "rigid" or "vehicle".
+ </member>
+ <member name="mass" type="float" setter="set_mass" getter="get_mass" default="1.0">
+ The mass of the physics body, in kilograms. This is only used when the body type is "rigid" or "vehicle".
+ </member>
+ </members>
+</class>
diff --git a/modules/gltf/editor/editor_scene_exporter_gltf_plugin.cpp b/modules/gltf/editor/editor_scene_exporter_gltf_plugin.cpp
index 5f6ec5904c..554fe5a422 100644
--- a/modules/gltf/editor/editor_scene_exporter_gltf_plugin.cpp
+++ b/modules/gltf/editor/editor_scene_exporter_gltf_plugin.cpp
@@ -37,6 +37,7 @@
#include "editor/editor_file_system.h"
#include "editor/editor_node.h"
#include "editor/gui/editor_file_dialog.h"
+#include "scene/gui/popup_menu.h"
String SceneExporterGLTFPlugin::get_name() const {
return "ConvertGLTF2";
diff --git a/modules/gltf/extensions/SCsub b/modules/gltf/extensions/SCsub
index ad214bb79c..105a1736de 100644
--- a/modules/gltf/extensions/SCsub
+++ b/modules/gltf/extensions/SCsub
@@ -7,3 +7,4 @@ env_gltf = env_modules.Clone()
# Godot source files
env_gltf.add_source_files(env.modules_sources, "*.cpp")
+env_gltf.add_source_files(env.modules_sources, "physics/*.cpp")
diff --git a/modules/gltf/extensions/physics/gltf_collider.cpp b/modules/gltf/extensions/physics/gltf_collider.cpp
new file mode 100644
index 0000000000..1a42a84874
--- /dev/null
+++ b/modules/gltf/extensions/physics/gltf_collider.cpp
@@ -0,0 +1,308 @@
+/**************************************************************************/
+/* gltf_collider.cpp */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/**************************************************************************/
+
+#include "gltf_collider.h"
+
+#include "../../gltf_state.h"
+#include "core/math/convex_hull.h"
+#include "scene/3d/area_3d.h"
+#include "scene/resources/box_shape_3d.h"
+#include "scene/resources/capsule_shape_3d.h"
+#include "scene/resources/concave_polygon_shape_3d.h"
+#include "scene/resources/convex_polygon_shape_3d.h"
+#include "scene/resources/cylinder_shape_3d.h"
+#include "scene/resources/importer_mesh.h"
+#include "scene/resources/sphere_shape_3d.h"
+
+void GLTFCollider::_bind_methods() {
+ ClassDB::bind_static_method("GLTFCollider", D_METHOD("from_node", "collider_node"), &GLTFCollider::from_node);
+ ClassDB::bind_method(D_METHOD("to_node", "cache_shapes"), &GLTFCollider::to_node, DEFVAL(false));
+
+ ClassDB::bind_static_method("GLTFCollider", D_METHOD("from_dictionary", "dictionary"), &GLTFCollider::from_dictionary);
+ ClassDB::bind_method(D_METHOD("to_dictionary"), &GLTFCollider::to_dictionary);
+
+ ClassDB::bind_method(D_METHOD("get_shape_type"), &GLTFCollider::get_shape_type);
+ ClassDB::bind_method(D_METHOD("set_shape_type", "shape_type"), &GLTFCollider::set_shape_type);
+ ClassDB::bind_method(D_METHOD("get_size"), &GLTFCollider::get_size);
+ ClassDB::bind_method(D_METHOD("set_size", "size"), &GLTFCollider::set_size);
+ ClassDB::bind_method(D_METHOD("get_radius"), &GLTFCollider::get_radius);
+ ClassDB::bind_method(D_METHOD("set_radius", "radius"), &GLTFCollider::set_radius);
+ ClassDB::bind_method(D_METHOD("get_height"), &GLTFCollider::get_height);
+ ClassDB::bind_method(D_METHOD("set_height", "height"), &GLTFCollider::set_height);
+ ClassDB::bind_method(D_METHOD("get_is_trigger"), &GLTFCollider::get_is_trigger);
+ ClassDB::bind_method(D_METHOD("set_is_trigger", "is_trigger"), &GLTFCollider::set_is_trigger);
+ ClassDB::bind_method(D_METHOD("get_mesh_index"), &GLTFCollider::get_mesh_index);
+ ClassDB::bind_method(D_METHOD("set_mesh_index", "mesh_index"), &GLTFCollider::set_mesh_index);
+ ClassDB::bind_method(D_METHOD("get_importer_mesh"), &GLTFCollider::get_importer_mesh);
+ ClassDB::bind_method(D_METHOD("set_importer_mesh", "importer_mesh"), &GLTFCollider::set_importer_mesh);
+
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "shape_type"), "set_shape_type", "get_shape_type");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "size"), "set_size", "get_size");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radius"), "set_radius", "get_radius");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "height"), "set_height", "get_height");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_trigger"), "set_is_trigger", "get_is_trigger");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "mesh_index"), "set_mesh_index", "get_mesh_index");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "importer_mesh", PROPERTY_HINT_RESOURCE_TYPE, "ImporterMesh"), "set_importer_mesh", "get_importer_mesh");
+}
+
+String GLTFCollider::get_shape_type() const {
+ return shape_type;
+}
+
+void GLTFCollider::set_shape_type(String p_shape_type) {
+ shape_type = p_shape_type;
+}
+
+Vector3 GLTFCollider::get_size() const {
+ return size;
+}
+
+void GLTFCollider::set_size(Vector3 p_size) {
+ size = p_size;
+}
+
+real_t GLTFCollider::get_radius() const {
+ return radius;
+}
+
+void GLTFCollider::set_radius(real_t p_radius) {
+ radius = p_radius;
+}
+
+real_t GLTFCollider::get_height() const {
+ return height;
+}
+
+void GLTFCollider::set_height(real_t p_height) {
+ height = p_height;
+}
+
+bool GLTFCollider::get_is_trigger() const {
+ return is_trigger;
+}
+
+void GLTFCollider::set_is_trigger(bool p_is_trigger) {
+ is_trigger = p_is_trigger;
+}
+
+GLTFMeshIndex GLTFCollider::get_mesh_index() const {
+ return mesh_index;
+}
+
+void GLTFCollider::set_mesh_index(GLTFMeshIndex p_mesh_index) {
+ mesh_index = p_mesh_index;
+}
+
+Ref<ImporterMesh> GLTFCollider::get_importer_mesh() const {
+ return importer_mesh;
+}
+
+void GLTFCollider::set_importer_mesh(Ref<ImporterMesh> p_importer_mesh) {
+ importer_mesh = p_importer_mesh;
+}
+
+Ref<GLTFCollider> GLTFCollider::from_node(const CollisionShape3D *p_collider_node) {
+ Ref<GLTFCollider> collider;
+ collider.instantiate();
+ ERR_FAIL_NULL_V_MSG(p_collider_node, collider, "Tried to create a GLTFCollider from a CollisionShape3D node, but the given node was null.");
+ Node *parent = p_collider_node->get_parent();
+ if (cast_to<const Area3D>(parent)) {
+ collider->set_is_trigger(true);
+ }
+ // All the code for working with the shape is below this comment.
+ Ref<Shape3D> shape = p_collider_node->get_shape();
+ ERR_FAIL_COND_V_MSG(shape.is_null(), collider, "Tried to create a GLTFCollider from a CollisionShape3D node, but the given node had a null shape.");
+ collider->_shape_cache = shape;
+ if (cast_to<BoxShape3D>(shape.ptr())) {
+ collider->shape_type = "box";
+ Ref<BoxShape3D> box = shape;
+ collider->set_size(box->get_size());
+ } else if (cast_to<const CapsuleShape3D>(shape.ptr())) {
+ collider->shape_type = "capsule";
+ Ref<CapsuleShape3D> capsule = shape;
+ collider->set_radius(capsule->get_radius());
+ collider->set_height(capsule->get_height());
+ } else if (cast_to<const CylinderShape3D>(shape.ptr())) {
+ collider->shape_type = "cylinder";
+ Ref<CylinderShape3D> cylinder = shape;
+ collider->set_radius(cylinder->get_radius());
+ collider->set_height(cylinder->get_height());
+ } else if (cast_to<const SphereShape3D>(shape.ptr())) {
+ collider->shape_type = "sphere";
+ Ref<SphereShape3D> sphere = shape;
+ collider->set_radius(sphere->get_radius());
+ } else if (cast_to<const ConvexPolygonShape3D>(shape.ptr())) {
+ collider->shape_type = "hull";
+ Ref<ConvexPolygonShape3D> convex = shape;
+ Vector<Vector3> hull_points = convex->get_points();
+ ERR_FAIL_COND_V_MSG(hull_points.size() < 3, collider, "GLTFCollider: Convex hull has fewer points (" + itos(hull_points.size()) + ") than the minimum of 3. At least 3 points are required in order to save to GLTF, since it uses a mesh to represent convex hulls.");
+ if (hull_points.size() > 255) {
+ WARN_PRINT("GLTFCollider: Convex hull has more points (" + itos(hull_points.size()) + ") than the recommended maximum of 255. This may not load correctly in other engines.");
+ }
+ // Convert the convex hull points into an array of faces.
+ Geometry3D::MeshData md;
+ Error err = ConvexHullComputer::convex_hull(hull_points, md);
+ ERR_FAIL_COND_V_MSG(err != OK, collider, "GLTFCollider: Failed to compute convex hull.");
+ Vector<Vector3> face_vertices;
+ for (uint32_t i = 0; i < md.faces.size(); i++) {
+ uint32_t index_count = md.faces[i].indices.size();
+ for (uint32_t j = 1; j < index_count - 1; j++) {
+ face_vertices.append(hull_points[md.faces[i].indices[0]]);
+ face_vertices.append(hull_points[md.faces[i].indices[j]]);
+ face_vertices.append(hull_points[md.faces[i].indices[j + 1]]);
+ }
+ }
+ // Create an ImporterMesh from the faces.
+ Ref<ImporterMesh> importer_mesh;
+ importer_mesh.instantiate();
+ Array surface_array;
+ surface_array.resize(Mesh::ArrayType::ARRAY_MAX);
+ surface_array[Mesh::ArrayType::ARRAY_VERTEX] = face_vertices;
+ importer_mesh->add_surface(Mesh::PRIMITIVE_TRIANGLES, surface_array);
+ collider->set_importer_mesh(importer_mesh);
+ } else if (cast_to<const ConcavePolygonShape3D>(shape.ptr())) {
+ collider->shape_type = "trimesh";
+ Ref<ConcavePolygonShape3D> concave = shape;
+ Ref<ImporterMesh> importer_mesh;
+ importer_mesh.instantiate();
+ Array surface_array;
+ surface_array.resize(Mesh::ArrayType::ARRAY_MAX);
+ surface_array[Mesh::ArrayType::ARRAY_VERTEX] = concave->get_faces();
+ importer_mesh->add_surface(Mesh::PRIMITIVE_TRIANGLES, surface_array);
+ collider->set_importer_mesh(importer_mesh);
+ } else {
+ ERR_PRINT("Tried to create a GLTFCollider from a CollisionShape3D node, but the given node's shape '" + String(Variant(shape)) +
+ "' had an unsupported shape type. Only BoxShape3D, CapsuleShape3D, CylinderShape3D, SphereShape3D, ConcavePolygonShape3D, and ConvexPolygonShape3D are supported.");
+ }
+ return collider;
+}
+
+CollisionShape3D *GLTFCollider::to_node(bool p_cache_shapes) {
+ CollisionShape3D *collider = memnew(CollisionShape3D);
+ if (!p_cache_shapes || _shape_cache == nullptr) {
+ if (shape_type == "box") {
+ Ref<BoxShape3D> box;
+ box.instantiate();
+ box->set_size(size);
+ _shape_cache = box;
+ } else if (shape_type == "capsule") {
+ Ref<CapsuleShape3D> capsule;
+ capsule.instantiate();
+ capsule->set_radius(radius);
+ capsule->set_height(height);
+ _shape_cache = capsule;
+ } else if (shape_type == "cylinder") {
+ Ref<CylinderShape3D> cylinder;
+ cylinder.instantiate();
+ cylinder->set_radius(radius);
+ cylinder->set_height(height);
+ _shape_cache = cylinder;
+ } else if (shape_type == "sphere") {
+ Ref<SphereShape3D> sphere;
+ sphere.instantiate();
+ sphere->set_radius(radius);
+ _shape_cache = sphere;
+ } else if (shape_type == "hull") {
+ ERR_FAIL_COND_V_MSG(importer_mesh.is_null(), collider, "GLTFCollider: Error converting convex hull collider to a node: The mesh resource is null.");
+ Ref<ConvexPolygonShape3D> convex = importer_mesh->get_mesh()->create_convex_shape();
+ _shape_cache = convex;
+ } else if (shape_type == "trimesh") {
+ ERR_FAIL_COND_V_MSG(importer_mesh.is_null(), collider, "GLTFCollider: Error converting concave mesh collider to a node: The mesh resource is null.");
+ Ref<ConcavePolygonShape3D> concave = importer_mesh->create_trimesh_shape();
+ _shape_cache = concave;
+ } else {
+ ERR_PRINT("GLTFCollider: Error converting to a node: Shape type '" + shape_type + "' is unknown.");
+ }
+ }
+ collider->set_shape(_shape_cache);
+ return collider;
+}
+
+Ref<GLTFCollider> GLTFCollider::from_dictionary(const Dictionary p_dictionary) {
+ ERR_FAIL_COND_V_MSG(!p_dictionary.has("type"), Ref<GLTFCollider>(), "Failed to parse GLTF collider, missing required field 'type'.");
+ Ref<GLTFCollider> collider;
+ collider.instantiate();
+ const String &shape_type = p_dictionary["type"];
+ collider->shape_type = shape_type;
+ if (shape_type != "box" && shape_type != "capsule" && shape_type != "cylinder" && shape_type != "sphere" && shape_type != "hull" && shape_type != "trimesh") {
+ ERR_PRINT("Error parsing GLTF collider: Shape type '" + shape_type + "' is unknown. Only box, capsule, cylinder, sphere, hull, and trimesh are supported.");
+ }
+ if (p_dictionary.has("radius")) {
+ collider->set_radius(p_dictionary["radius"]);
+ }
+ if (p_dictionary.has("height")) {
+ collider->set_height(p_dictionary["height"]);
+ }
+ if (p_dictionary.has("size")) {
+ const Array &arr = p_dictionary["size"];
+ if (arr.size() == 3) {
+ collider->set_size(Vector3(arr[0], arr[1], arr[2]));
+ } else {
+ ERR_PRINT("Error parsing GLTF collider: The size must have exactly 3 numbers.");
+ }
+ }
+ if (p_dictionary.has("isTrigger")) {
+ collider->set_is_trigger(p_dictionary["isTrigger"]);
+ }
+ if (p_dictionary.has("mesh")) {
+ collider->set_mesh_index(p_dictionary["mesh"]);
+ }
+ if (unlikely(collider->get_mesh_index() < 0 && (shape_type == "hull" || shape_type == "trimesh"))) {
+ ERR_PRINT("Error parsing GLTF collider: The mesh-based shape type '" + shape_type + "' does not have a valid mesh index.");
+ }
+ return collider;
+}
+
+Dictionary GLTFCollider::to_dictionary() const {
+ Dictionary d;
+ d["type"] = shape_type;
+ if (shape_type == "box") {
+ Array size_array;
+ size_array.resize(3);
+ size_array[0] = size.x;
+ size_array[1] = size.y;
+ size_array[2] = size.z;
+ d["size"] = size_array;
+ } else if (shape_type == "capsule") {
+ d["radius"] = get_radius();
+ d["height"] = get_height();
+ } else if (shape_type == "cylinder") {
+ d["radius"] = get_radius();
+ d["height"] = get_height();
+ } else if (shape_type == "sphere") {
+ d["radius"] = get_radius();
+ } else if (shape_type == "trimesh" || shape_type == "hull") {
+ d["mesh"] = get_mesh_index();
+ }
+ if (is_trigger) {
+ d["isTrigger"] = is_trigger;
+ }
+ return d;
+}
diff --git a/modules/gltf/extensions/physics/gltf_collider.h b/modules/gltf/extensions/physics/gltf_collider.h
new file mode 100644
index 0000000000..94c7011618
--- /dev/null
+++ b/modules/gltf/extensions/physics/gltf_collider.h
@@ -0,0 +1,88 @@
+/**************************************************************************/
+/* gltf_collider.h */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/**************************************************************************/
+
+#ifndef GLTF_COLLIDER_H
+#define GLTF_COLLIDER_H
+
+#include "../../gltf_defines.h"
+#include "scene/3d/collision_shape_3d.h"
+
+class ImporterMesh;
+
+// GLTFCollider is an intermediary between OMI_collider and Godot's collision shape nodes.
+// https://github.com/omigroup/gltf-extensions/tree/main/extensions/2.0/OMI_collider
+
+class GLTFCollider : public Resource {
+ GDCLASS(GLTFCollider, Resource)
+
+protected:
+ static void _bind_methods();
+
+private:
+ String shape_type;
+ Vector3 size = Vector3(1.0, 1.0, 1.0);
+ real_t radius = 0.5;
+ real_t height = 2.0;
+ bool is_trigger = false;
+ GLTFMeshIndex mesh_index = -1;
+ Ref<ImporterMesh> importer_mesh = nullptr;
+ // Internal only, for caching Godot shape resources. Used in `to_node`.
+ Ref<Shape3D> _shape_cache = nullptr;
+
+public:
+ String get_shape_type() const;
+ void set_shape_type(String p_shape_type);
+
+ Vector3 get_size() const;
+ void set_size(Vector3 p_size);
+
+ real_t get_radius() const;
+ void set_radius(real_t p_radius);
+
+ real_t get_height() const;
+ void set_height(real_t p_height);
+
+ bool get_is_trigger() const;
+ void set_is_trigger(bool p_is_trigger);
+
+ GLTFMeshIndex get_mesh_index() const;
+ void set_mesh_index(GLTFMeshIndex p_mesh_index);
+
+ Ref<ImporterMesh> get_importer_mesh() const;
+ void set_importer_mesh(Ref<ImporterMesh> p_importer_mesh);
+
+ static Ref<GLTFCollider> from_node(const CollisionShape3D *p_collider_node);
+ CollisionShape3D *to_node(bool p_cache_shapes = false);
+
+ static Ref<GLTFCollider> from_dictionary(const Dictionary p_dictionary);
+ Dictionary to_dictionary() const;
+};
+
+#endif // GLTF_COLLIDER_H
diff --git a/modules/gltf/extensions/physics/gltf_document_extension_physics.cpp b/modules/gltf/extensions/physics/gltf_document_extension_physics.cpp
new file mode 100644
index 0000000000..e36a9fbb95
--- /dev/null
+++ b/modules/gltf/extensions/physics/gltf_document_extension_physics.cpp
@@ -0,0 +1,272 @@
+/**************************************************************************/
+/* gltf_document_extension_physics.cpp */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/**************************************************************************/
+
+#include "gltf_document_extension_physics.h"
+
+#include "scene/3d/area_3d.h"
+
+// Import process.
+Error GLTFDocumentExtensionPhysics::import_preflight(Ref<GLTFState> p_state, Vector<String> p_extensions) {
+ if (!p_extensions.has("OMI_collider") && !p_extensions.has("OMI_physics_body")) {
+ return ERR_SKIP;
+ }
+ Dictionary state_json = p_state->get_json();
+ if (state_json.has("extensions")) {
+ Dictionary state_extensions = state_json["extensions"];
+ if (state_extensions.has("OMI_collider")) {
+ Dictionary omi_collider_ext = state_extensions["OMI_collider"];
+ if (omi_collider_ext.has("colliders")) {
+ Array state_collider_dicts = omi_collider_ext["colliders"];
+ if (state_collider_dicts.size() > 0) {
+ Array state_colliders;
+ for (int i = 0; i < state_collider_dicts.size(); i++) {
+ state_colliders.push_back(GLTFCollider::from_dictionary(state_collider_dicts[i]));
+ }
+ p_state->set_additional_data("GLTFColliders", state_colliders);
+ }
+ }
+ }
+ }
+ return OK;
+}
+
+Vector<String> GLTFDocumentExtensionPhysics::get_supported_extensions() {
+ Vector<String> ret;
+ ret.push_back("OMI_collider");
+ ret.push_back("OMI_physics_body");
+ return ret;
+}
+
+Error GLTFDocumentExtensionPhysics::parse_node_extensions(Ref<GLTFState> p_state, Ref<GLTFNode> p_gltf_node, Dictionary &p_extensions) {
+ if (p_extensions.has("OMI_collider")) {
+ Dictionary node_collider_ext = p_extensions["OMI_collider"];
+ if (node_collider_ext.has("collider")) {
+ // "collider" is the index of the collider in the state colliders array.
+ int node_collider_index = node_collider_ext["collider"];
+ Array state_colliders = p_state->get_additional_data("GLTFColliders");
+ ERR_FAIL_INDEX_V_MSG(node_collider_index, state_colliders.size(), Error::ERR_FILE_CORRUPT, "GLTF Physics: On node " + p_gltf_node->get_name() + ", the collider index " + itos(node_collider_index) + " is not in the state colliders (size: " + itos(state_colliders.size()) + ").");
+ p_gltf_node->set_additional_data(StringName("GLTFCollider"), state_colliders[node_collider_index]);
+ } else {
+ p_gltf_node->set_additional_data(StringName("GLTFCollider"), GLTFCollider::from_dictionary(p_extensions["OMI_collider"]));
+ }
+ }
+ if (p_extensions.has("OMI_physics_body")) {
+ p_gltf_node->set_additional_data(StringName("GLTFPhysicsBody"), GLTFPhysicsBody::from_dictionary(p_extensions["OMI_physics_body"]));
+ }
+ return OK;
+}
+
+void _setup_collider_mesh_resource_from_index_if_needed(Ref<GLTFState> p_state, Ref<GLTFCollider> p_collider) {
+ GLTFMeshIndex collider_mesh_index = p_collider->get_mesh_index();
+ if (collider_mesh_index == -1) {
+ return; // No mesh for this collider.
+ }
+ Ref<ImporterMesh> importer_mesh = p_collider->get_importer_mesh();
+ if (importer_mesh.is_valid()) {
+ return; // The mesh resource is already set up.
+ }
+ TypedArray<GLTFMesh> state_meshes = p_state->get_meshes();
+ ERR_FAIL_INDEX_MSG(collider_mesh_index, state_meshes.size(), "GLTF Physics: When importing '" + p_state->get_scene_name() + "', the collider mesh index " + itos(collider_mesh_index) + " is not in the state meshes (size: " + itos(state_meshes.size()) + ").");
+ Ref<GLTFMesh> gltf_mesh = state_meshes[collider_mesh_index];
+ ERR_FAIL_COND(gltf_mesh.is_null());
+ importer_mesh = gltf_mesh->get_mesh();
+ ERR_FAIL_COND(importer_mesh.is_null());
+ p_collider->set_importer_mesh(importer_mesh);
+}
+
+CollisionObject3D *_generate_collision_with_body(Ref<GLTFState> p_state, Ref<GLTFNode> p_gltf_node, Ref<GLTFCollider> p_collider, Ref<GLTFPhysicsBody> p_physics_body) {
+ print_verbose("glTF: Creating collision for: " + p_gltf_node->get_name());
+ bool is_trigger = p_collider->get_is_trigger();
+ // This method is used for the case where we must generate a parent body.
+ // This is can happen for multiple reasons. One possibility is that this
+ // GLTF file is using OMI_collider but not OMI_physics_body, or at least
+ // this particular node is not using it. Another possibility is that the
+ // physics body information is set up on the same GLTF node, not a parent.
+ CollisionObject3D *body;
+ if (p_physics_body.is_valid()) {
+ // This code is run when the physics body is on the same GLTF node.
+ body = p_physics_body->to_node();
+ if (is_trigger != (p_physics_body->get_body_type() == "trigger")) {
+ // Edge case: If the body's trigger and the collider's trigger
+ // are in disagreement, we need to create another new body.
+ CollisionObject3D *child = _generate_collision_with_body(p_state, p_gltf_node, p_collider, nullptr);
+ child->set_name(p_gltf_node->get_name() + (is_trigger ? String("Trigger") : String("Solid")));
+ body->add_child(child);
+ return body;
+ }
+ } else if (is_trigger) {
+ body = memnew(Area3D);
+ } else {
+ body = memnew(StaticBody3D);
+ }
+ CollisionShape3D *shape = p_collider->to_node();
+ shape->set_name(p_gltf_node->get_name() + "Shape");
+ body->add_child(shape);
+ return body;
+}
+
+Node3D *GLTFDocumentExtensionPhysics::generate_scene_node(Ref<GLTFState> p_state, Ref<GLTFNode> p_gltf_node, Node *p_scene_parent) {
+ Ref<GLTFPhysicsBody> physics_body = p_gltf_node->get_additional_data(StringName("GLTFPhysicsBody"));
+ Ref<GLTFCollider> collider = p_gltf_node->get_additional_data(StringName("GLTFCollider"));
+ if (collider.is_valid()) {
+ _setup_collider_mesh_resource_from_index_if_needed(p_state, collider);
+ // If the collider has the correct type of parent, we just return one node.
+ if (collider->get_is_trigger()) {
+ if (Object::cast_to<Area3D>(p_scene_parent)) {
+ return collider->to_node(true);
+ }
+ } else {
+ if (Object::cast_to<PhysicsBody3D>(p_scene_parent)) {
+ return collider->to_node(true);
+ }
+ }
+ return _generate_collision_with_body(p_state, p_gltf_node, collider, physics_body);
+ }
+ if (physics_body.is_valid()) {
+ return physics_body->to_node();
+ }
+ return nullptr;
+}
+
+// Export process.
+bool _are_all_faces_equal(const Vector<Face3> &p_a, const Vector<Face3> &p_b) {
+ if (p_a.size() != p_b.size()) {
+ return false;
+ }
+ for (int i = 0; i < p_a.size(); i++) {
+ const Vector3 *a_vertices = p_a[i].vertex;
+ const Vector3 *b_vertices = p_b[i].vertex;
+ for (int j = 0; j < 3; j++) {
+ if (!a_vertices[j].is_equal_approx(b_vertices[j])) {
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
+GLTFMeshIndex _get_or_insert_mesh_in_state(Ref<GLTFState> p_state, Ref<ImporterMesh> p_mesh) {
+ ERR_FAIL_COND_V(p_mesh.is_null(), -1);
+ TypedArray<GLTFMesh> state_meshes = p_state->get_meshes();
+ Vector<Face3> mesh_faces = p_mesh->get_faces();
+ // De-duplication: If the state already has the mesh we need, use that one.
+ for (GLTFMeshIndex i = 0; i < state_meshes.size(); i++) {
+ Ref<GLTFMesh> state_gltf_mesh = state_meshes[i];
+ ERR_CONTINUE(state_gltf_mesh.is_null());
+ Ref<ImporterMesh> state_importer_mesh = state_gltf_mesh->get_mesh();
+ ERR_CONTINUE(state_importer_mesh.is_null());
+ if (state_importer_mesh == p_mesh) {
+ return i;
+ }
+ if (_are_all_faces_equal(state_importer_mesh->get_faces(), mesh_faces)) {
+ return i;
+ }
+ }
+ // After the loop, we have checked that the mesh is not equal to any of the
+ // meshes in the state. So we insert a new mesh into the state mesh array.
+ Ref<GLTFMesh> gltf_mesh;
+ gltf_mesh.instantiate();
+ gltf_mesh->set_mesh(p_mesh);
+ GLTFMeshIndex mesh_index = state_meshes.size();
+ state_meshes.push_back(gltf_mesh);
+ p_state->set_meshes(state_meshes);
+ return mesh_index;
+}
+
+void GLTFDocumentExtensionPhysics::convert_scene_node(Ref<GLTFState> p_state, Ref<GLTFNode> p_gltf_node, Node *p_scene_node) {
+ if (cast_to<CollisionShape3D>(p_scene_node)) {
+ CollisionShape3D *shape = Object::cast_to<CollisionShape3D>(p_scene_node);
+ Ref<GLTFCollider> collider = GLTFCollider::from_node(shape);
+ {
+ Ref<ImporterMesh> importer_mesh = collider->get_importer_mesh();
+ if (importer_mesh.is_valid()) {
+ collider->set_mesh_index(_get_or_insert_mesh_in_state(p_state, importer_mesh));
+ }
+ }
+ p_gltf_node->set_additional_data(StringName("GLTFCollider"), collider);
+ } else if (cast_to<CollisionObject3D>(p_scene_node)) {
+ CollisionObject3D *body = Object::cast_to<CollisionObject3D>(p_scene_node);
+ p_gltf_node->set_additional_data(StringName("GLTFPhysicsBody"), GLTFPhysicsBody::from_node(body));
+ }
+}
+
+Array _get_or_create_state_colliders_in_state(Ref<GLTFState> p_state) {
+ Dictionary state_json = p_state->get_json();
+ Dictionary state_extensions;
+ if (state_json.has("extensions")) {
+ state_extensions = state_json["extensions"];
+ } else {
+ state_json["extensions"] = state_extensions;
+ }
+ Dictionary omi_collider_ext;
+ if (state_extensions.has("OMI_collider")) {
+ omi_collider_ext = state_extensions["OMI_collider"];
+ } else {
+ state_extensions["OMI_collider"] = omi_collider_ext;
+ p_state->add_used_extension("OMI_collider");
+ }
+ Array state_colliders;
+ if (omi_collider_ext.has("colliders")) {
+ state_colliders = omi_collider_ext["colliders"];
+ } else {
+ omi_collider_ext["colliders"] = state_colliders;
+ }
+ return state_colliders;
+}
+
+Error GLTFDocumentExtensionPhysics::export_node(Ref<GLTFState> p_state, Ref<GLTFNode> p_gltf_node, Dictionary &r_node_json, Node *p_node) {
+ Dictionary node_extensions = r_node_json["extensions"];
+ Ref<GLTFPhysicsBody> physics_body = p_gltf_node->get_additional_data(StringName("GLTFPhysicsBody"));
+ if (physics_body.is_valid()) {
+ node_extensions["OMI_physics_body"] = physics_body->to_dictionary();
+ p_state->add_used_extension("OMI_physics_body");
+ }
+ Ref<GLTFCollider> collider = p_gltf_node->get_additional_data(StringName("GLTFCollider"));
+ if (collider.is_valid()) {
+ Array state_colliders = _get_or_create_state_colliders_in_state(p_state);
+ int size = state_colliders.size();
+ Dictionary omi_collider_ext;
+ node_extensions["OMI_collider"] = omi_collider_ext;
+ Dictionary collider_dict = collider->to_dictionary();
+ for (int i = 0; i < size; i++) {
+ Dictionary other = state_colliders[i];
+ if (other == collider_dict) {
+ // De-duplication: If we already have an identical collider,
+ // set the collider index to the existing one and return.
+ omi_collider_ext["collider"] = i;
+ return OK;
+ }
+ }
+ // If we don't have an identical collider, add it to the array.
+ state_colliders.push_back(collider_dict);
+ omi_collider_ext["collider"] = size;
+ }
+ return OK;
+}
diff --git a/modules/gltf/extensions/physics/gltf_document_extension_physics.h b/modules/gltf/extensions/physics/gltf_document_extension_physics.h
new file mode 100644
index 0000000000..5c4e739dba
--- /dev/null
+++ b/modules/gltf/extensions/physics/gltf_document_extension_physics.h
@@ -0,0 +1,53 @@
+/**************************************************************************/
+/* gltf_document_extension_physics.h */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/**************************************************************************/
+
+#ifndef GLTF_DOCUMENT_EXTENSION_PHYSICS_H
+#define GLTF_DOCUMENT_EXTENSION_PHYSICS_H
+
+#include "../gltf_document_extension.h"
+
+#include "gltf_collider.h"
+#include "gltf_physics_body.h"
+
+class GLTFDocumentExtensionPhysics : public GLTFDocumentExtension {
+ GDCLASS(GLTFDocumentExtensionPhysics, GLTFDocumentExtension);
+
+public:
+ // Import process.
+ Error import_preflight(Ref<GLTFState> p_state, Vector<String> p_extensions) override;
+ Vector<String> get_supported_extensions() override;
+ Error parse_node_extensions(Ref<GLTFState> p_state, Ref<GLTFNode> p_gltf_node, Dictionary &p_extensions) override;
+ Node3D *generate_scene_node(Ref<GLTFState> p_state, Ref<GLTFNode> p_gltf_node, Node *p_scene_parent) override;
+ // Export process.
+ void convert_scene_node(Ref<GLTFState> p_state, Ref<GLTFNode> p_gltf_node, Node *p_scene_node) override;
+ Error export_node(Ref<GLTFState> p_state, Ref<GLTFNode> p_gltf_node, Dictionary &r_node_json, Node *p_scene_node) override;
+};
+
+#endif // GLTF_DOCUMENT_EXTENSION_PHYSICS_H
diff --git a/modules/gltf/extensions/physics/gltf_physics_body.cpp b/modules/gltf/extensions/physics/gltf_physics_body.cpp
new file mode 100644
index 0000000000..b7fb23d37f
--- /dev/null
+++ b/modules/gltf/extensions/physics/gltf_physics_body.cpp
@@ -0,0 +1,237 @@
+/**************************************************************************/
+/* gltf_physics_body.cpp */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/**************************************************************************/
+
+#include "gltf_physics_body.h"
+
+#include "scene/3d/area_3d.h"
+#include "scene/3d/vehicle_body_3d.h"
+
+void GLTFPhysicsBody::_bind_methods() {
+ ClassDB::bind_static_method("GLTFPhysicsBody", D_METHOD("from_node", "body_node"), &GLTFPhysicsBody::from_node);
+ ClassDB::bind_method(D_METHOD("to_node"), &GLTFPhysicsBody::to_node);
+
+ ClassDB::bind_static_method("GLTFPhysicsBody", D_METHOD("from_dictionary", "dictionary"), &GLTFPhysicsBody::from_dictionary);
+ ClassDB::bind_method(D_METHOD("to_dictionary"), &GLTFPhysicsBody::to_dictionary);
+
+ ClassDB::bind_method(D_METHOD("get_body_type"), &GLTFPhysicsBody::get_body_type);
+ ClassDB::bind_method(D_METHOD("set_body_type", "body_type"), &GLTFPhysicsBody::set_body_type);
+ ClassDB::bind_method(D_METHOD("get_mass"), &GLTFPhysicsBody::get_mass);
+ ClassDB::bind_method(D_METHOD("set_mass", "mass"), &GLTFPhysicsBody::set_mass);
+ ClassDB::bind_method(D_METHOD("get_linear_velocity"), &GLTFPhysicsBody::get_linear_velocity);
+ ClassDB::bind_method(D_METHOD("set_linear_velocity", "linear_velocity"), &GLTFPhysicsBody::set_linear_velocity);
+ ClassDB::bind_method(D_METHOD("get_angular_velocity"), &GLTFPhysicsBody::get_angular_velocity);
+ ClassDB::bind_method(D_METHOD("set_angular_velocity", "angular_velocity"), &GLTFPhysicsBody::set_angular_velocity);
+ ClassDB::bind_method(D_METHOD("get_inertia"), &GLTFPhysicsBody::get_inertia);
+ ClassDB::bind_method(D_METHOD("set_inertia", "inertia"), &GLTFPhysicsBody::set_inertia);
+
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "body_type"), "set_body_type", "get_body_type");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "mass"), "set_mass", "get_mass");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "linear_velocity"), "set_linear_velocity", "get_linear_velocity");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "angular_velocity"), "set_angular_velocity", "get_angular_velocity");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "inertia"), "set_inertia", "get_inertia");
+}
+
+String GLTFPhysicsBody::get_body_type() const {
+ return body_type;
+}
+
+void GLTFPhysicsBody::set_body_type(String p_body_type) {
+ body_type = p_body_type;
+}
+
+real_t GLTFPhysicsBody::get_mass() const {
+ return mass;
+}
+
+void GLTFPhysicsBody::set_mass(real_t p_mass) {
+ mass = p_mass;
+}
+
+Vector3 GLTFPhysicsBody::get_linear_velocity() const {
+ return linear_velocity;
+}
+
+void GLTFPhysicsBody::set_linear_velocity(Vector3 p_linear_velocity) {
+ linear_velocity = p_linear_velocity;
+}
+
+Vector3 GLTFPhysicsBody::get_angular_velocity() const {
+ return angular_velocity;
+}
+
+void GLTFPhysicsBody::set_angular_velocity(Vector3 p_angular_velocity) {
+ angular_velocity = p_angular_velocity;
+}
+
+Vector3 GLTFPhysicsBody::get_inertia() const {
+ return inertia;
+}
+
+void GLTFPhysicsBody::set_inertia(Vector3 p_inertia) {
+ inertia = p_inertia;
+}
+
+Ref<GLTFPhysicsBody> GLTFPhysicsBody::from_node(const CollisionObject3D *p_body_node) {
+ Ref<GLTFPhysicsBody> physics_body;
+ physics_body.instantiate();
+ ERR_FAIL_COND_V_MSG(!p_body_node, physics_body, "Tried to create a GLTFPhysicsBody from a CollisionObject3D node, but the given node was null.");
+ if (cast_to<CharacterBody3D>(p_body_node)) {
+ physics_body->body_type = "character";
+ } else if (cast_to<AnimatableBody3D>(p_body_node)) {
+ physics_body->body_type = "kinematic";
+ } else if (cast_to<RigidBody3D>(p_body_node)) {
+ const RigidBody3D *body = cast_to<const RigidBody3D>(p_body_node);
+ physics_body->mass = body->get_mass();
+ physics_body->linear_velocity = body->get_linear_velocity();
+ physics_body->angular_velocity = body->get_angular_velocity();
+ physics_body->inertia = body->get_inertia();
+ if (cast_to<VehicleBody3D>(p_body_node)) {
+ physics_body->body_type = "vehicle";
+ } else {
+ physics_body->body_type = "rigid";
+ }
+ } else if (cast_to<StaticBody3D>(p_body_node)) {
+ physics_body->body_type = "static";
+ } else if (cast_to<Area3D>(p_body_node)) {
+ physics_body->body_type = "trigger";
+ }
+ return physics_body;
+}
+
+CollisionObject3D *GLTFPhysicsBody::to_node() const {
+ if (body_type == "character") {
+ CharacterBody3D *body = memnew(CharacterBody3D);
+ return body;
+ }
+ if (body_type == "kinematic") {
+ AnimatableBody3D *body = memnew(AnimatableBody3D);
+ return body;
+ }
+ if (body_type == "vehicle") {
+ VehicleBody3D *body = memnew(VehicleBody3D);
+ body->set_mass(mass);
+ body->set_linear_velocity(linear_velocity);
+ body->set_angular_velocity(angular_velocity);
+ body->set_inertia(inertia);
+ return body;
+ }
+ if (body_type == "rigid") {
+ RigidBody3D *body = memnew(RigidBody3D);
+ body->set_mass(mass);
+ body->set_linear_velocity(linear_velocity);
+ body->set_angular_velocity(angular_velocity);
+ body->set_inertia(inertia);
+ return body;
+ }
+ if (body_type == "static") {
+ StaticBody3D *body = memnew(StaticBody3D);
+ return body;
+ }
+ if (body_type == "trigger") {
+ Area3D *body = memnew(Area3D);
+ return body;
+ }
+ ERR_FAIL_V_MSG(nullptr, "Error converting GLTFPhysicsBody to a node: Body type '" + body_type + "' is unknown.");
+}
+
+Ref<GLTFPhysicsBody> GLTFPhysicsBody::from_dictionary(const Dictionary p_dictionary) {
+ Ref<GLTFPhysicsBody> physics_body;
+ physics_body.instantiate();
+ ERR_FAIL_COND_V_MSG(!p_dictionary.has("type"), physics_body, "Failed to parse GLTF physics body, missing required field 'type'.");
+ const String &body_type = p_dictionary["type"];
+ physics_body->body_type = body_type;
+
+ if (p_dictionary.has("mass")) {
+ physics_body->mass = p_dictionary["mass"];
+ }
+ if (p_dictionary.has("linearVelocity")) {
+ const Array &arr = p_dictionary["linearVelocity"];
+ if (arr.size() == 3) {
+ physics_body->set_linear_velocity(Vector3(arr[0], arr[1], arr[2]));
+ } else {
+ ERR_PRINT("Error parsing GLTF physics body: The linear velocity vector must have exactly 3 numbers.");
+ }
+ }
+ if (p_dictionary.has("angularVelocity")) {
+ const Array &arr = p_dictionary["angularVelocity"];
+ if (arr.size() == 3) {
+ physics_body->set_angular_velocity(Vector3(arr[0], arr[1], arr[2]));
+ } else {
+ ERR_PRINT("Error parsing GLTF physics body: The angular velocity vector must have exactly 3 numbers.");
+ }
+ }
+ if (p_dictionary.has("inertiaTensor")) {
+ const Array &arr = p_dictionary["inertiaTensor"];
+ if (arr.size() == 9) {
+ // Only use the diagonal elements of the inertia tensor matrix (principal axes).
+ physics_body->set_inertia(Vector3(arr[0], arr[4], arr[8]));
+ } else {
+ ERR_PRINT("Error parsing GLTF physics body: The inertia tensor must be a 3x3 matrix (9 number array).");
+ }
+ }
+ if (body_type != "character" && body_type != "kinematic" && body_type != "rigid" && body_type != "static" && body_type != "trigger" && body_type != "vehicle") {
+ ERR_PRINT("Error parsing GLTF physics body: Body type '" + body_type + "' is unknown.");
+ }
+ return physics_body;
+}
+
+Dictionary GLTFPhysicsBody::to_dictionary() const {
+ Dictionary d;
+ d["type"] = body_type;
+ if (mass != 1.0) {
+ d["mass"] = mass;
+ }
+ if (linear_velocity != Vector3()) {
+ Array velocity_array;
+ velocity_array.resize(3);
+ velocity_array[0] = linear_velocity.x;
+ velocity_array[1] = linear_velocity.y;
+ velocity_array[2] = linear_velocity.z;
+ d["linearVelocity"] = velocity_array;
+ }
+ if (angular_velocity != Vector3()) {
+ Array velocity_array;
+ velocity_array.resize(3);
+ velocity_array[0] = angular_velocity.x;
+ velocity_array[1] = angular_velocity.y;
+ velocity_array[2] = angular_velocity.z;
+ d["angularVelocity"] = velocity_array;
+ }
+ if (inertia != Vector3()) {
+ Array inertia_array;
+ inertia_array.resize(9);
+ inertia_array.fill(0.0);
+ inertia_array[0] = inertia.x;
+ inertia_array[4] = inertia.y;
+ inertia_array[8] = inertia.z;
+ d["inertiaTensor"] = inertia_array;
+ }
+ return d;
+}
diff --git a/modules/gltf/extensions/physics/gltf_physics_body.h b/modules/gltf/extensions/physics/gltf_physics_body.h
new file mode 100644
index 0000000000..1562c65b2b
--- /dev/null
+++ b/modules/gltf/extensions/physics/gltf_physics_body.h
@@ -0,0 +1,75 @@
+/**************************************************************************/
+/* gltf_physics_body.h */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/**************************************************************************/
+
+#ifndef GLTF_PHYSICS_BODY_H
+#define GLTF_PHYSICS_BODY_H
+
+#include "scene/3d/physics_body_3d.h"
+
+// GLTFPhysicsBody is an intermediary between OMI_physics_body and Godot's physics body nodes.
+// https://github.com/omigroup/gltf-extensions/tree/main/extensions/2.0/OMI_physics_body
+
+class GLTFPhysicsBody : public Resource {
+ GDCLASS(GLTFPhysicsBody, Resource)
+
+protected:
+ static void _bind_methods();
+
+private:
+ String body_type = "static";
+ real_t mass = 1.0;
+ Vector3 linear_velocity = Vector3();
+ Vector3 angular_velocity = Vector3();
+ Vector3 inertia = Vector3();
+
+public:
+ String get_body_type() const;
+ void set_body_type(String p_body_type);
+
+ real_t get_mass() const;
+ void set_mass(real_t p_mass);
+
+ Vector3 get_linear_velocity() const;
+ void set_linear_velocity(Vector3 p_linear_velocity);
+
+ Vector3 get_angular_velocity() const;
+ void set_angular_velocity(Vector3 p_angular_velocity);
+
+ Vector3 get_inertia() const;
+ void set_inertia(Vector3 p_inertia);
+
+ static Ref<GLTFPhysicsBody> from_node(const CollisionObject3D *p_body_node);
+ CollisionObject3D *to_node() const;
+
+ static Ref<GLTFPhysicsBody> from_dictionary(const Dictionary p_dictionary);
+ Dictionary to_dictionary() const;
+};
+
+#endif // GLTF_PHYSICS_BODY_H
diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp
index 7087c30688..251aa6375f 100644
--- a/modules/gltf/gltf_document.cpp
+++ b/modules/gltf/gltf_document.cpp
@@ -6478,7 +6478,7 @@ GLTFAnimation::Track GLTFDocument::_convert_animation_track(Ref<GLTFState> p_sta
bool last = false;
while (true) {
Vector3 scale;
- Error err = p_animation->scale_track_interpolate(p_track_i, time, &scale);
+ Error err = p_animation->try_scale_track_interpolate(p_track_i, time, &scale);
ERR_CONTINUE(err != OK);
p_track.scale_track.values.push_back(scale);
p_track.scale_track.times.push_back(time);
@@ -6513,7 +6513,7 @@ GLTFAnimation::Track GLTFDocument::_convert_animation_track(Ref<GLTFState> p_sta
bool last = false;
while (true) {
Vector3 scale;
- Error err = p_animation->position_track_interpolate(p_track_i, time, &scale);
+ Error err = p_animation->try_position_track_interpolate(p_track_i, time, &scale);
ERR_CONTINUE(err != OK);
p_track.position_track.values.push_back(scale);
p_track.position_track.times.push_back(time);
@@ -6548,7 +6548,7 @@ GLTFAnimation::Track GLTFDocument::_convert_animation_track(Ref<GLTFState> p_sta
bool last = false;
while (true) {
Quaternion rotation;
- Error err = p_animation->rotation_track_interpolate(p_track_i, time, &rotation);
+ Error err = p_animation->try_rotation_track_interpolate(p_track_i, time, &rotation);
ERR_CONTINUE(err != OK);
p_track.rotation_track.values.push_back(rotation);
p_track.rotation_track.times.push_back(time);
@@ -6588,7 +6588,7 @@ GLTFAnimation::Track GLTFDocument::_convert_animation_track(Ref<GLTFState> p_sta
bool last = false;
while (true) {
Vector3 position;
- Error err = p_animation->position_track_interpolate(p_track_i, time, &position);
+ Error err = p_animation->try_position_track_interpolate(p_track_i, time, &position);
ERR_CONTINUE(err != OK);
p_track.position_track.values.push_back(position);
p_track.position_track.times.push_back(time);
@@ -6621,7 +6621,7 @@ GLTFAnimation::Track GLTFDocument::_convert_animation_track(Ref<GLTFState> p_sta
bool last = false;
while (true) {
Quaternion rotation;
- Error err = p_animation->rotation_track_interpolate(p_track_i, time, &rotation);
+ Error err = p_animation->try_rotation_track_interpolate(p_track_i, time, &rotation);
ERR_CONTINUE(err != OK);
p_track.rotation_track.values.push_back(rotation);
p_track.rotation_track.times.push_back(time);
@@ -6657,7 +6657,7 @@ GLTFAnimation::Track GLTFDocument::_convert_animation_track(Ref<GLTFState> p_sta
bool last = false;
while (true) {
Vector3 scale;
- Error err = p_animation->scale_track_interpolate(p_track_i, time, &scale);
+ Error err = p_animation->try_scale_track_interpolate(p_track_i, time, &scale);
ERR_CONTINUE(err != OK);
p_track.scale_track.values.push_back(scale);
p_track.scale_track.times.push_back(time);
@@ -7190,9 +7190,9 @@ PackedByteArray GLTFDocument::_serialize_glb_buffer(Ref<GLTFState> p_state, Erro
const int32_t header_size = 12;
const int32_t chunk_header_size = 8;
- for (int32_t pad_i = 0; pad_i < (chunk_header_size + json.utf8().length()) % 4; pad_i++) {
- json += " ";
- }
+ int32_t padding = (chunk_header_size + json.utf8().length()) % 4;
+ json += String(" ").repeat(padding);
+
CharString cs = json.utf8();
const uint32_t text_chunk_length = cs.length();
@@ -7467,7 +7467,7 @@ Error GLTFDocument::_parse_gltf_extensions(Ref<GLTFState> p_state) {
supported_extensions.insert(ext_supported_extensions[i]);
}
}
- Error ret = Error::OK;
+ Error ret = OK;
for (int i = 0; i < p_state->extensions_required.size(); i++) {
if (!supported_extensions.has(p_state->extensions_required[i])) {
ERR_PRINT("GLTF: Can't import file '" + p_state->filename + "', required extension '" + String(p_state->extensions_required[i]) + "' is not supported. Are you missing a GLTFDocumentExtension plugin?");
diff --git a/modules/gltf/register_types.cpp b/modules/gltf/register_types.cpp
index 4754c316a1..2f66e5c5a5 100644
--- a/modules/gltf/register_types.cpp
+++ b/modules/gltf/register_types.cpp
@@ -32,6 +32,7 @@
#include "extensions/gltf_document_extension_convert_importer_mesh.h"
#include "extensions/gltf_spec_gloss.h"
+#include "extensions/physics/gltf_document_extension_physics.h"
#include "gltf_document.h"
#ifdef TOOLS_ENABLED
@@ -114,12 +115,14 @@ void initialize_gltf_module(ModuleInitializationLevel p_level) {
GDREGISTER_CLASS(GLTFAnimation);
GDREGISTER_CLASS(GLTFBufferView);
GDREGISTER_CLASS(GLTFCamera);
+ GDREGISTER_CLASS(GLTFCollider);
GDREGISTER_CLASS(GLTFDocument);
GDREGISTER_CLASS(GLTFDocumentExtension);
GDREGISTER_CLASS(GLTFDocumentExtensionConvertImporterMesh);
GDREGISTER_CLASS(GLTFLight);
GDREGISTER_CLASS(GLTFMesh);
GDREGISTER_CLASS(GLTFNode);
+ GDREGISTER_CLASS(GLTFPhysicsBody);
GDREGISTER_CLASS(GLTFSkeleton);
GDREGISTER_CLASS(GLTFSkin);
GDREGISTER_CLASS(GLTFSpecGloss);
@@ -127,6 +130,7 @@ void initialize_gltf_module(ModuleInitializationLevel p_level) {
GDREGISTER_CLASS(GLTFTexture);
GDREGISTER_CLASS(GLTFTextureSampler);
// Register GLTFDocumentExtension classes with GLTFDocument.
+ GLTF_REGISTER_DOCUMENT_EXTENSION(GLTFDocumentExtensionPhysics);
bool is_editor = ::Engine::get_singleton()->is_editor_hint();
if (!is_editor) {
GLTF_REGISTER_DOCUMENT_EXTENSION(GLTFDocumentExtensionConvertImporterMesh);
diff --git a/modules/gridmap/doc_classes/GridMap.xml b/modules/gridmap/doc_classes/GridMap.xml
index 8e25d0fb84..e413560c16 100644
--- a/modules/gridmap/doc_classes/GridMap.xml
+++ b/modules/gridmap/doc_classes/GridMap.xml
@@ -73,14 +73,14 @@
<return type="bool" />
<param index="0" name="layer_number" type="int" />
<description>
- Returns whether or not the specified layer of the [member collision_layer] is enabled, given a [code]layer_number[/code] between 1 and 32.
+ Returns whether or not the specified layer of the [member collision_layer] is enabled, given a [param layer_number] between 1 and 32.
</description>
</method>
<method name="get_collision_mask_value" qualifiers="const">
<return type="bool" />
<param index="0" name="layer_number" type="int" />
<description>
- Returns whether or not the specified layer of the [member collision_mask] is enabled, given a [code]layer_number[/code] between 1 and 32.
+ Returns whether or not the specified layer of the [member collision_mask] is enabled, given a [param layer_number] between 1 and 32.
</description>
</method>
<method name="get_meshes" qualifiers="const">
@@ -113,7 +113,7 @@
<return type="Vector3i[]" />
<param index="0" name="item" type="int" />
<description>
- Returns an array of all cells with the given item index specified in [code]item[/code].
+ Returns an array of all cells with the given item index specified in [param item].
</description>
</method>
<method name="local_to_map" qualifiers="const">
@@ -161,7 +161,7 @@
<param index="0" name="layer_number" type="int" />
<param index="1" name="value" type="bool" />
<description>
- Based on [code]value[/code], enables or disables the specified layer in the [member collision_layer], given a [code]layer_number[/code] between 1 and 32.
+ Based on [param value], enables or disables the specified layer in the [member collision_layer], given a [param layer_number] between 1 and 32.
</description>
</method>
<method name="set_collision_mask_value">
@@ -169,7 +169,7 @@
<param index="0" name="layer_number" type="int" />
<param index="1" name="value" type="bool" />
<description>
- Based on [code]value[/code], enables or disables the specified layer in the [member collision_mask], given a [code]layer_number[/code] between 1 and 32.
+ Based on [param value], enables or disables the specified layer in the [member collision_mask], given a [param layer_number] between 1 and 32.
</description>
</method>
<method name="set_navigation_map">
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index a77b1d83ad..0d6436594e 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -522,12 +522,7 @@ String CSharpLanguage::_get_indentation() const {
if (use_space_indentation) {
int indent_size = EDITOR_GET("text_editor/behavior/indent/size");
-
- String space_indent = "";
- for (int i = 0; i < indent_size; i++) {
- space_indent += " ";
- }
- return space_indent;
+ return String(" ").repeat(indent_size);
}
}
#endif
diff --git a/modules/mono/editor/editor_internal_calls.cpp b/modules/mono/editor/editor_internal_calls.cpp
index ad9ab66cc9..34b9974d10 100644
--- a/modules/mono/editor/editor_internal_calls.cpp
+++ b/modules/mono/editor/editor_internal_calls.cpp
@@ -42,6 +42,7 @@
#include "editor/editor_paths.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
+#include "editor/gui/editor_run_bar.h"
#include "editor/plugins/script_editor_plugin.h"
#include "main/main.h"
@@ -156,11 +157,11 @@ void godot_icall_Internal_EditorNodeShowScriptScreen() {
}
void godot_icall_Internal_EditorRunPlay() {
- EditorNode::get_singleton()->run_play();
+ EditorRunBar::get_singleton()->play_main_scene();
}
void godot_icall_Internal_EditorRunStop() {
- EditorNode::get_singleton()->run_stop();
+ EditorRunBar::get_singleton()->stop_playing();
}
void godot_icall_Internal_ScriptEditorDebugger_ReloadScripts() {
diff --git a/modules/multiplayer/doc_classes/MultiplayerSpawner.xml b/modules/multiplayer/doc_classes/MultiplayerSpawner.xml
index 36f69f2155..e6564a8aac 100644
--- a/modules/multiplayer/doc_classes/MultiplayerSpawner.xml
+++ b/modules/multiplayer/doc_classes/MultiplayerSpawner.xml
@@ -41,7 +41,7 @@
<return type="Node" />
<param index="0" name="data" type="Variant" default="null" />
<description>
- Requests a custom spawn, with [code]data[/code] passed to [member spawn_function] on all peers. Returns the locally spawned node instance already inside the scene tree, and added as a child of the node pointed by [member spawn_path].
+ Requests a custom spawn, with [param data] passed to [member spawn_function] on all peers. Returns the locally spawned node instance already inside the scene tree, and added as a child of the node pointed by [member spawn_path].
[b]Note:[/b] Spawnable scenes are spawned automatically. [method spawn] is only needed for custom spawns.
</description>
</method>
diff --git a/modules/multiplayer/doc_classes/MultiplayerSynchronizer.xml b/modules/multiplayer/doc_classes/MultiplayerSynchronizer.xml
index a3fb0c786e..2c93539ae1 100644
--- a/modules/multiplayer/doc_classes/MultiplayerSynchronizer.xml
+++ b/modules/multiplayer/doc_classes/MultiplayerSynchronizer.xml
@@ -17,14 +17,14 @@
<param index="0" name="filter" type="Callable" />
<description>
Adds a peer visibility filter for this synchronizer.
- [code]filter[/code] should take a peer ID [int] and return a [bool].
+ [param filter] should take a peer ID [int] and return a [bool].
</description>
</method>
<method name="get_visibility_for" qualifiers="const">
<return type="bool" />
<param index="0" name="peer" type="int" />
<description>
- Queries the current visibility for peer [code]peer[/code].
+ Queries the current visibility for peer [param peer].
</description>
</method>
<method name="remove_visibility_filter">
@@ -39,14 +39,14 @@
<param index="0" name="peer" type="int" />
<param index="1" name="visible" type="bool" />
<description>
- Sets the visibility of [code]peer[/code] to [code]visible[/code]. If [code]peer[/code] is [code]0[/code], the value of [member public_visibility] will be updated instead.
+ Sets the visibility of [param peer] to [param visible]. If [param peer] is [code]0[/code], the value of [member public_visibility] will be updated instead.
</description>
</method>
<method name="update_visibility">
<return type="void" />
<param index="0" name="for_peer" type="int" default="0" />
<description>
- Updates the visibility of [code]peer[/code] according to visibility filters. If [code]peer[/code] is [code]0[/code] (the default), all peers' visibilties are updated.
+ Updates the visibility of [param for_peer] according to visibility filters. If [param for_peer] is [code]0[/code] (the default), all peers' visibilties are updated.
</description>
</method>
</methods>
@@ -77,7 +77,7 @@
<signal name="visibility_changed">
<param index="0" name="for_peer" type="int" />
<description>
- Emitted when visibility of [code]for_peer[/code] is updated. See [method update_visibility].
+ Emitted when visibility of [param for_peer] is updated. See [method update_visibility].
</description>
</signal>
</signals>
diff --git a/modules/multiplayer/doc_classes/SceneMultiplayer.xml b/modules/multiplayer/doc_classes/SceneMultiplayer.xml
index 1ab37bfd82..2445d60f48 100644
--- a/modules/multiplayer/doc_classes/SceneMultiplayer.xml
+++ b/modules/multiplayer/doc_classes/SceneMultiplayer.xml
@@ -55,7 +55,7 @@
<param index="2" name="mode" type="int" enum="MultiplayerPeer.TransferMode" default="2" />
<param index="3" name="channel" type="int" default="0" />
<description>
- Sends the given raw [code]bytes[/code] to a specific peer identified by [code]id[/code] (see [method MultiplayerPeer.set_target_peer]). Default ID is [code]0[/code], i.e. broadcast to all peers.
+ Sends the given raw [param bytes] to a specific peer identified by [param id] (see [method MultiplayerPeer.set_target_peer]). Default ID is [code]0[/code], i.e. broadcast to all peers.
</description>
</method>
</methods>
@@ -100,7 +100,7 @@
<param index="0" name="id" type="int" />
<param index="1" name="packet" type="PackedByteArray" />
<description>
- Emitted when this MultiplayerAPI's [member MultiplayerAPI.multiplayer_peer] receives a [code]packet[/code] with custom data (see [method send_bytes]). ID is the peer ID of the peer that sent the packet.
+ Emitted when this MultiplayerAPI's [member MultiplayerAPI.multiplayer_peer] receives a [param packet] with custom data (see [method send_bytes]). ID is the peer ID of the peer that sent the packet.
</description>
</signal>
</signals>
diff --git a/modules/multiplayer/doc_classes/SceneReplicationConfig.xml b/modules/multiplayer/doc_classes/SceneReplicationConfig.xml
index 56ae219bab..53ea1d19a1 100644
--- a/modules/multiplayer/doc_classes/SceneReplicationConfig.xml
+++ b/modules/multiplayer/doc_classes/SceneReplicationConfig.xml
@@ -13,7 +13,7 @@
<param index="0" name="path" type="NodePath" />
<param index="1" name="index" type="int" default="-1" />
<description>
- Adds the property identified by the given [code]path[/code] to the list of the properties being synchronized, optionally passing an [code]index[/code].
+ Adds the property identified by the given [param path] to the list of the properties being synchronized, optionally passing an [param index].
</description>
</method>
<method name="get_properties" qualifiers="const">
@@ -26,28 +26,28 @@
<return type="bool" />
<param index="0" name="path" type="NodePath" />
<description>
- Returns whether the given [code]path[/code] is configured for synchronization.
+ Returns whether the given [param path] is configured for synchronization.
</description>
</method>
<method name="property_get_index" qualifiers="const">
<return type="int" />
<param index="0" name="path" type="NodePath" />
<description>
- Finds the index of the given [code]path[/code].
+ Finds the index of the given [param path].
</description>
</method>
<method name="property_get_spawn">
<return type="bool" />
<param index="0" name="path" type="NodePath" />
<description>
- Returns whether the property identified by the given [code]path[/code] is configured to be synchronized on spawn.
+ Returns whether the property identified by the given [param path] is configured to be synchronized on spawn.
</description>
</method>
<method name="property_get_sync">
<return type="bool" />
<param index="0" name="path" type="NodePath" />
<description>
- Returns whether the property identified by the given [code]path[/code] is configured to be synchronized on process.
+ Returns whether the property identified by the given [param path] is configured to be synchronized on process.
</description>
</method>
<method name="property_set_spawn">
@@ -55,7 +55,7 @@
<param index="0" name="path" type="NodePath" />
<param index="1" name="enabled" type="bool" />
<description>
- Sets whether the property identified by the given [code]path[/code] is configured to be synchronized on spawn.
+ Sets whether the property identified by the given [param path] is configured to be synchronized on spawn.
</description>
</method>
<method name="property_set_sync">
@@ -63,14 +63,14 @@
<param index="0" name="path" type="NodePath" />
<param index="1" name="enabled" type="bool" />
<description>
- Sets whether the property identified by the given [code]path[/code] is configured to be synchronized on process.
+ Sets whether the property identified by the given [param path] is configured to be synchronized on process.
</description>
</method>
<method name="remove_property">
<return type="void" />
<param index="0" name="path" type="NodePath" />
<description>
- Removes the property identified by the given [code]path[/code] from the configuration.
+ Removes the property identified by the given [param path] from the configuration.
</description>
</method>
</methods>
diff --git a/modules/noise/config.py b/modules/noise/config.py
index 2318d28c53..e6d5e1a646 100644
--- a/modules/noise/config.py
+++ b/modules/noise/config.py
@@ -11,6 +11,7 @@ def get_doc_classes():
"FastNoiseLite",
"Noise",
"NoiseTexture2D",
+ "NoiseTexture3D",
]
diff --git a/modules/noise/doc_classes/Noise.xml b/modules/noise/doc_classes/Noise.xml
index d214a02cf1..c075b5b629 100644
--- a/modules/noise/doc_classes/Noise.xml
+++ b/modules/noise/doc_classes/Noise.xml
@@ -19,8 +19,20 @@
<param index="3" name="in_3d_space" type="bool" default="false" />
<param index="4" name="normalize" type="bool" default="true" />
<description>
- Returns a 2D [Image] noise image.
- Note: With [param normalize] set to [code]false[/code] the default implementation expects the noise generator to return values in the range [code]-1.0[/code] to [code]1.0[/code].
+ Returns an [Image] containing 2D noise values.
+ [b]Note:[/b] With [param normalize] set to [code]false[/code], the default implementation expects the noise generator to return values in the range [code]-1.0[/code] to [code]1.0[/code].
+ </description>
+ </method>
+ <method name="get_image_3d" qualifiers="const">
+ <return type="Image[]" />
+ <param index="0" name="width" type="int" />
+ <param index="1" name="height" type="int" />
+ <param index="2" name="depth" type="int" />
+ <param index="3" name="invert" type="bool" default="false" />
+ <param index="4" name="normalize" type="bool" default="true" />
+ <description>
+ Returns an [Array] of [Image]s containing 3D noise values for use with [method ImageTexture3D.create].
+ [b]Note:[/b] With [param normalize] set to [code]false[/code], the default implementation expects the noise generator to return values in the range [code]-1.0[/code] to [code]1.0[/code].
</description>
</method>
<method name="get_noise_1d" qualifiers="const">
@@ -70,8 +82,21 @@
<param index="4" name="skirt" type="float" default="0.1" />
<param index="5" name="normalize" type="bool" default="true" />
<description>
- Returns a seamless 2D [Image] noise image.
- Note: With [param normalize] set to [code]false[/code] the default implementation expects the noise generator to return values in the range [code]-1.0[/code] to [code]1.0[/code].
+ Returns an [Image] containing seamless 2D noise values.
+ [b]Note:[/b] With [param normalize] set to [code]false[/code], the default implementation expects the noise generator to return values in the range [code]-1.0[/code] to [code]1.0[/code].
+ </description>
+ </method>
+ <method name="get_seamless_image_3d" qualifiers="const">
+ <return type="Image[]" />
+ <param index="0" name="width" type="int" />
+ <param index="1" name="height" type="int" />
+ <param index="2" name="depth" type="int" />
+ <param index="3" name="invert" type="bool" default="false" />
+ <param index="4" name="skirt" type="float" default="0.1" />
+ <param index="5" name="normalize" type="bool" default="true" />
+ <description>
+ Returns an [Array] of [Image]s containing seamless 3D noise values for use with [method ImageTexture3D.create].
+ [b]Note:[/b] With [param normalize] set to [code]false[/code], the default implementation expects the noise generator to return values in the range [code]-1.0[/code] to [code]1.0[/code].
</description>
</method>
</methods>
diff --git a/modules/noise/doc_classes/NoiseTexture3D.xml b/modules/noise/doc_classes/NoiseTexture3D.xml
new file mode 100644
index 0000000000..7394e7ff08
--- /dev/null
+++ b/modules/noise/doc_classes/NoiseTexture3D.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="NoiseTexture3D" inherits="Texture3D" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
+ <brief_description>
+ A texture filled with noise generated by a [Noise] object.
+ </brief_description>
+ <description>
+ Uses [FastNoiseLite] or other libraries to fill the texture data of your desired size.
+ The class uses [Thread]s to generate the texture data internally, so [method Texture3D.get_data] may return [code]null[/code] if the generation process has not completed yet. In that case, you need to wait for the texture to be generated before accessing the image:
+ [codeblock]
+ var texture = NoiseTexture3D.new()
+ texture.noise = FastNoiseLite.new()
+ await texture.changed
+ var data = texture.get_data()
+ [/codeblock]
+ </description>
+ <tutorials>
+ </tutorials>
+ <members>
+ <member name="color_ramp" type="Gradient" setter="set_color_ramp" getter="get_color_ramp">
+ A [Gradient] which is used to map the luminance of each pixel to a color value.
+ </member>
+ <member name="depth" type="int" setter="set_depth" getter="get_depth" default="64">
+ Depth of the generated texture.
+ </member>
+ <member name="height" type="int" setter="set_height" getter="get_height" default="64">
+ Height of the generated texture.
+ </member>
+ <member name="invert" type="bool" setter="set_invert" getter="get_invert" default="false">
+ If [code]true[/code], inverts the noise texture. White becomes black, black becomes white.
+ </member>
+ <member name="noise" type="Noise" setter="set_noise" getter="get_noise">
+ The instance of the [Noise] object.
+ </member>
+ <member name="normalize" type="bool" setter="set_normalize" getter="is_normalized" default="true">
+ If [code]true[/code], the noise image coming from the noise generator is normalized to the range [code]0.0[/code] to [code]1.0[/code].
+ Turning normalization off can affect the contrast and allows you to generate non repeating tileable noise textures.
+ </member>
+ <member name="seamless" type="bool" setter="set_seamless" getter="get_seamless" default="false">
+ If [code]true[/code], a seamless texture is requested from the [Noise] resource.
+ [b]Note:[/b] Seamless noise textures may take longer to generate and/or can have a lower contrast compared to non-seamless noise depending on the used [Noise] resource. This is because some implementations use higher dimensions for generating seamless noise.
+ </member>
+ <member name="seamless_blend_skirt" type="float" setter="set_seamless_blend_skirt" getter="get_seamless_blend_skirt" default="0.1">
+ Used for the default/fallback implementation of the seamless texture generation. It determines the distance over which the seams are blended. High values may result in less details and contrast. See [Noise] for further details.
+ </member>
+ <member name="width" type="int" setter="set_width" getter="get_width" default="64">
+ Width of the generated texture.
+ </member>
+ </members>
+</class>
diff --git a/modules/noise/fastnoise_lite.cpp b/modules/noise/fastnoise_lite.cpp
index 224c082c0f..4aea98c4de 100644
--- a/modules/noise/fastnoise_lite.cpp
+++ b/modules/noise/fastnoise_lite.cpp
@@ -416,7 +416,7 @@ void FastNoiseLite::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "noise_type", PROPERTY_HINT_ENUM, "Simplex,Simplex Smooth,Cellular,Perlin,Value Cubic,Value"), "set_noise_type", "get_noise_type");
ADD_PROPERTY(PropertyInfo(Variant::INT, "seed"), "set_seed", "get_seed");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "frequency", PROPERTY_HINT_RANGE, ".001,1"), "set_frequency", "get_frequency");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "frequency", PROPERTY_HINT_RANGE, ".0001,1,.0001"), "set_frequency", "get_frequency");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "offset", PROPERTY_HINT_RANGE, "-999999999,999999999,0.01"), "set_offset", "get_offset");
ADD_GROUP("Fractal", "fractal_");
diff --git a/modules/noise/noise.cpp b/modules/noise/noise.cpp
index e95788b863..1115d92f58 100644
--- a/modules/noise/noise.cpp
+++ b/modules/noise/noise.cpp
@@ -32,21 +32,40 @@
#include <float.h>
-Ref<Image> Noise::get_seamless_image(int p_width, int p_height, bool p_invert, bool p_in_3d_space, real_t p_blend_skirt, bool p_normalize) const {
- ERR_FAIL_COND_V(p_width <= 0 || p_height <= 0, Ref<Image>());
+Vector<Ref<Image>> Noise::_get_seamless_image(int p_width, int p_height, int p_depth, bool p_invert, bool p_in_3d_space, real_t p_blend_skirt, bool p_normalize) const {
+ ERR_FAIL_COND_V(p_width <= 0 || p_height <= 0 || p_depth <= 0, Vector<Ref<Image>>());
int skirt_width = MAX(1, p_width * p_blend_skirt);
int skirt_height = MAX(1, p_height * p_blend_skirt);
+ int skirt_depth = MAX(1, p_depth * p_blend_skirt);
int src_width = p_width + skirt_width;
int src_height = p_height + skirt_height;
+ int src_depth = p_depth + skirt_depth;
+
+ Vector<Ref<Image>> src = _get_image(src_width, src_height, src_depth, p_invert, p_in_3d_space, p_normalize);
+ bool grayscale = (src[0]->get_format() == Image::FORMAT_L8);
- Ref<Image> src = get_image(src_width, src_height, p_invert, p_in_3d_space, p_normalize);
- bool grayscale = (src->get_format() == Image::FORMAT_L8);
if (grayscale) {
- return _generate_seamless_image<uint8_t>(src, p_width, p_height, p_invert, p_blend_skirt);
+ return _generate_seamless_image<uint8_t>(src, p_width, p_height, p_depth, p_invert, p_blend_skirt);
} else {
- return _generate_seamless_image<uint32_t>(src, p_width, p_height, p_invert, p_blend_skirt);
+ return _generate_seamless_image<uint32_t>(src, p_width, p_height, p_depth, p_invert, p_blend_skirt);
+ }
+}
+
+Ref<Image> Noise::get_seamless_image(int p_width, int p_height, bool p_invert, bool p_in_3d_space, real_t p_blend_skirt, bool p_normalize) const {
+ Vector<Ref<Image>> images = _get_seamless_image(p_width, p_height, 1, p_invert, p_in_3d_space, p_blend_skirt, p_normalize);
+ return images[0];
+}
+
+TypedArray<Image> Noise::get_seamless_image_3d(int p_width, int p_height, int p_depth, bool p_invert, real_t p_blend_skirt, bool p_normalize) const {
+ Vector<Ref<Image>> images = _get_seamless_image(p_width, p_height, p_depth, p_invert, true, p_blend_skirt, p_normalize);
+
+ TypedArray<Image> ret;
+ ret.resize(images.size());
+ for (int i = 0; i < images.size(); i++) {
+ ret[i] = images[i];
}
+ return ret;
}
// Template specialization for faster grayscale blending.
@@ -58,61 +77,104 @@ uint8_t Noise::_alpha_blend<uint8_t>(uint8_t p_bg, uint8_t p_fg, int p_alpha) co
return (uint8_t)((alpha * p_fg + inv_alpha * p_bg) >> 8);
}
-Ref<Image> Noise::get_image(int p_width, int p_height, bool p_invert, bool p_in_3d_space, bool p_normalize) const {
- ERR_FAIL_COND_V(p_width <= 0 || p_height <= 0, Ref<Image>());
-
- Vector<uint8_t> data;
- data.resize(p_width * p_height);
+Vector<Ref<Image>> Noise::_get_image(int p_width, int p_height, int p_depth, bool p_invert, bool p_in_3d_space, bool p_normalize) const {
+ ERR_FAIL_COND_V(p_width <= 0 || p_height <= 0 || p_depth <= 0, Vector<Ref<Image>>());
- uint8_t *wd8 = data.ptrw();
+ Vector<Ref<Image>> images;
+ images.resize(p_depth);
if (p_normalize) {
// Get all values and identify min/max values.
- Vector<real_t> values;
- values.resize(p_width * p_height);
+ LocalVector<real_t> values;
+ values.resize(p_width * p_height * p_depth);
+
real_t min_val = FLT_MAX;
real_t max_val = -FLT_MAX;
- for (int y = 0, i = 0; y < p_height; y++) {
- for (int x = 0; x < p_width; x++, i++) {
- values.set(i, p_in_3d_space ? get_noise_3d(x, y, 0.0) : get_noise_2d(x, y));
- if (values[i] > max_val) {
- max_val = values[i];
- }
- if (values[i] < min_val) {
- min_val = values[i];
+ int idx = 0;
+ for (int d = 0; d < p_depth; d++) {
+ for (int y = 0; y < p_height; y++) {
+ for (int x = 0; x < p_width; x++) {
+ values[idx] = p_in_3d_space ? get_noise_3d(x, y, d) : get_noise_2d(x, y);
+ if (values[idx] > max_val) {
+ max_val = values[idx];
+ }
+ if (values[idx] < min_val) {
+ min_val = values[idx];
+ }
+ idx++;
}
}
}
+ idx = 0;
// Normalize values and write to texture.
- uint8_t ivalue;
- for (int i = 0, x = 0; i < p_height; i++) {
- for (int j = 0; j < p_width; j++, x++) {
- if (max_val == min_val) {
- ivalue = 0;
- } else {
- ivalue = static_cast<uint8_t>(CLAMP((values[x] - min_val) / (max_val - min_val) * 255.f, 0, 255));
- }
-
- if (p_invert) {
- ivalue = 255 - ivalue;
+ for (int d = 0; d < p_depth; d++) {
+ Vector<uint8_t> data;
+ data.resize(p_width * p_height);
+
+ uint8_t *wd8 = data.ptrw();
+ uint8_t ivalue;
+
+ for (int y = 0; y < p_height; y++) {
+ for (int x = 0; x < p_width; x++) {
+ if (max_val == min_val) {
+ ivalue = 0;
+ } else {
+ ivalue = static_cast<uint8_t>(CLAMP((values[idx] - min_val) / (max_val - min_val) * 255.f, 0, 255));
+ }
+
+ if (p_invert) {
+ ivalue = 255 - ivalue;
+ }
+
+ wd8[x + y * p_width] = ivalue;
+ idx++;
}
-
- wd8[x] = ivalue;
}
+ Ref<Image> img = memnew(Image(p_width, p_height, false, Image::FORMAT_L8, data));
+ images.write[d] = img;
}
} else {
// Without normalization, the expected range of the noise function is [-1, 1].
- uint8_t ivalue;
- for (int y = 0, i = 0; y < p_height; y++) {
- for (int x = 0; x < p_width; x++, i++) {
- float value = (p_in_3d_space ? get_noise_3d(x, y, 0.0) : get_noise_2d(x, y));
- ivalue = static_cast<uint8_t>(CLAMP(value * 127.5f + 127.5f, 0.0f, 255.0f));
- wd8[i] = p_invert ? (255 - ivalue) : ivalue;
+
+ for (int d = 0; d < p_depth; d++) {
+ Vector<uint8_t> data;
+ data.resize(p_width * p_height);
+
+ uint8_t *wd8 = data.ptrw();
+
+ uint8_t ivalue;
+ int idx = 0;
+ for (int y = 0; y < p_height; y++) {
+ for (int x = 0; x < p_width; x++) {
+ float value = (p_in_3d_space ? get_noise_3d(x, y, d) : get_noise_2d(x, y));
+ ivalue = static_cast<uint8_t>(CLAMP(value * 127.5f + 127.5f, 0.0f, 255.0f));
+ wd8[idx] = p_invert ? (255 - ivalue) : ivalue;
+ idx++;
+ }
}
+
+ Ref<Image> img = memnew(Image(p_width, p_height, false, Image::FORMAT_L8, data));
+ images.write[d] = img;
}
}
- return memnew(Image(p_width, p_height, false, Image::FORMAT_L8, data));
+ return images;
+}
+
+Ref<Image> Noise::get_image(int p_width, int p_height, bool p_invert, bool p_in_3d_space, bool p_normalize) const {
+ Vector<Ref<Image>> images = _get_image(p_width, p_height, 1, p_invert, p_in_3d_space, p_normalize);
+ return images[0];
+}
+
+TypedArray<Image> Noise::get_image_3d(int p_width, int p_height, int p_depth, bool p_invert, bool p_normalize) const {
+ Vector<Ref<Image>> images = _get_image(p_width, p_height, p_depth, p_invert, true, p_normalize);
+
+ TypedArray<Image> ret;
+ ret.resize(images.size());
+ for (int i = 0; i < images.size(); i++) {
+ ret[i] = images[i];
+ }
+ return ret;
}
void Noise::_bind_methods() {
@@ -126,4 +188,6 @@ void Noise::_bind_methods() {
// Textures.
ClassDB::bind_method(D_METHOD("get_image", "width", "height", "invert", "in_3d_space", "normalize"), &Noise::get_image, DEFVAL(false), DEFVAL(false), DEFVAL(true));
ClassDB::bind_method(D_METHOD("get_seamless_image", "width", "height", "invert", "in_3d_space", "skirt", "normalize"), &Noise::get_seamless_image, DEFVAL(false), DEFVAL(false), DEFVAL(0.1), DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("get_image_3d", "width", "height", "depth", "invert", "normalize"), &Noise::get_image_3d, DEFVAL(false), DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("get_seamless_image_3d", "width", "height", "depth", "invert", "skirt", "normalize"), &Noise::get_seamless_image_3d, DEFVAL(false), DEFVAL(0.1), DEFVAL(true));
}
diff --git a/modules/noise/noise.h b/modules/noise/noise.h
index f7e615c2aa..6c49c12bc2 100644
--- a/modules/noise/noise.h
+++ b/modules/noise/noise.h
@@ -32,6 +32,7 @@
#define NOISE_H
#include "core/io/image.h"
+#include "core/variant/typed_array.h"
class Noise : public Resource {
GDCLASS(Noise, Resource);
@@ -81,7 +82,7 @@ class Noise : public Resource {
};
template <typename T>
- Ref<Image> _generate_seamless_image(Ref<Image> p_src, int p_width, int p_height, bool p_invert, real_t p_blend_skirt) const {
+ Vector<Ref<Image>> _generate_seamless_image(Vector<Ref<Image>> p_src, int p_width, int p_height, int p_depth, bool p_invert, real_t p_blend_skirt) const {
/*
To make a seamless image, we swap the quadrants so the edges are perfect matches.
We initially get a 10% larger image so we have an overlap we can use to blend over the seams.
@@ -101,7 +102,7 @@ class Noise : public Resource {
on Source it's translated to
corner of Q1/s3 unless the ALT_XY modulo moves it to Q4
*/
- ERR_FAIL_COND_V(p_blend_skirt < 0, Ref<Image>());
+ ERR_FAIL_COND_V(p_blend_skirt < 0, Vector<Ref<Image>>());
int skirt_width = MAX(1, p_width * p_blend_skirt);
int skirt_height = MAX(1, p_height * p_blend_skirt);
@@ -112,83 +113,139 @@ class Noise : public Resource {
int skirt_edge_x = half_width + skirt_width;
int skirt_edge_y = half_height + skirt_height;
- Vector<uint8_t> dest;
- dest.resize(p_width * p_height * Image::get_format_pixel_size(p_src->get_format()));
-
- img_buff<T> rd_src = {
- (T *)p_src->get_data().ptr(),
- src_width, src_height,
- half_width, half_height,
- p_width, p_height
- };
-
- // `wr` is setup for straight x/y coordinate array access.
- img_buff<T> wr = {
- (T *)dest.ptrw(),
- p_width, p_height,
- 0, 0, 0, 0
- };
- // `rd_dest` is a readable pointer to `wr`, i.e. what has already been written to the output buffer.
- img_buff<T> rd_dest = {
- (T *)dest.ptr(),
- p_width, p_height,
- 0, 0, 0, 0
- };
+ Image::Format format = p_src[0]->get_format();
+ int pixel_size = Image::get_format_pixel_size(format);
+
+ Vector<Ref<Image>> images;
+ images.resize(p_src.size());
+
+ // First blend across x and y for all slices.
+ for (int d = 0; d < images.size(); d++) {
+ Vector<uint8_t> dest;
+ dest.resize(p_width * p_height * pixel_size);
+
+ img_buff<T> rd_src = {
+ (T *)p_src[d]->get_data().ptr(),
+ src_width, src_height,
+ half_width, half_height,
+ p_width, p_height
+ };
+
+ // `wr` is setup for straight x/y coordinate array access.
+ img_buff<T> wr = {
+ (T *)dest.ptrw(),
+ p_width, p_height,
+ 0, 0, 0, 0
+ };
+ // `rd_dest` is a readable pointer to `wr`, i.e. what has already been written to the output buffer.
+ img_buff<T> rd_dest = {
+ (T *)dest.ptr(),
+ p_width, p_height,
+ 0, 0, 0, 0
+ };
+
+ // Swap the quadrants to make edges seamless.
+ for (int y = 0; y < p_height; y++) {
+ for (int x = 0; x < p_width; x++) {
+ // rd_src has a half offset and the shorter modulo ignores the skirt.
+ // It reads and writes in Q1-4 order (see map above), skipping the skirt.
+ wr(x, y) = rd_src(x, y, img_buff<T>::ALT_XY);
+ }
+ }
- // Swap the quadrants to make edges seamless.
- for (int y = 0; y < p_height; y++) {
- for (int x = 0; x < p_width; x++) {
- // rd_src has a half offset and the shorter modulo ignores the skirt.
- // It reads and writes in Q1-4 order (see map above), skipping the skirt.
- wr(x, y) = rd_src(x, y, img_buff<T>::ALT_XY);
+ // Blend the vertical skirt over the middle seam.
+ for (int x = half_width; x < skirt_edge_x; x++) {
+ int alpha = 255 * (1 - Math::smoothstep(0.1f, 0.9f, float(x - half_width) / float(skirt_width)));
+ for (int y = 0; y < p_height; y++) {
+ // Skip the center square
+ if (y == half_height) {
+ y = skirt_edge_y - 1;
+ } else {
+ // Starts reading at s2, ALT_Y skips s3, and continues with s1.
+ wr(x, y) = _alpha_blend<T>(rd_dest(x, y), rd_src(x, y, img_buff<T>::ALT_Y), alpha);
+ }
+ }
}
- }
- // Blend the vertical skirt over the middle seam.
- for (int x = half_width; x < skirt_edge_x; x++) {
- int alpha = 255 * (1 - Math::smoothstep(0.1f, 0.9f, float(x - half_width) / float(skirt_width)));
- for (int y = 0; y < p_height; y++) {
- // Skip the center square
- if (y == half_height) {
- y = skirt_edge_y - 1;
- } else {
- // Starts reading at s2, ALT_Y skips s3, and continues with s1.
- wr(x, y) = _alpha_blend<T>(rd_dest(x, y), rd_src(x, y, img_buff<T>::ALT_Y), alpha);
+ // Blend the horizontal skirt over the middle seam.
+ for (int y = half_height; y < skirt_edge_y; y++) {
+ int alpha = 255 * (1 - Math::smoothstep(0.1f, 0.9f, float(y - half_height) / float(skirt_height)));
+ for (int x = 0; x < p_width; x++) {
+ // Skip the center square
+ if (x == half_width) {
+ x = skirt_edge_x - 1;
+ } else {
+ // Starts reading at s4, skips s3, continues with s5.
+ wr(x, y) = _alpha_blend<T>(rd_dest(x, y), rd_src(x, y, img_buff<T>::ALT_X), alpha);
+ }
}
}
- }
- // Blend the horizontal skirt over the middle seam.
- for (int y = half_height; y < skirt_edge_y; y++) {
- int alpha = 255 * (1 - Math::smoothstep(0.1f, 0.9f, float(y - half_height) / float(skirt_height)));
- for (int x = 0; x < p_width; x++) {
- // Skip the center square
- if (x == half_width) {
- x = skirt_edge_x - 1;
- } else {
- // Starts reading at s4, skips s3, continues with s5.
- wr(x, y) = _alpha_blend<T>(rd_dest(x, y), rd_src(x, y, img_buff<T>::ALT_X), alpha);
+ // Fill in the center square. Wr starts at the top left of Q4, which is the equivalent of the top left of s3, unless a modulo is used.
+ for (int y = half_height; y < skirt_edge_y; y++) {
+ for (int x = half_width; x < skirt_edge_x; x++) {
+ int xpos = 255 * (1 - Math::smoothstep(0.1f, 0.9f, float(x - half_width) / float(skirt_width)));
+ int ypos = 255 * (1 - Math::smoothstep(0.1f, 0.9f, float(y - half_height) / float(skirt_height)));
+
+ // Blend s3(Q1) onto s5(Q2) for the top half.
+ T top_blend = _alpha_blend<T>(rd_src(x, y, img_buff<T>::ALT_X), rd_src(x, y, img_buff<T>::DEFAULT), xpos);
+ // Blend s1(Q3) onto Q4 for the bottom half.
+ T bottom_blend = _alpha_blend<T>(rd_src(x, y, img_buff<T>::ALT_XY), rd_src(x, y, img_buff<T>::ALT_Y), xpos);
+ // Blend the top half onto the bottom half.
+ wr(x, y) = _alpha_blend<T>(bottom_blend, top_blend, ypos);
}
}
+ Ref<Image> image = memnew(Image(p_width, p_height, false, format, dest));
+ p_src.write[d].unref();
+ images.write[d] = image;
}
- // Fill in the center square. Wr starts at the top left of Q4, which is the equivalent of the top left of s3, unless a modulo is used.
- for (int y = half_height; y < skirt_edge_y; y++) {
- for (int x = half_width; x < skirt_edge_x; x++) {
- int xpos = 255 * (1 - Math::smoothstep(0.1f, 0.9f, float(x - half_width) / float(skirt_width)));
- int ypos = 255 * (1 - Math::smoothstep(0.1f, 0.9f, float(y - half_height) / float(skirt_height)));
-
- // Blend s3(Q1) onto s5(Q2) for the top half.
- T top_blend = _alpha_blend<T>(rd_src(x, y, img_buff<T>::ALT_X), rd_src(x, y, img_buff<T>::DEFAULT), xpos);
- // Blend s1(Q3) onto Q4 for the bottom half.
- T bottom_blend = _alpha_blend<T>(rd_src(x, y, img_buff<T>::ALT_XY), rd_src(x, y, img_buff<T>::ALT_Y), xpos);
- // Blend the top half onto the bottom half.
- wr(x, y) = _alpha_blend<T>(bottom_blend, top_blend, ypos);
+ // Now blend across z.
+ if (p_depth > 1) {
+ int skirt_depth = MAX(1, p_depth * p_blend_skirt);
+ int half_depth = p_depth * 0.5;
+ int skirt_edge_z = half_depth + skirt_depth;
+
+ // Swap halves on depth.
+ for (int i = 0; i < half_depth; i++) {
+ Ref<Image> img = images[i];
+ images.write[i] = images[i + half_depth];
+ images.write[i + half_depth] = img;
}
+
+ Vector<Ref<Image>> new_images = images;
+ new_images.resize(p_depth);
+
+ // Scale seamless generation to third dimension.
+ for (int z = half_depth; z < skirt_edge_z; z++) {
+ int alpha = 255 * (1 - Math::smoothstep(0.1f, 0.9f, float(z - half_depth) / float(skirt_depth)));
+
+ Vector<uint8_t> img = images[z % p_depth]->get_data();
+ Vector<uint8_t> skirt = images[(z - half_depth) + p_depth]->get_data();
+
+ Vector<uint8_t> dest;
+ dest.resize(images[0]->get_width() * images[0]->get_height() * Image::get_format_pixel_size(images[0]->get_format()));
+
+ for (int i = 0; i < img.size(); i++) {
+ uint8_t fg, bg, out;
+
+ fg = skirt[i];
+ bg = img[i];
+
+ uint16_t a = alpha + 1;
+ uint16_t inv_a = 256 - alpha;
+
+ out = (uint8_t)((a * fg + inv_a * bg) >> 8);
+
+ dest.write[i] = out;
+ }
+
+ Ref<Image> new_image = memnew(Image(images[0]->get_width(), images[0]->get_height(), false, images[0]->get_format(), dest));
+ new_images.write[z % p_depth] = new_image;
+ }
+ return new_images;
}
- Ref<Image> image = memnew(Image(p_width, p_height, false, p_src->get_format(), dest));
- p_src.unref();
- return image;
+ return images;
}
template <typename T>
@@ -233,8 +290,13 @@ public:
virtual real_t get_noise_3dv(Vector3 p_v) const = 0;
virtual real_t get_noise_3d(real_t p_x, real_t p_y, real_t p_z) const = 0;
+ Vector<Ref<Image>> _get_image(int p_width, int p_height, int p_depth, bool p_invert = false, bool p_in_3d_space = false, bool p_normalize = true) const;
virtual Ref<Image> get_image(int p_width, int p_height, bool p_invert = false, bool p_in_3d_space = false, bool p_normalize = true) const;
+ virtual TypedArray<Image> get_image_3d(int p_width, int p_height, int p_depth, bool p_invert = false, bool p_normalize = true) const;
+
+ Vector<Ref<Image>> _get_seamless_image(int p_width, int p_height, int p_depth, bool p_invert = false, bool p_in_3d_space = false, real_t p_blend_skirt = 0.1, bool p_normalize = true) const;
virtual Ref<Image> get_seamless_image(int p_width, int p_height, bool p_invert = false, bool p_in_3d_space = false, real_t p_blend_skirt = 0.1, bool p_normalize = true) const;
+ virtual TypedArray<Image> get_seamless_image_3d(int p_width, int p_height, int p_depth, bool p_invert = false, real_t p_blend_skirt = 0.1, bool p_normalize = true) const;
};
#endif // NOISE_H
diff --git a/modules/noise/noise_texture_2d.cpp b/modules/noise/noise_texture_2d.cpp
index 0d5e778875..e4b2e0b4ac 100644
--- a/modules/noise/noise_texture_2d.cpp
+++ b/modules/noise/noise_texture_2d.cpp
@@ -44,7 +44,9 @@ NoiseTexture2D::~NoiseTexture2D() {
if (texture.is_valid()) {
RS::get_singleton()->free(texture);
}
- noise_thread.wait_to_finish();
+ if (noise_thread.is_started()) {
+ noise_thread.wait_to_finish();
+ }
}
void NoiseTexture2D::_bind_methods() {
diff --git a/modules/noise/noise_texture_3d.cpp b/modules/noise/noise_texture_3d.cpp
new file mode 100644
index 0000000000..25d75b8ffb
--- /dev/null
+++ b/modules/noise/noise_texture_3d.cpp
@@ -0,0 +1,352 @@
+/**************************************************************************/
+/* noise_texture_3d.cpp */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/**************************************************************************/
+
+#include "noise_texture_3d.h"
+
+#include "core/core_string_names.h"
+#include "noise.h"
+
+NoiseTexture3D::NoiseTexture3D() {
+ noise = Ref<Noise>();
+
+ _queue_update();
+}
+
+NoiseTexture3D::~NoiseTexture3D() {
+ ERR_FAIL_NULL(RenderingServer::get_singleton());
+ if (texture.is_valid()) {
+ RS::get_singleton()->free(texture);
+ }
+ if (noise_thread.is_started()) {
+ noise_thread.wait_to_finish();
+ }
+}
+
+void NoiseTexture3D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("_update_texture"), &NoiseTexture3D::_update_texture);
+ ClassDB::bind_method(D_METHOD("_generate_texture"), &NoiseTexture3D::_generate_texture);
+ ClassDB::bind_method(D_METHOD("_thread_done", "image"), &NoiseTexture3D::_thread_done);
+
+ ClassDB::bind_method(D_METHOD("set_width", "width"), &NoiseTexture3D::set_width);
+ ClassDB::bind_method(D_METHOD("set_height", "height"), &NoiseTexture3D::set_height);
+ ClassDB::bind_method(D_METHOD("set_depth", "depth"), &NoiseTexture3D::set_depth);
+
+ ClassDB::bind_method(D_METHOD("set_invert", "invert"), &NoiseTexture3D::set_invert);
+ ClassDB::bind_method(D_METHOD("get_invert"), &NoiseTexture3D::get_invert);
+
+ ClassDB::bind_method(D_METHOD("set_seamless", "seamless"), &NoiseTexture3D::set_seamless);
+ ClassDB::bind_method(D_METHOD("get_seamless"), &NoiseTexture3D::get_seamless);
+
+ ClassDB::bind_method(D_METHOD("set_seamless_blend_skirt", "seamless_blend_skirt"), &NoiseTexture3D::set_seamless_blend_skirt);
+ ClassDB::bind_method(D_METHOD("get_seamless_blend_skirt"), &NoiseTexture3D::get_seamless_blend_skirt);
+
+ ClassDB::bind_method(D_METHOD("set_normalize", "normalize"), &NoiseTexture3D::set_normalize);
+ ClassDB::bind_method(D_METHOD("is_normalized"), &NoiseTexture3D::is_normalized);
+
+ ClassDB::bind_method(D_METHOD("set_color_ramp", "gradient"), &NoiseTexture3D::set_color_ramp);
+ ClassDB::bind_method(D_METHOD("get_color_ramp"), &NoiseTexture3D::get_color_ramp);
+
+ ClassDB::bind_method(D_METHOD("set_noise", "noise"), &NoiseTexture3D::set_noise);
+ ClassDB::bind_method(D_METHOD("get_noise"), &NoiseTexture3D::get_noise);
+
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "width", PROPERTY_HINT_RANGE, "1,2048,1,or_greater,suffix:px"), "set_width", "get_width");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "height", PROPERTY_HINT_RANGE, "1,2048,1,or_greater,suffix:px"), "set_height", "get_height");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "depth", PROPERTY_HINT_RANGE, "1,2048,1,or_greater,suffix:px"), "set_depth", "get_depth");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "invert"), "set_invert", "get_invert");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "seamless"), "set_seamless", "get_seamless");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "seamless_blend_skirt", PROPERTY_HINT_RANGE, "0.05,1,0.001"), "set_seamless_blend_skirt", "get_seamless_blend_skirt");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "normalize"), "set_normalize", "is_normalized");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "color_ramp", PROPERTY_HINT_RESOURCE_TYPE, "Gradient"), "set_color_ramp", "get_color_ramp");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "noise", PROPERTY_HINT_RESOURCE_TYPE, "Noise"), "set_noise", "get_noise");
+}
+
+void NoiseTexture3D::_validate_property(PropertyInfo &p_property) const {
+ if (p_property.name == "seamless_blend_skirt") {
+ if (!seamless) {
+ p_property.usage = PROPERTY_USAGE_NO_EDITOR;
+ }
+ }
+}
+
+void NoiseTexture3D::_set_texture_data(const TypedArray<Image> &p_data) {
+ if (!p_data.is_empty()) {
+ Vector<Ref<Image>> data;
+
+ data.resize(p_data.size());
+
+ for (int i = 0; i < data.size(); i++) {
+ data.write[i] = p_data[i];
+ }
+
+ if (texture.is_valid()) {
+ RID new_texture = RS::get_singleton()->texture_3d_create(data[0]->get_format(), data[0]->get_width(), data[0]->get_height(), data.size(), false, data);
+ RS::get_singleton()->texture_replace(texture, new_texture);
+ } else {
+ texture = RS::get_singleton()->texture_3d_create(data[0]->get_format(), data[0]->get_width(), data[0]->get_height(), data.size(), false, data);
+ }
+ }
+ emit_changed();
+}
+
+void NoiseTexture3D::_thread_done(const TypedArray<Image> &p_data) {
+ _set_texture_data(p_data);
+ noise_thread.wait_to_finish();
+ if (regen_queued) {
+ noise_thread.start(_thread_function, this);
+ regen_queued = false;
+ }
+}
+
+void NoiseTexture3D::_thread_function(void *p_ud) {
+ NoiseTexture3D *tex = static_cast<NoiseTexture3D *>(p_ud);
+ tex->call_deferred(SNAME("_thread_done"), tex->_generate_texture());
+}
+
+void NoiseTexture3D::_queue_update() {
+ if (update_queued) {
+ return;
+ }
+
+ update_queued = true;
+ call_deferred(SNAME("_update_texture"));
+}
+
+TypedArray<Image> NoiseTexture3D::_generate_texture() {
+ // Prevent memdelete due to unref() on other thread.
+ Ref<Noise> ref_noise = noise;
+
+ if (ref_noise.is_null()) {
+ return TypedArray<Image>();
+ }
+
+ Vector<Ref<Image>> images;
+
+ if (seamless) {
+ images = ref_noise->_get_seamless_image(width, height, depth, invert, true, seamless_blend_skirt, normalize);
+ } else {
+ images = ref_noise->_get_image(width, height, depth, invert, true, normalize);
+ }
+
+ if (color_ramp.is_valid()) {
+ for (int i = 0; i < images.size(); i++) {
+ images.write[i] = _modulate_with_gradient(images[i], color_ramp);
+ }
+ }
+
+ TypedArray<Image> new_data;
+ new_data.resize(images.size());
+
+ for (int i = 0; i < new_data.size(); i++) {
+ new_data[i] = images[i];
+ }
+
+ return new_data;
+}
+
+Ref<Image> NoiseTexture3D::_modulate_with_gradient(Ref<Image> p_image, Ref<Gradient> p_gradient) {
+ int w = p_image->get_width();
+ int h = p_image->get_height();
+
+ Ref<Image> new_image = Image::create_empty(w, h, false, Image::FORMAT_RGBA8);
+
+ for (int row = 0; row < h; row++) {
+ for (int col = 0; col < w; col++) {
+ Color pixel_color = p_image->get_pixel(col, row);
+ Color ramp_color = p_gradient->get_color_at_offset(pixel_color.get_luminance());
+ new_image->set_pixel(col, row, ramp_color);
+ }
+ }
+
+ return new_image;
+}
+
+void NoiseTexture3D::_update_texture() {
+ bool use_thread = true;
+ if (first_time) {
+ use_thread = false;
+ first_time = false;
+ }
+ if (use_thread) {
+ if (!noise_thread.is_started()) {
+ noise_thread.start(_thread_function, this);
+ regen_queued = false;
+ } else {
+ regen_queued = true;
+ }
+
+ } else {
+ TypedArray<Image> new_data = _generate_texture();
+ _set_texture_data(new_data);
+ }
+ update_queued = false;
+}
+
+void NoiseTexture3D::set_noise(Ref<Noise> p_noise) {
+ if (p_noise == noise) {
+ return;
+ }
+ if (noise.is_valid()) {
+ noise->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &NoiseTexture3D::_queue_update));
+ }
+ noise = p_noise;
+ if (noise.is_valid()) {
+ noise->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &NoiseTexture3D::_queue_update));
+ }
+ _queue_update();
+}
+
+Ref<Noise> NoiseTexture3D::get_noise() {
+ return noise;
+}
+
+void NoiseTexture3D::set_width(int p_width) {
+ ERR_FAIL_COND(p_width <= 0);
+ if (p_width == width) {
+ return;
+ }
+ width = p_width;
+ _queue_update();
+}
+
+void NoiseTexture3D::set_height(int p_height) {
+ ERR_FAIL_COND(p_height <= 0);
+ if (p_height == height) {
+ return;
+ }
+ height = p_height;
+ _queue_update();
+}
+
+void NoiseTexture3D::set_depth(int p_depth) {
+ ERR_FAIL_COND(p_depth <= 0);
+ if (p_depth == depth) {
+ return;
+ }
+ depth = p_depth;
+ _queue_update();
+}
+
+void NoiseTexture3D::set_invert(bool p_invert) {
+ if (p_invert == invert) {
+ return;
+ }
+ invert = p_invert;
+ _queue_update();
+}
+
+bool NoiseTexture3D::get_invert() const {
+ return invert;
+}
+
+void NoiseTexture3D::set_seamless(bool p_seamless) {
+ if (p_seamless == seamless) {
+ return;
+ }
+ seamless = p_seamless;
+ _queue_update();
+ notify_property_list_changed();
+}
+
+bool NoiseTexture3D::get_seamless() {
+ return seamless;
+}
+
+void NoiseTexture3D::set_seamless_blend_skirt(real_t p_blend_skirt) {
+ ERR_FAIL_COND(p_blend_skirt < 0.05 || p_blend_skirt > 1);
+
+ if (p_blend_skirt == seamless_blend_skirt) {
+ return;
+ }
+ seamless_blend_skirt = p_blend_skirt;
+ _queue_update();
+}
+real_t NoiseTexture3D::get_seamless_blend_skirt() {
+ return seamless_blend_skirt;
+}
+
+void NoiseTexture3D::set_color_ramp(const Ref<Gradient> &p_gradient) {
+ if (p_gradient == color_ramp) {
+ return;
+ }
+ if (color_ramp.is_valid()) {
+ color_ramp->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &NoiseTexture3D::_queue_update));
+ }
+ color_ramp = p_gradient;
+ if (color_ramp.is_valid()) {
+ color_ramp->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &NoiseTexture3D::_queue_update));
+ }
+ _queue_update();
+}
+
+void NoiseTexture3D::set_normalize(bool p_normalize) {
+ if (normalize == p_normalize) {
+ return;
+ }
+ normalize = p_normalize;
+ _queue_update();
+}
+
+bool NoiseTexture3D::is_normalized() const {
+ return normalize;
+}
+
+Ref<Gradient> NoiseTexture3D::get_color_ramp() const {
+ return color_ramp;
+}
+
+int NoiseTexture3D::get_width() const {
+ return width;
+}
+
+int NoiseTexture3D::get_height() const {
+ return height;
+}
+
+int NoiseTexture3D::get_depth() const {
+ return depth;
+}
+
+RID NoiseTexture3D::get_rid() const {
+ if (!texture.is_valid()) {
+ texture = RS::get_singleton()->texture_3d_placeholder_create();
+ }
+
+ return texture;
+}
+
+Vector<Ref<Image>> NoiseTexture3D::get_data() const {
+ ERR_FAIL_COND_V(!texture.is_valid(), Vector<Ref<Image>>());
+ return RS::get_singleton()->texture_3d_get(texture);
+}
+
+Image::Format NoiseTexture3D::get_format() const {
+ ERR_FAIL_COND_V(!texture.is_valid(), Image::FORMAT_L8);
+ return RS::get_singleton()->texture_3d_get(texture)[0]->get_format();
+}
diff --git a/modules/noise/noise_texture_3d.h b/modules/noise/noise_texture_3d.h
new file mode 100644
index 0000000000..397711ca98
--- /dev/null
+++ b/modules/noise/noise_texture_3d.h
@@ -0,0 +1,113 @@
+/**************************************************************************/
+/* noise_texture_3d.h */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/**************************************************************************/
+
+#ifndef NOISE_TEXTURE_3D_H
+#define NOISE_TEXTURE_3D_H
+
+#include "noise.h"
+
+#include "core/object/ref_counted.h"
+#include "scene/resources/texture.h"
+
+class NoiseTexture3D : public Texture3D {
+ GDCLASS(NoiseTexture3D, Texture3D);
+
+private:
+ Thread noise_thread;
+
+ bool first_time = true;
+ bool update_queued = false;
+ bool regen_queued = false;
+
+ mutable RID texture;
+ uint32_t flags = 0;
+
+ int width = 64;
+ int height = 64;
+ int depth = 64;
+ bool invert = false;
+ bool seamless = false;
+ real_t seamless_blend_skirt = 0.1;
+ bool normalize = true;
+
+ Ref<Gradient> color_ramp;
+ Ref<Noise> noise;
+
+ void _thread_done(const TypedArray<Image> &p_data);
+ static void _thread_function(void *p_ud);
+
+ void _queue_update();
+ TypedArray<Image> _generate_texture();
+ void _update_texture();
+ void _set_texture_data(const TypedArray<Image> &p_data);
+
+ Ref<Image> _modulate_with_gradient(Ref<Image> p_image, Ref<Gradient> p_gradient);
+
+protected:
+ static void _bind_methods();
+ void _validate_property(PropertyInfo &p_property) const;
+
+public:
+ void set_noise(Ref<Noise> p_noise);
+ Ref<Noise> get_noise();
+
+ void set_width(int p_width);
+ void set_height(int p_height);
+ void set_depth(int p_depth);
+
+ void set_invert(bool p_invert);
+ bool get_invert() const;
+
+ void set_seamless(bool p_seamless);
+ bool get_seamless();
+
+ void set_seamless_blend_skirt(real_t p_blend_skirt);
+ real_t get_seamless_blend_skirt();
+
+ void set_normalize(bool p_normalize);
+ bool is_normalized() const;
+
+ void set_color_ramp(const Ref<Gradient> &p_gradient);
+ Ref<Gradient> get_color_ramp() const;
+
+ virtual int get_width() const override;
+ virtual int get_height() const override;
+ virtual int get_depth() const override;
+
+ virtual RID get_rid() const override;
+
+ virtual Vector<Ref<Image>> get_data() const override;
+ virtual Image::Format get_format() const override;
+
+ NoiseTexture3D();
+ virtual ~NoiseTexture3D();
+};
+
+#endif // NOISE_TEXTURE_3D_H
diff --git a/modules/noise/register_types.cpp b/modules/noise/register_types.cpp
index 1298d72e98..f48d4e7e4d 100644
--- a/modules/noise/register_types.cpp
+++ b/modules/noise/register_types.cpp
@@ -33,6 +33,7 @@
#include "fastnoise_lite.h"
#include "noise.h"
#include "noise_texture_2d.h"
+#include "noise_texture_3d.h"
#ifdef TOOLS_ENABLED
#include "editor/editor_plugin.h"
@@ -41,6 +42,7 @@
void initialize_noise_module(ModuleInitializationLevel p_level) {
if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) {
+ GDREGISTER_CLASS(NoiseTexture3D);
GDREGISTER_CLASS(NoiseTexture2D);
GDREGISTER_ABSTRACT_CLASS(Noise);
GDREGISTER_CLASS(FastNoiseLite);
diff --git a/modules/noise/tests/test_noise_texture_3d.h b/modules/noise/tests/test_noise_texture_3d.h
new file mode 100644
index 0000000000..b46d386296
--- /dev/null
+++ b/modules/noise/tests/test_noise_texture_3d.h
@@ -0,0 +1,235 @@
+/**************************************************************************/
+/* test_noise_texture_3d.h */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/**************************************************************************/
+
+#ifndef TEST_NOISE_TEXTURE_3D_H
+#define TEST_NOISE_TEXTURE_3D_H
+
+#include "tests/test_macros.h"
+
+#include "modules/noise/noise_texture_3d.h"
+
+namespace TestNoiseTexture3D {
+
+class NoiseTexture3DTester : public RefCounted {
+ GDCLASS(NoiseTexture3DTester, RefCounted);
+
+ const NoiseTexture3D *const texture;
+
+public:
+ NoiseTexture3DTester(const NoiseTexture3D *const p_texture) :
+ texture{ p_texture } {};
+
+ Color compute_average_color(const Ref<Image> &p_noise_image) {
+ Color r_avg_color{};
+
+ for (int i = 0; i < p_noise_image->get_width(); ++i) {
+ for (int j = 0; j < p_noise_image->get_height(); ++j) {
+ const Color pixel = p_noise_image->get_pixel(i, j);
+ r_avg_color += pixel;
+ }
+ }
+
+ int pixel_count = p_noise_image->get_width() * p_noise_image->get_height();
+ r_avg_color /= pixel_count;
+ return r_avg_color;
+ }
+
+ void check_mip_and_color_ramp() {
+ const Vector<Ref<Image>> noise_data = texture->get_data();
+
+ for (int i = 0; i < noise_data.size(); i++) {
+ const Ref<Image> noise_image = noise_data[i];
+
+ CHECK(noise_image.is_valid());
+ CHECK(noise_image->get_width() == texture->get_width());
+ CHECK(noise_image->get_height() == texture->get_height());
+
+ CHECK(noise_image->get_format() == Image::FORMAT_RGBA8);
+ CHECK(!noise_image->has_mipmaps());
+
+ Color avg_color = compute_average_color(noise_image);
+
+ // Check that the noise texture is modulated correctly by the color ramp (Gradient).
+ CHECK_FALSE_MESSAGE((avg_color.r + avg_color.g + avg_color.b) == doctest::Approx(0.0), "The noise texture should not be all black");
+ CHECK_FALSE_MESSAGE((avg_color.r + avg_color.g + avg_color.b) == doctest::Approx(noise_image->get_width() * noise_image->get_height() * 3.0), "The noise texture should not be all white");
+ CHECK_MESSAGE(avg_color.g == doctest::Approx(0.0), "The noise texture should not have any green when modulated correctly by the color ramp");
+ }
+ }
+
+ void check_seamless_texture_grayscale() {
+ const Vector<Ref<Image>> noise_data = texture->get_data();
+
+ for (int i = 0; i < noise_data.size(); i++) {
+ const Ref<Image> noise_image = noise_data[i];
+
+ CHECK(noise_image.is_valid());
+ CHECK(noise_image->get_width() == texture->get_width());
+ CHECK(noise_image->get_height() == texture->get_height());
+
+ CHECK(noise_image->get_format() == Image::FORMAT_L8);
+
+ Color avg_color = compute_average_color(noise_image);
+
+ // Since it's a grayscale image and every channel except the alpha channel has the
+ // same values (conversion happens in Image::get_pixel) we only need to test one channel.
+ CHECK(avg_color.r == doctest::Approx(0.5).epsilon(0.05));
+ }
+ }
+
+ void check_seamless_texture_rgba() {
+ const Vector<Ref<Image>> noise_data = texture->get_data();
+
+ for (int i = 0; i < noise_data.size(); i++) {
+ const Ref<Image> noise_image = noise_data[i];
+
+ CHECK(noise_image.is_valid());
+ CHECK(noise_image->get_width() == texture->get_width());
+ CHECK(noise_image->get_height() == texture->get_height());
+
+ CHECK(noise_image->get_format() == Image::FORMAT_RGBA8);
+
+ // Check that the noise texture is modulated correctly by the color ramp (Gradient).
+ Color avg_color = compute_average_color(noise_image);
+
+ // We use a default (black to white) gradient, so the average of the red, green and blue channels should be the same.
+ CHECK(avg_color.r == doctest::Approx(0.5).epsilon(0.05));
+ CHECK(avg_color.g == doctest::Approx(0.5).epsilon(0.05));
+ CHECK(avg_color.b == doctest::Approx(0.5).epsilon(0.05));
+ }
+ }
+};
+
+TEST_CASE("[NoiseTexture][SceneTree] Getter and setter") {
+ Ref<NoiseTexture3D> noise_texture = memnew(NoiseTexture3D);
+
+ Ref<FastNoiseLite> noise = memnew(FastNoiseLite);
+ noise_texture->set_noise(noise);
+ CHECK(noise_texture->get_noise() == noise);
+ noise_texture->set_noise(nullptr);
+ CHECK(noise_texture->get_noise() == nullptr);
+
+ noise_texture->set_width(8);
+ noise_texture->set_height(4);
+ noise_texture->set_depth(2);
+ CHECK(noise_texture->get_width() == 8);
+ CHECK(noise_texture->get_height() == 4);
+ CHECK(noise_texture->get_depth() == 2);
+
+ ERR_PRINT_OFF;
+ noise_texture->set_width(-1);
+ noise_texture->set_height(-1);
+ noise_texture->set_depth(-1);
+ ERR_PRINT_ON;
+ CHECK(noise_texture->get_width() == 8);
+ CHECK(noise_texture->get_height() == 4);
+ CHECK(noise_texture->get_depth() == 2);
+
+ noise_texture->set_invert(true);
+ CHECK(noise_texture->get_invert() == true);
+ noise_texture->set_invert(false);
+ CHECK(noise_texture->get_invert() == false);
+
+ noise_texture->set_seamless(true);
+ CHECK(noise_texture->get_seamless() == true);
+ noise_texture->set_seamless(false);
+ CHECK(noise_texture->get_seamless() == false);
+
+ noise_texture->set_seamless_blend_skirt(0.45);
+ CHECK(noise_texture->get_seamless_blend_skirt() == doctest::Approx(0.45));
+
+ ERR_PRINT_OFF;
+ noise_texture->set_seamless_blend_skirt(-1.0);
+ noise_texture->set_seamless_blend_skirt(2.0);
+ CHECK(noise_texture->get_seamless_blend_skirt() == doctest::Approx(0.45));
+ ERR_PRINT_ON;
+
+ Ref<Gradient> gradient = memnew(Gradient);
+ noise_texture->set_color_ramp(gradient);
+ CHECK(noise_texture->get_color_ramp() == gradient);
+ noise_texture->set_color_ramp(nullptr);
+ CHECK(noise_texture->get_color_ramp() == nullptr);
+}
+
+TEST_CASE("[NoiseTexture3D][SceneTree] Generating a basic noise texture with mipmaps and color ramp modulation") {
+ Ref<NoiseTexture3D> noise_texture = memnew(NoiseTexture3D);
+
+ Ref<FastNoiseLite> noise = memnew(FastNoiseLite);
+ noise_texture->set_noise(noise);
+
+ Ref<Gradient> gradient = memnew(Gradient);
+ Vector<Gradient::Point> points;
+ points.push_back({ 0.0, Color(1, 0, 0) });
+ points.push_back({ 1.0, Color(0, 0, 1) });
+ gradient->set_points(points);
+ noise_texture->set_color_ramp(gradient);
+ noise_texture->set_width(16);
+ noise_texture->set_height(16);
+ noise_texture->set_depth(16);
+
+ Ref<NoiseTexture3DTester> tester = memnew(NoiseTexture3DTester(noise_texture.ptr()));
+ noise_texture->connect("changed", callable_mp(tester.ptr(), &NoiseTexture3DTester::check_mip_and_color_ramp));
+ MessageQueue::get_singleton()->flush();
+}
+
+TEST_CASE("[NoiseTexture3D][SceneTree] Generating a seamless noise texture") {
+ Ref<NoiseTexture3D> noise_texture = memnew(NoiseTexture3D);
+
+ Ref<FastNoiseLite> noise = memnew(FastNoiseLite);
+ noise->set_frequency(0.5);
+ noise_texture->set_noise(noise);
+ noise_texture->set_width(16);
+ noise_texture->set_height(16);
+ noise_texture->set_depth(16);
+ noise_texture->set_seamless(true);
+
+ Ref<NoiseTexture3DTester> tester = memnew(NoiseTexture3DTester(noise_texture.ptr()));
+
+ SUBCASE("Grayscale(L8) 16x16x16, with seamless blend skirt of 0.05") {
+ noise_texture->set_seamless_blend_skirt(0.05);
+ noise_texture->connect("changed", callable_mp(tester.ptr(), &NoiseTexture3DTester::check_seamless_texture_grayscale));
+ MessageQueue::get_singleton()->flush();
+ }
+
+ SUBCASE("16x16x16 modulated with default (transparent)black and white gradient (RGBA8), with seamless blend skirt of 1.0") {
+ Ref<Gradient> gradient = memnew(Gradient);
+ Vector<Gradient::Point> points;
+ points.push_back({ 0.0, Color(0, 0, 0, 0) });
+ points.push_back({ 1.0, Color(1, 1, 1, 1) });
+ gradient->set_points(points);
+ noise_texture->set_color_ramp(gradient);
+ noise_texture->set_seamless_blend_skirt(1.0);
+ noise_texture->connect("changed", callable_mp(tester.ptr(), &NoiseTexture3DTester::check_seamless_texture_rgba));
+ MessageQueue::get_singleton()->flush();
+ }
+}
+
+} //namespace TestNoiseTexture3D
+
+#endif // TEST_NOISE_TEXTURE_3D_H
diff --git a/modules/openxr/action_map/openxr_action_map.cpp b/modules/openxr/action_map/openxr_action_map.cpp
index d2f6be2233..63abbf0d71 100644
--- a/modules/openxr/action_map/openxr_action_map.cpp
+++ b/modules/openxr/action_map/openxr_action_map.cpp
@@ -415,7 +415,7 @@ void OpenXRActionMap::create_default_action_sets() {
profile->add_new_binding(grip_pose, "/user/hand/left/input/grip/pose,/user/hand/right/input/grip/pose");
profile->add_new_binding(palm_pose, "/user/hand/left/input/palm_ext/pose,/user/hand/right/input/palm_ext/pose");
profile->add_new_binding(menu_button, "/user/hand/left/input/menu/click");
- profile->add_new_binding(select_button, "/user/hand/left/input/system/click"); // we'll map system to select
+ profile->add_new_binding(select_button, "/user/hand/right/input/system/click"); // we'll map system to select
profile->add_new_binding(ax_button, "/user/hand/left/input/x/click,/user/hand/right/input/a/click"); // x on left hand, a on right hand
profile->add_new_binding(by_button, "/user/hand/left/input/y/click,/user/hand/right/input/b/click"); // y on left hand, b on right hand
profile->add_new_binding(trigger, "/user/hand/left/input/trigger/value,/user/hand/right/input/trigger/value");
@@ -439,7 +439,7 @@ void OpenXRActionMap::create_default_action_sets() {
profile->add_new_binding(grip_pose, "/user/hand/left/input/grip/pose,/user/hand/right/input/grip/pose");
profile->add_new_binding(palm_pose, "/user/hand/left/input/palm_ext/pose,/user/hand/right/input/palm_ext/pose");
profile->add_new_binding(menu_button, "/user/hand/left/input/menu/click");
- profile->add_new_binding(select_button, "/user/hand/left/input/system/click"); // we'll map system to select
+ profile->add_new_binding(select_button, "/user/hand/right/input/system/click"); // we'll map system to select
profile->add_new_binding(ax_button, "/user/hand/left/input/x/click,/user/hand/right/input/a/click"); // x on left hand, a on right hand
profile->add_new_binding(by_button, "/user/hand/left/input/y/click,/user/hand/right/input/b/click"); // y on left hand, b on right hand
profile->add_new_binding(trigger, "/user/hand/left/input/trigger/value,/user/hand/right/input/trigger/value");
diff --git a/modules/openxr/extensions/openxr_htc_controller_extension.cpp b/modules/openxr/extensions/openxr_htc_controller_extension.cpp
index 4d141b0695..116762ee8d 100644
--- a/modules/openxr/extensions/openxr_htc_controller_extension.cpp
+++ b/modules/openxr/extensions/openxr_htc_controller_extension.cpp
@@ -108,7 +108,7 @@ void OpenXRHTCControllerExtension::on_register_metadata() {
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Trigger touch", "/user/hand/left", "/user/hand/left/input/trigger/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Trigger", "/user/hand/right", "/user/hand/right/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Trigger click", "/user/hand/right", "/user/hand/right/input/trigger/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
- metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Trigger touch", "/user/hand/right", "/user/hand/right/input/trigger/touch ", "", OpenXRAction::OPENXR_ACTION_BOOL);
+ metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Trigger touch", "/user/hand/right", "/user/hand/right/input/trigger/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Squeeze click", "/user/hand/left", "/user/hand/left/input/squeeze/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Squeeze touch", "/user/hand/left", "/user/hand/left/input/squeeze/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
@@ -122,6 +122,7 @@ void OpenXRHTCControllerExtension::on_register_metadata() {
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Thumbstick click", "/user/hand/right", "/user/hand/right/input/thumbstick/click", "", OpenXRAction::OPENXR_ACTION_BOOL);
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Thumbstick touch", "/user/hand/right", "/user/hand/right/input/thumbstick/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
+ metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Thumbrest touch", "/user/hand/left", "/user/hand/left/input/thumbrest/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Thumbrest touch", "/user/hand/right", "/user/hand/right/input/thumbrest/touch", "", OpenXRAction::OPENXR_ACTION_BOOL);
metadata->register_io_path("/interaction_profiles/htc/vive_focus3_controller", "Haptic output", "/user/hand/left", "/user/hand/left/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC);
diff --git a/modules/openxr/extensions/openxr_opengl_extension.cpp b/modules/openxr/extensions/openxr_opengl_extension.cpp
index 20ccfe3906..83d31036a4 100644
--- a/modules/openxr/extensions/openxr_opengl_extension.cpp
+++ b/modules/openxr/extensions/openxr_opengl_extension.cpp
@@ -37,7 +37,7 @@
#include "servers/rendering/rendering_server_globals.h"
#include "servers/rendering_server.h"
-// OpenXR requires us to submit sRGB textures so that it recognises the content
+// OpenXR requires us to submit sRGB textures so that it recognizes the content
// as being in sRGB color space. We do fall back on "normal" textures but this
// will likely result in incorrect colors as OpenXR will double the sRGB conversion.
// All major XR runtimes support sRGB textures.
diff --git a/modules/raycast/raycast_occlusion_cull.cpp b/modules/raycast/raycast_occlusion_cull.cpp
index 9394f71e40..8c03115f05 100644
--- a/modules/raycast/raycast_occlusion_cull.cpp
+++ b/modules/raycast/raycast_occlusion_cull.cpp
@@ -604,7 +604,9 @@ RaycastOcclusionCull::~RaycastOcclusionCull() {
for (KeyValue<RID, Scenario> &K : scenarios) {
Scenario &scenario = K.value;
if (scenario.commit_thread) {
- scenario.commit_thread->wait_to_finish();
+ if (scenario.commit_thread->is_started()) {
+ scenario.commit_thread->wait_to_finish();
+ }
memdelete(scenario.commit_thread);
}
diff --git a/modules/upnp/doc_classes/UPNP.xml b/modules/upnp/doc_classes/UPNP.xml
index 1159cbb43a..a099a193bb 100644
--- a/modules/upnp/doc_classes/UPNP.xml
+++ b/modules/upnp/doc_classes/UPNP.xml
@@ -74,11 +74,11 @@
<param index="3" name="proto" type="String" default="&quot;UDP&quot;" />
<param index="4" name="duration" type="int" default="0" />
<description>
- Adds a mapping to forward the external [code]port[/code] (between 1 and 65535, although recommended to use port 1024 or above) on the default gateway (see [method get_gateway]) to the [code]internal_port[/code] on the local machine for the given protocol [code]proto[/code] (either [code]"TCP"[/code] or [code]"UDP"[/code], with UDP being the default). If a port mapping for the given port and protocol combination already exists on that gateway device, this method tries to overwrite it. If that is not desired, you can retrieve the gateway manually with [method get_gateway] and call [method add_port_mapping] on it, if any. Note that forwarding a well-known port (below 1024) with UPnP may fail depending on the device.
+ Adds a mapping to forward the external [param port] (between 1 and 65535, although recommended to use port 1024 or above) on the default gateway (see [method get_gateway]) to the [param port_internal] on the local machine for the given protocol [param proto] (either [code]"TCP"[/code] or [code]"UDP"[/code], with UDP being the default). If a port mapping for the given port and protocol combination already exists on that gateway device, this method tries to overwrite it. If that is not desired, you can retrieve the gateway manually with [method get_gateway] and call [method add_port_mapping] on it, if any. Note that forwarding a well-known port (below 1024) with UPnP may fail depending on the device.
Depending on the gateway device, if a mapping for that port already exists, it will either be updated or it will refuse this command due to that conflict, especially if the existing mapping for that port wasn't created via UPnP or points to a different network address (or device) than this one.
- If [code]internal_port[/code] is [code]0[/code] (the default), the same port number is used for both the external and the internal port (the [code]port[/code] value).
- The description ([code]desc[/code]) is shown in some routers management UIs and can be used to point out which application added the mapping.
- The mapping's lease [code]duration[/code] can be limited by specifying a duration in seconds. The default of [code]0[/code] means no duration, i.e. a permanent lease and notably some devices only support these permanent leases. Note that whether permanent or not, this is only a request and the gateway may still decide at any point to remove the mapping (which usually happens on a reboot of the gateway, when its external IP address changes, or on some models when it detects a port mapping has become inactive, i.e. had no traffic for multiple minutes). If not [code]0[/code] (permanent), the allowed range according to spec is between [code]120[/code] (2 minutes) and [code]86400[/code] seconds (24 hours).
+ If [param port_internal] is [code]0[/code] (the default), the same port number is used for both the external and the internal port (the [param port] value).
+ The description ([param desc]) is shown in some routers management UIs and can be used to point out which application added the mapping.
+ The mapping's lease [param duration] can be limited by specifying a duration in seconds. The default of [code]0[/code] means no duration, i.e. a permanent lease and notably some devices only support these permanent leases. Note that whether permanent or not, this is only a request and the gateway may still decide at any point to remove the mapping (which usually happens on a reboot of the gateway, when its external IP address changes, or on some models when it detects a port mapping has become inactive, i.e. had no traffic for multiple minutes). If not [code]0[/code] (permanent), the allowed range according to spec is between [code]120[/code] (2 minutes) and [code]86400[/code] seconds (24 hours).
See [enum UPNPResult] for possible return values.
</description>
</method>
@@ -93,7 +93,7 @@
<param index="0" name="port" type="int" />
<param index="1" name="proto" type="String" default="&quot;UDP&quot;" />
<description>
- Deletes the port mapping for the given port and protocol combination on the default gateway (see [method get_gateway]) if one exists. [code]port[/code] must be a valid port between 1 and 65535, [code]proto[/code] can be either [code]"TCP"[/code] or [code]"UDP"[/code]. May be refused for mappings pointing to addresses other than this one, for well-known ports (below 1024), or for mappings not added via UPnP. See [enum UPNPResult] for possible return values.
+ Deletes the port mapping for the given port and protocol combination on the default gateway (see [method get_gateway]) if one exists. [param port] must be a valid port between 1 and 65535, [param proto] can be either [code]"TCP"[/code] or [code]"UDP"[/code]. May be refused for mappings pointing to addresses other than this one, for well-known ports (below 1024), or for mappings not added via UPnP. See [enum UPNPResult] for possible return values.
</description>
</method>
<method name="discover">
@@ -103,7 +103,7 @@
<param index="2" name="device_filter" type="String" default="&quot;InternetGatewayDevice&quot;" />
<description>
Discovers local [UPNPDevice]s. Clears the list of previously discovered devices.
- Filters for IGD (InternetGatewayDevice) type devices by default, as those manage port forwarding. [code]timeout[/code] is the time to wait for responses in milliseconds. [code]ttl[/code] is the time-to-live; only touch this if you know what you're doing.
+ Filters for IGD (InternetGatewayDevice) type devices by default, as those manage port forwarding. [param timeout] is the time to wait for responses in milliseconds. [param ttl] is the time-to-live; only touch this if you know what you're doing.
See [enum UPNPResult] for possible return values.
</description>
</method>
@@ -111,7 +111,7 @@
<return type="UPNPDevice" />
<param index="0" name="index" type="int" />
<description>
- Returns the [UPNPDevice] at the given [code]index[/code].
+ Returns the [UPNPDevice] at the given [param index].
</description>
</method>
<method name="get_device_count" qualifiers="const">
@@ -136,7 +136,7 @@
<return type="void" />
<param index="0" name="index" type="int" />
<description>
- Removes the device at [code]index[/code] from the list of discovered devices.
+ Removes the device at [param index] from the list of discovered devices.
</description>
</method>
<method name="set_device">
@@ -144,7 +144,7 @@
<param index="0" name="index" type="int" />
<param index="1" name="device" type="UPNPDevice" />
<description>
- Sets the device at [code]index[/code] from the list of discovered devices to [code]device[/code].
+ Sets the device at [param index] from the list of discovered devices to [param device].
</description>
</method>
</methods>
diff --git a/modules/webrtc/doc_classes/WebRTCMultiplayerPeer.xml b/modules/webrtc/doc_classes/WebRTCMultiplayerPeer.xml
index 607b8c05e2..fa58bf5d58 100644
--- a/modules/webrtc/doc_classes/WebRTCMultiplayerPeer.xml
+++ b/modules/webrtc/doc_classes/WebRTCMultiplayerPeer.xml
@@ -18,8 +18,8 @@
<param index="1" name="peer_id" type="int" />
<param index="2" name="unreliable_lifetime" type="int" default="1" />
<description>
- Add a new peer to the mesh with the given [code]peer_id[/code]. The [WebRTCPeerConnection] must be in state [constant WebRTCPeerConnection.STATE_NEW].
- Three channels will be created for reliable, unreliable, and ordered transport. The value of [code]unreliable_lifetime[/code] will be passed to the [code]maxPacketLifetime[/code] option when creating unreliable and ordered channels (see [method WebRTCPeerConnection.create_data_channel]).
+ Add a new peer to the mesh with the given [param peer_id]. The [WebRTCPeerConnection] must be in state [constant WebRTCPeerConnection.STATE_NEW].
+ Three channels will be created for reliable, unreliable, and ordered transport. The value of [param unreliable_lifetime] will be passed to the [code]"maxPacketLifetime"[/code] option when creating unreliable and ordered channels (see [method WebRTCPeerConnection.create_data_channel]).
</description>
</method>
<method name="create_client">
@@ -27,8 +27,8 @@
<param index="0" name="peer_id" type="int" />
<param index="1" name="channels_config" type="Array" default="[]" />
<description>
- Initialize the multiplayer peer as a client with the given [code]peer_id[/code] (must be between 2 and 2147483647). In this mode, you should only call [method add_peer] once and with [code]peer_id[/code] of [code]1[/code]. This mode enables [method MultiplayerPeer.is_server_relay_supported], allowing the upper [MultiplayerAPI] layer to perform peer exchange and packet relaying.
- You can optionally specify a [code]channels_config[/code] array of [enum MultiplayerPeer.TransferMode] which will be used to create extra channels (WebRTC only supports one transfer mode per channel).
+ Initialize the multiplayer peer as a client with the given [param peer_id] (must be between 2 and 2147483647). In this mode, you should only call [method add_peer] once and with [param peer_id] of [code]1[/code]. This mode enables [method MultiplayerPeer.is_server_relay_supported], allowing the upper [MultiplayerAPI] layer to perform peer exchange and packet relaying.
+ You can optionally specify a [param channels_config] array of [enum MultiplayerPeer.TransferMode] which will be used to create extra channels (WebRTC only supports one transfer mode per channel).
</description>
</method>
<method name="create_mesh">
@@ -36,7 +36,7 @@
<param index="0" name="peer_id" type="int" />
<param index="1" name="channels_config" type="Array" default="[]" />
<description>
- Initialize the multiplayer peer as a mesh (i.e. all peers connect to each other) with the given [code]peer_id[/code] (must be between 1 and 2147483647).
+ Initialize the multiplayer peer as a mesh (i.e. all peers connect to each other) with the given [param peer_id] (must be between 1 and 2147483647).
</description>
</method>
<method name="create_server">
@@ -44,14 +44,14 @@
<param index="0" name="channels_config" type="Array" default="[]" />
<description>
Initialize the multiplayer peer as a server (with unique ID of [code]1[/code]). This mode enables [method MultiplayerPeer.is_server_relay_supported], allowing the upper [MultiplayerAPI] layer to perform peer exchange and packet relaying.
- You can optionally specify a [code]channels_config[/code] array of [enum MultiplayerPeer.TransferMode] which will be used to create extra channels (WebRTC only supports one transfer mode per channel).
+ You can optionally specify a [param channels_config] array of [enum MultiplayerPeer.TransferMode] which will be used to create extra channels (WebRTC only supports one transfer mode per channel).
</description>
</method>
<method name="get_peer">
<return type="Dictionary" />
<param index="0" name="peer_id" type="int" />
<description>
- Returns a dictionary representation of the peer with given [code]peer_id[/code] with three keys. [code]connection[/code] containing the [WebRTCPeerConnection] to this peer, [code]channels[/code] an array of three [WebRTCDataChannel], and [code]connected[/code] a boolean representing if the peer connection is currently connected (all three channels are open).
+ Returns a dictionary representation of the peer with given [param peer_id] with three keys. [code]"connection"[/code] containing the [WebRTCPeerConnection] to this peer, [code]"channels"[/code] an array of three [WebRTCDataChannel], and [code]"connected"[/code] a boolean representing if the peer connection is currently connected (all three channels are open).
</description>
</method>
<method name="get_peers">
@@ -64,14 +64,14 @@
<return type="bool" />
<param index="0" name="peer_id" type="int" />
<description>
- Returns [code]true[/code] if the given [code]peer_id[/code] is in the peers map (it might not be connected though).
+ Returns [code]true[/code] if the given [param peer_id] is in the peers map (it might not be connected though).
</description>
</method>
<method name="remove_peer">
<return type="void" />
<param index="0" name="peer_id" type="int" />
<description>
- Remove the peer with given [code]peer_id[/code] from the mesh. If the peer was connected, and [signal MultiplayerPeer.peer_connected] was emitted for it, then [signal MultiplayerPeer.peer_disconnected] will be emitted.
+ Remove the peer with given [param peer_id] from the mesh. If the peer was connected, and [signal MultiplayerPeer.peer_connected] was emitted for it, then [signal MultiplayerPeer.peer_disconnected] will be emitted.
</description>
</method>
</methods>
diff --git a/modules/webrtc/doc_classes/WebRTCPeerConnection.xml b/modules/webrtc/doc_classes/WebRTCPeerConnection.xml
index 1e1f54d8b2..99a5381f0c 100644
--- a/modules/webrtc/doc_classes/WebRTCPeerConnection.xml
+++ b/modules/webrtc/doc_classes/WebRTCPeerConnection.xml
@@ -35,9 +35,9 @@
<param index="0" name="label" type="String" />
<param index="1" name="options" type="Dictionary" default="{}" />
<description>
- Returns a new [WebRTCDataChannel] (or [code]null[/code] on failure) with given [code]label[/code] and optionally configured via the [code]options[/code] dictionary. This method can only be called when the connection is in state [constant STATE_NEW].
- There are two ways to create a working data channel: either call [method create_data_channel] on only one of the peer and listen to [signal data_channel_received] on the other, or call [method create_data_channel] on both peers, with the same values, and the [code]negotiated[/code] option set to [code]true[/code].
- Valid [code]options[/code] are:
+ Returns a new [WebRTCDataChannel] (or [code]null[/code] on failure) with given [param label] and optionally configured via the [param options] dictionary. This method can only be called when the connection is in state [constant STATE_NEW].
+ There are two ways to create a working data channel: either call [method create_data_channel] on only one of the peer and listen to [signal data_channel_received] on the other, or call [method create_data_channel] on both peers, with the same values, and the [code]"negotiated"[/code] option set to [code]true[/code].
+ Valid [param options] are:
[codeblock]
{
"negotiated": true, # When set to true (default off), means the channel is negotiated out of band. "id" must be set too. "data_channel_received" will not be called.
@@ -83,8 +83,8 @@
<return type="int" enum="Error" />
<param index="0" name="configuration" type="Dictionary" default="{}" />
<description>
- Re-initialize this peer connection, closing any previously active connection, and going back to state [constant STATE_NEW]. A dictionary of [code]options[/code] can be passed to configure the peer connection.
- Valid [code]options[/code] are:
+ Re-initialize this peer connection, closing any previously active connection, and going back to state [constant STATE_NEW]. A dictionary of [param configuration] options can be passed to configure the peer connection.
+ Valid [param configuration] options are:
[codeblock]
{
"iceServers": [
@@ -111,7 +111,7 @@
<return type="void" />
<param index="0" name="extension_class" type="StringName" />
<description>
- Sets the [code]extension_class[/code] as the default [WebRTCPeerConnectionExtension] returned when creating a new [WebRTCPeerConnection].
+ Sets the [param extension_class] as the default [WebRTCPeerConnectionExtension] returned when creating a new [WebRTCPeerConnection].
</description>
</method>
<method name="set_local_description">
@@ -129,8 +129,8 @@
<param index="1" name="sdp" type="String" />
<description>
Sets the SDP description of the remote peer. This should be called with the values generated by a remote peer and received over the signaling server.
- If [code]type[/code] is [code]offer[/code] the peer will emit [signal session_description_created] with the appropriate answer.
- If [code]type[/code] is [code]answer[/code] the peer will start emitting [signal ice_candidate_created].
+ If [param type] is [code]"offer"[/code] the peer will emit [signal session_description_created] with the appropriate answer.
+ If [param type] is [code]"answer"[/code] the peer will start emitting [signal ice_candidate_created].
</description>
</method>
</methods>
diff --git a/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml b/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml
index 57feadcc99..ff94d4452a 100644
--- a/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml
+++ b/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml
@@ -32,7 +32,7 @@
<return type="WebSocketPeer" />
<param index="0" name="peer_id" type="int" />
<description>
- Returns the [WebSocketPeer] associated to the given [code]peer_id[/code].
+ Returns the [WebSocketPeer] associated to the given [param peer_id].
</description>
</method>
<method name="get_peer_address" qualifiers="const">
diff --git a/modules/websocket/doc_classes/WebSocketPeer.xml b/modules/websocket/doc_classes/WebSocketPeer.xml
index 580adfd2d2..61f0be22f6 100644
--- a/modules/websocket/doc_classes/WebSocketPeer.xml
+++ b/modules/websocket/doc_classes/WebSocketPeer.xml
@@ -61,7 +61,7 @@
<param index="1" name="tls_client_options" type="TLSOptions" default="null" />
<description>
Connects to the given URL. TLS certificates will be verified against the hostname when connecting using the [code]wss://[/code] protocol. You can pass the optional [param tls_client_options] parameter to customize the trusted certification authorities, or disable the common name verification. See [method TLSOptions.client] and [method TLSOptions.client_unsafe].
- [b]Note:[/b] To avoid mixed content warnings or errors in Web, you may have to use a [code]url[/code] that starts with [code]wss://[/code] (secure) instead of [code]ws://[/code]. When doing so, make sure to use the fully qualified domain name that matches the one defined in the server's TLS certificate. Do not connect directly via the IP address for [code]wss://[/code] connections, as it won't match with the TLS certificate.
+ [b]Note:[/b] To avoid mixed content warnings or errors in Web, you may have to use a [param url] that starts with [code]wss://[/code] (secure) instead of [code]ws://[/code]. When doing so, make sure to use the fully qualified domain name that matches the one defined in the server's TLS certificate. Do not connect directly via the IP address for [code]wss://[/code] connections, as it won't match with the TLS certificate.
</description>
</method>
<method name="get_close_code" qualifiers="const">
diff --git a/modules/webxr/doc_classes/WebXRInterface.xml b/modules/webxr/doc_classes/WebXRInterface.xml
index ed162b1da2..9591afa536 100644
--- a/modules/webxr/doc_classes/WebXRInterface.xml
+++ b/modules/webxr/doc_classes/WebXRInterface.xml
@@ -109,7 +109,7 @@
<return type="int" enum="WebXRInterface.TargetRayMode" />
<param index="0" name="input_source_id" type="int" />
<description>
- Returns the target ray mode for the given [code]input_source_id[/code].
+ Returns the target ray mode for the given [param input_source_id].
This can help interpret the input coming from that input source. See [url=https://developer.mozilla.org/en-US/docs/Web/API/XRInputSource/targetRayMode]XRInputSource.targetRayMode[/url] for more information.
</description>
</method>
@@ -117,7 +117,7 @@
<return type="XRPositionalTracker" />
<param index="0" name="input_source_id" type="int" />
<description>
- Gets an [XRPositionalTracker] for the given [code]input_source_id[/code].
+ Gets an [XRPositionalTracker] for the given [param input_source_id].
In the context of WebXR, an input source can be an advanced VR controller like the Oculus Touch or Index controllers, or even a tap on the screen, a spoken voice command or a button press on the device itself. When a non-traditional input source is used, interpret the position and orientation of the [XRPositionalTracker] as a ray pointing at the object the user wishes to interact with.
Use this method to get information about the input source that triggered one of these signals:
- [signal selectstart]
@@ -132,14 +132,14 @@
<return type="bool" />
<param index="0" name="input_source_id" type="int" />
<description>
- Returns [code]true[/code] if there is an active input source with the given [code]input_source_id[/code].
+ Returns [code]true[/code] if there is an active input source with the given [param input_source_id].
</description>
</method>
<method name="is_session_supported">
<return type="void" />
<param index="0" name="session_mode" type="String" />
<description>
- Checks if the given [code]session_mode[/code] is supported by the user's browser.
+ Checks if the given [param session_mode] is supported by the user's browser.
Possible values come from [url=https://developer.mozilla.org/en-US/docs/Web/API/XRSessionMode]WebXR's XRSessionMode[/url], including: [code]"immersive-vr"[/code], [code]"immersive-ar"[/code], and [code]"inline"[/code].
This method returns nothing, instead it emits the [signal session_supported] signal with the result.
</description>
@@ -229,7 +229,7 @@
<param index="0" name="message" type="String" />
<description>
Emitted by [method XRInterface.initialize] if the session fails to start.
- [code]message[/code] may optionally contain an error message from WebXR, or an empty string if no message is available.
+ [param message] may optionally contain an error message from WebXR, or an empty string if no message is available.
</description>
</signal>
<signal name="session_started">
@@ -242,7 +242,7 @@
<param index="0" name="session_mode" type="String" />
<param index="1" name="supported" type="bool" />
<description>
- Emitted by [method is_session_supported] to indicate if the given [code]session_mode[/code] is supported or not.
+ Emitted by [method is_session_supported] to indicate if the given [param session_mode] is supported or not.
</description>
</signal>
<signal name="squeeze">
diff --git a/platform/android/doc_classes/EditorExportPlatformAndroid.xml b/platform/android/doc_classes/EditorExportPlatformAndroid.xml
index 570e8f01f1..1a07774287 100644
--- a/platform/android/doc_classes/EditorExportPlatformAndroid.xml
+++ b/platform/android/doc_classes/EditorExportPlatformAndroid.xml
@@ -153,7 +153,7 @@
Must be required by a HostApduService or OffHostApduService to ensure that only the system can bind to it. See [url=https://developer.android.com/reference/android/Manifest.permission#BIND_NFC_SERVICE]BIND_NFC_SERVICE[/url].
</member>
<member name="permissions/bind_notification_listener_service" type="bool" setter="" getter="">
- Must be required by an NotificationListenerService, to ensure that only the system can bind to it. See [url=https://developer.android.com/reference/android/Manifest.permission#BIND_NOTIFICATION_LISTENER_SERVICE]BIND_NOTIFICATION_LISTENER_SERVICE[/url].
+ Must be required by a NotificationListenerService, to ensure that only the system can bind to it. See [url=https://developer.android.com/reference/android/Manifest.permission#BIND_NOTIFICATION_LISTENER_SERVICE]BIND_NOTIFICATION_LISTENER_SERVICE[/url].
</member>
<member name="permissions/bind_print_service" type="bool" setter="" getter="">
Must be required by a PrintService, to ensure that only the system can bind to it. See [url=https://developer.android.com/reference/android/Manifest.permission#BIND_PRINT_SERVICE]BIND_PRINT_SERVICE[/url].
diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp
index 0f0132a5d1..f52edf2b61 100644
--- a/platform/android/export/export_plugin.cpp
+++ b/platform/android/export/export_plugin.cpp
@@ -3306,6 +3306,8 @@ EditorExportPlatformAndroid::EditorExportPlatformAndroid() {
EditorExportPlatformAndroid::~EditorExportPlatformAndroid() {
#ifndef ANDROID_ENABLED
quit_request.set();
- check_for_changes_thread.wait_to_finish();
+ if (check_for_changes_thread.is_started()) {
+ check_for_changes_thread.wait_to_finish();
+ }
#endif
}
diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp
index 1a0087e18d..18091649e3 100644
--- a/platform/android/java_godot_lib_jni.cpp
+++ b/platform/android/java_godot_lib_jni.cpp
@@ -199,10 +199,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_resize(JNIEnv *env, j
if (p_surface) {
ANativeWindow *native_window = ANativeWindow_fromSurface(env, p_surface);
os_android->set_native_window(native_window);
-
- DisplayServerAndroid::get_singleton()->reset_window();
- DisplayServerAndroid::get_singleton()->notify_surface_changed(p_width, p_height);
}
+ DisplayServerAndroid::get_singleton()->reset_window();
+ DisplayServerAndroid::get_singleton()->notify_surface_changed(p_width, p_height);
}
}
}
@@ -244,7 +243,7 @@ JNIEXPORT jboolean JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env,
if (step.get() == 0) {
// Since Godot is initialized on the UI thread, main_thread_id was set to that thread's id,
// but for Godot purposes, the main thread is the one running the game loop
- Main::setup2(Thread::get_caller_id());
+ Main::setup2();
input_handler = new AndroidInputHandler();
step.increment();
return true;
@@ -447,39 +446,29 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_callobject(JNIEnv *en
Object *obj = ObjectDB::get_instance(ObjectID(ID));
ERR_FAIL_NULL(obj);
- int res = env->PushLocalFrame(16);
- ERR_FAIL_COND(res != 0);
-
String str_method = jstring_to_string(method, env);
int count = env->GetArrayLength(params);
+
Variant *vlist = (Variant *)alloca(sizeof(Variant) * count);
- Variant **vptr = (Variant **)alloca(sizeof(Variant *) * count);
+ const Variant **vptr = (const Variant **)alloca(sizeof(Variant *) * count);
+
for (int i = 0; i < count; i++) {
jobject jobj = env->GetObjectArrayElement(params, i);
- Variant v;
- if (jobj) {
- v = _jobject_to_variant(env, jobj);
- }
- memnew_placement(&vlist[i], Variant);
- vlist[i] = v;
+ ERR_FAIL_NULL(jobj);
+ memnew_placement(&vlist[i], Variant(_jobject_to_variant(env, jobj)));
vptr[i] = &vlist[i];
env->DeleteLocalRef(jobj);
}
Callable::CallError err;
- obj->callp(str_method, (const Variant **)vptr, count, err);
-
- env->PopLocalFrame(nullptr);
+ obj->callp(str_method, vptr, count, err);
}
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv *env, jclass clazz, jlong ID, jstring method, jobjectArray params) {
Object *obj = ObjectDB::get_instance(ObjectID(ID));
ERR_FAIL_NULL(obj);
- int res = env->PushLocalFrame(16);
- ERR_FAIL_COND(res != 0);
-
String str_method = jstring_to_string(method, env);
int count = env->GetArrayLength(params);
@@ -489,16 +478,13 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv *
for (int i = 0; i < count; i++) {
jobject jobj = env->GetObjectArrayElement(params, i);
- if (jobj) {
- args[i] = _jobject_to_variant(env, jobj);
- }
- env->DeleteLocalRef(jobj);
+ ERR_FAIL_NULL(jobj);
+ memnew_placement(&args[i], Variant(_jobject_to_variant(env, jobj)));
argptrs[i] = &args[i];
+ env->DeleteLocalRef(jobj);
}
- MessageQueue::get_singleton()->push_callp(obj, str_method, (const Variant **)argptrs, count);
-
- env->PopLocalFrame(nullptr);
+ MessageQueue::get_singleton()->push_callp(obj, str_method, argptrs, count);
}
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_requestPermissionResult(JNIEnv *env, jclass clazz, jstring p_permission, jboolean p_result) {
diff --git a/platform/android/plugin/godot_plugin_jni.cpp b/platform/android/plugin/godot_plugin_jni.cpp
index 4bb90cb971..843c015d49 100644
--- a/platform/android/plugin/godot_plugin_jni.cpp
+++ b/platform/android/plugin/godot_plugin_jni.cpp
@@ -120,7 +120,8 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_plugin_GodotPlugin_nativeEmitS
for (int i = 0; i < count; i++) {
jobject j_param = env->GetObjectArrayElement(j_signal_params, i);
- variant_params[i] = _jobject_to_variant(env, j_param);
+ ERR_FAIL_NULL(j_param);
+ memnew_placement(&variant_params[i], Variant(_jobject_to_variant(env, j_param)));
args[i] = &variant_params[i];
env->DeleteLocalRef(j_param);
}
diff --git a/platform/ios/doc_classes/EditorExportPlatformIOS.xml b/platform/ios/doc_classes/EditorExportPlatformIOS.xml
index 249ee4323c..ef2b0a256d 100644
--- a/platform/ios/doc_classes/EditorExportPlatformIOS.xml
+++ b/platform/ios/doc_classes/EditorExportPlatformIOS.xml
@@ -10,7 +10,7 @@
</tutorials>
<members>
<member name="application/app_store_team_id" type="String" setter="" getter="">
- Apple Team ID, unique 10-character string. To locate your Team ID check "Membership details" section in your Apple developer account dashboard, or "Organisational Unit" of your code signing certificate. See [url=https://developer.apple.com/help/account/manage-your-team/locate-your-team-id]Locate your Team ID[/url].
+ Apple Team ID, unique 10-character string. To locate your Team ID check "Membership details" section in your Apple developer account dashboard, or "Organizational Unit" of your code signing certificate. See [url=https://developer.apple.com/help/account/manage-your-team/locate-your-team-id]Locate your Team ID[/url].
</member>
<member name="application/bundle_identifier" type="String" setter="" getter="">
Unique application identifier in a reverse-DNS format, can only contain alphanumeric characters ([code]A-Z[/code], [code]a-z[/code], and [code]0-9[/code]), hyphens ([code]-[/code]), and periods ([code].[/code]).
diff --git a/platform/ios/export/export_plugin.cpp b/platform/ios/export/export_plugin.cpp
index b6d70048e3..9c0e4e39e8 100644
--- a/platform/ios/export/export_plugin.cpp
+++ b/platform/ios/export/export_plugin.cpp
@@ -33,6 +33,7 @@
#include "core/string/translation.h"
#include "editor/editor_node.h"
#include "editor/editor_scale.h"
+#include "editor/export/editor_export.h"
#include "platform/ios/logo_svg.gen.h"
#include "modules/modules_enabled.gen.h" // For svg.
@@ -111,13 +112,13 @@ static const LoadingScreenInfo loading_screen_infos[] = {
{ PNAME("landscape_launch_screens/ipad_1024x768"), "Default-Landscape.png", 1024, 768, false },
{ PNAME("landscape_launch_screens/ipad_2048x1536"), "Default-Landscape@2x.png", 2048, 1536, false },
- { PNAME("portrait_launch_screens/iphone_640x960"), "Default-480h@2x.png", 640, 960, true },
- { PNAME("portrait_launch_screens/iphone_640x1136"), "Default-568h@2x.png", 640, 1136, true },
- { PNAME("portrait_launch_screens/iphone_750x1334"), "Default-667h@2x.png", 750, 1334, true },
- { PNAME("portrait_launch_screens/iphone_1125x2436"), "Default-Portrait-X.png", 1125, 2436, true },
- { PNAME("portrait_launch_screens/ipad_768x1024"), "Default-Portrait.png", 768, 1024, true },
- { PNAME("portrait_launch_screens/ipad_1536x2048"), "Default-Portrait@2x.png", 1536, 2048, true },
- { PNAME("portrait_launch_screens/iphone_1242x2208"), "Default-Portrait-736h@3x.png", 1242, 2208, true }
+ { PNAME("portrait_launch_screens/iphone_640x960"), "Default-480h@2x.png", 640, 960, false },
+ { PNAME("portrait_launch_screens/iphone_640x1136"), "Default-568h@2x.png", 640, 1136, false },
+ { PNAME("portrait_launch_screens/iphone_750x1334"), "Default-667h@2x.png", 750, 1334, false },
+ { PNAME("portrait_launch_screens/iphone_1125x2436"), "Default-Portrait-X.png", 1125, 2436, false },
+ { PNAME("portrait_launch_screens/ipad_768x1024"), "Default-Portrait.png", 768, 1024, false },
+ { PNAME("portrait_launch_screens/ipad_1536x2048"), "Default-Portrait@2x.png", 1536, 2048, false },
+ { PNAME("portrait_launch_screens/iphone_1242x2208"), "Default-Portrait-736h@3x.png", 1242, 2208, false }
};
String EditorExportPlatformIOS::get_export_option_warning(const EditorExportPreset *p_preset, const StringName &p_name) const {
@@ -1983,6 +1984,8 @@ EditorExportPlatformIOS::EditorExportPlatformIOS() {
EditorExportPlatformIOS::~EditorExportPlatformIOS() {
#ifndef ANDROID_ENABLED
quit_request.set();
- check_for_changes_thread.wait_to_finish();
+ if (check_for_changes_thread.is_started()) {
+ check_for_changes_thread.wait_to_finish();
+ }
#endif
}
diff --git a/platform/ios/os_ios.mm b/platform/ios/os_ios.mm
index b2f72c310f..739db419a3 100644
--- a/platform/ios/os_ios.mm
+++ b/platform/ios/os_ios.mm
@@ -240,10 +240,20 @@ Error OS_IOS::open_dynamic_library(const String p_path, void *&p_library_handle,
}
if (!FileAccess::exists(path)) {
+ // Load .dylib converted to framework from within the executable path.
+ path = get_framework_executable(get_executable_path().get_base_dir().path_join(p_path.get_file().get_basename() + ".framework"));
+ }
+
+ if (!FileAccess::exists(path)) {
// Load .dylib or framework from a standard iOS location.
path = get_framework_executable(get_executable_path().get_base_dir().path_join("Frameworks").path_join(p_path.get_file()));
}
+ if (!FileAccess::exists(path)) {
+ // Load .dylib converted to framework from a standard iOS location.
+ path = get_framework_executable(get_executable_path().get_base_dir().path_join("Frameworks").path_join(p_path.get_file().get_basename() + ".framework"));
+ }
+
p_library_handle = dlopen(path.utf8().get_data(), RTLD_NOW);
ERR_FAIL_COND_V_MSG(!p_library_handle, ERR_CANT_OPEN, "Can't open dynamic library: " + p_path + ", error: " + dlerror() + ".");
diff --git a/platform/linuxbsd/export/export_plugin.cpp b/platform/linuxbsd/export/export_plugin.cpp
index 317c6575b3..9544cc761d 100644
--- a/platform/linuxbsd/export/export_plugin.cpp
+++ b/platform/linuxbsd/export/export_plugin.cpp
@@ -34,6 +34,7 @@
#include "editor/editor_node.h"
#include "editor/editor_paths.h"
#include "editor/editor_scale.h"
+#include "editor/export/editor_export.h"
#include "platform/linuxbsd/logo_svg.gen.h"
#include "platform/linuxbsd/run_icon_svg.gen.h"
diff --git a/platform/macos/doc_classes/EditorExportPlatformMacOS.xml b/platform/macos/doc_classes/EditorExportPlatformMacOS.xml
index 1a9fd431c7..f57af3bbd7 100644
--- a/platform/macos/doc_classes/EditorExportPlatformMacOS.xml
+++ b/platform/macos/doc_classes/EditorExportPlatformMacOS.xml
@@ -46,7 +46,7 @@
Official export templates include [code]universal[/code] binaries only.
</member>
<member name="codesign/apple_team_id" type="String" setter="" getter="">
- Apple Team ID, unique 10-character string. To locate your Team ID check "Membership details" section in your Apple developer account dashboard, or "Organisational Unit" of your code signing certificate. See [url=https://developer.apple.com/help/account/manage-your-team/locate-your-team-id]Locate your Team ID[/url].
+ Apple Team ID, unique 10-character string. To locate your Team ID check "Membership details" section in your Apple developer account dashboard, or "Organizational Unit" of your code signing certificate. See [url=https://developer.apple.com/help/account/manage-your-team/locate-your-team-id]Locate your Team ID[/url].
</member>
<member name="codesign/certificate_file" type="String" setter="" getter="">
PKCS #12 certificate file used to sign [code].app[/code] bundle.
diff --git a/platform/macos/os_macos.h b/platform/macos/os_macos.h
index c539f7f529..eb7a30203a 100644
--- a/platform/macos/os_macos.h
+++ b/platform/macos/os_macos.h
@@ -98,6 +98,7 @@ public:
virtual String get_system_dir(SystemDir p_dir, bool p_shared_storage = true) const override;
virtual Error shell_open(String p_uri) override;
+ virtual Error shell_show_in_file_manager(String p_path, bool p_open_folder) override;
virtual String get_locale() const override;
diff --git a/platform/macos/os_macos.mm b/platform/macos/os_macos.mm
index 71a250153b..74cdef6f25 100644
--- a/platform/macos/os_macos.mm
+++ b/platform/macos/os_macos.mm
@@ -287,6 +287,27 @@ String OS_MacOS::get_system_dir(SystemDir p_dir, bool p_shared_storage) const {
return ret;
}
+Error OS_MacOS::shell_show_in_file_manager(String p_path, bool p_open_folder) {
+ bool open_folder = false;
+ if (DirAccess::dir_exists_absolute(p_path) && p_open_folder) {
+ open_folder = true;
+ }
+
+ if (!p_path.begins_with("file://")) {
+ p_path = String("file://") + p_path;
+ }
+
+ NSString *string = [NSString stringWithUTF8String:p_path.utf8().get_data()];
+ NSURL *uri = [[NSURL alloc] initWithString:[string stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]]];
+
+ if (open_folder) {
+ [[NSWorkspace sharedWorkspace] openURL:uri];
+ } else {
+ [[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:@[ uri ]];
+ }
+ return OK;
+}
+
Error OS_MacOS::shell_open(String p_uri) {
NSString *string = [NSString stringWithUTF8String:p_uri.utf8().get_data()];
NSURL *uri = [[NSURL alloc] initWithString:string];
diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp
index 85964c53e6..c20e3316a5 100644
--- a/platform/uwp/export/export.cpp
+++ b/platform/uwp/export/export.cpp
@@ -31,6 +31,7 @@
#include "export.h"
#include "editor/editor_settings.h"
+#include "editor/export/editor_export.h"
#include "export_plugin.h"
void register_uwp_exporter_types() {
diff --git a/platform/web/audio_driver_web.cpp b/platform/web/audio_driver_web.cpp
index 1d7b96d707..c6c67db3de 100644
--- a/platform/web/audio_driver_web.cpp
+++ b/platform/web/audio_driver_web.cpp
@@ -103,7 +103,7 @@ void AudioDriverWeb::_audio_driver_capture(int p_from, int p_samples) {
Error AudioDriverWeb::init() {
int latency = GLOBAL_GET("audio/driver/output_latency");
if (!audio_context.inited) {
- audio_context.mix_rate = GLOBAL_GET("audio/driver/mix_rate");
+ audio_context.mix_rate = _get_configured_mix_rate();
audio_context.channel_count = godot_audio_init(&audio_context.mix_rate, latency, &_state_change_callback, &_latency_update_callback);
audio_context.inited = true;
}
diff --git a/platform/web/export/export.cpp b/platform/web/export/export.cpp
index 54d9774da5..80c29024a8 100644
--- a/platform/web/export/export.cpp
+++ b/platform/web/export/export.cpp
@@ -31,6 +31,7 @@
#include "export.h"
#include "editor/editor_settings.h"
+#include "editor/export/editor_export.h"
#include "export_plugin.h"
void register_web_exporter_types() {
diff --git a/platform/web/export/export_plugin.cpp b/platform/web/export/export_plugin.cpp
index 7a62cd2a4a..2fff628c85 100644
--- a/platform/web/export/export_plugin.cpp
+++ b/platform/web/export/export_plugin.cpp
@@ -33,6 +33,7 @@
#include "core/config/project_settings.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
+#include "editor/export/editor_export.h"
#include "platform/web/logo_svg.gen.h"
#include "platform/web/run_icon_svg.gen.h"
@@ -686,5 +687,7 @@ EditorExportPlatformWeb::~EditorExportPlatformWeb() {
server->stop();
}
server_quit = true;
- server_thread.wait_to_finish();
+ if (server_thread.is_started()) {
+ server_thread.wait_to_finish();
+ }
}
diff --git a/platform/windows/export/export_plugin.cpp b/platform/windows/export/export_plugin.cpp
index 05b25eae03..1863a3083b 100644
--- a/platform/windows/export/export_plugin.cpp
+++ b/platform/windows/export/export_plugin.cpp
@@ -35,6 +35,7 @@
#include "editor/editor_node.h"
#include "editor/editor_paths.h"
#include "editor/editor_scale.h"
+#include "editor/export/editor_export.h"
#include "platform/windows/logo_svg.gen.h"
#include "platform/windows/run_icon_svg.gen.h"
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index b237c94072..a13d6ed986 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -706,16 +706,16 @@ Dictionary OS_Windows::get_memory_info() const {
}
if (pref_info.PhysicalTotal * pref_info.PageSize != 0) {
- meminfo["physical"] = pref_info.PhysicalTotal * pref_info.PageSize;
+ meminfo["physical"] = static_cast<int64_t>(pref_info.PhysicalTotal * pref_info.PageSize);
}
if (pref_info.PhysicalAvailable * pref_info.PageSize != 0) {
- meminfo["free"] = pref_info.PhysicalAvailable * pref_info.PageSize;
+ meminfo["free"] = static_cast<int64_t>(pref_info.PhysicalAvailable * pref_info.PageSize);
}
if (pref_info.CommitLimit * pref_info.PageSize != 0) {
- meminfo["available"] = pref_info.CommitLimit * pref_info.PageSize;
+ meminfo["available"] = static_cast<int64_t>(pref_info.CommitLimit * pref_info.PageSize);
}
if (HighLimit - LowLimit != 0) {
- meminfo["stack"] = HighLimit - LowLimit;
+ meminfo["stack"] = static_cast<int64_t>(HighLimit - LowLimit);
}
return meminfo;
@@ -1351,6 +1351,51 @@ Error OS_Windows::shell_open(String p_uri) {
}
}
+Error OS_Windows::shell_show_in_file_manager(String p_path, bool p_open_folder) {
+ p_path = p_path.trim_suffix("file://");
+
+ bool open_folder = false;
+ if (DirAccess::dir_exists_absolute(p_path) && p_open_folder) {
+ open_folder = true;
+ }
+
+ if (p_path.begins_with("\"")) {
+ p_path = String("\"") + p_path;
+ }
+ if (p_path.ends_with("\"")) {
+ p_path = p_path + String("\"");
+ }
+ p_path = p_path.replace("/", "\\");
+
+ INT_PTR ret = OK;
+ if (open_folder) {
+ ret = (INT_PTR)ShellExecuteW(nullptr, nullptr, L"explorer.exe", LPCWSTR(p_path.utf16().get_data()), nullptr, SW_SHOWNORMAL);
+ } else {
+ ret = (INT_PTR)ShellExecuteW(nullptr, nullptr, L"explorer.exe", LPCWSTR((String("/select,") + p_path).utf16().get_data()), nullptr, SW_SHOWNORMAL);
+ }
+
+ if (ret > 32) {
+ return OK;
+ } else {
+ switch (ret) {
+ case ERROR_FILE_NOT_FOUND:
+ case SE_ERR_DLLNOTFOUND:
+ return ERR_FILE_NOT_FOUND;
+ case ERROR_PATH_NOT_FOUND:
+ return ERR_FILE_BAD_PATH;
+ case ERROR_BAD_FORMAT:
+ return ERR_FILE_CORRUPT;
+ case SE_ERR_ACCESSDENIED:
+ return ERR_UNAUTHORIZED;
+ case 0:
+ case SE_ERR_OOM:
+ return ERR_OUT_OF_MEMORY;
+ default:
+ return FAILED;
+ }
+ }
+}
+
String OS_Windows::get_locale() const {
const _WinLocale *wl = &_win_locales[0];
diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h
index 5dee83769b..960c3f30a9 100644
--- a/platform/windows/os_windows.h
+++ b/platform/windows/os_windows.h
@@ -214,6 +214,7 @@ public:
virtual String get_unique_id() const override;
virtual Error shell_open(String p_uri) override;
+ virtual Error shell_show_in_file_manager(String p_path, bool p_open_folder) override;
void run();
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index c678b4bf02..1b59351b30 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -907,9 +907,7 @@ void RigidBody2D::_notification(int p_what) {
} break;
case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {
- if (Engine::get_singleton()->is_editor_hint()) {
- update_configuration_warnings();
- }
+ update_configuration_warnings();
} break;
}
#endif
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index dc8953b32c..35f57607ec 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -1637,6 +1637,7 @@ void TileMap::_physics_update_dirty_quadrants(SelfList<TileMapQuadrant>::List &r
// Create the body.
RID body = ps->body_create();
bodies_coords[body] = E_cell;
+ bodies_layers[body] = q.layer;
ps->body_set_mode(body, collision_animatable ? PhysicsServer2D::BODY_MODE_KINEMATIC : PhysicsServer2D::BODY_MODE_STATIC);
ps->body_set_space(body, space);
@@ -1692,6 +1693,7 @@ void TileMap::_physics_cleanup_quadrant(TileMapQuadrant *p_quadrant) {
ERR_FAIL_NULL(PhysicsServer2D::get_singleton());
for (RID body : p_quadrant->bodies) {
bodies_coords.erase(body);
+ bodies_layers.erase(body);
PhysicsServer2D::get_singleton()->free(body);
}
p_quadrant->bodies.clear();
@@ -2895,6 +2897,11 @@ Vector2i TileMap::get_coords_for_body_rid(RID p_physics_body) {
return bodies_coords[p_physics_body];
}
+int TileMap::get_layer_for_body_rid(RID p_physics_body) {
+ ERR_FAIL_COND_V_MSG(!bodies_layers.has(p_physics_body), int(), vformat("No tiles for the given body RID %d.", p_physics_body));
+ return bodies_layers[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.");
@@ -4154,6 +4161,7 @@ void TileMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_cell_tile_data", "layer", "coords", "use_proxies"), &TileMap::get_cell_tile_data, DEFVAL(false));
ClassDB::bind_method(D_METHOD("get_coords_for_body_rid", "body"), &TileMap::get_coords_for_body_rid);
+ ClassDB::bind_method(D_METHOD("get_layer_for_body_rid", "body"), &TileMap::get_layer_for_body_rid);
ClassDB::bind_method(D_METHOD("get_pattern", "layer", "coords_array"), &TileMap::get_pattern);
ClassDB::bind_method(D_METHOD("map_pattern", "position_in_tilemap", "coords_in_pattern", "pattern"), &TileMap::map_pattern);
diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h
index 1f3c672f17..3c135d1317 100644
--- a/scene/2d/tile_map.h
+++ b/scene/2d/tile_map.h
@@ -219,6 +219,8 @@ private:
// Mapping for RID to coords.
HashMap<RID, Vector2i> bodies_coords;
+ // Mapping for RID to tile layer.
+ HashMap<RID, int> bodies_layers;
// Quadrants and internals management.
Vector2i _coords_to_quadrant_coords(int p_layer, const Vector2i &p_coords) const;
@@ -396,6 +398,8 @@ public:
// For finding tiles from collision.
Vector2i get_coords_for_body_rid(RID p_physics_body);
+ // For getting their layers as well.
+ int get_layer_for_body_rid(RID p_physics_body);
// Fixing and clearing methods.
void fix_invalid_tiles();
diff --git a/scene/3d/collision_object_3d.cpp b/scene/3d/collision_object_3d.cpp
index 19d1b83cab..6d8d60dcaa 100644
--- a/scene/3d/collision_object_3d.cpp
+++ b/scene/3d/collision_object_3d.cpp
@@ -83,13 +83,9 @@ void CollisionObject3D::_notification(int p_what) {
_update_pickable();
} break;
-#ifdef TOOLS_ENABLED
case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {
- if (Engine::get_singleton()->is_editor_hint()) {
- update_configuration_warnings();
- }
+ update_configuration_warnings();
} break;
-#endif
case NOTIFICATION_TRANSFORM_CHANGED: {
if (only_update_transform_changes) {
diff --git a/scene/3d/collision_polygon_3d.cpp b/scene/3d/collision_polygon_3d.cpp
index 53a61c1368..9a2ed00274 100644
--- a/scene/3d/collision_polygon_3d.cpp
+++ b/scene/3d/collision_polygon_3d.cpp
@@ -104,11 +104,7 @@ void CollisionPolygon3D::_notification(int p_what) {
if (parent) {
_update_in_shape_owner(true);
}
-#ifdef TOOLS_ENABLED
- if (Engine::get_singleton()->is_editor_hint()) {
- update_configuration_warnings();
- }
-#endif
+ update_configuration_warnings();
} break;
case NOTIFICATION_UNPARENTED: {
diff --git a/scene/3d/collision_shape_3d.cpp b/scene/3d/collision_shape_3d.cpp
index f1d918ad9b..b7f3b12c25 100644
--- a/scene/3d/collision_shape_3d.cpp
+++ b/scene/3d/collision_shape_3d.cpp
@@ -99,11 +99,7 @@ void CollisionShape3D::_notification(int p_what) {
if (parent) {
_update_in_shape_owner(true);
}
-#ifdef TOOLS_ENABLED
- if (Engine::get_singleton()->is_editor_hint()) {
- update_configuration_warnings();
- }
-#endif
+ update_configuration_warnings();
} break;
case NOTIFICATION_UNPARENTED: {
diff --git a/scene/3d/light_3d.cpp b/scene/3d/light_3d.cpp
index 16c82bf6d2..18198b566e 100644
--- a/scene/3d/light_3d.cpp
+++ b/scene/3d/light_3d.cpp
@@ -284,6 +284,9 @@ void Light3D::_update_visibility() {
void Light3D::_notification(int p_what) {
switch (p_what) {
+ case NOTIFICATION_TRANSFORM_CHANGED: {
+ update_configuration_warnings();
+ } break;
case NOTIFICATION_VISIBILITY_CHANGED:
case NOTIFICATION_ENTER_TREE: {
_update_visibility();
diff --git a/scene/3d/navigation_region_3d.cpp b/scene/3d/navigation_region_3d.cpp
index 6af8999b89..85633c1dc7 100644
--- a/scene/3d/navigation_region_3d.cpp
+++ b/scene/3d/navigation_region_3d.cpp
@@ -270,7 +270,9 @@ void NavigationRegion3D::bake_navigation_mesh(bool p_on_thread) {
void NavigationRegion3D::_bake_finished(Ref<NavigationMesh> p_nav_mesh) {
set_navigation_mesh(p_nav_mesh);
- bake_thread.wait_to_finish();
+ if (bake_thread.is_started()) {
+ bake_thread.wait_to_finish();
+ }
emit_signal(SNAME("bake_finished"));
}
@@ -372,6 +374,10 @@ NavigationRegion3D::NavigationRegion3D() {
}
NavigationRegion3D::~NavigationRegion3D() {
+ if (bake_thread.is_started()) {
+ bake_thread.wait_to_finish();
+ }
+
if (navigation_mesh.is_valid()) {
navigation_mesh->disconnect("changed", callable_mp(this, &NavigationRegion3D::_navigation_changed));
}
diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp
index b7d63258db..4be695d189 100644
--- a/scene/3d/physics_body_3d.cpp
+++ b/scene/3d/physics_body_3d.cpp
@@ -599,9 +599,7 @@ void RigidBody3D::_notification(int p_what) {
} break;
case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {
- if (Engine::get_singleton()->is_editor_hint()) {
- update_configuration_warnings();
- }
+ update_configuration_warnings();
} break;
}
#endif
diff --git a/scene/animation/animation_node_state_machine.cpp b/scene/animation/animation_node_state_machine.cpp
index a02dd7532a..071e2e7f37 100644
--- a/scene/animation/animation_node_state_machine.cpp
+++ b/scene/animation/animation_node_state_machine.cpp
@@ -864,7 +864,7 @@ double AnimationNodeStateMachinePlayback::_process(const String &p_base_path, An
// Find next and see when to transition.
_transition_to_next_recursive(tree, p_state_machine, p_test_only);
- // Predict reamin time.
+ // Predict remaining time.
double remain = rem; // If we can't predict the end of state machine, the time remaining must be INFINITY.
if (p_state_machine->get_state_machine_type() == AnimationNodeStateMachine::STATE_MACHINE_TYPE_NESTED) {
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index fc3a3d306f..9835e7a065 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -528,7 +528,7 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, double
Vector3 loc;
- Error err = a->position_track_interpolate(i, p_time, &loc);
+ Error err = a->try_position_track_interpolate(i, p_time, &loc);
//ERR_CONTINUE(err!=OK); //used for testing, should be removed
if (err != OK) {
@@ -556,7 +556,7 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, double
Quaternion rot;
- Error err = a->rotation_track_interpolate(i, p_time, &rot);
+ Error err = a->try_rotation_track_interpolate(i, p_time, &rot);
//ERR_CONTINUE(err!=OK); //used for testing, should be removed
if (err != OK) {
@@ -584,7 +584,7 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, double
Vector3 scale;
- Error err = a->scale_track_interpolate(i, p_time, &scale);
+ Error err = a->try_scale_track_interpolate(i, p_time, &scale);
//ERR_CONTINUE(err!=OK); //used for testing, should be removed
if (err != OK) {
@@ -612,7 +612,7 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, double
float blend;
- Error err = a->blend_shape_track_interpolate(i, p_time, &blend);
+ Error err = a->try_blend_shape_track_interpolate(i, p_time, &blend);
//ERR_CONTINUE(err!=OK); //used for testing, should be removed
if (err != OK) {
diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp
index de9824a515..c6cb3873e0 100644
--- a/scene/animation/animation_tree.cpp
+++ b/scene/animation/animation_tree.cpp
@@ -654,7 +654,7 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
// If a value track without a key is cached first, the initial value cannot be determined.
// It is a corner case, but which may cause problems with blending.
- ERR_CONTINUE_MSG(anim->track_get_key_count(i) == 0, "AnimationTree: '" + String(E) + "', value track: '" + String(path) + "' must have at least one key to cache for blending.");
+ ERR_CONTINUE_MSG(anim->track_get_key_count(i) == 0, "AnimationTree: '" + String(E) + "', Value Track: '" + String(path) + "' must have at least one key to cache for blending.");
track_value->init_value = anim->track_get_key_value(i, 0);
track_value->init_value.zero();
@@ -867,10 +867,10 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
track_value->is_using_angle |= anim->track_get_interpolation_type(i) == Animation::INTERPOLATION_LINEAR_ANGLE || anim->track_get_interpolation_type(i) == Animation::INTERPOLATION_CUBIC_ANGLE;
if (was_discrete != track_value->is_discrete) {
- ERR_PRINT_ED("Value track: " + String(path) + " with different update modes are blended. Blending prioritizes Discrete mode, so other update mode tracks will not be blended.");
+ ERR_PRINT_ED("Value Track: " + String(path) + " with different update modes are blended. Blending prioritizes Discrete mode, so other update mode tracks will not be blended.");
}
if (was_using_angle != track_value->is_using_angle) {
- WARN_PRINT_ED("Value track: " + String(path) + " with different interpolation types for rotation are blended. Blending prioritizes angle interpolation, so the blending result uses the shortest path referenced to the initial (RESET animation) value.");
+ WARN_PRINT_ED("Value Track: " + String(path) + " with different interpolation types for rotation are blended. Blending prioritizes angle interpolation, so the blending result uses the shortest path referenced to the initial (RESET animation) value.");
}
}
@@ -1181,36 +1181,36 @@ void AnimationTree::_process_graph(double p_delta) {
if (!backward) {
if (prev_time > time) {
- Error err = a->position_track_interpolate(i, prev_time, &loc[0]);
+ Error err = a->try_position_track_interpolate(i, prev_time, &loc[0]);
if (err != OK) {
continue;
}
loc[0] = post_process_key_value(a, i, loc[0], t->object, t->bone_idx);
- a->position_track_interpolate(i, (double)a->get_length(), &loc[1]);
+ a->try_position_track_interpolate(i, (double)a->get_length(), &loc[1]);
loc[1] = post_process_key_value(a, i, loc[1], t->object, t->bone_idx);
root_motion_cache.loc += (loc[1] - loc[0]) * blend;
prev_time = 0;
}
} else {
if (prev_time < time) {
- Error err = a->position_track_interpolate(i, prev_time, &loc[0]);
+ Error err = a->try_position_track_interpolate(i, prev_time, &loc[0]);
if (err != OK) {
continue;
}
loc[0] = post_process_key_value(a, i, loc[0], t->object, t->bone_idx);
- a->position_track_interpolate(i, 0, &loc[1]);
+ a->try_position_track_interpolate(i, 0, &loc[1]);
loc[1] = post_process_key_value(a, i, loc[1], t->object, t->bone_idx);
root_motion_cache.loc += (loc[1] - loc[0]) * blend;
prev_time = (double)a->get_length();
}
}
- Error err = a->position_track_interpolate(i, prev_time, &loc[0]);
+ Error err = a->try_position_track_interpolate(i, prev_time, &loc[0]);
if (err != OK) {
continue;
}
loc[0] = post_process_key_value(a, i, loc[0], t->object, t->bone_idx);
- a->position_track_interpolate(i, time, &loc[1]);
+ a->try_position_track_interpolate(i, time, &loc[1]);
loc[1] = post_process_key_value(a, i, loc[1], t->object, t->bone_idx);
root_motion_cache.loc += (loc[1] - loc[0]) * blend;
prev_time = !backward ? 0 : (double)a->get_length();
@@ -1219,7 +1219,7 @@ void AnimationTree::_process_graph(double p_delta) {
{
Vector3 loc;
- Error err = a->position_track_interpolate(i, time, &loc);
+ Error err = a->try_position_track_interpolate(i, time, &loc);
if (err != OK) {
continue;
}
@@ -1276,36 +1276,36 @@ void AnimationTree::_process_graph(double p_delta) {
if (!backward) {
if (prev_time > time) {
- Error err = a->rotation_track_interpolate(i, prev_time, &rot[0]);
+ Error err = a->try_rotation_track_interpolate(i, prev_time, &rot[0]);
if (err != OK) {
continue;
}
rot[0] = post_process_key_value(a, i, rot[0], t->object, t->bone_idx);
- a->rotation_track_interpolate(i, (double)a->get_length(), &rot[1]);
+ a->try_rotation_track_interpolate(i, (double)a->get_length(), &rot[1]);
rot[1] = post_process_key_value(a, i, rot[1], t->object, t->bone_idx);
root_motion_cache.rot = (root_motion_cache.rot * Quaternion().slerp(rot[0].inverse() * rot[1], blend)).normalized();
prev_time = 0;
}
} else {
if (prev_time < time) {
- Error err = a->rotation_track_interpolate(i, prev_time, &rot[0]);
+ Error err = a->try_rotation_track_interpolate(i, prev_time, &rot[0]);
if (err != OK) {
continue;
}
rot[0] = post_process_key_value(a, i, rot[0], t->object, t->bone_idx);
- a->rotation_track_interpolate(i, 0, &rot[1]);
+ a->try_rotation_track_interpolate(i, 0, &rot[1]);
root_motion_cache.rot = (root_motion_cache.rot * Quaternion().slerp(rot[0].inverse() * rot[1], blend)).normalized();
prev_time = (double)a->get_length();
}
}
- Error err = a->rotation_track_interpolate(i, prev_time, &rot[0]);
+ Error err = a->try_rotation_track_interpolate(i, prev_time, &rot[0]);
if (err != OK) {
continue;
}
rot[0] = post_process_key_value(a, i, rot[0], t->object, t->bone_idx);
- a->rotation_track_interpolate(i, time, &rot[1]);
+ a->try_rotation_track_interpolate(i, time, &rot[1]);
rot[1] = post_process_key_value(a, i, rot[1], t->object, t->bone_idx);
root_motion_cache.rot = (root_motion_cache.rot * Quaternion().slerp(rot[0].inverse() * rot[1], blend)).normalized();
prev_time = !backward ? 0 : (double)a->get_length();
@@ -1314,7 +1314,7 @@ void AnimationTree::_process_graph(double p_delta) {
{
Quaternion rot;
- Error err = a->rotation_track_interpolate(i, time, &rot);
+ Error err = a->try_rotation_track_interpolate(i, time, &rot);
if (err != OK) {
continue;
}
@@ -1371,37 +1371,37 @@ void AnimationTree::_process_graph(double p_delta) {
if (!backward) {
if (prev_time > time) {
- Error err = a->scale_track_interpolate(i, prev_time, &scale[0]);
+ Error err = a->try_scale_track_interpolate(i, prev_time, &scale[0]);
if (err != OK) {
continue;
}
scale[0] = post_process_key_value(a, i, scale[0], t->object, t->bone_idx);
- a->scale_track_interpolate(i, (double)a->get_length(), &scale[1]);
+ a->try_scale_track_interpolate(i, (double)a->get_length(), &scale[1]);
root_motion_cache.scale += (scale[1] - scale[0]) * blend;
scale[1] = post_process_key_value(a, i, scale[1], t->object, t->bone_idx);
prev_time = 0;
}
} else {
if (prev_time < time) {
- Error err = a->scale_track_interpolate(i, prev_time, &scale[0]);
+ Error err = a->try_scale_track_interpolate(i, prev_time, &scale[0]);
if (err != OK) {
continue;
}
scale[0] = post_process_key_value(a, i, scale[0], t->object, t->bone_idx);
- a->scale_track_interpolate(i, 0, &scale[1]);
+ a->try_scale_track_interpolate(i, 0, &scale[1]);
scale[1] = post_process_key_value(a, i, scale[1], t->object, t->bone_idx);
root_motion_cache.scale += (scale[1] - scale[0]) * blend;
prev_time = (double)a->get_length();
}
}
- Error err = a->scale_track_interpolate(i, prev_time, &scale[0]);
+ Error err = a->try_scale_track_interpolate(i, prev_time, &scale[0]);
if (err != OK) {
continue;
}
scale[0] = post_process_key_value(a, i, scale[0], t->object, t->bone_idx);
- a->scale_track_interpolate(i, time, &scale[1]);
+ a->try_scale_track_interpolate(i, time, &scale[1]);
scale[1] = post_process_key_value(a, i, scale[1], t->object, t->bone_idx);
root_motion_cache.scale += (scale[1] - scale[0]) * blend;
prev_time = !backward ? 0 : (double)a->get_length();
@@ -1410,7 +1410,7 @@ void AnimationTree::_process_graph(double p_delta) {
{
Vector3 scale;
- Error err = a->scale_track_interpolate(i, time, &scale);
+ Error err = a->try_scale_track_interpolate(i, time, &scale);
if (err != OK) {
continue;
}
@@ -1429,7 +1429,7 @@ void AnimationTree::_process_graph(double p_delta) {
float value;
- Error err = a->blend_shape_track_interpolate(i, time, &value);
+ Error err = a->try_blend_shape_track_interpolate(i, time, &value);
//ERR_CONTINUE(err!=OK); //used for testing, should be removed
if (err != OK) {
diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp
index 70d87e221c..46ac8187c4 100644
--- a/scene/gui/button.cpp
+++ b/scene/gui/button.cpp
@@ -233,13 +233,13 @@ void Button::_notification(int p_what) {
}
Rect2 icon_region;
- HorizontalAlignment icon_align_rtl_checked = icon_alignment;
+ HorizontalAlignment icon_align_rtl_checked = horizontal_icon_alignment;
HorizontalAlignment align_rtl_checked = alignment;
// Swap icon and text alignment sides if right-to-left layout is set.
if (rtl) {
- if (icon_alignment == HORIZONTAL_ALIGNMENT_RIGHT) {
+ if (horizontal_icon_alignment == HORIZONTAL_ALIGNMENT_RIGHT) {
icon_align_rtl_checked = HORIZONTAL_ALIGNMENT_LEFT;
- } else if (icon_alignment == HORIZONTAL_ALIGNMENT_LEFT) {
+ } else if (horizontal_icon_alignment == HORIZONTAL_ALIGNMENT_LEFT) {
icon_align_rtl_checked = HORIZONTAL_ALIGNMENT_RIGHT;
}
if (alignment == HORIZONTAL_ALIGNMENT_RIGHT) {
@@ -251,6 +251,14 @@ void Button::_notification(int p_what) {
if (!_icon.is_null()) {
int valign = size.height - style->get_minimum_size().y;
+ int voffset = 0;
+ Size2 icon_size = _icon->get_size();
+
+ // Fix vertical size.
+ if (vertical_icon_alignment != VERTICAL_ALIGNMENT_CENTER) {
+ valign -= text_buf->get_size().height;
+ }
+
float icon_ofs_region = 0.0;
Point2 style_offset;
if (icon_align_rtl_checked == HORIZONTAL_ALIGNMENT_LEFT) {
@@ -268,7 +276,6 @@ void Button::_notification(int p_what) {
}
style_offset.y = style->get_margin(SIDE_TOP);
- Size2 icon_size = _icon->get_size();
if (expand_icon) {
Size2 _size = get_size() - style->get_offset() * 2;
int icon_text_separation = text.is_empty() ? 0 : theme_cache.h_separation;
@@ -276,6 +283,9 @@ void Button::_notification(int p_what) {
if (!clip_text && icon_align_rtl_checked != HORIZONTAL_ALIGNMENT_CENTER) {
_size.width -= text_buf->get_size().width;
}
+ if (vertical_icon_alignment != VERTICAL_ALIGNMENT_CENTER) {
+ _size.height -= text_buf->get_size().height;
+ }
float icon_width = _icon->get_width() * _size.height / _icon->get_height();
float icon_height = _size.height;
@@ -288,12 +298,19 @@ void Button::_notification(int p_what) {
}
icon_size = _fit_icon_size(icon_size);
+ if (vertical_icon_alignment == VERTICAL_ALIGNMENT_TOP) {
+ voffset = -(valign - icon_size.y) / 2;
+ }
+ if (vertical_icon_alignment == VERTICAL_ALIGNMENT_BOTTOM) {
+ voffset = (valign - icon_size.y) / 2 + text_buf->get_size().y;
+ }
+
if (icon_align_rtl_checked == HORIZONTAL_ALIGNMENT_LEFT) {
- icon_region = Rect2(style_offset + Point2(icon_ofs_region, Math::floor((valign - icon_size.y) * 0.5)), icon_size);
+ icon_region = Rect2(style_offset + Point2(icon_ofs_region, voffset + Math::floor((valign - icon_size.y) * 0.5)), icon_size);
} else if (icon_align_rtl_checked == HORIZONTAL_ALIGNMENT_CENTER) {
- icon_region = Rect2(style_offset + Point2(icon_ofs_region + Math::floor((size.x - icon_size.x) * 0.5), Math::floor((valign - icon_size.y) * 0.5)), icon_size);
+ icon_region = Rect2(style_offset + Point2(icon_ofs_region + Math::floor((size.x - icon_size.x) * 0.5), voffset + Math::floor((valign - icon_size.y) * 0.5)), icon_size);
} else {
- icon_region = Rect2(style_offset + Point2(icon_ofs_region + size.x - icon_size.x, Math::floor((valign - icon_size.y) * 0.5)), icon_size);
+ icon_region = Rect2(style_offset + Point2(icon_ofs_region + size.x - icon_size.x, voffset + Math::floor((valign - icon_size.y) * 0.5)), icon_size);
}
if (icon_region.size.width > 0) {
@@ -320,6 +337,13 @@ void Button::_notification(int p_what) {
Point2 text_ofs = (size - style->get_minimum_size() - icon_ofs - text_buf->get_size() - Point2(_internal_margin[SIDE_RIGHT] - _internal_margin[SIDE_LEFT], 0)) / 2.0;
+ if (vertical_icon_alignment == VERTICAL_ALIGNMENT_TOP) {
+ text_ofs.y += icon_region.size.height / 2;
+ }
+ if (vertical_icon_alignment == VERTICAL_ALIGNMENT_BOTTOM) {
+ text_ofs.y -= icon_region.size.height / 2;
+ }
+
text_buf->set_alignment(align_rtl_checked);
text_buf->set_width(text_width);
switch (align_rtl_checked) {
@@ -395,9 +419,13 @@ Size2 Button::get_minimum_size_for_text_and_icon(const String &p_text, Ref<Textu
if (!expand_icon && p_icon.is_valid()) {
Size2 icon_size = _fit_icon_size(p_icon->get_size());
- minsize.height = MAX(minsize.height, icon_size.height);
+ if (vertical_icon_alignment == VERTICAL_ALIGNMENT_CENTER) {
+ minsize.height = MAX(minsize.height, icon_size.height);
+ } else {
+ minsize.height += icon_size.height;
+ }
- if (icon_alignment != HORIZONTAL_ALIGNMENT_CENTER) {
+ if (horizontal_icon_alignment != HORIZONTAL_ALIGNMENT_CENTER) {
minsize.width += icon_size.width;
if (!xl_text.is_empty() || !p_text.is_empty()) {
minsize.width += MAX(0, theme_cache.h_separation);
@@ -410,7 +438,11 @@ Size2 Button::get_minimum_size_for_text_and_icon(const String &p_text, Ref<Textu
if (!xl_text.is_empty() || !p_text.is_empty()) {
Ref<Font> font = theme_cache.font;
float font_height = font->get_height(theme_cache.font_size);
- minsize.height = MAX(font_height, minsize.height);
+ if (vertical_icon_alignment == VERTICAL_ALIGNMENT_CENTER) {
+ minsize.height = MAX(font_height, minsize.height);
+ } else {
+ minsize.height += font_height;
+ }
}
return theme_cache.normal->get_minimum_size() + minsize;
@@ -556,13 +588,23 @@ HorizontalAlignment Button::get_text_alignment() const {
}
void Button::set_icon_alignment(HorizontalAlignment p_alignment) {
- icon_alignment = p_alignment;
+ horizontal_icon_alignment = p_alignment;
+ update_minimum_size();
+ queue_redraw();
+}
+
+void Button::set_vertical_icon_alignment(VerticalAlignment p_alignment) {
+ vertical_icon_alignment = p_alignment;
update_minimum_size();
queue_redraw();
}
HorizontalAlignment Button::get_icon_alignment() const {
- return icon_alignment;
+ return horizontal_icon_alignment;
+}
+
+VerticalAlignment Button::get_vertical_icon_alignment() const {
+ return vertical_icon_alignment;
}
void Button::_bind_methods() {
@@ -584,6 +626,8 @@ void Button::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_text_alignment"), &Button::get_text_alignment);
ClassDB::bind_method(D_METHOD("set_icon_alignment", "icon_alignment"), &Button::set_icon_alignment);
ClassDB::bind_method(D_METHOD("get_icon_alignment"), &Button::get_icon_alignment);
+ ClassDB::bind_method(D_METHOD("set_vertical_icon_alignment", "vertical_icon_alignment"), &Button::set_vertical_icon_alignment);
+ ClassDB::bind_method(D_METHOD("get_vertical_icon_alignment"), &Button::get_vertical_icon_alignment);
ClassDB::bind_method(D_METHOD("set_expand_icon", "enabled"), &Button::set_expand_icon);
ClassDB::bind_method(D_METHOD("is_expand_icon"), &Button::is_expand_icon);
@@ -598,6 +642,7 @@ void Button::_bind_methods() {
ADD_GROUP("Icon Behavior", "");
ADD_PROPERTY(PropertyInfo(Variant::INT, "icon_alignment", PROPERTY_HINT_ENUM, "Left,Center,Right"), "set_icon_alignment", "get_icon_alignment");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "vertical_icon_alignment", PROPERTY_HINT_ENUM, "Top,Center,Bottom"), "set_vertical_icon_alignment", "get_vertical_icon_alignment");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "expand_icon"), "set_expand_icon", "is_expand_icon");
ADD_GROUP("BiDi", "");
diff --git a/scene/gui/button.h b/scene/gui/button.h
index 3634b5344c..733f40c84e 100644
--- a/scene/gui/button.h
+++ b/scene/gui/button.h
@@ -51,7 +51,8 @@ private:
bool expand_icon = false;
bool clip_text = false;
HorizontalAlignment alignment = HORIZONTAL_ALIGNMENT_CENTER;
- HorizontalAlignment icon_alignment = HORIZONTAL_ALIGNMENT_LEFT;
+ HorizontalAlignment horizontal_icon_alignment = HORIZONTAL_ALIGNMENT_LEFT;
+ VerticalAlignment vertical_icon_alignment = VERTICAL_ALIGNMENT_CENTER;
float _internal_margin[4] = {};
struct ThemeCache {
@@ -135,7 +136,9 @@ public:
HorizontalAlignment get_text_alignment() const;
void set_icon_alignment(HorizontalAlignment p_alignment);
+ void set_vertical_icon_alignment(VerticalAlignment p_alignment);
HorizontalAlignment get_icon_alignment() const;
+ VerticalAlignment get_vertical_icon_alignment() const;
Button(const String &p_text = String());
~Button();
diff --git a/scene/gui/code_edit.cpp b/scene/gui/code_edit.cpp
index 92407e75df..d83182c775 100644
--- a/scene/gui/code_edit.cpp
+++ b/scene/gui/code_edit.cpp
@@ -1007,6 +1007,116 @@ void CodeEdit::unindent_lines() {
queue_redraw();
}
+void CodeEdit::convert_indent(int p_from_line, int p_to_line) {
+ if (!is_editable()) {
+ return;
+ }
+
+ // Check line range.
+ p_from_line = (p_from_line < 0) ? 0 : p_from_line;
+ p_to_line = (p_to_line < 0) ? get_line_count() - 1 : p_to_line;
+
+ ERR_FAIL_COND(p_from_line >= get_line_count());
+ ERR_FAIL_COND(p_to_line >= get_line_count());
+ ERR_FAIL_COND(p_to_line < p_from_line);
+
+ // Store caret states.
+ Vector<int> caret_columns;
+ Vector<Pair<int, int>> from_selections;
+ Vector<Pair<int, int>> to_selections;
+ caret_columns.resize(get_caret_count());
+ from_selections.resize(get_caret_count());
+ to_selections.resize(get_caret_count());
+ for (int c = 0; c < get_caret_count(); c++) {
+ caret_columns.write[c] = get_caret_column(c);
+
+ // Set "selection_from_line" to -1 to allow checking if there was a selection later.
+ if (!has_selection(c)) {
+ from_selections.write[c].first = -1;
+ continue;
+ }
+ from_selections.write[c].first = get_selection_from_line(c);
+ from_selections.write[c].second = get_selection_from_column(c);
+ to_selections.write[c].first = get_selection_to_line(c);
+ to_selections.write[c].second = get_selection_to_column(c);
+ }
+
+ // Check lines within range.
+ const char32_t from_indent_char = indent_using_spaces ? '\t' : ' ';
+ int size_diff = indent_using_spaces ? indent_size - 1 : -(indent_size - 1);
+ bool changed_indentation = false;
+ for (int i = p_from_line; i <= p_to_line; i++) {
+ String line = get_line(i);
+
+ if (line.length() <= 0) {
+ continue;
+ }
+
+ // Check chars in the line.
+ int j = 0;
+ int space_count = 0;
+ bool line_changed = false;
+ while (j < line.length() && (line[j] == ' ' || line[j] == '\t')) {
+ if (line[j] != from_indent_char) {
+ space_count = 0;
+ j++;
+ continue;
+ }
+ space_count++;
+
+ if (!indent_using_spaces && space_count != indent_size) {
+ j++;
+ continue;
+ }
+
+ line_changed = true;
+ if (!changed_indentation) {
+ begin_complex_operation();
+ changed_indentation = true;
+ }
+
+ // Calculate new caret state.
+ for (int c = 0; c < get_caret_count(); c++) {
+ if (get_caret_line(c) != i || caret_columns[c] <= j) {
+ continue;
+ }
+ caret_columns.write[c] += size_diff;
+
+ if (from_selections.write[c].first == -1) {
+ continue;
+ }
+ from_selections.write[c].second = from_selections[c].first == i ? from_selections[c].second + size_diff : from_selections[c].second;
+ to_selections.write[c].second = to_selections[c].first == i ? to_selections[c].second + size_diff : to_selections[c].second;
+ }
+
+ // Calculate new line.
+ line = line.left(j + ((size_diff < 0) ? size_diff : 0)) + indent_text + line.substr(j + 1);
+
+ space_count = 0;
+ j += size_diff;
+ }
+
+ if (line_changed) {
+ set_line(i, line);
+ }
+ }
+
+ if (!changed_indentation) {
+ return;
+ }
+
+ // Restore caret states.
+ for (int c = 0; c < get_caret_count(); c++) {
+ set_caret_column(caret_columns[c], c == 0, c);
+ if (from_selections.write[c].first != -1) {
+ select(from_selections.write[c].first, from_selections.write[c].second, to_selections.write[c].first, to_selections.write[c].second, c);
+ }
+ }
+ merge_overlapping_carets();
+ end_complex_operation();
+ queue_redraw();
+}
+
int CodeEdit::_calculate_spaces_till_next_left_indent(int p_column) const {
int spaces_till_indent = p_column % indent_size;
if (spaces_till_indent == 0) {
@@ -2197,6 +2307,8 @@ void CodeEdit::_bind_methods() {
ClassDB::bind_method(D_METHOD("indent_lines"), &CodeEdit::indent_lines);
ClassDB::bind_method(D_METHOD("unindent_lines"), &CodeEdit::unindent_lines);
+ ClassDB::bind_method(D_METHOD("convert_indent", "from_line", "to_line"), &CodeEdit::convert_indent, DEFVAL(-1), DEFVAL(-1));
+
/* Auto brace completion */
ClassDB::bind_method(D_METHOD("set_auto_brace_completion_enabled", "enable"), &CodeEdit::set_auto_brace_completion_enabled);
ClassDB::bind_method(D_METHOD("is_auto_brace_completion_enabled"), &CodeEdit::is_auto_brace_completion_enabled);
diff --git a/scene/gui/code_edit.h b/scene/gui/code_edit.h
index ee73758bef..a086707745 100644
--- a/scene/gui/code_edit.h
+++ b/scene/gui/code_edit.h
@@ -314,6 +314,8 @@ public:
void indent_lines();
void unindent_lines();
+ void convert_indent(int p_from_line = -1, int p_to_line = -1);
+
/* Auto brace completion */
void set_auto_brace_completion_enabled(bool p_enabled);
bool is_auto_brace_completion_enabled() const;
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index cad09a1d9f..5e861ba45d 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -67,9 +67,11 @@ void ColorPicker::_notification(int p_what) {
for (int i = 0; i < SLIDER_COUNT; i++) {
labels[i]->set_custom_minimum_size(Size2(theme_cache.label_width, 0));
+ sliders[i]->add_theme_constant_override(SNAME("center_grabber"), theme_cache.center_slider_grabbers);
set_offset((Side)i, get_offset((Side)i) + theme_cache.content_margin);
}
alpha_label->set_custom_minimum_size(Size2(theme_cache.label_width, 0));
+ alpha_label->add_theme_constant_override(SNAME("center_grabber"), theme_cache.center_slider_grabbers);
set_offset((Side)0, get_offset((Side)0) + theme_cache.content_margin);
for (int i = 0; i < MODE_BUTTON_COUNT; i++) {
@@ -122,6 +124,8 @@ void ColorPicker::_update_theme_item_cache() {
theme_cache.sv_height = get_theme_constant(SNAME("sv_height"));
theme_cache.h_width = get_theme_constant(SNAME("h_width"));
+ theme_cache.center_slider_grabbers = get_theme_constant(SNAME("center_slider_grabbers"));
+
theme_cache.screen_picker = get_theme_icon(SNAME("screen_picker"));
theme_cache.expanded_arrow = get_theme_icon(SNAME("expanded_arrow"));
theme_cache.folded_arrow = get_theme_icon(SNAME("folded_arrow"));
@@ -1909,34 +1913,23 @@ void ColorPickerButton::_modal_closed() {
void ColorPickerButton::pressed() {
_update_picker();
- Size2 size = get_size() * get_viewport()->get_canvas_transform().get_scale();
+ Size2 minsize = popup->get_contents_minimum_size();
+ float viewport_height = get_viewport_rect().size.y;
popup->reset_size();
picker->_update_presets();
picker->_update_recent_presets();
- Rect2i usable_rect = popup->get_usable_parent_rect();
- //let's try different positions to see which one we can use
-
- Rect2i cp_rect(Point2i(), popup->get_size());
- for (int i = 0; i < 4; i++) {
- if (i > 1) {
- cp_rect.position.y = get_screen_position().y - cp_rect.size.y;
- } else {
- cp_rect.position.y = get_screen_position().y + size.height;
- }
-
- if (i & 1) {
- cp_rect.position.x = get_screen_position().x;
- } else {
- cp_rect.position.x = get_screen_position().x - MAX(0, (cp_rect.size.x - size.x));
- }
-
- if (usable_rect.encloses(cp_rect)) {
- break;
- }
+ // Determine in which direction to show the popup. By default popup horizontally centered below the button.
+ // But if the popup doesn't fit below and the button is in the bottom half of the viewport, show above.
+ bool show_above = false;
+ if (get_global_position().y + get_size().y + minsize.y > viewport_height && get_global_position().y * 2 + get_size().y > viewport_height) {
+ show_above = true;
}
- popup->set_position(cp_rect.position);
+
+ float h_offset = (get_size().x - minsize.x) / 2;
+ float v_offset = show_above ? -minsize.y : get_size().y;
+ popup->set_position(get_screen_position() + Vector2(h_offset, v_offset));
popup->popup();
picker->set_focus_on_line_edit();
}
diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h
index 6e894efb00..018ae10955 100644
--- a/scene/gui/color_picker.h
+++ b/scene/gui/color_picker.h
@@ -213,6 +213,8 @@ private:
int sv_width = 0;
int h_width = 0;
+ bool center_slider_grabbers = true;
+
Ref<Texture2D> screen_picker;
Ref<Texture2D> expanded_arrow;
Ref<Texture2D> folded_arrow;
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 03f5146110..6ef39c88d8 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -1735,13 +1735,18 @@ real_t Control::get_stretch_ratio() const {
// Input events.
void Control::_call_gui_input(const Ref<InputEvent> &p_event) {
- emit_signal(SceneStringNames::get_singleton()->gui_input, p_event); //signal should be first, so it's possible to override an event (and then accept it)
+ if (p_event->get_device() != InputEvent::DEVICE_ID_INTERNAL) {
+ emit_signal(SceneStringNames::get_singleton()->gui_input, p_event); // Signal should be first, so it's possible to override an event (and then accept it).
+ }
if (!is_inside_tree() || get_viewport()->is_input_handled()) {
- return; //input was handled, abort
+ return; // Input was handled, abort.
+ }
+
+ if (p_event->get_device() != InputEvent::DEVICE_ID_INTERNAL) {
+ GDVIRTUAL_CALL(_gui_input, p_event);
}
- GDVIRTUAL_CALL(_gui_input, p_event);
if (!is_inside_tree() || get_viewport()->is_input_handled()) {
- return; //input was handled, abort
+ return; // Input was handled, abort.
}
gui_input(p_event);
}
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index 946e8a2ad5..f2f98b1889 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -62,6 +62,15 @@ GraphEditMinimap::GraphEditMinimap(GraphEdit *p_edit) {
is_resizing = false;
}
+Control::CursorShape GraphEditMinimap::get_cursor_shape(const Point2 &p_pos) const {
+ Ref<Texture2D> resizer = get_theme_icon(SNAME("resizer"));
+ if (is_resizing || (p_pos.x < resizer->get_width() && p_pos.y < resizer->get_height())) {
+ return CURSOR_FDIAGSIZE;
+ }
+
+ return Control::get_cursor_shape(p_pos);
+}
+
void GraphEditMinimap::update_minimap() {
Vector2 graph_offset = _get_graph_offset();
Vector2 graph_size = _get_graph_size();
@@ -190,6 +199,14 @@ void GraphEditMinimap::_adjust_graph_scroll(const Vector2 &p_offset) {
ge->set_scroll_ofs(p_offset + graph_offset - camera_size / 2);
}
+Control::CursorShape GraphEdit::get_cursor_shape(const Point2 &p_pos) const {
+ if (moving_selection) {
+ return CURSOR_MOVE;
+ }
+
+ return Control::get_cursor_shape(p_pos);
+}
+
PackedStringArray GraphEdit::get_configuration_warnings() const {
PackedStringArray warnings = Control::get_configuration_warnings();
diff --git a/scene/gui/graph_edit.h b/scene/gui/graph_edit.h
index dfe6b94906..8b02fbfddc 100644
--- a/scene/gui/graph_edit.h
+++ b/scene/gui/graph_edit.h
@@ -64,6 +64,8 @@ protected:
public:
GraphEditMinimap(GraphEdit *p_edit);
+ virtual CursorShape get_cursor_shape(const Point2 &p_pos = Point2i()) const override;
+
void update_minimap();
Rect2 get_camera_rect();
@@ -286,6 +288,8 @@ protected:
GDVIRTUAL4R(bool, _is_node_hover_valid, StringName, int, StringName, int);
public:
+ virtual CursorShape get_cursor_shape(const Point2 &p_pos = Point2i()) const override;
+
PackedStringArray get_configuration_warnings() const override;
Error connect_node(const StringName &p_from, int p_from_port, const StringName &p_to, int p_to_port);
diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp
index 8b2d462d85..6031730b81 100644
--- a/scene/gui/graph_node.cpp
+++ b/scene/gui/graph_node.cpp
@@ -990,7 +990,6 @@ void GraphNode::gui_input(const Ref<InputEvent> &p_ev) {
Ref<InputEventMouseMotion> mm = p_ev;
if (resizing && mm.is_valid()) {
Vector2 mpos = mm->get_position();
-
Vector2 diff = mpos - resizing_from;
emit_signal(SNAME("resize_request"), resizing_from_size + diff);
@@ -1055,6 +1054,18 @@ bool GraphNode::is_selectable() {
return selectable;
}
+Control::CursorShape GraphNode::get_cursor_shape(const Point2 &p_pos) const {
+ if (resizable) {
+ Ref<Texture2D> resizer = get_theme_icon(SNAME("resizer"));
+
+ if (resizing || (p_pos.x > get_size().x - resizer->get_width() && p_pos.y > get_size().y - resizer->get_height())) {
+ return CURSOR_FDIAGSIZE;
+ }
+ }
+
+ return Control::get_cursor_shape(p_pos);
+}
+
Vector<int> GraphNode::get_allowed_size_flags_horizontal() const {
Vector<int> flags;
flags.append(SIZE_FILL);
diff --git a/scene/gui/graph_node.h b/scene/gui/graph_node.h
index a118efb37a..e6ecc3d89b 100644
--- a/scene/gui/graph_node.h
+++ b/scene/gui/graph_node.h
@@ -197,6 +197,8 @@ public:
virtual Size2 get_minimum_size() const override;
+ virtual CursorShape get_cursor_shape(const Point2 &p_pos = Point2i()) const override;
+
virtual Vector<int> get_allowed_size_flags_horizontal() const override;
virtual Vector<int> get_allowed_size_flags_vertical() const override;
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index c23232c974..30f161d27a 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -897,7 +897,7 @@ void ItemList::gui_input(const Ref<InputEvent> &p_event) {
} else {
Ref<InputEventKey> k = p_event;
- if (k.is_valid() && k->get_unicode()) {
+ if (allow_search && k.is_valid() && k->get_unicode()) {
uint64_t now = OS::get_singleton()->get_ticks_msec();
uint64_t diff = now - search_time_msec;
uint64_t max_interval = uint64_t(GLOBAL_GET("gui/timers/incremental_search_max_interval_msec"));
@@ -1586,6 +1586,14 @@ bool ItemList::get_allow_reselect() const {
return allow_reselect;
}
+void ItemList::set_allow_search(bool p_allow) {
+ allow_search = p_allow;
+}
+
+bool ItemList::get_allow_search() const {
+ return allow_search;
+}
+
void ItemList::set_icon_scale(real_t p_scale) {
ERR_FAIL_COND(!Math::is_finite(p_scale));
icon_scale = p_scale;
@@ -1828,6 +1836,9 @@ void ItemList::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_allow_reselect", "allow"), &ItemList::set_allow_reselect);
ClassDB::bind_method(D_METHOD("get_allow_reselect"), &ItemList::get_allow_reselect);
+ ClassDB::bind_method(D_METHOD("set_allow_search", "allow"), &ItemList::set_allow_search);
+ ClassDB::bind_method(D_METHOD("get_allow_search"), &ItemList::get_allow_search);
+
ClassDB::bind_method(D_METHOD("set_auto_height", "enable"), &ItemList::set_auto_height);
ClassDB::bind_method(D_METHOD("has_auto_height"), &ItemList::has_auto_height);
@@ -1845,6 +1856,7 @@ void ItemList::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "select_mode", PROPERTY_HINT_ENUM, "Single,Multi"), "set_select_mode", "get_select_mode");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_reselect"), "set_allow_reselect", "get_allow_reselect");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_rmb_select"), "set_allow_rmb_select", "get_allow_rmb_select");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_search"), "set_allow_search", "get_allow_search");
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_text_lines", PROPERTY_HINT_RANGE, "1,10,1,or_greater"), "set_max_text_lines", "get_max_text_lines");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "auto_height"), "set_auto_height", "has_auto_height");
ADD_PROPERTY(PropertyInfo(Variant::INT, "text_overrun_behavior", PROPERTY_HINT_ENUM, "Trim Nothing,Trim Characters,Trim Words,Ellipsis,Word Ellipsis"), "set_text_overrun_behavior", "get_text_overrun_behavior");
diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h
index d050f4a9d0..cd91f97410 100644
--- a/scene/gui/item_list.h
+++ b/scene/gui/item_list.h
@@ -90,6 +90,7 @@ private:
bool ensure_selected_visible = false;
bool same_column_width = false;
+ bool allow_search = true;
bool auto_height = false;
float auto_height_value = 0.0;
@@ -258,6 +259,9 @@ public:
void set_allow_reselect(bool p_allow);
bool get_allow_reselect() const;
+ void set_allow_search(bool p_allow);
+ bool get_allow_search() const;
+
void ensure_current_is_visible();
void sort_items_by_text();
diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp
index b678f46091..85dd73beeb 100644
--- a/scene/gui/scroll_container.cpp
+++ b/scene/gui/scroll_container.cpp
@@ -482,6 +482,22 @@ int ScrollContainer::get_v_scroll() const {
return v_scroll->get_value();
}
+void ScrollContainer::set_horizontal_custom_step(float p_custom_step) {
+ h_scroll->set_custom_step(p_custom_step);
+}
+
+float ScrollContainer::get_horizontal_custom_step() const {
+ return h_scroll->get_custom_step();
+}
+
+void ScrollContainer::set_vertical_custom_step(float p_custom_step) {
+ v_scroll->set_custom_step(p_custom_step);
+}
+
+float ScrollContainer::get_vertical_custom_step() const {
+ return v_scroll->get_custom_step();
+}
+
void ScrollContainer::set_horizontal_scroll_mode(ScrollMode p_mode) {
if (horizontal_scroll_mode == p_mode) {
return;
@@ -570,6 +586,12 @@ void ScrollContainer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_v_scroll", "value"), &ScrollContainer::set_v_scroll);
ClassDB::bind_method(D_METHOD("get_v_scroll"), &ScrollContainer::get_v_scroll);
+ ClassDB::bind_method(D_METHOD("set_horizontal_custom_step", "value"), &ScrollContainer::set_horizontal_custom_step);
+ ClassDB::bind_method(D_METHOD("get_horizontal_custom_step"), &ScrollContainer::get_horizontal_custom_step);
+
+ ClassDB::bind_method(D_METHOD("set_vertical_custom_step", "value"), &ScrollContainer::set_vertical_custom_step);
+ ClassDB::bind_method(D_METHOD("get_vertical_custom_step"), &ScrollContainer::get_vertical_custom_step);
+
ClassDB::bind_method(D_METHOD("set_horizontal_scroll_mode", "enable"), &ScrollContainer::set_horizontal_scroll_mode);
ClassDB::bind_method(D_METHOD("get_horizontal_scroll_mode"), &ScrollContainer::get_horizontal_scroll_mode);
@@ -594,6 +616,8 @@ void ScrollContainer::_bind_methods() {
ADD_GROUP("Scroll", "scroll_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "scroll_horizontal", PROPERTY_HINT_NONE, "suffix:px"), "set_h_scroll", "get_h_scroll");
ADD_PROPERTY(PropertyInfo(Variant::INT, "scroll_vertical", PROPERTY_HINT_NONE, "suffix:px"), "set_v_scroll", "get_v_scroll");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "scroll_horizontal_custom_step", PROPERTY_HINT_RANGE, "-1,4096,suffix:px"), "set_horizontal_custom_step", "get_horizontal_custom_step");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "scroll_vertical_custom_step", PROPERTY_HINT_RANGE, "-1,4096,suffix:px"), "set_vertical_custom_step", "get_vertical_custom_step");
ADD_PROPERTY(PropertyInfo(Variant::INT, "horizontal_scroll_mode", PROPERTY_HINT_ENUM, "Disabled,Auto,Always Show,Never Show"), "set_horizontal_scroll_mode", "get_horizontal_scroll_mode");
ADD_PROPERTY(PropertyInfo(Variant::INT, "vertical_scroll_mode", PROPERTY_HINT_ENUM, "Disabled,Auto,Always Show,Never Show"), "set_vertical_scroll_mode", "get_vertical_scroll_mode");
ADD_PROPERTY(PropertyInfo(Variant::INT, "scroll_deadzone"), "set_deadzone", "get_deadzone");
diff --git a/scene/gui/scroll_container.h b/scene/gui/scroll_container.h
index 56bc3f8381..dbd1b3904a 100644
--- a/scene/gui/scroll_container.h
+++ b/scene/gui/scroll_container.h
@@ -98,6 +98,12 @@ public:
void set_v_scroll(int p_pos);
int get_v_scroll() const;
+ void set_horizontal_custom_step(float p_custom_step);
+ float get_horizontal_custom_step() const;
+
+ void set_vertical_custom_step(float p_custom_step);
+ float get_vertical_custom_step() const;
+
void set_horizontal_scroll_mode(ScrollMode p_mode);
ScrollMode get_horizontal_scroll_mode() const;
diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp
index 292a4cfea2..b9efa449cb 100644
--- a/scene/gui/slider.cpp
+++ b/scene/gui/slider.cpp
@@ -64,8 +64,8 @@ void Slider::gui_input(const Ref<InputEvent> &p_event) {
grab.pos = orientation == VERTICAL ? mb->get_position().y : mb->get_position().x;
- double grab_width = (double)grabber->get_size().width;
- double grab_height = (double)grabber->get_size().height;
+ double grab_width = (double)grabber->get_width();
+ double grab_height = (double)grabber->get_height();
double max = orientation == VERTICAL ? get_size().height - grab_height : get_size().width - grab_width;
if (orientation == VERTICAL) {
set_as_ratio(1 - (((double)grab.pos - (grab_height / 2.0)) / max));
@@ -103,7 +103,7 @@ void Slider::gui_input(const Ref<InputEvent> &p_event) {
if (orientation == VERTICAL) {
motion = -motion;
}
- double areasize = orientation == VERTICAL ? size.height - grabber->get_size().height : size.width - grabber->get_size().width;
+ double areasize = orientation == VERTICAL ? size.height - grabber->get_height() : size.width - grabber->get_width();
if (areasize <= 0) {
return;
}
@@ -159,6 +159,9 @@ void Slider::_update_theme_item_cache() {
theme_cache.grabber_hl_icon = get_theme_icon(SNAME("grabber_highlight"));
theme_cache.grabber_disabled_icon = get_theme_icon(SNAME("grabber_disabled"));
theme_cache.tick_icon = get_theme_icon(SNAME("tick"));
+
+ theme_cache.center_grabber = get_theme_constant(SNAME("center_grabber"));
+ theme_cache.grabber_offset = get_theme_constant(SNAME("grabber_offset"));
}
void Slider::_notification(int p_what) {
@@ -213,39 +216,41 @@ void Slider::_notification(int p_what) {
if (orientation == VERTICAL) {
int widget_width = style->get_minimum_size().width;
- double areasize = size.height - grabber->get_size().height;
+ double areasize = size.height - (theme_cache.center_grabber ? 0 : grabber->get_height());
+ int grabber_shift = theme_cache.center_grabber ? grabber->get_height() / 2 : 0;
style->draw(ci, Rect2i(Point2i(size.width / 2 - widget_width / 2, 0), Size2i(widget_width, size.height)));
- grabber_area->draw(ci, Rect2i(Point2i((size.width - widget_width) / 2, size.height - areasize * ratio - grabber->get_size().height / 2), Size2i(widget_width, areasize * ratio + grabber->get_size().height / 2)));
+ grabber_area->draw(ci, Rect2i(Point2i((size.width - widget_width) / 2, size.height - areasize * ratio - grabber->get_height() / 2 + grabber_shift), Size2i(widget_width, areasize * ratio + grabber->get_height() / 2 - grabber_shift)));
if (ticks > 1) {
- int grabber_offset = (grabber->get_size().height / 2 - tick->get_height() / 2);
+ int grabber_offset = (grabber->get_height() / 2 - tick->get_height() / 2);
for (int i = 0; i < ticks; i++) {
if (!ticks_on_borders && (i == 0 || i + 1 == ticks)) {
continue;
}
- int ofs = (i * areasize / (ticks - 1)) + grabber_offset;
+ int ofs = (i * areasize / (ticks - 1)) + grabber_offset - grabber_shift;
tick->draw(ci, Point2i((size.width - widget_width) / 2, ofs));
}
}
- grabber->draw(ci, Point2i(size.width / 2 - grabber->get_size().width / 2 + get_theme_constant(SNAME("grabber_offset")), size.height - ratio * areasize - grabber->get_size().height));
+ grabber->draw(ci, Point2i(size.width / 2 - grabber->get_width() / 2 + theme_cache.grabber_offset, size.height - ratio * areasize - grabber->get_height() + grabber_shift));
} else {
int widget_height = style->get_minimum_size().height;
- double areasize = size.width - grabber->get_size().width;
+ double areasize = size.width - (theme_cache.center_grabber ? 0 : grabber->get_size().width);
+ int grabber_shift = theme_cache.center_grabber ? -grabber->get_width() / 2 : 0;
style->draw(ci, Rect2i(Point2i(0, (size.height - widget_height) / 2), Size2i(size.width, widget_height)));
- grabber_area->draw(ci, Rect2i(Point2i(0, (size.height - widget_height) / 2), Size2i(areasize * ratio + grabber->get_size().width / 2, widget_height)));
+ grabber_area->draw(ci, Rect2i(Point2i(0, (size.height - widget_height) / 2), Size2i(areasize * ratio + grabber->get_width() / 2 + grabber_shift, widget_height)));
if (ticks > 1) {
- int grabber_offset = (grabber->get_size().width / 2 - tick->get_width() / 2);
+ int grabber_offset = (grabber->get_width() / 2 - tick->get_width() / 2);
for (int i = 0; i < ticks; i++) {
if ((!ticks_on_borders) && ((i == 0) || ((i + 1) == ticks))) {
continue;
}
- int ofs = (i * areasize / (ticks - 1)) + grabber_offset;
+ int ofs = (i * areasize / (ticks - 1)) + grabber_offset + grabber_shift;
tick->draw(ci, Point2i(ofs, (size.height - widget_height) / 2));
}
}
- grabber->draw(ci, Point2i(ratio * areasize, size.height / 2 - grabber->get_size().height / 2 + get_theme_constant(SNAME("grabber_offset"))));
+ grabber->draw(ci, Point2i(ratio * areasize + grabber_shift, size.height / 2 - grabber->get_height() / 2 + theme_cache.grabber_offset));
}
} break;
}
diff --git a/scene/gui/slider.h b/scene/gui/slider.h
index 42778684af..684445f2b3 100644
--- a/scene/gui/slider.h
+++ b/scene/gui/slider.h
@@ -58,6 +58,9 @@ class Slider : public Range {
Ref<Texture2D> grabber_hl_icon;
Ref<Texture2D> grabber_disabled_icon;
Ref<Texture2D> tick_icon;
+
+ bool center_grabber = false;
+ int grabber_offset = 0;
} theme_cache;
protected:
diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp
index 818e19ab29..1b148defc1 100644
--- a/scene/gui/tab_container.cpp
+++ b/scene/gui/tab_container.cpp
@@ -564,12 +564,12 @@ void TabContainer::add_child_notify(Node *p_child) {
}
void TabContainer::move_child_notify(Node *p_child) {
+ Container::move_child_notify(p_child);
+
if (p_child == tab_bar) {
return;
}
- Container::move_child_notify(p_child);
-
Control *c = Object::cast_to<Control>(p_child);
if (c && !c->is_set_as_top_level()) {
int old_idx = -1;
@@ -588,12 +588,12 @@ void TabContainer::move_child_notify(Node *p_child) {
}
void TabContainer::remove_child_notify(Node *p_child) {
+ Container::remove_child_notify(p_child);
+
if (p_child == tab_bar) {
return;
}
- Container::remove_child_notify(p_child);
-
Control *c = Object::cast_to<Control>(p_child);
if (!c || c->is_set_as_top_level()) {
return;
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 1564f9bc62..e29f044537 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -1851,23 +1851,28 @@ void TextEdit::gui_input(const Ref<InputEvent> &p_gui_input) {
Point2i pos = get_line_column_at_pos(mpos);
int row = pos.y;
int col = pos.x;
- int caret = carets.size() - 1;
+ bool selection_clicked = false;
if (is_move_caret_on_right_click_enabled()) {
- if (has_selection(caret)) {
- int from_line = get_selection_from_line(caret);
- int to_line = get_selection_to_line(caret);
- int from_column = get_selection_from_column(caret);
- int to_column = get_selection_to_column(caret);
-
- if (row < from_line || row > to_line || (row == from_line && col < from_column) || (row == to_line && col > to_column)) {
- // Right click is outside the selected text.
- deselect(caret);
+ if (has_selection()) {
+ for (int i = 0; i < get_caret_count(); i++) {
+ int from_line = get_selection_from_line(i);
+ int to_line = get_selection_to_line(i);
+ int from_column = get_selection_from_column(i);
+ int to_column = get_selection_to_column(i);
+
+ if (row >= from_line && row <= to_line && (row != from_line || col >= from_column) && (row != to_line || col <= to_column)) {
+ // Right click in one of the selected text
+ selection_clicked = true;
+ break;
+ }
}
}
- if (!has_selection(caret)) {
- set_caret_line(row, true, false, 0, caret);
- set_caret_column(col, true, caret);
+ if (!selection_clicked) {
+ deselect();
+ remove_secondary_carets();
+ set_caret_line(row, false, false);
+ set_caret_column(col);
}
merge_overlapping_carets();
}
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index e22890562f..18d00d519c 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -38,6 +38,7 @@
#include "core/string/print_string.h"
#include "core/string/translation.h"
#include "scene/gui/box_container.h"
+#include "scene/gui/text_edit.h"
#include "scene/main/window.h"
#include <limits.h>
@@ -166,6 +167,18 @@ TreeItem::TreeCellMode TreeItem::get_cell_mode(int p_column) const {
return cells[p_column].mode;
}
+/* multiline editable */
+void TreeItem::set_edit_multiline(int p_column, bool p_multiline) {
+ ERR_FAIL_INDEX(p_column, cells.size());
+ cells.write[p_column].edit_multiline = p_multiline;
+ _changed_notify(p_column);
+}
+
+bool TreeItem::is_edit_multiline(int p_column) const {
+ ERR_FAIL_INDEX_V(p_column, cells.size(), false);
+ return cells[p_column].edit_multiline;
+}
+
/* check mode */
void TreeItem::set_checked(int p_column, bool p_checked) {
ERR_FAIL_INDEX(p_column, cells.size());
@@ -1404,6 +1417,9 @@ void TreeItem::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_cell_mode", "column", "mode"), &TreeItem::set_cell_mode);
ClassDB::bind_method(D_METHOD("get_cell_mode", "column"), &TreeItem::get_cell_mode);
+ ClassDB::bind_method(D_METHOD("set_edit_multiline", "column", "multiline"), &TreeItem::set_edit_multiline);
+ ClassDB::bind_method(D_METHOD("is_edit_multiline", "column"), &TreeItem::is_edit_multiline);
+
ClassDB::bind_method(D_METHOD("set_checked", "column", "checked"), &TreeItem::set_checked);
ClassDB::bind_method(D_METHOD("set_indeterminate", "column", "indeterminate"), &TreeItem::set_indeterminate);
ClassDB::bind_method(D_METHOD("is_checked", "column"), &TreeItem::is_checked);
@@ -1726,7 +1742,7 @@ int Tree::compute_item_height(TreeItem *p_item) const {
}
}
}
- int item_min_height = p_item->get_custom_minimum_height();
+ int item_min_height = MAX(theme_cache.font->get_height(theme_cache.font_size), p_item->get_custom_minimum_height());
if (height < item_min_height) {
height = item_min_height;
}
@@ -1757,7 +1773,7 @@ int Tree::get_item_height(TreeItem *p_item) const {
return height;
}
-void Tree::draw_item_rect(TreeItem::Cell &p_cell, const Rect2i &p_rect, const Color &p_color, const Color &p_icon_color, int p_ol_size, const Color &p_ol_color) {
+void Tree::draw_item_rect(TreeItem::Cell &p_cell, const Rect2i &p_rect, const Point2 &p_draw_ofs, const Color &p_color, const Color &p_icon_color, int p_ol_size, const Color &p_ol_color) {
ERR_FAIL_COND(theme_cache.font.is_null());
Rect2i rect = p_rect;
@@ -1795,7 +1811,7 @@ void Tree::draw_item_rect(TreeItem::Cell &p_cell, const Rect2i &p_rect, const Co
if (rtl && rect.size.width > 0) {
Point2 draw_pos = rect.position;
- draw_pos.y += Math::floor((rect.size.y - p_cell.text_buf->get_size().y) / 2.0);
+ draw_pos.y += Math::floor(p_draw_ofs.y) - _get_title_button_height();
p_cell.text_buf->set_width(rect.size.width);
if (p_ol_size > 0 && p_ol_color.a > 0) {
p_cell.text_buf->draw_outline(ci, draw_pos, p_ol_size, p_ol_color);
@@ -1815,7 +1831,7 @@ void Tree::draw_item_rect(TreeItem::Cell &p_cell, const Rect2i &p_rect, const Co
if (!rtl && rect.size.width > 0) {
Point2 draw_pos = rect.position;
- draw_pos.y += Math::floor((rect.size.y - p_cell.text_buf->get_size().y) / 2.0);
+ draw_pos.y += Math::floor(p_draw_ofs.y) - _get_title_button_height();
p_cell.text_buf->set_width(rect.size.width);
if (p_ol_size > 0 && p_ol_color.a > 0) {
p_cell.text_buf->draw_outline(ci, draw_pos, p_ol_size, p_ol_color);
@@ -2108,12 +2124,12 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
}
Point2i text_pos = item_rect.position;
- text_pos.y += Math::floor((item_rect.size.y - p_item->cells[i].text_buf->get_size().y) / 2);
+ text_pos.y += Math::floor(p_draw_ofs.y) - _get_title_button_height();
int text_width = p_item->cells[i].text_buf->get_size().x;
switch (p_item->cells[i].mode) {
case TreeItem::CELL_MODE_STRING: {
- draw_item_rect(p_item->cells.write[i], item_rect, cell_color, icon_col, outline_size, font_outline_color);
+ draw_item_rect(p_item->cells.write[i], item_rect, p_draw_ofs, cell_color, icon_col, outline_size, font_outline_color);
} break;
case TreeItem::CELL_MODE_CHECK: {
Ref<Texture2D> checked = theme_cache.checked;
@@ -2137,7 +2153,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
item_rect.size.x -= check_w;
item_rect.position.x += check_w;
- draw_item_rect(p_item->cells.write[i], item_rect, cell_color, icon_col, outline_size, font_outline_color);
+ draw_item_rect(p_item->cells.write[i], item_rect, p_draw_ofs, cell_color, icon_col, outline_size, font_outline_color);
} break;
case TreeItem::CELL_MODE_RANGE: {
@@ -2216,7 +2232,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
}
if (!p_item->cells[i].editable) {
- draw_item_rect(p_item->cells.write[i], item_rect, cell_color, icon_col, outline_size, font_outline_color);
+ draw_item_rect(p_item->cells.write[i], item_rect, p_draw_ofs, cell_color, icon_col, outline_size, font_outline_color);
break;
}
@@ -2244,7 +2260,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
ir.position += theme_cache.custom_button->get_offset();
}
- draw_item_rect(p_item->cells.write[i], ir, cell_color, icon_col, outline_size, font_outline_color);
+ draw_item_rect(p_item->cells.write[i], ir, p_draw_ofs, cell_color, icon_col, outline_size, font_outline_color);
downarrow->draw(ci, arrow_pos);
@@ -2975,7 +2991,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, int
return item_h; // nothing found
}
-void Tree::_text_editor_modal_close() {
+void Tree::_text_editor_popup_modal_close() {
if (Input::get_singleton()->is_key_pressed(Key::ESCAPE) ||
Input::get_singleton()->is_key_pressed(Key::KP_ENTER) ||
Input::get_singleton()->is_key_pressed(Key::ENTER)) {
@@ -2986,10 +3002,51 @@ void Tree::_text_editor_modal_close() {
return;
}
- _text_editor_submit(text_editor->get_text());
+ if (!popup_edited_item) {
+ return;
+ }
+
+ if (popup_edited_item->is_edit_multiline(popup_edited_item_col) && popup_edited_item->get_cell_mode(popup_edited_item_col) == TreeItem::CELL_MODE_STRING) {
+ _apply_multiline_edit();
+ } else {
+ _line_editor_submit(line_editor->get_text());
+ }
+}
+
+void Tree::_text_editor_gui_input(const Ref<InputEvent> &p_event) {
+ if (p_event->is_action_pressed("ui_text_newline_blank", true)) {
+ accept_event();
+ } else if (p_event->is_action_pressed("ui_text_newline")) {
+ popup_editor->hide();
+ _apply_multiline_edit();
+ accept_event();
+ }
+}
+
+void Tree::_apply_multiline_edit() {
+ if (!popup_edited_item) {
+ return;
+ }
+
+ if (popup_edited_item_col < 0 || popup_edited_item_col > columns.size()) {
+ return;
+ }
+
+ TreeItem::Cell &c = popup_edited_item->cells.write[popup_edited_item_col];
+ switch (c.mode) {
+ case TreeItem::CELL_MODE_STRING: {
+ c.text = text_editor->get_text();
+ } break;
+ default: {
+ ERR_FAIL();
+ }
+ }
+
+ item_edited(popup_edited_item_col, popup_edited_item);
+ queue_redraw();
}
-void Tree::_text_editor_submit(String p_text) {
+void Tree::_line_editor_submit(String p_text) {
popup_editor->hide();
if (!popup_edited_item) {
@@ -3395,7 +3452,7 @@ void Tree::gui_input(const Ref<InputEvent> &p_event) {
accept_event();
}
- if (k.is_valid()) { // Incremental search
+ if (allow_search && k.is_valid()) { // Incremental search
if (!k->is_pressed()) {
return;
@@ -3830,18 +3887,16 @@ bool Tree::edit_selected() {
popup_menu->popup();
popup_edited_item = s;
popup_edited_item_col = col;
- return true;
- } else if (c.mode == TreeItem::CELL_MODE_STRING || c.mode == TreeItem::CELL_MODE_RANGE) {
+ return true;
+ } else if ((c.mode == TreeItem::CELL_MODE_STRING && !c.edit_multiline) || c.mode == TreeItem::CELL_MODE_RANGE) {
Rect2 popup_rect;
int value_editor_height = c.mode == TreeItem::CELL_MODE_RANGE ? value_editor->get_minimum_size().height : 0;
// "floor()" centers vertically.
- Vector2 ofs(0, Math::floor((MAX(text_editor->get_minimum_size().height, rect.size.height - value_editor_height) - rect.size.height) / 2));
+ Vector2 ofs(0, Math::floor((MAX(line_editor->get_minimum_size().height, rect.size.height - value_editor_height) - rect.size.height) / 2));
- Point2i textedpos = get_screen_position() + rect.position - ofs;
- cache.text_editor_position = textedpos;
- popup_rect.position = textedpos;
+ popup_rect.position = get_screen_position() + rect.position - ofs;
popup_rect.size = rect.size;
// Account for icon.
@@ -3849,9 +3904,12 @@ bool Tree::edit_selected() {
popup_rect.position.x += icon_size.x;
popup_rect.size.x -= icon_size.x;
- text_editor->clear();
- text_editor->set_text(c.mode == TreeItem::CELL_MODE_STRING ? c.text : String::num(c.val, Math::range_step_decimals(c.step)));
- text_editor->select_all();
+ line_editor->clear();
+ line_editor->set_text(c.mode == TreeItem::CELL_MODE_STRING ? c.text : String::num(c.val, Math::range_step_decimals(c.step)));
+ line_editor->select_all();
+ line_editor->show();
+
+ text_editor->hide();
if (c.mode == TreeItem::CELL_MODE_RANGE) {
popup_rect.size.y += value_editor_height;
@@ -3873,6 +3931,22 @@ bool Tree::edit_selected() {
popup_editor->popup();
popup_editor->child_controls_changed();
+ line_editor->grab_focus();
+
+ return true;
+ } else if (c.mode == TreeItem::CELL_MODE_STRING && c.edit_multiline) {
+ line_editor->hide();
+
+ text_editor->clear();
+ text_editor->set_text(c.text);
+ text_editor->select_all();
+ text_editor->show();
+
+ popup_editor->set_position(get_screen_position() + rect.position);
+ popup_editor->set_size(rect.size);
+ popup_editor->popup();
+ popup_editor->child_controls_changed();
+
text_editor->grab_focus();
return true;
@@ -4144,14 +4218,10 @@ void Tree::_notification(int p_what) {
case NOTIFICATION_TRANSFORM_CHANGED: {
if (popup_edited_item != nullptr) {
Rect2 rect = popup_edited_item->get_meta("__focus_rect");
- Vector2 ofs(0, (text_editor->get_size().height - rect.size.height) / 2);
- Point2i textedpos = get_global_position() + rect.position - ofs;
- if (cache.text_editor_position != textedpos) {
- cache.text_editor_position = textedpos;
- text_editor->set_position(textedpos);
- value_editor->set_position(textedpos + Point2i(0, text_editor->get_size().height));
- }
+ popup_editor->set_position(get_global_position() + rect.position);
+ popup_editor->set_size(rect.size);
+ popup_editor->child_controls_changed();
}
} break;
}
@@ -5246,6 +5316,14 @@ bool Tree::get_allow_reselect() const {
return allow_reselect;
}
+void Tree::set_allow_search(bool p_allow) {
+ allow_search = p_allow;
+}
+
+bool Tree::get_allow_search() const {
+ return allow_search;
+}
+
void Tree::_bind_methods() {
ClassDB::bind_method(D_METHOD("clear"), &Tree::clear);
ClassDB::bind_method(D_METHOD("create_item", "parent", "index"), &Tree::create_item, DEFVAL(Variant()), DEFVAL(-1));
@@ -5326,10 +5404,14 @@ void Tree::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_allow_reselect", "allow"), &Tree::set_allow_reselect);
ClassDB::bind_method(D_METHOD("get_allow_reselect"), &Tree::get_allow_reselect);
+ ClassDB::bind_method(D_METHOD("set_allow_search", "allow"), &Tree::set_allow_search);
+ ClassDB::bind_method(D_METHOD("get_allow_search"), &Tree::get_allow_search);
+
ADD_PROPERTY(PropertyInfo(Variant::INT, "columns"), "set_columns", "get_columns");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "column_titles_visible"), "set_column_titles_visible", "are_column_titles_visible");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_reselect"), "set_allow_reselect", "get_allow_reselect");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_rmb_select"), "set_allow_rmb_select", "get_allow_rmb_select");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_search"), "set_allow_search", "get_allow_search");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "hide_folding"), "set_hide_folding", "is_folding_hidden");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enable_recursive_folding"), "set_enable_recursive_folding", "is_recursive_folding_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "hide_root"), "set_hide_root", "is_root_hidden");
@@ -5374,17 +5456,26 @@ Tree::Tree() {
popup_editor = memnew(Popup);
add_child(popup_editor, false, INTERNAL_MODE_FRONT);
+
popup_editor_vb = memnew(VBoxContainer);
- popup_editor->add_child(popup_editor_vb);
popup_editor_vb->add_theme_constant_override("separation", 0);
popup_editor_vb->set_anchors_and_offsets_preset(PRESET_FULL_RECT);
- text_editor = memnew(LineEdit);
- popup_editor_vb->add_child(text_editor);
+ popup_editor->add_child(popup_editor_vb);
+
+ line_editor = memnew(LineEdit);
+ line_editor->set_v_size_flags(SIZE_EXPAND_FILL);
+ line_editor->hide();
+ popup_editor_vb->add_child(line_editor);
+
+ text_editor = memnew(TextEdit);
text_editor->set_v_size_flags(SIZE_EXPAND_FILL);
+ text_editor->hide();
+ popup_editor_vb->add_child(text_editor);
+
value_editor = memnew(HSlider);
- popup_editor_vb->add_child(value_editor);
value_editor->set_v_size_flags(SIZE_EXPAND_FILL);
value_editor->hide();
+ popup_editor_vb->add_child(value_editor);
h_scroll = memnew(HScrollBar);
v_scroll = memnew(VScrollBar);
@@ -5398,8 +5489,9 @@ Tree::Tree() {
h_scroll->connect("value_changed", callable_mp(this, &Tree::_scroll_moved));
v_scroll->connect("value_changed", callable_mp(this, &Tree::_scroll_moved));
- text_editor->connect("text_submitted", callable_mp(this, &Tree::_text_editor_submit));
- popup_editor->connect("popup_hide", callable_mp(this, &Tree::_text_editor_modal_close));
+ line_editor->connect("text_submitted", callable_mp(this, &Tree::_line_editor_submit));
+ text_editor->connect("gui_input", callable_mp(this, &Tree::_text_editor_gui_input));
+ popup_editor->connect("popup_hide", callable_mp(this, &Tree::_text_editor_popup_modal_close));
popup_menu->connect("id_pressed", callable_mp(this, &Tree::popup_select));
value_editor->connect("value_changed", callable_mp(this, &Tree::value_editor_changed));
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index 42fc719f46..75ce6b689d 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -36,8 +36,9 @@
#include "scene/gui/popup_menu.h"
#include "scene/gui/scroll_bar.h"
#include "scene/gui/slider.h"
-#include "scene/resources/text_line.h"
+#include "scene/resources/text_paragraph.h"
+class TextEdit;
class Tree;
class TreeItem : public Object {
@@ -61,8 +62,9 @@ private:
Ref<Texture2D> icon;
Rect2i icon_region;
String text;
+ bool edit_multiline = false;
String suffix;
- Ref<TextLine> text_buf;
+ Ref<TextParagraph> text_buf;
String language;
TextServer::StructuredTextParser st_parser = TextServer::STRUCTURED_TEXT_DEFAULT;
Array st_args;
@@ -198,6 +200,10 @@ public:
void set_cell_mode(int p_column, TreeCellMode p_mode);
TreeCellMode get_cell_mode(int p_column) const;
+ /* multiline editable */
+ void set_edit_multiline(int p_column, bool p_multiline);
+ bool is_edit_multiline(int p_column) const;
+
/* check mode */
void set_checked(int p_column, bool p_checked);
void set_indeterminate(int p_column, bool p_indeterminate);
@@ -436,7 +442,7 @@ private:
bool clip_content = false;
String title;
HorizontalAlignment title_alignment = HORIZONTAL_ALIGNMENT_CENTER;
- Ref<TextLine> text_buf;
+ Ref<TextParagraph> text_buf;
String language;
Control::TextDirection text_direction = Control::TEXT_DIRECTION_INHERITED;
ColumnInfo() {
@@ -449,7 +455,8 @@ private:
VBoxContainer *popup_editor_vb = nullptr;
Popup *popup_editor = nullptr;
- LineEdit *text_editor = nullptr;
+ LineEdit *line_editor = nullptr;
+ TextEdit *text_editor = nullptr;
HSlider *value_editor = nullptr;
bool updating_value_editor = false;
uint64_t focus_in_id = 0;
@@ -469,12 +476,14 @@ private:
void update_item_cell(TreeItem *p_item, int p_col);
void update_item_cache(TreeItem *p_item);
//void draw_item_text(String p_text,const Ref<Texture2D>& p_icon,int p_icon_max_w,bool p_tool,Rect2i p_rect,const Color& p_color);
- void draw_item_rect(TreeItem::Cell &p_cell, const Rect2i &p_rect, const Color &p_color, const Color &p_icon_color, int p_ol_size, const Color &p_ol_color);
+ void draw_item_rect(TreeItem::Cell &p_cell, const Rect2i &p_rect, const Point2 &p_draw_ofs, const Color &p_color, const Color &p_icon_color, int p_ol_size, const Color &p_ol_color);
int draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 &p_draw_size, TreeItem *p_item);
void select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_col, TreeItem *p_prev = nullptr, bool *r_in_range = nullptr, bool p_force_deselect = false);
int propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, int x_limit, bool p_double_click, TreeItem *p_item, MouseButton p_button, const Ref<InputEventWithModifiers> &p_mod);
- void _text_editor_submit(String p_text);
- void _text_editor_modal_close();
+ void _line_editor_submit(String p_text);
+ void _apply_multiline_edit();
+ void _text_editor_popup_modal_close();
+ void _text_editor_gui_input(const Ref<InputEvent> &p_event);
void value_editor_changed(double p_value);
void popup_select(int p_option);
@@ -578,8 +587,6 @@ private:
TreeItem *hover_item = nullptr;
int hover_cell = -1;
- Point2i text_editor_position;
-
bool rtl = false;
} cache;
@@ -625,6 +632,7 @@ private:
bool scrolling = false;
bool allow_reselect = false;
+ bool allow_search = true;
bool force_edit_checkbox_only_on_checkbox = false;
@@ -753,6 +761,9 @@ public:
void set_allow_reselect(bool p_allow);
bool get_allow_reselect() const;
+ void set_allow_search(bool p_allow);
+ bool get_allow_search() const;
+
Size2 get_minimum_size() const override;
Tree();
diff --git a/scene/main/canvas_item.cpp b/scene/main/canvas_item.cpp
index 71602d6243..279ac7953d 100644
--- a/scene/main/canvas_item.cpp
+++ b/scene/main/canvas_item.cpp
@@ -569,8 +569,7 @@ void CanvasItem::draw_line(const Point2 &p_from, const Point2 &p_to, const Color
void CanvasItem::draw_polyline(const Vector<Point2> &p_points, const Color &p_color, real_t p_width, bool p_antialiased) {
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
- Vector<Color> colors;
- colors.push_back(p_color);
+ Vector<Color> colors = { p_color };
RenderingServer::get_singleton()->canvas_item_add_polyline(canvas_item, p_points, colors, p_width, p_antialiased);
}
@@ -598,8 +597,7 @@ void CanvasItem::draw_arc(const Vector2 &p_center, real_t p_radius, real_t p_sta
void CanvasItem::draw_multiline(const Vector<Point2> &p_points, const Color &p_color, real_t p_width) {
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
- Vector<Color> colors;
- colors.push_back(p_color);
+ Vector<Color> colors = { p_color };
RenderingServer::get_singleton()->canvas_item_add_multiline(canvas_item, p_points, colors, p_width);
}
@@ -727,8 +725,7 @@ void CanvasItem::draw_polygon(const Vector<Point2> &p_points, const Vector<Color
void CanvasItem::draw_colored_polygon(const Vector<Point2> &p_points, const Color &p_color, const Vector<Point2> &p_uvs, Ref<Texture2D> p_texture) {
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
- Vector<Color> colors;
- colors.push_back(p_color);
+ Vector<Color> colors = { p_color };
RID rid = p_texture.is_valid() ? p_texture->get_rid() : RID();
RenderingServer::get_singleton()->canvas_item_add_polygon(canvas_item, p_points, colors, p_uvs, rid);
}
diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp
index 0d53f740db..ddc694f894 100644
--- a/scene/main/http_request.cpp
+++ b/scene/main/http_request.cpp
@@ -190,7 +190,9 @@ void HTTPRequest::cancel_request() {
set_process_internal(false);
} else {
thread_request_quit.set();
- thread.wait_to_finish();
+ if (thread.is_started()) {
+ thread.wait_to_finish();
+ }
}
file.unref();
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 2082736653..b947526e96 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -2791,7 +2791,9 @@ void Node::request_ready() {
}
void Node::_call_input(const Ref<InputEvent> &p_event) {
- GDVIRTUAL_CALL(_input, p_event);
+ if (p_event->get_device() != InputEvent::DEVICE_ID_INTERNAL) {
+ GDVIRTUAL_CALL(_input, p_event);
+ }
if (!is_inside_tree() || !get_viewport() || get_viewport()->is_input_handled()) {
return;
}
@@ -2799,7 +2801,9 @@ void Node::_call_input(const Ref<InputEvent> &p_event) {
}
void Node::_call_shortcut_input(const Ref<InputEvent> &p_event) {
- GDVIRTUAL_CALL(_shortcut_input, p_event);
+ if (p_event->get_device() != InputEvent::DEVICE_ID_INTERNAL) {
+ GDVIRTUAL_CALL(_shortcut_input, p_event);
+ }
if (!is_inside_tree() || !get_viewport() || get_viewport()->is_input_handled()) {
return;
}
@@ -2807,7 +2811,9 @@ void Node::_call_shortcut_input(const Ref<InputEvent> &p_event) {
}
void Node::_call_unhandled_input(const Ref<InputEvent> &p_event) {
- GDVIRTUAL_CALL(_unhandled_input, p_event);
+ if (p_event->get_device() != InputEvent::DEVICE_ID_INTERNAL) {
+ GDVIRTUAL_CALL(_unhandled_input, p_event);
+ }
if (!is_inside_tree() || !get_viewport() || get_viewport()->is_input_handled()) {
return;
}
@@ -2815,7 +2821,9 @@ void Node::_call_unhandled_input(const Ref<InputEvent> &p_event) {
}
void Node::_call_unhandled_key_input(const Ref<InputEvent> &p_event) {
- GDVIRTUAL_CALL(_unhandled_key_input, p_event);
+ if (p_event->get_device() != InputEvent::DEVICE_ID_INTERNAL) {
+ GDVIRTUAL_CALL(_unhandled_key_input, p_event);
+ }
if (!is_inside_tree() || !get_viewport() || get_viewport()->is_input_handled()) {
return;
}
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index f3c2f4b0cc..07560b4a82 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -2601,6 +2601,10 @@ bool Viewport::_sub_windows_forward_input(const Ref<InputEvent> &p_event) {
}
gui.subwindow_focused->_rect_changed_callback(new_rect);
+
+ if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_CURSOR_SHAPE)) {
+ DisplayServer::get_singleton()->cursor_set_shape(DisplayServer::CURSOR_MOVE);
+ }
}
if (gui.subwindow_drag == SUB_WINDOW_DRAG_CLOSE) {
gui.subwindow_drag_close_inside = gui.subwindow_drag_close_rect.has_point(mm->get_position());
diff --git a/scene/main/window.cpp b/scene/main/window.cpp
index d16a12fcff..3d11e6647e 100644
--- a/scene/main/window.cpp
+++ b/scene/main/window.cpp
@@ -1377,7 +1377,9 @@ void Window::_window_input(const Ref<InputEvent> &p_ev) {
}
}
- emit_signal(SceneStringNames::get_singleton()->window_input, p_ev);
+ if (p_ev->get_device() != InputEvent::DEVICE_ID_INTERNAL) {
+ emit_signal(SceneStringNames::get_singleton()->window_input, p_ev);
+ }
if (is_inside_tree()) {
push_input(p_ev);
diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp
index bfbc92a8d4..7078d60de5 100644
--- a/scene/resources/animation.cpp
+++ b/scene/resources/animation.cpp
@@ -1088,7 +1088,7 @@ Error Animation::position_track_get_key(int p_track, int p_key, Vector3 *r_posit
return OK;
}
-Error Animation::position_track_interpolate(int p_track, double p_time, Vector3 *r_interpolation) const {
+Error Animation::try_position_track_interpolate(int p_track, double p_time, Vector3 *r_interpolation) const {
ERR_FAIL_INDEX_V(p_track, tracks.size(), ERR_INVALID_PARAMETER);
Track *t = tracks[p_track];
ERR_FAIL_COND_V(t->type != TYPE_POSITION_3D, ERR_INVALID_PARAMETER);
@@ -1114,6 +1114,14 @@ Error Animation::position_track_interpolate(int p_track, double p_time, Vector3
return OK;
}
+Vector3 Animation::position_track_interpolate(int p_track, double p_time) const {
+ Vector3 ret = Vector3(0, 0, 0);
+ ERR_FAIL_INDEX_V(p_track, tracks.size(), ret);
+ bool err = try_position_track_interpolate(p_track, p_time, &ret);
+ ERR_FAIL_COND_V_MSG(err, ret, "3D Position Track: '" + tracks[p_track]->path + "' is unavailable.");
+ return ret;
+}
+
////
int Animation::rotation_track_insert_key(int p_track, double p_time, const Quaternion &p_rotation) {
@@ -1160,7 +1168,7 @@ Error Animation::rotation_track_get_key(int p_track, int p_key, Quaternion *r_ro
return OK;
}
-Error Animation::rotation_track_interpolate(int p_track, double p_time, Quaternion *r_interpolation) const {
+Error Animation::try_rotation_track_interpolate(int p_track, double p_time, Quaternion *r_interpolation) const {
ERR_FAIL_INDEX_V(p_track, tracks.size(), ERR_INVALID_PARAMETER);
Track *t = tracks[p_track];
ERR_FAIL_COND_V(t->type != TYPE_ROTATION_3D, ERR_INVALID_PARAMETER);
@@ -1186,6 +1194,14 @@ Error Animation::rotation_track_interpolate(int p_track, double p_time, Quaterni
return OK;
}
+Quaternion Animation::rotation_track_interpolate(int p_track, double p_time) const {
+ Quaternion ret = Quaternion(0, 0, 0, 1);
+ ERR_FAIL_INDEX_V(p_track, tracks.size(), ret);
+ bool err = try_rotation_track_interpolate(p_track, p_time, &ret);
+ ERR_FAIL_COND_V_MSG(err, ret, "3D Rotation Track: '" + tracks[p_track]->path + "' is unavailable.");
+ return ret;
+}
+
////
int Animation::scale_track_insert_key(int p_track, double p_time, const Vector3 &p_scale) {
@@ -1232,7 +1248,7 @@ Error Animation::scale_track_get_key(int p_track, int p_key, Vector3 *r_scale) c
return OK;
}
-Error Animation::scale_track_interpolate(int p_track, double p_time, Vector3 *r_interpolation) const {
+Error Animation::try_scale_track_interpolate(int p_track, double p_time, Vector3 *r_interpolation) const {
ERR_FAIL_INDEX_V(p_track, tracks.size(), ERR_INVALID_PARAMETER);
Track *t = tracks[p_track];
ERR_FAIL_COND_V(t->type != TYPE_SCALE_3D, ERR_INVALID_PARAMETER);
@@ -1258,6 +1274,16 @@ Error Animation::scale_track_interpolate(int p_track, double p_time, Vector3 *r_
return OK;
}
+Vector3 Animation::scale_track_interpolate(int p_track, double p_time) const {
+ Vector3 ret = Vector3(1, 1, 1);
+ ERR_FAIL_INDEX_V(p_track, tracks.size(), ret);
+ bool err = try_scale_track_interpolate(p_track, p_time, &ret);
+ ERR_FAIL_COND_V_MSG(err, ret, "3D Scale Track: '" + tracks[p_track]->path + "' is unavailable.");
+ return ret;
+}
+
+////
+
int Animation::blend_shape_track_insert_key(int p_track, double p_time, float p_blend_shape) {
ERR_FAIL_INDEX_V(p_track, tracks.size(), -1);
Track *t = tracks[p_track];
@@ -1302,7 +1328,7 @@ Error Animation::blend_shape_track_get_key(int p_track, int p_key, float *r_blen
return OK;
}
-Error Animation::blend_shape_track_interpolate(int p_track, double p_time, float *r_interpolation) const {
+Error Animation::try_blend_shape_track_interpolate(int p_track, double p_time, float *r_interpolation) const {
ERR_FAIL_INDEX_V(p_track, tracks.size(), ERR_INVALID_PARAMETER);
Track *t = tracks[p_track];
ERR_FAIL_COND_V(t->type != TYPE_BLEND_SHAPE, ERR_INVALID_PARAMETER);
@@ -1328,6 +1354,16 @@ Error Animation::blend_shape_track_interpolate(int p_track, double p_time, float
return OK;
}
+float Animation::blend_shape_track_interpolate(int p_track, double p_time) const {
+ float ret = 0;
+ ERR_FAIL_INDEX_V(p_track, tracks.size(), ret);
+ bool err = try_blend_shape_track_interpolate(p_track, p_time, &ret);
+ ERR_FAIL_COND_V_MSG(err, ret, "Blend Shape Track: '" + tracks[p_track]->path + "' is unavailable.");
+ return ret;
+}
+
+////
+
void Animation::track_remove_key_at_time(int p_track, double p_time) {
int idx = track_find_key(p_track, p_time, FIND_MODE_APPROX);
ERR_FAIL_COND(idx < 0);
@@ -3796,6 +3832,11 @@ void Animation::_bind_methods() {
ClassDB::bind_method(D_METHOD("scale_track_insert_key", "track_idx", "time", "scale"), &Animation::scale_track_insert_key);
ClassDB::bind_method(D_METHOD("blend_shape_track_insert_key", "track_idx", "time", "amount"), &Animation::blend_shape_track_insert_key);
+ ClassDB::bind_method(D_METHOD("position_track_interpolate", "track_idx", "time_sec"), &Animation::position_track_interpolate);
+ ClassDB::bind_method(D_METHOD("rotation_track_interpolate", "track_idx", "time_sec"), &Animation::rotation_track_interpolate);
+ ClassDB::bind_method(D_METHOD("scale_track_interpolate", "track_idx", "time_sec"), &Animation::scale_track_interpolate);
+ ClassDB::bind_method(D_METHOD("blend_shape_track_interpolate", "track_idx", "time_sec"), &Animation::blend_shape_track_interpolate);
+
ClassDB::bind_method(D_METHOD("track_insert_key", "track_idx", "time", "key", "transition"), &Animation::track_insert_key, DEFVAL(1));
ClassDB::bind_method(D_METHOD("track_remove_key", "track_idx", "key_idx"), &Animation::track_remove_key);
ClassDB::bind_method(D_METHOD("track_remove_key_at_time", "track_idx", "time"), &Animation::track_remove_key_at_time);
@@ -4551,7 +4592,7 @@ Vector3i Animation::_compress_key(uint32_t p_track, const AABB &p_bounds, int32_
if (p_key >= 0) {
position_track_get_key(p_track, p_key, &pos);
} else {
- position_track_interpolate(p_track, p_time, &pos);
+ try_position_track_interpolate(p_track, p_time, &pos);
}
pos = (pos - p_bounds.position) / p_bounds.size;
for (int j = 0; j < 3; j++) {
@@ -4563,7 +4604,7 @@ Vector3i Animation::_compress_key(uint32_t p_track, const AABB &p_bounds, int32_
if (p_key >= 0) {
rotation_track_get_key(p_track, p_key, &rot);
} else {
- rotation_track_interpolate(p_track, p_time, &rot);
+ try_rotation_track_interpolate(p_track, p_time, &rot);
}
Vector3 axis = rot.get_axis();
float angle = rot.get_angle();
@@ -4580,7 +4621,7 @@ Vector3i Animation::_compress_key(uint32_t p_track, const AABB &p_bounds, int32_
if (p_key >= 0) {
scale_track_get_key(p_track, p_key, &scale);
} else {
- scale_track_interpolate(p_track, p_time, &scale);
+ try_scale_track_interpolate(p_track, p_time, &scale);
}
scale = (scale - p_bounds.position) / p_bounds.size;
for (int j = 0; j < 3; j++) {
@@ -4592,7 +4633,7 @@ Vector3i Animation::_compress_key(uint32_t p_track, const AABB &p_bounds, int32_
if (p_key >= 0) {
blend_shape_track_get_key(p_track, p_key, &blend);
} else {
- blend_shape_track_interpolate(p_track, p_time, &blend);
+ try_blend_shape_track_interpolate(p_track, p_time, &blend);
}
blend = (blend / float(Compression::BLEND_SHAPE_RANGE)) * 0.5 + 0.5;
diff --git a/scene/resources/animation.h b/scene/resources/animation.h
index 2c2ddb7095..c128c14e49 100644
--- a/scene/resources/animation.h
+++ b/scene/resources/animation.h
@@ -410,19 +410,23 @@ public:
int position_track_insert_key(int p_track, double p_time, const Vector3 &p_position);
Error position_track_get_key(int p_track, int p_key, Vector3 *r_position) const;
- Error position_track_interpolate(int p_track, double p_time, Vector3 *r_interpolation) const;
+ Error try_position_track_interpolate(int p_track, double p_time, Vector3 *r_interpolation) const;
+ Vector3 position_track_interpolate(int p_track, double p_time) const;
int rotation_track_insert_key(int p_track, double p_time, const Quaternion &p_rotation);
Error rotation_track_get_key(int p_track, int p_key, Quaternion *r_rotation) const;
- Error rotation_track_interpolate(int p_track, double p_time, Quaternion *r_interpolation) const;
+ Error try_rotation_track_interpolate(int p_track, double p_time, Quaternion *r_interpolation) const;
+ Quaternion rotation_track_interpolate(int p_track, double p_time) const;
int scale_track_insert_key(int p_track, double p_time, const Vector3 &p_scale);
Error scale_track_get_key(int p_track, int p_key, Vector3 *r_scale) const;
- Error scale_track_interpolate(int p_track, double p_time, Vector3 *r_interpolation) const;
+ Error try_scale_track_interpolate(int p_track, double p_time, Vector3 *r_interpolation) const;
+ Vector3 scale_track_interpolate(int p_track, double p_time) const;
int blend_shape_track_insert_key(int p_track, double p_time, float p_blend);
Error blend_shape_track_get_key(int p_track, int p_key, float *r_blend) const;
- Error blend_shape_track_interpolate(int p_track, double p_time, float *r_blend) const;
+ Error try_blend_shape_track_interpolate(int p_track, double p_time, float *r_blend) const;
+ float blend_shape_track_interpolate(int p_track, double p_time) const;
void track_set_interpolation_type(int p_track, InterpolationType p_interp);
InterpolationType track_get_interpolation_type(int p_track) const;
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index 06daa5a46f..1bfcf8d3ac 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -565,6 +565,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_icon("grabber_disabled", "HSlider", icons["slider_grabber_disabled"]);
theme->set_icon("tick", "HSlider", icons["hslider_tick"]);
+ theme->set_constant("center_grabber", "HSlider", 0);
theme->set_constant("grabber_offset", "HSlider", 0);
// VSlider
@@ -578,6 +579,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_icon("grabber_disabled", "VSlider", icons["slider_grabber_disabled"]);
theme->set_icon("tick", "VSlider", icons["vslider_tick"]);
+ theme->set_constant("center_grabber", "VSlider", 0);
theme->set_constant("grabber_offset", "VSlider", 0);
// SpinBox
@@ -909,6 +911,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_constant("sv_height", "ColorPicker", 256 * scale);
theme->set_constant("h_width", "ColorPicker", 30 * scale);
theme->set_constant("label_width", "ColorPicker", 10 * scale);
+ theme->set_constant("center_slider_grabbers", "ColorPicker", 1);
theme->set_icon("folded_arrow", "ColorPicker", icons["arrow_right"]);
theme->set_icon("expanded_arrow", "ColorPicker", icons["arrow_down"]);
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index 3deb1ccaab..d0aa224773 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -211,6 +211,7 @@ void ShaderMaterial::_get_property_list(List<PropertyInfo> *p_list) const {
shader->get_shader_uniform_list(&list, true);
HashMap<String, HashMap<String, List<PropertyInfo>>> groups;
+ LocalVector<Pair<String, LocalVector<String>>> vgroups;
{
HashMap<String, List<PropertyInfo>> none_subgroup;
none_subgroup.insert("<None>", List<PropertyInfo>());
@@ -248,6 +249,7 @@ void ShaderMaterial::_get_property_list(List<PropertyInfo> *p_list) const {
subgroup_map.insert("<None>", none_subgroup);
groups.insert(last_group, subgroup_map);
+ vgroups.push_back(Pair<String, LocalVector<String>>(last_group, { "<None>" }));
}
if (!groups[last_group].has(last_subgroup)) {
@@ -260,6 +262,12 @@ void ShaderMaterial::_get_property_list(List<PropertyInfo> *p_list) const {
subgroup.push_back(info);
groups[last_group].insert(last_subgroup, subgroup);
+ for (Pair<String, LocalVector<String>> &group : vgroups) {
+ if (group.first == last_group) {
+ group.second.push_back(last_subgroup);
+ break;
+ }
+ }
}
} else {
last_group = "<None>";
@@ -277,6 +285,8 @@ void ShaderMaterial::_get_property_list(List<PropertyInfo> *p_list) const {
info.name = "Shader Parameters";
info.hint_string = "shader_parameter/";
groups["<None>"]["<None>"].push_back(info);
+
+ vgroups.push_back(Pair<String, LocalVector<String>>("<None>", { "<None>" }));
}
PropertyInfo info = E->get();
@@ -290,21 +300,10 @@ void ShaderMaterial::_get_property_list(List<PropertyInfo> *p_list) const {
groups[last_group][last_subgroup].push_back(info);
}
- List<String> group_names;
- for (HashMap<String, HashMap<String, List<PropertyInfo>>>::Iterator group = groups.begin(); group; ++group) {
- group_names.push_back(group->key);
- }
- group_names.sort();
-
- for (const String &group_name : group_names) {
- List<String> subgroup_names;
- HashMap<String, List<PropertyInfo>> &subgroups = groups[group_name];
- for (HashMap<String, List<PropertyInfo>>::Iterator subgroup = subgroups.begin(); subgroup; ++subgroup) {
- subgroup_names.push_back(subgroup->key);
- }
- subgroup_names.sort();
- for (const String &subgroup_name : subgroup_names) {
- List<PropertyInfo> &prop_infos = subgroups[subgroup_name];
+ for (const Pair<String, LocalVector<String>> &group_pair : vgroups) {
+ String group = group_pair.first;
+ for (const String &subgroup : group_pair.second) {
+ List<PropertyInfo> &prop_infos = groups[group][subgroup];
for (List<PropertyInfo>::Element *item = prop_infos.front(); item; item = item->next()) {
p_list->push_back(item->get());
}
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp
index a1e7558653..1cb7c9e574 100644
--- a/scene/resources/packed_scene.cpp
+++ b/scene/resources/packed_scene.cpp
@@ -263,17 +263,16 @@ Node *SceneState::instantiate(GenEditState p_edit_state) const {
}
} else {
- if (Engine::get_singleton()->is_editor_hint()) {
- // If editor, just set the metadata and be it.
- node->set(PackedScene::META_POINTER_PROPERTY_BASE + String(prop_name), prop_variant);
- continue;
+ node->set(PackedScene::META_POINTER_PROPERTY_BASE + String(prop_name), prop_variant);
+
+ if (!Engine::get_singleton()->is_editor_hint()) {
+ // If not editor, do an actual deferred sed of the property path.
+ DeferredNodePathProperties dnp;
+ dnp.path = prop_variant;
+ dnp.base = node;
+ dnp.property = prop_name;
+ deferred_node_paths.push_back(dnp);
}
- // Do an actual deferred sed of the property path.
- DeferredNodePathProperties dnp;
- dnp.path = prop_variant;
- dnp.base = node;
- dnp.property = prop_name;
- deferred_node_paths.push_back(dnp);
}
continue;
}
diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp
index 448e800900..c30e009356 100644
--- a/scene/resources/resource_format_text.cpp
+++ b/scene/resources/resource_format_text.cpp
@@ -946,14 +946,24 @@ Error ResourceLoaderText::rename_dependencies(Ref<FileAccess> p_f, const String
} else {
if (fw.is_null()) {
fw = FileAccess::open(p_path + ".depren", FileAccess::WRITE);
+
+ if (res_uid == ResourceUID::INVALID_ID) {
+ res_uid = ResourceSaver::get_resource_id_for_path(p_path);
+ }
+
+ String uid_text = "";
+ if (res_uid != ResourceUID::INVALID_ID) {
+ uid_text = " uid=\"" + ResourceUID::get_singleton()->id_to_text(res_uid) + "\"";
+ }
+
if (is_scene) {
- fw->store_line("[gd_scene load_steps=" + itos(resources_total) + " format=" + itos(FORMAT_VERSION) + "]\n");
+ fw->store_line("[gd_scene load_steps=" + itos(resources_total) + " format=" + itos(FORMAT_VERSION) + uid_text + "]\n");
} else {
String script_res_text;
if (!script_class.is_empty()) {
script_res_text = "script_class=\"" + script_class + "\" ";
}
- fw->store_line("[gd_resource type=\"" + res_type + "\" " + script_res_text + "load_steps=" + itos(resources_total) + " format=" + itos(FORMAT_VERSION) + "]\n");
+ fw->store_line("[gd_resource type=\"" + res_type + "\" " + script_res_text + "load_steps=" + itos(resources_total) + " format=" + itos(FORMAT_VERSION) + uid_text + "]\n");
}
}
diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp
index eaaf2b2115..c296523475 100644
--- a/scene/resources/surface_tool.cpp
+++ b/scene/resources/surface_tool.cpp
@@ -989,9 +989,21 @@ void SurfaceTool::create_from_blend_shape(const Ref<Mesh> &p_existing, int p_sur
}
ERR_FAIL_COND(shape_idx == -1);
ERR_FAIL_COND(shape_idx >= arr.size());
- Array mesh = arr[shape_idx];
- ERR_FAIL_COND(mesh.size() != RS::ARRAY_MAX);
- _create_list_from_arrays(arr[shape_idx], &vertex_array, &index_array, format);
+ Array blendshape_mesh_arrays = arr[shape_idx];
+ ERR_FAIL_COND(blendshape_mesh_arrays.size() != RS::ARRAY_MAX);
+
+ Array source_mesh_arrays = p_existing->surface_get_arrays(p_surface);
+ ERR_FAIL_COND(source_mesh_arrays.size() != RS::ARRAY_MAX);
+
+ // Copy BlendShape vertex data over while keeping e.g. bones, weights, index from existing mesh intact.
+ source_mesh_arrays[RS::ARRAY_VERTEX] = blendshape_mesh_arrays[RS::ARRAY_VERTEX];
+ source_mesh_arrays[RS::ARRAY_NORMAL] = blendshape_mesh_arrays[RS::ARRAY_NORMAL];
+ source_mesh_arrays[RS::ARRAY_TANGENT] = blendshape_mesh_arrays[RS::ARRAY_TANGENT];
+
+ _create_list_from_arrays(source_mesh_arrays, &vertex_array, &index_array, format);
+
+ material = p_existing->surface_get_material(p_surface);
+ format = p_existing->surface_get_format(p_surface);
for (int j = 0; j < RS::ARRAY_CUSTOM_COUNT; j++) {
if (format & custom_mask[j]) {
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index 282c531555..7de10149db 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -168,7 +168,8 @@ void ImageTexture::_get_property_list(List<PropertyInfo> *p_list) const {
}
Ref<ImageTexture> ImageTexture::create_from_image(const Ref<Image> &p_image) {
- ERR_FAIL_COND_V_MSG(p_image.is_null() || p_image->is_empty(), Ref<ImageTexture>(), "Invalid image");
+ ERR_FAIL_COND_V_MSG(p_image.is_null(), Ref<ImageTexture>(), "Invalid image: null");
+ ERR_FAIL_COND_V_MSG(p_image->is_empty(), Ref<ImageTexture>(), "Invalid image: image is empty");
Ref<ImageTexture> image_texture;
image_texture.instantiate();
diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp
index 42e4a0fa3d..a361b7584a 100644
--- a/scene/resources/visual_shader.cpp
+++ b/scene/resources/visual_shader.cpp
@@ -611,6 +611,36 @@ void VisualShaderNodeCustom::_set_initialized(bool p_enabled) {
is_initialized = p_enabled;
}
+String VisualShaderNodeCustom::_get_name() const {
+ String ret;
+ GDVIRTUAL_CALL(_get_name, ret);
+ return ret;
+}
+
+String VisualShaderNodeCustom::_get_description() const {
+ String ret;
+ GDVIRTUAL_CALL(_get_description, ret);
+ return ret;
+}
+
+String VisualShaderNodeCustom::_get_category() const {
+ String ret;
+ GDVIRTUAL_CALL(_get_category, ret);
+ return ret;
+}
+
+VisualShaderNodeCustom::PortType VisualShaderNodeCustom::_get_return_icon_type() const {
+ PortType ret = PORT_TYPE_SCALAR;
+ GDVIRTUAL_CALL(_get_return_icon_type, ret);
+ return ret;
+}
+
+bool VisualShaderNodeCustom::_is_highend() const {
+ bool ret = false;
+ GDVIRTUAL_CALL(_is_highend, ret);
+ return ret;
+}
+
void VisualShaderNodeCustom::_bind_methods() {
GDVIRTUAL_BIND(_get_name);
GDVIRTUAL_BIND(_get_description);
diff --git a/scene/resources/visual_shader.h b/scene/resources/visual_shader.h
index 2838a49209..38d51dba9c 100644
--- a/scene/resources/visual_shader.h
+++ b/scene/resources/visual_shader.h
@@ -411,6 +411,12 @@ public:
bool _is_initialized();
void _set_initialized(bool p_enabled);
+
+ String _get_name() const;
+ String _get_description() const;
+ String _get_category() const;
+ PortType _get_return_icon_type() const;
+ bool _is_highend() const;
};
/////
diff --git a/servers/audio/audio_driver_dummy.cpp b/servers/audio/audio_driver_dummy.cpp
index e6257d9260..e1bfcbaca1 100644
--- a/servers/audio/audio_driver_dummy.cpp
+++ b/servers/audio/audio_driver_dummy.cpp
@@ -41,7 +41,7 @@ Error AudioDriverDummy::init() {
samples_in = nullptr;
if (mix_rate == -1) {
- mix_rate = GLOBAL_GET("audio/driver/mix_rate");
+ mix_rate = _get_configured_mix_rate();
}
channels = get_channels();
@@ -136,7 +136,9 @@ void AudioDriverDummy::mix_audio(int p_frames, int32_t *p_buffer) {
void AudioDriverDummy::finish() {
if (use_threads) {
exit_thread.set();
- thread.wait_to_finish();
+ if (thread.is_started()) {
+ thread.wait_to_finish();
+ }
}
if (samples_in) {
diff --git a/servers/audio/effects/audio_effect_record.cpp b/servers/audio/effects/audio_effect_record.cpp
index e82f6e518e..cc6ac31d29 100644
--- a/servers/audio/effects/audio_effect_record.cpp
+++ b/servers/audio/effects/audio_effect_record.cpp
@@ -120,7 +120,9 @@ void AudioEffectRecordInstance::init() {
}
void AudioEffectRecordInstance::finish() {
- io_thread.wait_to_finish();
+ if (io_thread.is_started()) {
+ io_thread.wait_to_finish();
+ }
}
AudioEffectRecordInstance::~AudioEffectRecordInstance() {
diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp
index 0344bf322d..49991e41d3 100644
--- a/servers/audio_server.cpp
+++ b/servers/audio_server.cpp
@@ -115,6 +115,20 @@ void AudioDriver::input_buffer_write(int32_t sample) {
}
}
+int AudioDriver::_get_configured_mix_rate() {
+ StringName audio_driver_setting = "audio/driver/mix_rate";
+ int mix_rate = GLOBAL_GET(audio_driver_setting);
+
+ // In the case of invalid mix rate, let's default to a sensible value..
+ if (mix_rate <= 0) {
+ WARN_PRINT(vformat("Invalid mix rate of %d, consider reassigning setting \'%s\'. \nDefaulting mix rate to value %d.",
+ mix_rate, audio_driver_setting, AudioDriverManager::DEFAULT_MIX_RATE));
+ mix_rate = AudioDriverManager::DEFAULT_MIX_RATE;
+ }
+
+ return mix_rate;
+}
+
AudioDriver::SpeakerMode AudioDriver::get_speaker_mode_by_total_channels(int p_channels) const {
switch (p_channels) {
case 4:
diff --git a/servers/audio_server.h b/servers/audio_server.h
index 155beb2000..6585043f63 100644
--- a/servers/audio_server.h
+++ b/servers/audio_server.h
@@ -66,6 +66,8 @@ protected:
void input_buffer_init(int driver_buffer_frames);
void input_buffer_write(int32_t sample);
+ int _get_configured_mix_rate();
+
#ifdef DEBUG_ENABLED
_FORCE_INLINE_ void start_counting_ticks() { prof_ticks = OS::get_singleton()->get_ticks_usec(); }
_FORCE_INLINE_ void stop_counting_ticks() { prof_time += OS::get_singleton()->get_ticks_usec() - prof_ticks; }
@@ -136,7 +138,6 @@ class AudioDriverManager {
MAX_DRIVERS = 10
};
- static const int DEFAULT_MIX_RATE = 44100;
static const int DEFAULT_OUTPUT_LATENCY = 15;
static AudioDriver *drivers[MAX_DRIVERS];
@@ -145,6 +146,8 @@ class AudioDriverManager {
static AudioDriverDummy dummy_driver;
public:
+ static const int DEFAULT_MIX_RATE = 44100;
+
static void add_driver(AudioDriver *p_driver);
static void initialize(int p_driver);
static int get_driver_count();
diff --git a/servers/physics_2d/godot_shape_2d.cpp b/servers/physics_2d/godot_shape_2d.cpp
index 67c24e29b0..dadd8173c6 100644
--- a/servers/physics_2d/godot_shape_2d.cpp
+++ b/servers/physics_2d/godot_shape_2d.cpp
@@ -179,7 +179,7 @@ Variant GodotSeparationRayShape2D::get_data() const {
/*********************************************************/
void GodotSegmentShape2D::get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const {
- if (Math::abs(p_normal.dot(n)) > _SEGMENT_IS_VALID_SUPPORT_THRESHOLD) {
+ if (Math::abs(p_normal.dot(n)) > segment_is_valid_support_threshold) {
r_supports[0] = a;
r_supports[1] = b;
r_amount = 2;
@@ -308,7 +308,7 @@ void GodotRectangleShape2D::get_supports(const Vector2 &p_normal, Vector2 *r_sup
Vector2 ag;
ag[i] = 1.0;
real_t dp = ag.dot(p_normal);
- if (Math::abs(dp) < _SEGMENT_IS_VALID_SUPPORT_THRESHOLD) {
+ if (Math::abs(dp) <= segment_is_valid_support_threshold) {
continue;
}
@@ -368,10 +368,9 @@ Variant GodotRectangleShape2D::get_data() const {
void GodotCapsuleShape2D::get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const {
Vector2 n = p_normal;
- real_t d = n.y;
real_t h = height * 0.5 - radius; // half-height of the rectangle part
- if (h > 0 && Math::abs(d) < (1.0 - _SEGMENT_IS_VALID_SUPPORT_THRESHOLD)) {
+ if (h > 0 && Math::abs(n.x) > segment_is_valid_support_threshold) {
// make it flat
n.y = 0.0;
n.normalize();
@@ -384,7 +383,7 @@ void GodotCapsuleShape2D::get_supports(const Vector2 &p_normal, Vector2 *r_suppo
r_supports[1].y -= h;
} else {
n *= radius;
- n.y += (d > 0) ? h : -h;
+ n.y += (n.y > 0) ? h : -h;
r_amount = 1;
*r_supports = n;
}
@@ -506,7 +505,7 @@ void GodotConvexPolygonShape2D::get_supports(const Vector2 &p_normal, Vector2 *r
}
//test segment
- if (points[i].normal.dot(p_normal) > _SEGMENT_IS_VALID_SUPPORT_THRESHOLD) {
+ if (points[i].normal.dot(p_normal) > segment_is_valid_support_threshold) {
r_amount = 2;
r_supports[0] = points[i].pos;
r_supports[1] = points[(i + 1) % point_count].pos;
diff --git a/servers/physics_2d/godot_shape_2d.h b/servers/physics_2d/godot_shape_2d.h
index 50b2bfd4e9..28c69574a0 100644
--- a/servers/physics_2d/godot_shape_2d.h
+++ b/servers/physics_2d/godot_shape_2d.h
@@ -32,7 +32,6 @@
#define GODOT_SHAPE_2D_H
#include "servers/physics_server_2d.h"
-#define _SEGMENT_IS_VALID_SUPPORT_THRESHOLD 0.99998
class GodotShape2D;
@@ -53,6 +52,10 @@ class GodotShape2D {
HashMap<GodotShapeOwner2D *, int> owners;
protected:
+ const double segment_is_valid_support_threshold = 0.99998;
+ const double segment_is_valid_support_threshold_lower =
+ Math::sqrt(1.0 - segment_is_valid_support_threshold * segment_is_valid_support_threshold);
+
void configure(const Rect2 &p_aabb);
public:
@@ -95,7 +98,7 @@ public:
}
if (r_amount == 1) {
- if (Math::abs(p_normal.dot(p_cast.normalized())) < (1.0 - _SEGMENT_IS_VALID_SUPPORT_THRESHOLD)) {
+ if (Math::abs(p_normal.dot(p_cast.normalized())) < segment_is_valid_support_threshold_lower) {
//make line because they are parallel
r_amount = 2;
r_supports[1] = r_supports[0] + p_cast;
@@ -105,7 +108,7 @@ public:
}
} else {
- if (Math::abs(p_normal.dot(p_cast.normalized())) < (1.0 - _SEGMENT_IS_VALID_SUPPORT_THRESHOLD)) {
+ if (Math::abs(p_normal.dot(p_cast.normalized())) < segment_is_valid_support_threshold_lower) {
//optimize line and make it larger because they are parallel
if ((r_supports[1] - r_supports[0]).dot(p_cast) > 0) {
//larger towards 1
diff --git a/servers/physics_3d/godot_shape_3d.cpp b/servers/physics_3d/godot_shape_3d.cpp
index d566d612ce..50154a85ec 100644
--- a/servers/physics_3d/godot_shape_3d.cpp
+++ b/servers/physics_3d/godot_shape_3d.cpp
@@ -52,11 +52,11 @@ subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution.
*/
-constexpr double edge_support_threshold = 0.0002;
-constexpr double face_support_threshold = 0.9998;
+const double support_threshold = 0.9998;
+const double support_threshold_lower = Math::sqrt(1.0 - support_threshold * support_threshold);
-constexpr double cylinder_edge_support_threshold = 0.002;
-constexpr double cylinder_face_support_threshold = 0.999;
+const double cylinder_support_threshold = 0.999;
+const double cylinder_support_threshold_lower = Math::sqrt(1.0 - cylinder_support_threshold * cylinder_support_threshold);
void GodotShape3D::configure(const AABB &p_aabb) {
aabb = p_aabb;
@@ -184,7 +184,7 @@ Vector3 GodotSeparationRayShape3D::get_support(const Vector3 &p_normal) const {
}
void GodotSeparationRayShape3D::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const {
- if (Math::abs(p_normal.z) < edge_support_threshold) {
+ if (Math::abs(p_normal.z) < support_threshold_lower) {
r_amount = 2;
r_type = FEATURE_EDGE;
r_supports[0] = Vector3(0, 0, 0);
@@ -335,7 +335,7 @@ void GodotBoxShape3D::get_supports(const Vector3 &p_normal, int p_max, Vector3 *
Vector3 axis;
axis[i] = 1.0;
real_t dot = p_normal.dot(axis);
- if (Math::abs(dot) > face_support_threshold) {
+ if (Math::abs(dot) > support_threshold) {
//Vector3 axis_b;
bool neg = dot < 0;
@@ -376,7 +376,7 @@ void GodotBoxShape3D::get_supports(const Vector3 &p_normal, int p_max, Vector3 *
Vector3 axis;
axis[i] = 1.0;
- if (Math::abs(p_normal.dot(axis)) < edge_support_threshold) {
+ if (Math::abs(p_normal.dot(axis)) < support_threshold_lower) {
r_amount = 2;
r_type = FEATURE_EDGE;
@@ -523,7 +523,7 @@ void GodotCapsuleShape3D::get_supports(const Vector3 &p_normal, int p_max, Vecto
real_t d = n.y;
real_t h = height * 0.5 - radius; // half-height of the cylinder part
- if (h > 0 && Math::abs(d) < edge_support_threshold) {
+ if (h > 0 && Math::abs(d) < support_threshold_lower) {
// make it flat
n.y = 0.0;
n.normalize();
@@ -701,7 +701,7 @@ Vector3 GodotCylinderShape3D::get_support(const Vector3 &p_normal) const {
void GodotCylinderShape3D::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const {
real_t d = p_normal.y;
- if (Math::abs(d) > cylinder_face_support_threshold) {
+ if (Math::abs(d) > cylinder_support_threshold) {
real_t h = (d > 0) ? height : -height;
Vector3 n = p_normal;
@@ -716,7 +716,7 @@ void GodotCylinderShape3D::get_supports(const Vector3 &p_normal, int p_max, Vect
r_supports[1].x += radius;
r_supports[2] = n;
r_supports[2].z += radius;
- } else if (Math::abs(d) < cylinder_edge_support_threshold) {
+ } else if (Math::abs(d) < cylinder_support_threshold_lower) {
// make it flat
Vector3 n = p_normal;
n.y = 0.0;
@@ -925,7 +925,7 @@ void GodotConvexPolygonShape3D::get_supports(const Vector3 &p_normal, int p_max,
}
for (int i = 0; i < fc; i++) {
- if (faces[i].plane.normal.dot(p_normal) > face_support_threshold) {
+ if (faces[i].plane.normal.dot(p_normal) > support_threshold) {
int ic = faces[i].indices.size();
const int *ind = faces[i].indices.ptr();
@@ -954,7 +954,7 @@ void GodotConvexPolygonShape3D::get_supports(const Vector3 &p_normal, int p_max,
for (int i = 0; i < ec; i++) {
real_t dot = (vertices[edges[i].vertex_a] - vertices[edges[i].vertex_b]).normalized().dot(p_normal);
dot = ABS(dot);
- if (dot < edge_support_threshold && (edges[i].vertex_a == vtx || edges[i].vertex_b == vtx)) {
+ if (dot < support_threshold_lower && (edges[i].vertex_a == vtx || edges[i].vertex_b == vtx)) {
r_amount = 2;
r_type = FEATURE_EDGE;
r_supports[0] = vertices[edges[i].vertex_a];
@@ -1197,7 +1197,7 @@ void GodotFaceShape3D::get_supports(const Vector3 &p_normal, int p_max, Vector3
Vector3 n = p_normal;
/** TEST FACE AS SUPPORT **/
- if (Math::abs(normal.dot(n)) > face_support_threshold) {
+ if (Math::abs(normal.dot(n)) > support_threshold) {
r_amount = 3;
r_type = FEATURE_FACE;
for (int i = 0; i < 3; i++) {
@@ -1231,7 +1231,7 @@ void GodotFaceShape3D::get_supports(const Vector3 &p_normal, int p_max, Vector3
// check if edge is valid as a support
real_t dot = (vertex[i] - vertex[nx]).normalized().dot(n);
dot = ABS(dot);
- if (dot < edge_support_threshold) {
+ if (dot < support_threshold_lower) {
r_amount = 2;
r_type = FEATURE_EDGE;
r_supports[0] = vertex[i];
diff --git a/servers/rendering/renderer_canvas_cull.cpp b/servers/rendering/renderer_canvas_cull.cpp
index b9e3c4f303..706477cedb 100644
--- a/servers/rendering/renderer_canvas_cull.cpp
+++ b/servers/rendering/renderer_canvas_cull.cpp
@@ -1177,17 +1177,31 @@ 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);
+ ERR_FAIL_COND(p_points.is_empty() || p_points.size() % 2 != 0);
+ ERR_FAIL_COND(p_colors.size() != 1 && p_colors.size() * 2 != p_points.size());
// TODO: `canvas_item_add_line`(`multiline`, `polyline`) share logic, should factor out.
if (p_width < 0) {
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
+ Vector<Color> colors;
+ if (p_colors.size() == 1) {
+ colors = p_colors;
+ } else { //} else if (p_colors.size() << 1 == p_points.size()) {
+ colors.resize(p_points.size());
+ Color *colors_ptr = colors.ptrw();
+ for (int i = 0; i < p_colors.size(); i++) {
+ Color color = p_colors[i];
+ colors_ptr[i * 2 + 0] = color;
+ colors_ptr[i * 2 + 1] = color;
+ }
+ }
+
Item::CommandPolygon *pline = canvas_item->alloc_command<Item::CommandPolygon>();
ERR_FAIL_COND(!pline);
pline->primitive = RS::PRIMITIVE_LINES;
- pline->polygon.create(Vector<int>(), p_points, p_colors);
+ pline->polygon.create(Vector<int>(), p_points, colors);
} else {
if (p_colors.size() == 1) {
Color color = p_colors[0];
@@ -1197,16 +1211,14 @@ void RendererCanvasCull::canvas_item_add_multiline(RID p_item, const Vector<Poin
canvas_item_add_line(p_item, from, to, color, p_width);
}
- } else if (p_colors.size() == p_points.size() >> 1) {
- for (int i = 0; i < p_points.size() >> 1; i++) {
+ } else { //} else if (p_colors.size() << 1 == p_points.size()) {
+ for (int i = 0; i < p_colors.size(); i++) {
Color color = p_colors[i];
Vector2 from = p_points[i * 2 + 0];
Vector2 to = p_points[i * 2 + 1];
canvas_item_add_line(p_item, from, to, color, p_width);
}
- } else {
- ERR_FAIL_MSG("Length of p_colors is invalid.");
}
}
}
diff --git a/servers/rendering/renderer_rd/environment/fog.cpp b/servers/rendering/renderer_rd/environment/fog.cpp
index 4253ea8610..78b785153f 100644
--- a/servers/rendering/renderer_rd/environment/fog.cpp
+++ b/servers/rendering/renderer_rd/environment/fog.cpp
@@ -388,6 +388,37 @@ Fog::FogShaderData::~FogShaderData() {
////////////////////////////////////////////////////////////////////////////////
// Volumetric Fog
+bool Fog::VolumetricFog::sync_gi_dependent_sets_validity(bool p_ensure_freed) {
+ bool null = gi_dependent_sets.copy_uniform_set.is_null();
+ bool valid = !null && RD::get_singleton()->uniform_set_is_valid(gi_dependent_sets.copy_uniform_set);
+
+#ifdef DEV_ENABLED
+ // It's all-or-nothing, or something else has changed that requires dev attention.
+ DEV_ASSERT(null == gi_dependent_sets.process_uniform_set_density.is_null());
+ DEV_ASSERT(null == gi_dependent_sets.process_uniform_set.is_null());
+ DEV_ASSERT(null == gi_dependent_sets.process_uniform_set2.is_null());
+ DEV_ASSERT(valid == RD::get_singleton()->uniform_set_is_valid(gi_dependent_sets.process_uniform_set_density));
+ DEV_ASSERT(valid == RD::get_singleton()->uniform_set_is_valid(gi_dependent_sets.process_uniform_set));
+ DEV_ASSERT(valid == RD::get_singleton()->uniform_set_is_valid(gi_dependent_sets.process_uniform_set2));
+#endif
+
+ if (valid) {
+ if (p_ensure_freed) {
+ RD::get_singleton()->free(gi_dependent_sets.copy_uniform_set);
+ RD::get_singleton()->free(gi_dependent_sets.process_uniform_set_density);
+ RD::get_singleton()->free(gi_dependent_sets.process_uniform_set);
+ RD::get_singleton()->free(gi_dependent_sets.process_uniform_set2);
+ valid = false;
+ }
+ }
+
+ if (!valid && !null) {
+ gi_dependent_sets = {};
+ }
+
+ return valid;
+}
+
void Fog::VolumetricFog::init(const Vector3i &fog_size, RID p_sky_shader) {
width = fog_size.x;
height = fog_size.y;
@@ -463,15 +494,9 @@ Fog::VolumetricFog::~VolumetricFog() {
if (fog_uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(fog_uniform_set)) {
RD::get_singleton()->free(fog_uniform_set);
}
- if (process_uniform_set_density.is_valid() && RD::get_singleton()->uniform_set_is_valid(process_uniform_set_density)) {
- RD::get_singleton()->free(process_uniform_set_density);
- }
- if (process_uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(process_uniform_set)) {
- RD::get_singleton()->free(process_uniform_set);
- }
- if (process_uniform_set2.is_valid() && RD::get_singleton()->uniform_set_is_valid(process_uniform_set2)) {
- RD::get_singleton()->free(process_uniform_set2);
- }
+
+ sync_gi_dependent_sets_validity(true);
+
if (sdfgi_uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(sdfgi_uniform_set)) {
RD::get_singleton()->free(sdfgi_uniform_set);
}
@@ -713,7 +738,7 @@ void Fog::volumetric_fog_update(const VolumetricFogSettings &p_settings, const P
RD::get_singleton()->compute_list_end();
}
- if (fog->process_uniform_set_density.is_null() || !RD::get_singleton()->uniform_set_is_valid(fog->process_uniform_set_density)) {
+ if (!fog->sync_gi_dependent_sets_validity()) {
//re create uniform set if needed
Vector<RD::Uniform> uniforms;
Vector<RD::Uniform> copy_uniforms;
@@ -910,9 +935,9 @@ void Fog::volumetric_fog_update(const VolumetricFogSettings &p_settings, const P
uniforms.push_back(u);
}
- fog->copy_uniform_set = RD::get_singleton()->uniform_set_create(copy_uniforms, volumetric_fog.process_shader.version_get_shader(volumetric_fog.process_shader_version, VolumetricFogShader::VOLUMETRIC_FOG_PROCESS_SHADER_COPY), 0);
+ fog->gi_dependent_sets.copy_uniform_set = RD::get_singleton()->uniform_set_create(copy_uniforms, volumetric_fog.process_shader.version_get_shader(volumetric_fog.process_shader_version, VolumetricFogShader::VOLUMETRIC_FOG_PROCESS_SHADER_COPY), 0);
- fog->process_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, volumetric_fog.process_shader.version_get_shader(volumetric_fog.process_shader_version, VolumetricFogShader::VOLUMETRIC_FOG_PROCESS_SHADER_FOG), 0);
+ fog->gi_dependent_sets.process_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, volumetric_fog.process_shader.version_get_shader(volumetric_fog.process_shader_version, VolumetricFogShader::VOLUMETRIC_FOG_PROCESS_SHADER_FOG), 0);
RID aux7 = uniforms.write[7].get_id(0);
RID aux8 = uniforms.write[8].get_id(0);
@@ -920,11 +945,11 @@ void Fog::volumetric_fog_update(const VolumetricFogSettings &p_settings, const P
uniforms.write[7].set_id(0, aux8);
uniforms.write[8].set_id(0, aux7);
- fog->process_uniform_set2 = RD::get_singleton()->uniform_set_create(uniforms, volumetric_fog.process_shader.version_get_shader(volumetric_fog.process_shader_version, VolumetricFogShader::VOLUMETRIC_FOG_PROCESS_SHADER_FOG), 0);
+ fog->gi_dependent_sets.process_uniform_set2 = RD::get_singleton()->uniform_set_create(uniforms, volumetric_fog.process_shader.version_get_shader(volumetric_fog.process_shader_version, VolumetricFogShader::VOLUMETRIC_FOG_PROCESS_SHADER_FOG), 0);
uniforms.remove_at(8);
uniforms.write[7].set_id(0, aux7);
- fog->process_uniform_set_density = RD::get_singleton()->uniform_set_create(uniforms, volumetric_fog.process_shader.version_get_shader(volumetric_fog.process_shader_version, VolumetricFogShader::VOLUMETRIC_FOG_PROCESS_SHADER_DENSITY), 0);
+ fog->gi_dependent_sets.process_uniform_set_density = RD::get_singleton()->uniform_set_create(uniforms, volumetric_fog.process_shader.version_get_shader(volumetric_fog.process_shader_version, VolumetricFogShader::VOLUMETRIC_FOG_PROCESS_SHADER_DENSITY), 0);
}
bool using_sdfgi = RendererSceneRenderRD::get_singleton()->environment_get_volumetric_fog_gi_inject(p_settings.env) > 0.0001 && RendererSceneRenderRD::get_singleton()->environment_get_sdfgi_enabled(p_settings.env) && (p_settings.sdfgi.is_valid());
@@ -1067,7 +1092,7 @@ void Fog::volumetric_fog_update(const VolumetricFogSettings &p_settings, const P
RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, volumetric_fog.process_pipelines[using_sdfgi ? VolumetricFogShader::VOLUMETRIC_FOG_PROCESS_SHADER_DENSITY_WITH_SDFGI : VolumetricFogShader::VOLUMETRIC_FOG_PROCESS_SHADER_DENSITY]);
- RD::get_singleton()->compute_list_bind_uniform_set(compute_list, fog->process_uniform_set_density, 0);
+ RD::get_singleton()->compute_list_bind_uniform_set(compute_list, fog->gi_dependent_sets.process_uniform_set_density, 0);
if (using_sdfgi) {
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, fog->sdfgi_uniform_set, 1);
@@ -1078,7 +1103,7 @@ void Fog::volumetric_fog_update(const VolumetricFogSettings &p_settings, const P
// Copy fog to history buffer
if (RendererSceneRenderRD::get_singleton()->environment_get_volumetric_fog_temporal_reprojection(p_settings.env)) {
RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, volumetric_fog.process_pipelines[VolumetricFogShader::VOLUMETRIC_FOG_PROCESS_SHADER_COPY]);
- RD::get_singleton()->compute_list_bind_uniform_set(compute_list, fog->copy_uniform_set, 0);
+ RD::get_singleton()->compute_list_bind_uniform_set(compute_list, fog->gi_dependent_sets.copy_uniform_set, 0);
RD::get_singleton()->compute_list_dispatch_threads(compute_list, fog->width, fog->height, fog->depth);
RD::get_singleton()->compute_list_add_barrier(compute_list);
}
@@ -1090,7 +1115,7 @@ void Fog::volumetric_fog_update(const VolumetricFogSettings &p_settings, const P
RENDER_TIMESTAMP("Filter Fog");
RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, volumetric_fog.process_pipelines[VolumetricFogShader::VOLUMETRIC_FOG_PROCESS_SHADER_FILTER]);
- RD::get_singleton()->compute_list_bind_uniform_set(compute_list, fog->process_uniform_set, 0);
+ RD::get_singleton()->compute_list_bind_uniform_set(compute_list, fog->gi_dependent_sets.process_uniform_set, 0);
RD::get_singleton()->compute_list_dispatch_threads(compute_list, fog->width, fog->height, fog->depth);
RD::get_singleton()->compute_list_end();
@@ -1101,7 +1126,7 @@ void Fog::volumetric_fog_update(const VolumetricFogSettings &p_settings, const P
compute_list = RD::get_singleton()->compute_list_begin();
RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, volumetric_fog.process_pipelines[VolumetricFogShader::VOLUMETRIC_FOG_PROCESS_SHADER_FILTER]);
- RD::get_singleton()->compute_list_bind_uniform_set(compute_list, fog->process_uniform_set2, 0);
+ RD::get_singleton()->compute_list_bind_uniform_set(compute_list, fog->gi_dependent_sets.process_uniform_set2, 0);
RD::get_singleton()->compute_list_dispatch_threads(compute_list, fog->width, fog->height, fog->depth);
RD::get_singleton()->compute_list_add_barrier(compute_list);
@@ -1112,7 +1137,7 @@ void Fog::volumetric_fog_update(const VolumetricFogSettings &p_settings, const P
RD::get_singleton()->draw_command_begin_label("Integrate Fog");
RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, volumetric_fog.process_pipelines[VolumetricFogShader::VOLUMETRIC_FOG_PROCESS_SHADER_FOG]);
- RD::get_singleton()->compute_list_bind_uniform_set(compute_list, fog->process_uniform_set, 0);
+ RD::get_singleton()->compute_list_bind_uniform_set(compute_list, fog->gi_dependent_sets.process_uniform_set, 0);
RD::get_singleton()->compute_list_dispatch_threads(compute_list, fog->width, fog->height, 1);
RD::get_singleton()->compute_list_end(RD::BARRIER_MASK_RASTER);
diff --git a/servers/rendering/renderer_rd/environment/fog.h b/servers/rendering/renderer_rd/environment/fog.h
index 0b6bcc29fb..277389c596 100644
--- a/servers/rendering/renderer_rd/environment/fog.h
+++ b/servers/rendering/renderer_rd/environment/fog.h
@@ -301,10 +301,14 @@ public:
RID emissive_map;
RID fog_uniform_set;
- RID copy_uniform_set;
- RID process_uniform_set_density;
- RID process_uniform_set;
- RID process_uniform_set2;
+
+ struct {
+ RID copy_uniform_set;
+ RID process_uniform_set_density;
+ RID process_uniform_set;
+ RID process_uniform_set2;
+ } gi_dependent_sets;
+
RID sdfgi_uniform_set;
RID sky_uniform_set;
@@ -313,6 +317,8 @@ public:
virtual void configure(RenderSceneBuffersRD *p_render_buffers) override{};
virtual void free_data() override{};
+ bool sync_gi_dependent_sets_validity(bool p_ensure_freed = false);
+
void init(const Vector3i &fog_size, RID p_sky_shader);
~VolumetricFog();
};
diff --git a/servers/rendering/renderer_rd/environment/gi.cpp b/servers/rendering/renderer_rd/environment/gi.cpp
index 08133bf8d6..c2a018c7c6 100644
--- a/servers/rendering/renderer_rd/environment/gi.cpp
+++ b/servers/rendering/renderer_rd/environment/gi.cpp
@@ -3493,6 +3493,9 @@ void GI::init(SkyRD *p_sky) {
if (RendererSceneRenderRD::get_singleton()->is_vrs_supported()) {
defines += "\n#define USE_VRS\n";
}
+ if (!RD::get_singleton()->sampler_is_format_supported_for_filter(RD::DATA_FORMAT_R8G8_UINT, RD::SAMPLER_FILTER_LINEAR)) {
+ defines += "\n#define SAMPLE_VOXEL_GI_NEAREST\n";
+ }
Vector<String> gi_modes;
@@ -3692,18 +3695,6 @@ void GI::setup_voxel_gi_instances(RenderDataRD *p_render_data, Ref<RenderSceneBu
}
rbgi->uniform_set[v] = RID();
}
- if (p_render_buffers->has_custom_data(RB_SCOPE_FOG)) {
- Ref<Fog::VolumetricFog> fog = p_render_buffers->get_custom_data(RB_SCOPE_FOG);
-
- if (RD::get_singleton()->uniform_set_is_valid(fog->fog_uniform_set)) {
- RD::get_singleton()->free(fog->fog_uniform_set);
- RD::get_singleton()->free(fog->process_uniform_set);
- RD::get_singleton()->free(fog->process_uniform_set2);
- }
- fog->fog_uniform_set = RID();
- fog->process_uniform_set = RID();
- fog->process_uniform_set2 = RID();
- }
}
if (p_voxel_gi_instances.size() > 0) {
@@ -3929,7 +3920,6 @@ void GI::process_gi(Ref<RenderSceneBuffersRD> p_render_buffers, const RID *p_nor
u.append_id(material_storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED));
uniforms.push_back(u);
}
-
{
RD::Uniform u;
u.uniform_type = RD::UNIFORM_TYPE_IMAGE;
diff --git a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp
index 6c948d3474..03f31f839e 100644
--- a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp
+++ b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp
@@ -632,7 +632,7 @@ void SceneShaderForwardClustered::init(const String p_defines) {
actions.renames["CAMERA_POSITION_WORLD"] = "scene_data.inv_view_matrix[3].xyz";
actions.renames["CAMERA_DIRECTION_WORLD"] = "scene_data.view_matrix[3].xyz";
actions.renames["CAMERA_VISIBLE_LAYERS"] = "scene_data.camera_visible_layers";
- actions.renames["NODE_POSITION_VIEW"] = "(read_model_matrix * scene_data.view_matrix)[3].xyz";
+ actions.renames["NODE_POSITION_VIEW"] = "(scene_data.view_matrix * read_model_matrix)[3].xyz";
actions.renames["VIEW_INDEX"] = "ViewIndex";
actions.renames["VIEW_MONO_LEFT"] = "0";
@@ -641,6 +641,7 @@ void SceneShaderForwardClustered::init(const String p_defines) {
//for light
actions.renames["VIEW"] = "view";
+ actions.renames["SPECULAR_AMOUNT"] = "specular_amount";
actions.renames["LIGHT_COLOR"] = "light_color";
actions.renames["LIGHT_IS_DIRECTIONAL"] = "is_directional";
actions.renames["LIGHT"] = "light";
diff --git a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp
index a93b994467..f3bc8a6e55 100644
--- a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp
+++ b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp
@@ -522,7 +522,7 @@ void SceneShaderForwardMobile::init(const String p_defines) {
actions.renames["CAMERA_POSITION_WORLD"] = "scene_data.inv_view_matrix[3].xyz";
actions.renames["CAMERA_DIRECTION_WORLD"] = "scene_data.view_matrix[3].xyz";
actions.renames["CAMERA_VISIBLE_LAYERS"] = "scene_data.camera_visible_layers";
- actions.renames["NODE_POSITION_VIEW"] = "(read_model_matrix * scene_data.view_matrix)[3].xyz";
+ actions.renames["NODE_POSITION_VIEW"] = "(scene_data.view_matrix * read_model_matrix)[3].xyz";
actions.renames["VIEW_INDEX"] = "ViewIndex";
actions.renames["VIEW_MONO_LEFT"] = "0";
@@ -531,6 +531,7 @@ void SceneShaderForwardMobile::init(const String p_defines) {
//for light
actions.renames["VIEW"] = "view";
+ actions.renames["SPECULAR_AMOUNT"] = "specular_amount";
actions.renames["LIGHT_COLOR"] = "light_color";
actions.renames["LIGHT_IS_DIRECTIONAL"] = "is_directional";
actions.renames["LIGHT"] = "light";
diff --git a/servers/rendering/renderer_rd/shaders/effects/cubemap_downsampler_raster.glsl b/servers/rendering/renderer_rd/shaders/effects/cubemap_downsampler_raster.glsl
index 0828ffd921..b8c64d09f4 100644
--- a/servers/rendering/renderer_rd/shaders/effects/cubemap_downsampler_raster.glsl
+++ b/servers/rendering/renderer_rd/shaders/effects/cubemap_downsampler_raster.glsl
@@ -55,109 +55,107 @@ void main() {
// Converted from compute shader which uses absolute coordinates.
// Could possibly simplify this
float face_size = float(params.face_size);
+ float inv_face_size = 1.0 / face_size;
+ vec2 id = floor(uv_interp);
- if (uv_interp.x < face_size && uv_interp.y < face_size) {
- float inv_face_size = 1.0 / face_size;
-
- float u0 = (uv_interp.x * 2.0 + 1.0 - 0.75) * inv_face_size - 1.0;
- float u1 = (uv_interp.x * 2.0 + 1.0 + 0.75) * inv_face_size - 1.0;
-
- float v0 = (uv_interp.y * 2.0 + 1.0 - 0.75) * -inv_face_size + 1.0;
- float v1 = (uv_interp.y * 2.0 + 1.0 + 0.75) * -inv_face_size + 1.0;
-
- float weights[4];
- weights[0] = calcWeight(u0, v0);
- weights[1] = calcWeight(u1, v0);
- weights[2] = calcWeight(u0, v1);
- weights[3] = calcWeight(u1, v1);
-
- const float wsum = 0.5 / (weights[0] + weights[1] + weights[2] + weights[3]);
- for (int i = 0; i < 4; i++) {
- weights[i] = weights[i] * wsum + .125;
- }
-
- vec3 dir;
- vec4 color;
- switch (params.face_id) {
- case 0:
- get_dir_0(dir, u0, v0);
- color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0];
-
- get_dir_0(dir, u1, v0);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1];
-
- get_dir_0(dir, u0, v1);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2];
-
- get_dir_0(dir, u1, v1);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3];
- break;
- case 1:
- get_dir_1(dir, u0, v0);
- color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0];
-
- get_dir_1(dir, u1, v0);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1];
-
- get_dir_1(dir, u0, v1);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2];
-
- get_dir_1(dir, u1, v1);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3];
- break;
- case 2:
- get_dir_2(dir, u0, v0);
- color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0];
-
- get_dir_2(dir, u1, v0);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1];
-
- get_dir_2(dir, u0, v1);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2];
-
- get_dir_2(dir, u1, v1);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3];
- break;
- case 3:
- get_dir_3(dir, u0, v0);
- color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0];
-
- get_dir_3(dir, u1, v0);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1];
-
- get_dir_3(dir, u0, v1);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2];
-
- get_dir_3(dir, u1, v1);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3];
- break;
- case 4:
- get_dir_4(dir, u0, v0);
- color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0];
-
- get_dir_4(dir, u1, v0);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1];
-
- get_dir_4(dir, u0, v1);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2];
-
- get_dir_4(dir, u1, v1);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3];
- break;
- default:
- get_dir_5(dir, u0, v0);
- color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0];
-
- get_dir_5(dir, u1, v0);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1];
-
- get_dir_5(dir, u0, v1);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2];
-
- get_dir_5(dir, u1, v1);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3];
- break;
- }
- frag_color = color;
+ float u1 = (id.x * 2.0 + 1.0 + 0.75) * inv_face_size - 1.0;
+ float u0 = (id.x * 2.0 + 1.0 - 0.75) * inv_face_size - 1.0;
+
+ float v0 = (id.y * 2.0 + 1.0 - 0.75) * -inv_face_size + 1.0;
+ float v1 = (id.y * 2.0 + 1.0 + 0.75) * -inv_face_size + 1.0;
+
+ float weights[4];
+ weights[0] = calcWeight(u0, v0);
+ weights[1] = calcWeight(u1, v0);
+ weights[2] = calcWeight(u0, v1);
+ weights[3] = calcWeight(u1, v1);
+
+ const float wsum = 0.5 / (weights[0] + weights[1] + weights[2] + weights[3]);
+ for (int i = 0; i < 4; i++) {
+ weights[i] = weights[i] * wsum + .125;
+ }
+
+ vec3 dir;
+ vec4 color;
+ switch (params.face_id) {
+ case 0:
+ get_dir_0(dir, u0, v0);
+ color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0];
+
+ get_dir_0(dir, u1, v0);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1];
+
+ get_dir_0(dir, u0, v1);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2];
+
+ get_dir_0(dir, u1, v1);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3];
+ break;
+ case 1:
+ get_dir_1(dir, u0, v0);
+ color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0];
+
+ get_dir_1(dir, u1, v0);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1];
+
+ get_dir_1(dir, u0, v1);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2];
+
+ get_dir_1(dir, u1, v1);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3];
+ break;
+ case 2:
+ get_dir_2(dir, u0, v0);
+ color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0];
+
+ get_dir_2(dir, u1, v0);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1];
+
+ get_dir_2(dir, u0, v1);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2];
+
+ get_dir_2(dir, u1, v1);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3];
+ break;
+ case 3:
+ get_dir_3(dir, u0, v0);
+ color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0];
+
+ get_dir_3(dir, u1, v0);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1];
+
+ get_dir_3(dir, u0, v1);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2];
+
+ get_dir_3(dir, u1, v1);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3];
+ break;
+ case 4:
+ get_dir_4(dir, u0, v0);
+ color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0];
+
+ get_dir_4(dir, u1, v0);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1];
+
+ get_dir_4(dir, u0, v1);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2];
+
+ get_dir_4(dir, u1, v1);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3];
+ break;
+ default:
+ get_dir_5(dir, u0, v0);
+ color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0];
+
+ get_dir_5(dir, u1, v0);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1];
+
+ get_dir_5(dir, u0, v1);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2];
+
+ get_dir_5(dir, u1, v1);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3];
+ break;
}
+ frag_color = color;
}
diff --git a/servers/rendering/renderer_rd/shaders/environment/gi.glsl b/servers/rendering/renderer_rd/shaders/environment/gi.glsl
index 459c4dcb1d..59af9501ba 100644
--- a/servers/rendering/renderer_rd/shaders/environment/gi.glsl
+++ b/servers/rendering/renderer_rd/shaders/environment/gi.glsl
@@ -4,6 +4,10 @@
#VERSION_DEFINES
+#ifdef SAMPLE_VOXEL_GI_NEAREST
+#extension GL_EXT_samplerless_texture_functions : enable
+#endif
+
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
#define M_PI 3.141592
@@ -625,7 +629,11 @@ void process_gi(ivec2 pos, vec3 vertex, inout vec4 ambient_light, inout vec4 ref
#ifdef USE_VOXEL_GI_INSTANCES
{
+#ifdef SAMPLE_VOXEL_GI_NEAREST
+ uvec2 voxel_gi_tex = texelFetch(voxel_gi_buffer, pos, 0).rg;
+#else
uvec2 voxel_gi_tex = texelFetch(usampler2D(voxel_gi_buffer, linear_sampler), pos, 0).rg;
+#endif
roughness *= roughness;
//find arbitrary tangent and bitangent, then build a matrix
vec3 v0 = abs(normal.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(0.0, 1.0, 0.0);
diff --git a/servers/rendering/renderer_rd/storage_rd/light_storage.h b/servers/rendering/renderer_rd/storage_rd/light_storage.h
index c36d1ef503..3360358169 100644
--- a/servers/rendering/renderer_rd/storage_rd/light_storage.h
+++ b/servers/rendering/renderer_rd/storage_rd/light_storage.h
@@ -93,11 +93,11 @@ private:
struct ShadowTransform {
Projection camera;
Transform3D transform;
- float farplane;
- float split;
- float bias_scale;
- float shadow_texel_size;
- float range_begin;
+ float farplane = 0.0;
+ float split = 0.0;
+ float bias_scale = 0.0;
+ float shadow_texel_size = 0.0;
+ float range_begin = 0.0;
Rect2 atlas_rect;
Vector2 uv_scale;
};
diff --git a/servers/rendering/renderer_viewport.cpp b/servers/rendering/renderer_viewport.cpp
index f609fa6023..8813c2e651 100644
--- a/servers/rendering/renderer_viewport.cpp
+++ b/servers/rendering/renderer_viewport.cpp
@@ -962,6 +962,13 @@ void RendererViewport::viewport_set_update_mode(RID p_viewport, RS::ViewportUpda
viewport->update_mode = p_mode;
}
+RID RendererViewport::viewport_get_render_target(RID p_viewport) const {
+ const Viewport *viewport = viewport_owner.get_or_null(p_viewport);
+ ERR_FAIL_COND_V(!viewport, RID());
+
+ return viewport->render_target;
+}
+
RID RendererViewport::viewport_get_texture(RID p_viewport) const {
const Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND_V(!viewport, RID());
diff --git a/servers/rendering/renderer_viewport.h b/servers/rendering/renderer_viewport.h
index c24275de6e..2f9537a47c 100644
--- a/servers/rendering/renderer_viewport.h
+++ b/servers/rendering/renderer_viewport.h
@@ -231,6 +231,7 @@ public:
void viewport_set_clear_mode(RID p_viewport, RS::ViewportClearMode p_clear_mode);
+ RID viewport_get_render_target(RID p_viewport) const;
RID viewport_get_texture(RID p_viewport) const;
RID viewport_get_occluder_debug_texture(RID p_viewport) const;
diff --git a/servers/rendering/rendering_device.cpp b/servers/rendering/rendering_device.cpp
index 2d000cc9da..0227f01f6f 100644
--- a/servers/rendering/rendering_device.cpp
+++ b/servers/rendering/rendering_device.cpp
@@ -731,6 +731,7 @@ void RenderingDevice::_bind_methods() {
ClassDB::bind_method(D_METHOD("framebuffer_is_valid", "framebuffer"), &RenderingDevice::framebuffer_is_valid);
ClassDB::bind_method(D_METHOD("sampler_create", "state"), &RenderingDevice::_sampler_create);
+ ClassDB::bind_method(D_METHOD("sampler_is_format_supported_for_filter", "format", "sampler_filter"), &RenderingDevice::sampler_is_format_supported_for_filter);
ClassDB::bind_method(D_METHOD("vertex_buffer_create", "size_bytes", "data", "use_as_storage"), &RenderingDevice::vertex_buffer_create, DEFVAL(Vector<uint8_t>()), DEFVAL(false));
ClassDB::bind_method(D_METHOD("vertex_format_create", "vertex_descriptions"), &RenderingDevice::_vertex_format_create);
diff --git a/servers/rendering/rendering_device.h b/servers/rendering/rendering_device.h
index 97acb3e7fd..e55db0a237 100644
--- a/servers/rendering/rendering_device.h
+++ b/servers/rendering/rendering_device.h
@@ -653,6 +653,7 @@ public:
};
virtual RID sampler_create(const SamplerState &p_state) = 0;
+ virtual bool sampler_is_format_supported_for_filter(DataFormat p_format, SamplerFilter p_sampler_filter) const = 0;
/**********************/
/**** VERTEX ARRAY ****/
diff --git a/servers/rendering/rendering_server_default.cpp b/servers/rendering/rendering_server_default.cpp
index 6017eff55e..5f14245307 100644
--- a/servers/rendering/rendering_server_default.cpp
+++ b/servers/rendering/rendering_server_default.cpp
@@ -237,7 +237,9 @@ void RenderingServerDefault::init() {
void RenderingServerDefault::finish() {
if (create_thread) {
command_queue.push(this, &RenderingServerDefault::_thread_exit);
- thread.wait_to_finish();
+ if (thread.is_started()) {
+ thread.wait_to_finish();
+ }
} else {
_finish();
}
diff --git a/servers/rendering/rendering_server_default.h b/servers/rendering/rendering_server_default.h
index 249e5c2d9d..d39bec8399 100644
--- a/servers/rendering/rendering_server_default.h
+++ b/servers/rendering/rendering_server_default.h
@@ -606,6 +606,7 @@ public:
FUNC2(viewport_set_update_mode, RID, ViewportUpdateMode)
+ FUNC1RC(RID, viewport_get_render_target, RID)
FUNC1RC(RID, viewport_get_texture, RID)
FUNC2(viewport_set_disable_2d, RID, bool)
diff --git a/servers/rendering/shader_compiler.cpp b/servers/rendering/shader_compiler.cpp
index 8d16a29659..af4ccdf6e3 100644
--- a/servers/rendering/shader_compiler.cpp
+++ b/servers/rendering/shader_compiler.cpp
@@ -38,12 +38,7 @@
#define SL ShaderLanguage
static String _mktab(int p_level) {
- String tb;
- for (int i = 0; i < p_level; i++) {
- tb += "\t";
- }
-
- return tb;
+ return String("\t").repeat(p_level);
}
static String _typestr(SL::DataType p_type) {
diff --git a/servers/rendering/shader_preprocessor.cpp b/servers/rendering/shader_preprocessor.cpp
index ff1d55f905..0644f5918c 100644
--- a/servers/rendering/shader_preprocessor.cpp
+++ b/servers/rendering/shader_preprocessor.cpp
@@ -54,9 +54,9 @@ int ShaderPreprocessor::Tokenizer::get_index() const {
return index;
}
-void ShaderPreprocessor::Tokenizer::get_and_clear_generated(Vector<ShaderPreprocessor::Token> *r_out) {
- for (int i = 0; i < generated.size(); i++) {
- r_out->push_back(generated[i]);
+void ShaderPreprocessor::Tokenizer::get_and_clear_generated(LocalVector<char32_t> *r_out) {
+ for (uint32_t i = 0; i < generated.size(); i++) {
+ r_out->push_back(generated[i].text);
}
generated.clear();
}
@@ -1206,18 +1206,14 @@ Error ShaderPreprocessor::preprocess(State *p_state, const String &p_code, Strin
break;
}
+ // Add autogenerated tokens if there are any.
+ p_tokenizer.get_and_clear_generated(&output);
+
if (state->disabled) {
// Preprocessor was disabled.
// Read the rest of the file into the output.
output.push_back(t.text);
continue;
- } else {
- // Add autogenerated tokens.
- Vector<Token> generated;
- p_tokenizer.get_and_clear_generated(&generated);
- for (int i = 0; i < generated.size(); i++) {
- output.push_back(generated[i].text);
- }
}
if (t.text == '#') {
diff --git a/servers/rendering/shader_preprocessor.h b/servers/rendering/shader_preprocessor.h
index f198af66f0..406b663228 100644
--- a/servers/rendering/shader_preprocessor.h
+++ b/servers/rendering/shader_preprocessor.h
@@ -83,7 +83,7 @@ private:
int line;
int index;
int size;
- Vector<Token> generated;
+ LocalVector<Token> generated;
private:
void add_generated(const Token &p_t);
@@ -95,7 +95,7 @@ private:
char32_t peek();
int consume_line_continuations(int p_offset);
- void get_and_clear_generated(Vector<Token> *r_out);
+ void get_and_clear_generated(LocalVector<char32_t> *r_out);
void backtrack(char32_t p_what);
LocalVector<Token> advance(char32_t p_what);
void skip_whitespace();
diff --git a/servers/rendering/shader_types.cpp b/servers/rendering/shader_types.cpp
index d95caeddc5..4e8057ef8f 100644
--- a/servers/rendering/shader_types.cpp
+++ b/servers/rendering/shader_types.cpp
@@ -187,6 +187,7 @@ ShaderTypes::ShaderTypes() {
shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["UV"] = constt(ShaderLanguage::TYPE_VEC2);
shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["UV2"] = constt(ShaderLanguage::TYPE_VEC2);
shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["VIEW"] = constt(ShaderLanguage::TYPE_VEC3);
+ shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["SPECULAR_AMOUNT"] = constt(ShaderLanguage::TYPE_FLOAT);
shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["LIGHT"] = constt(ShaderLanguage::TYPE_VEC3);
shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["LIGHT_COLOR"] = constt(ShaderLanguage::TYPE_VEC3);
shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["LIGHT_IS_DIRECTIONAL"] = constt(ShaderLanguage::TYPE_BOOL);
diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp
index 49617155cf..b8b642fac1 100644
--- a/servers/rendering_server.cpp
+++ b/servers/rendering_server.cpp
@@ -2198,6 +2198,7 @@ void RenderingServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("viewport_set_texture_mipmap_bias", "viewport", "mipmap_bias"), &RenderingServer::viewport_set_texture_mipmap_bias);
ClassDB::bind_method(D_METHOD("viewport_set_update_mode", "viewport", "update_mode"), &RenderingServer::viewport_set_update_mode);
ClassDB::bind_method(D_METHOD("viewport_set_clear_mode", "viewport", "clear_mode"), &RenderingServer::viewport_set_clear_mode);
+ ClassDB::bind_method(D_METHOD("viewport_get_render_target", "viewport"), &RenderingServer::viewport_get_render_target);
ClassDB::bind_method(D_METHOD("viewport_get_texture", "viewport"), &RenderingServer::viewport_get_texture);
ClassDB::bind_method(D_METHOD("viewport_set_disable_3d", "viewport", "disable"), &RenderingServer::viewport_set_disable_3d);
ClassDB::bind_method(D_METHOD("viewport_set_disable_2d", "viewport", "disable"), &RenderingServer::viewport_set_disable_2d);
@@ -2602,6 +2603,7 @@ void RenderingServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("canvas_item_add_line", "item", "from", "to", "color", "width", "antialiased"), &RenderingServer::canvas_item_add_line, DEFVAL(-1.0), DEFVAL(false));
ClassDB::bind_method(D_METHOD("canvas_item_add_polyline", "item", "points", "colors", "width", "antialiased"), &RenderingServer::canvas_item_add_polyline, DEFVAL(-1.0), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("canvas_item_add_multiline", "item", "points", "colors", "width"), &RenderingServer::canvas_item_add_multiline, DEFVAL(-1.0));
ClassDB::bind_method(D_METHOD("canvas_item_add_rect", "item", "rect", "color"), &RenderingServer::canvas_item_add_rect);
ClassDB::bind_method(D_METHOD("canvas_item_add_circle", "item", "pos", "radius", "color"), &RenderingServer::canvas_item_add_circle);
ClassDB::bind_method(D_METHOD("canvas_item_add_texture_rect", "item", "rect", "texture", "tile", "modulate", "transpose"), &RenderingServer::canvas_item_add_texture_rect, DEFVAL(false), DEFVAL(Color(1, 1, 1)), DEFVAL(false));
diff --git a/servers/rendering_server.h b/servers/rendering_server.h
index edf4771570..a5548db743 100644
--- a/servers/rendering_server.h
+++ b/servers/rendering_server.h
@@ -839,6 +839,7 @@ public:
virtual void viewport_set_clear_mode(RID p_viewport, ViewportClearMode p_clear_mode) = 0;
+ virtual RID viewport_get_render_target(RID p_viewport) const = 0;
virtual RID viewport_get_texture(RID p_viewport) const = 0;
enum ViewportEnvironmentMode {
diff --git a/tests/core/object/test_object.h b/tests/core/object/test_object.h
index 7e8f23a14f..98f9b3da65 100644
--- a/tests/core/object/test_object.h
+++ b/tests/core/object/test_object.h
@@ -339,6 +339,48 @@ TEST_CASE("[Object] Signals") {
CHECK_EQ(signals_after.size(), signals_after_empty_added.size());
}
+ SUBCASE("Deleting an object with connected signals should disconnect them") {
+ List<Object::Connection> signal_connections;
+
+ {
+ Object target;
+ target.add_user_signal(MethodInfo("my_custom_signal"));
+
+ ERR_PRINT_OFF;
+ target.connect("nonexistent_signal1", callable_mp(&object, &Object::notify_property_list_changed));
+ target.connect("my_custom_signal", callable_mp(&object, &Object::notify_property_list_changed));
+ target.connect("nonexistent_signal2", callable_mp(&object, &Object::notify_property_list_changed));
+ ERR_PRINT_ON;
+
+ signal_connections.clear();
+ object.get_all_signal_connections(&signal_connections);
+ CHECK(signal_connections.size() == 0);
+ signal_connections.clear();
+ object.get_signals_connected_to_this(&signal_connections);
+ CHECK(signal_connections.size() == 1);
+
+ ERR_PRINT_OFF;
+ object.connect("nonexistent_signal1", callable_mp(&target, &Object::notify_property_list_changed));
+ object.connect("my_custom_signal", callable_mp(&target, &Object::notify_property_list_changed));
+ object.connect("nonexistent_signal2", callable_mp(&target, &Object::notify_property_list_changed));
+ ERR_PRINT_ON;
+
+ signal_connections.clear();
+ object.get_all_signal_connections(&signal_connections);
+ CHECK(signal_connections.size() == 1);
+ signal_connections.clear();
+ object.get_signals_connected_to_this(&signal_connections);
+ CHECK(signal_connections.size() == 1);
+ }
+
+ signal_connections.clear();
+ object.get_all_signal_connections(&signal_connections);
+ CHECK(signal_connections.size() == 0);
+ signal_connections.clear();
+ object.get_signals_connected_to_this(&signal_connections);
+ CHECK(signal_connections.size() == 0);
+ }
+
SUBCASE("Emitting a non existing signal will return an error") {
Error err = object.emit_signal("some_signal");
CHECK(err == ERR_UNAVAILABLE);
diff --git a/tests/core/string/test_string.h b/tests/core/string/test_string.h
index abe9f78ccc..7c76e7aa7b 100644
--- a/tests/core/string/test_string.h
+++ b/tests/core/string/test_string.h
@@ -395,6 +395,12 @@ TEST_CASE("[String] Insertion") {
CHECK(s == "Who is Frederic Chopin?");
}
+TEST_CASE("[String] Erasing") {
+ String s = "Josephine is such a cute girl!";
+ s = s.erase(s.find("cute "), String("cute ").length());
+ CHECK(s == "Josephine is such a girl!");
+}
+
TEST_CASE("[String] Number to string") {
CHECK(String::num(0) == "0");
CHECK(String::num(0.0) == "0"); // No trailing zeros.
diff --git a/tests/scene/test_animation.h b/tests/scene/test_animation.h
index 0e16fc104c..89bf296815 100644
--- a/tests/scene/test_animation.h
+++ b/tests/scene/test_animation.h
@@ -82,11 +82,11 @@ TEST_CASE("[Animation] Create value track") {
CHECK(animation->track_get_key_transition(1, 0) == doctest::Approx(real_t(-1.0)));
// This is a value track, so the methods below should return errors.
- CHECK(animation->position_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
- CHECK(animation->rotation_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
- CHECK(animation->scale_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
+ CHECK(animation->try_position_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
+ CHECK(animation->try_rotation_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
+ CHECK(animation->try_scale_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
CHECK(animation->bezier_track_interpolate(0, 0.0) == doctest::Approx(0.0));
- CHECK(animation->blend_shape_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
+ CHECK(animation->try_blend_shape_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
ERR_PRINT_ON;
}
@@ -104,22 +104,22 @@ TEST_CASE("[Animation] Create 3D position track") {
Vector3 r_interpolation;
- CHECK(animation->position_track_interpolate(0, -0.2, &r_interpolation) == OK);
+ CHECK(animation->try_position_track_interpolate(0, -0.2, &r_interpolation) == OK);
CHECK(r_interpolation.is_equal_approx(Vector3(0, 1, 2)));
- CHECK(animation->position_track_interpolate(0, 0.0, &r_interpolation) == OK);
+ CHECK(animation->try_position_track_interpolate(0, 0.0, &r_interpolation) == OK);
CHECK(r_interpolation.is_equal_approx(Vector3(0, 1, 2)));
- CHECK(animation->position_track_interpolate(0, 0.2, &r_interpolation) == OK);
+ CHECK(animation->try_position_track_interpolate(0, 0.2, &r_interpolation) == OK);
CHECK(r_interpolation.is_equal_approx(Vector3(1.4, 2.2, 3.2)));
- CHECK(animation->position_track_interpolate(0, 0.4, &r_interpolation) == OK);
+ CHECK(animation->try_position_track_interpolate(0, 0.4, &r_interpolation) == OK);
CHECK(r_interpolation.is_equal_approx(Vector3(2.8, 3.4, 4.4)));
- CHECK(animation->position_track_interpolate(0, 0.5, &r_interpolation) == OK);
+ CHECK(animation->try_position_track_interpolate(0, 0.5, &r_interpolation) == OK);
CHECK(r_interpolation.is_equal_approx(Vector3(3.5, 4, 5)));
- CHECK(animation->position_track_interpolate(0, 0.6, &r_interpolation) == OK);
+ CHECK(animation->try_position_track_interpolate(0, 0.6, &r_interpolation) == OK);
CHECK(r_interpolation.is_equal_approx(Vector3(3.5, 4, 5)));
// 3D position tracks always use linear interpolation for performance reasons.
@@ -129,10 +129,10 @@ TEST_CASE("[Animation] Create 3D position track") {
// This is a 3D position track, so the methods below should return errors.
ERR_PRINT_OFF;
CHECK(animation->value_track_interpolate(0, 0.0).is_null());
- CHECK(animation->rotation_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
- CHECK(animation->scale_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
+ CHECK(animation->try_rotation_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
+ CHECK(animation->try_scale_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
CHECK(animation->bezier_track_interpolate(0, 0.0) == doctest::Approx(0.0));
- CHECK(animation->blend_shape_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
+ CHECK(animation->try_blend_shape_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
ERR_PRINT_ON;
}
@@ -150,22 +150,22 @@ TEST_CASE("[Animation] Create 3D rotation track") {
Quaternion r_interpolation;
- CHECK(animation->rotation_track_interpolate(0, -0.2, &r_interpolation) == OK);
+ CHECK(animation->try_rotation_track_interpolate(0, -0.2, &r_interpolation) == OK);
CHECK(r_interpolation.is_equal_approx(Quaternion(0.403423, 0.259035, 0.73846, 0.47416)));
- CHECK(animation->rotation_track_interpolate(0, 0.0, &r_interpolation) == OK);
+ CHECK(animation->try_rotation_track_interpolate(0, 0.0, &r_interpolation) == OK);
CHECK(r_interpolation.is_equal_approx(Quaternion(0.403423, 0.259035, 0.73846, 0.47416)));
- CHECK(animation->rotation_track_interpolate(0, 0.2, &r_interpolation) == OK);
+ CHECK(animation->try_rotation_track_interpolate(0, 0.2, &r_interpolation) == OK);
CHECK(r_interpolation.is_equal_approx(Quaternion(0.336182, 0.30704, 0.751515, 0.477425)));
- CHECK(animation->rotation_track_interpolate(0, 0.4, &r_interpolation) == OK);
+ CHECK(animation->try_rotation_track_interpolate(0, 0.4, &r_interpolation) == OK);
CHECK(r_interpolation.is_equal_approx(Quaternion(0.266585, 0.352893, 0.759303, 0.477344)));
- CHECK(animation->rotation_track_interpolate(0, 0.5, &r_interpolation) == OK);
+ CHECK(animation->try_rotation_track_interpolate(0, 0.5, &r_interpolation) == OK);
CHECK(r_interpolation.is_equal_approx(Quaternion(0.231055, 0.374912, 0.761204, 0.476048)));
- CHECK(animation->rotation_track_interpolate(0, 0.6, &r_interpolation) == OK);
+ CHECK(animation->try_rotation_track_interpolate(0, 0.6, &r_interpolation) == OK);
CHECK(r_interpolation.is_equal_approx(Quaternion(0.231055, 0.374912, 0.761204, 0.476048)));
// 3D rotation tracks always use linear interpolation for performance reasons.
@@ -175,10 +175,10 @@ TEST_CASE("[Animation] Create 3D rotation track") {
// This is a 3D rotation track, so the methods below should return errors.
ERR_PRINT_OFF;
CHECK(animation->value_track_interpolate(0, 0.0).is_null());
- CHECK(animation->position_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
- CHECK(animation->scale_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
+ CHECK(animation->try_position_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
+ CHECK(animation->try_scale_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
CHECK(animation->bezier_track_interpolate(0, 0.0) == doctest::Approx(real_t(0.0)));
- CHECK(animation->blend_shape_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
+ CHECK(animation->try_blend_shape_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
ERR_PRINT_ON;
}
@@ -196,22 +196,22 @@ TEST_CASE("[Animation] Create 3D scale track") {
Vector3 r_interpolation;
- CHECK(animation->scale_track_interpolate(0, -0.2, &r_interpolation) == OK);
+ CHECK(animation->try_scale_track_interpolate(0, -0.2, &r_interpolation) == OK);
CHECK(r_interpolation.is_equal_approx(Vector3(0, 1, 2)));
- CHECK(animation->scale_track_interpolate(0, 0.0, &r_interpolation) == OK);
+ CHECK(animation->try_scale_track_interpolate(0, 0.0, &r_interpolation) == OK);
CHECK(r_interpolation.is_equal_approx(Vector3(0, 1, 2)));
- CHECK(animation->scale_track_interpolate(0, 0.2, &r_interpolation) == OK);
+ CHECK(animation->try_scale_track_interpolate(0, 0.2, &r_interpolation) == OK);
CHECK(r_interpolation.is_equal_approx(Vector3(1.4, 2.2, 3.2)));
- CHECK(animation->scale_track_interpolate(0, 0.4, &r_interpolation) == OK);
+ CHECK(animation->try_scale_track_interpolate(0, 0.4, &r_interpolation) == OK);
CHECK(r_interpolation.is_equal_approx(Vector3(2.8, 3.4, 4.4)));
- CHECK(animation->scale_track_interpolate(0, 0.5, &r_interpolation) == OK);
+ CHECK(animation->try_scale_track_interpolate(0, 0.5, &r_interpolation) == OK);
CHECK(r_interpolation.is_equal_approx(Vector3(3.5, 4, 5)));
- CHECK(animation->scale_track_interpolate(0, 0.6, &r_interpolation) == OK);
+ CHECK(animation->try_scale_track_interpolate(0, 0.6, &r_interpolation) == OK);
CHECK(r_interpolation.is_equal_approx(Vector3(3.5, 4, 5)));
// 3D scale tracks always use linear interpolation for performance reasons.
@@ -221,10 +221,10 @@ TEST_CASE("[Animation] Create 3D scale track") {
// This is a 3D scale track, so the methods below should return errors.
ERR_PRINT_OFF;
CHECK(animation->value_track_interpolate(0, 0.0).is_null());
- CHECK(animation->position_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
- CHECK(animation->rotation_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
+ CHECK(animation->try_position_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
+ CHECK(animation->try_rotation_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
CHECK(animation->bezier_track_interpolate(0, 0.0) == doctest::Approx(0.0));
- CHECK(animation->blend_shape_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
+ CHECK(animation->try_blend_shape_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
ERR_PRINT_ON;
}
@@ -247,22 +247,22 @@ TEST_CASE("[Animation] Create blend shape track") {
CHECK(animation->blend_shape_track_get_key(0, 1, &r_blend) == OK);
CHECK(r_blend == doctest::Approx(1.0f));
- CHECK(animation->blend_shape_track_interpolate(0, -0.2, &r_blend) == OK);
+ CHECK(animation->try_blend_shape_track_interpolate(0, -0.2, &r_blend) == OK);
CHECK(r_blend == doctest::Approx(-1.0f));
- CHECK(animation->blend_shape_track_interpolate(0, 0.0, &r_blend) == OK);
+ CHECK(animation->try_blend_shape_track_interpolate(0, 0.0, &r_blend) == OK);
CHECK(r_blend == doctest::Approx(-1.0f));
- CHECK(animation->blend_shape_track_interpolate(0, 0.2, &r_blend) == OK);
+ CHECK(animation->try_blend_shape_track_interpolate(0, 0.2, &r_blend) == OK);
CHECK(r_blend == doctest::Approx(-0.2f));
- CHECK(animation->blend_shape_track_interpolate(0, 0.4, &r_blend) == OK);
+ CHECK(animation->try_blend_shape_track_interpolate(0, 0.4, &r_blend) == OK);
CHECK(r_blend == doctest::Approx(0.6f));
- CHECK(animation->blend_shape_track_interpolate(0, 0.5, &r_blend) == OK);
+ CHECK(animation->try_blend_shape_track_interpolate(0, 0.5, &r_blend) == OK);
CHECK(r_blend == doctest::Approx(1.0f));
- CHECK(animation->blend_shape_track_interpolate(0, 0.6, &r_blend) == OK);
+ CHECK(animation->try_blend_shape_track_interpolate(0, 0.6, &r_blend) == OK);
CHECK(r_blend == doctest::Approx(1.0f));
// Blend shape tracks always use linear interpolation for performance reasons.
@@ -272,9 +272,9 @@ TEST_CASE("[Animation] Create blend shape track") {
// This is a blend shape track, so the methods below should return errors.
ERR_PRINT_OFF;
CHECK(animation->value_track_interpolate(0, 0.0).is_null());
- CHECK(animation->position_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
- CHECK(animation->rotation_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
- CHECK(animation->scale_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
+ CHECK(animation->try_position_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
+ CHECK(animation->try_rotation_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
+ CHECK(animation->try_scale_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
CHECK(animation->bezier_track_interpolate(0, 0.0) == doctest::Approx(0.0));
ERR_PRINT_ON;
}
@@ -302,10 +302,10 @@ TEST_CASE("[Animation] Create Bezier track") {
// This is a bezier track, so the methods below should return errors.
ERR_PRINT_OFF;
CHECK(animation->value_track_interpolate(0, 0.0).is_null());
- CHECK(animation->position_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
- CHECK(animation->rotation_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
- CHECK(animation->scale_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
- CHECK(animation->blend_shape_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
+ CHECK(animation->try_position_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
+ CHECK(animation->try_rotation_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
+ CHECK(animation->try_scale_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
+ CHECK(animation->try_blend_shape_track_interpolate(0, 0.0, nullptr) == ERR_INVALID_PARAMETER);
ERR_PRINT_ON;
}
diff --git a/tests/scene/test_code_edit.h b/tests/scene/test_code_edit.h
index c5407d4bcd..9b8ad32e32 100644
--- a/tests/scene/test_code_edit.h
+++ b/tests/scene/test_code_edit.h
@@ -2314,6 +2314,143 @@ TEST_CASE("[SceneTree][CodeEdit] indent") {
}
}
+ SUBCASE("[CodeEdit] convert indent to tabs") {
+ code_edit->set_indent_size(4);
+ code_edit->set_indent_using_spaces(false);
+
+ // Only line.
+ code_edit->insert_text_at_caret(" test");
+ code_edit->set_caret_line(0);
+ code_edit->set_caret_column(8);
+ code_edit->select(0, 8, 0, 9);
+ code_edit->convert_indent();
+ CHECK(code_edit->get_line(0) == "\t\ttest");
+ CHECK(code_edit->get_caret_column() == 2);
+ CHECK(code_edit->get_selection_from_column() == 2);
+ CHECK(code_edit->get_selection_to_column() == 3);
+
+ // First line.
+ code_edit->set_text("");
+ code_edit->insert_text_at_caret(" test\n");
+ code_edit->set_caret_line(0);
+ code_edit->set_caret_column(8);
+ code_edit->select(0, 8, 0, 9);
+ code_edit->convert_indent();
+ CHECK(code_edit->get_line(0) == "\t\ttest");
+ CHECK(code_edit->get_caret_column() == 2);
+ CHECK(code_edit->get_selection_from_column() == 2);
+ CHECK(code_edit->get_selection_to_column() == 3);
+
+ // Middle line.
+ code_edit->set_text("");
+ code_edit->insert_text_at_caret("\n test\n");
+ code_edit->set_caret_line(1);
+ code_edit->set_caret_column(8);
+ code_edit->select(1, 8, 1, 9);
+ code_edit->convert_indent();
+ CHECK(code_edit->get_line(1) == "\t\ttest");
+ CHECK(code_edit->get_caret_column() == 2);
+ CHECK(code_edit->get_selection_from_column() == 2);
+ CHECK(code_edit->get_selection_to_column() == 3);
+
+ // End line.
+ code_edit->set_text("");
+ code_edit->insert_text_at_caret("\n test");
+ code_edit->set_caret_line(1);
+ code_edit->set_caret_column(8);
+ code_edit->select(1, 8, 1, 9);
+ code_edit->convert_indent();
+ CHECK(code_edit->get_line(1) == "\t\ttest");
+ CHECK(code_edit->get_caret_column() == 2);
+ CHECK(code_edit->get_selection_from_column() == 2);
+ CHECK(code_edit->get_selection_to_column() == 3);
+
+ // Within provided range.
+ code_edit->set_text("");
+ code_edit->insert_text_at_caret(" test\n test\n");
+ code_edit->set_caret_line(1);
+ code_edit->set_caret_column(8);
+ code_edit->select(1, 8, 1, 9);
+ code_edit->convert_indent(1, 1);
+ CHECK(code_edit->get_line(0) == " test");
+ CHECK(code_edit->get_line(1) == "\t\ttest");
+ CHECK(code_edit->get_caret_column() == 2);
+ CHECK(code_edit->get_selection_from_column() == 2);
+ CHECK(code_edit->get_selection_to_column() == 3);
+ }
+
+ SUBCASE("[CodeEdit] convert indent to spaces") {
+ code_edit->set_indent_size(4);
+ code_edit->set_indent_using_spaces(true);
+
+ // Only line.
+ code_edit->insert_text_at_caret("\t\ttest");
+ code_edit->set_caret_line(0);
+ code_edit->set_caret_column(2);
+ code_edit->select(0, 2, 0, 3);
+ code_edit->convert_indent();
+ CHECK(code_edit->get_line(0) == " test");
+ CHECK(code_edit->get_caret_column() == 8);
+ CHECK(code_edit->get_selection_from_column() == 8);
+ CHECK(code_edit->get_selection_to_column() == 9);
+
+ // First line.
+ code_edit->set_text("");
+ code_edit->insert_text_at_caret("\t\ttest\n");
+ code_edit->set_caret_line(0);
+ code_edit->set_caret_column(2);
+ code_edit->select(0, 2, 0, 3);
+ code_edit->convert_indent();
+ CHECK(code_edit->get_line(0) == " test");
+ CHECK(code_edit->get_caret_column() == 8);
+ CHECK(code_edit->get_selection_from_column() == 8);
+ CHECK(code_edit->get_selection_to_column() == 9);
+
+ // Middle line.
+ code_edit->set_text("");
+ code_edit->insert_text_at_caret("\n\t\ttest\n");
+ code_edit->set_caret_line(1);
+ code_edit->set_caret_column(2);
+ code_edit->select(1, 2, 1, 3);
+ code_edit->convert_indent();
+ CHECK(code_edit->get_line(1) == " test");
+ CHECK(code_edit->get_caret_column() == 8);
+ CHECK(code_edit->get_selection_from_column() == 8);
+ CHECK(code_edit->get_selection_to_column() == 9);
+
+ // End line.
+ code_edit->set_text("");
+ code_edit->insert_text_at_caret("\n\t\ttest");
+ code_edit->set_caret_line(1);
+ code_edit->set_caret_column(2);
+ code_edit->select(1, 2, 1, 3);
+ code_edit->convert_indent();
+ CHECK(code_edit->get_line(1) == " test");
+ CHECK(code_edit->get_caret_column() == 8);
+ CHECK(code_edit->get_selection_from_column() == 8);
+ CHECK(code_edit->get_selection_to_column() == 9);
+
+ // Within provided range.
+ code_edit->set_text("");
+ code_edit->insert_text_at_caret("\ttest\n\t\ttest\n");
+ code_edit->set_caret_line(1);
+ code_edit->set_caret_column(2);
+ code_edit->select(1, 2, 1, 3);
+ code_edit->convert_indent(1, 1);
+ CHECK(code_edit->get_line(0) == "\ttest");
+ CHECK(code_edit->get_line(1) == " test");
+ CHECK(code_edit->get_caret_column() == 8);
+ CHECK(code_edit->get_selection_from_column() == 8);
+ CHECK(code_edit->get_selection_to_column() == 9);
+
+ // Outside of range.
+ ERR_PRINT_OFF;
+ code_edit->convert_indent(0, 4);
+ code_edit->convert_indent(4, 5);
+ code_edit->convert_indent(4, 1);
+ ERR_PRINT_ON;
+ }
+
memdelete(code_edit);
}