summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/linux_builds.yml6
-rw-r--r--SConstruct9
-rw-r--r--core/SCsub1
-rw-r--r--core/config/engine.cpp13
-rw-r--r--core/config/engine.h6
-rw-r--r--core/core_bind.cpp117
-rw-r--r--core/core_bind.h58
-rw-r--r--core/core_constants.cpp4
-rw-r--r--core/debugger/remote_debugger_peer.cpp2
-rw-r--r--core/extension/SCsub7
-rw-r--r--core/extension/extension_api_dump.cpp805
-rw-r--r--core/extension/extension_api_dump.h (renamed from platform/javascript/http_client.h.inc)30
-rw-r--r--core/extension/gdnative_interface.cpp688
-rw-r--r--core/extension/gdnative_interface.h427
-rw-r--r--core/extension/native_extension.cpp411
-rw-r--r--core/extension/native_extension.h94
-rw-r--r--core/extension/native_extension_manager.cpp130
-rw-r--r--core/extension/native_extension_manager.h71
-rw-r--r--core/input/input.cpp110
-rw-r--r--core/input/input.h46
-rw-r--r--core/input/input_enums.h126
-rw-r--r--core/input/input_event.cpp119
-rw-r--r--core/input/input_event.h109
-rw-r--r--core/input/input_map.cpp5
-rw-r--r--core/io/file_access_network.cpp2
-rw-r--r--core/io/http_client.cpp704
-rw-r--r--core/io/http_client.h83
-rw-r--r--core/io/http_client_tcp.cpp666
-rw-r--r--core/io/http_client_tcp.h92
-rw-r--r--core/io/image.cpp12
-rw-r--r--core/io/image_loader.cpp2
-rw-r--r--core/io/json.cpp57
-rw-r--r--core/io/json.h38
-rw-r--r--core/io/marshalls.cpp509
-rw-r--r--core/io/marshalls.h32
-rw-r--r--core/io/multiplayer_api.cpp4
-rw-r--r--core/io/packet_peer.cpp2
-rw-r--r--core/io/resource.cpp4
-rw-r--r--core/io/resource_format_binary.cpp2
-rw-r--r--core/io/resource_loader.cpp2
-rw-r--r--core/io/resource_saver.cpp2
-rw-r--r--core/io/stream_peer.cpp2
-rw-r--r--core/math/basis.h8
-rw-r--r--core/math/geometry_2d.h13
-rw-r--r--core/math/quaternion.cpp5
-rw-r--r--core/math/quaternion.h7
-rw-r--r--core/math/transform_2d.cpp12
-rw-r--r--core/math/transform_2d.h2
-rw-r--r--core/math/transform_3d.cpp11
-rw-r--r--core/math/transform_3d.h2
-rw-r--r--core/object/SCsub5
-rw-r--r--core/object/class_db.cpp19
-rw-r--r--core/object/class_db.h8
-rw-r--r--core/object/make_virtuals.py152
-rw-r--r--core/object/method_bind.cpp29
-rw-r--r--core/object/method_bind.h2
-rw-r--r--core/object/object.cpp40
-rw-r--r--core/object/object.h47
-rw-r--r--core/object/ref_counted.h8
-rw-r--r--core/object/script_language.cpp4
-rw-r--r--core/object/script_language.h10
-rw-r--r--core/os/midi_driver.cpp10
-rw-r--r--core/register_core_types.cpp67
-rw-r--r--core/register_core_types.h1
-rw-r--r--core/string/translation_po.cpp2
-rw-r--r--core/string/ustring.cpp6
-rw-r--r--core/string/ustring.h2
-rw-r--r--core/templates/rid_owner.h3
-rw-r--r--core/variant/binder_common.h9
-rw-r--r--core/variant/method_ptrcall.h14
-rw-r--r--core/variant/variant.cpp6
-rw-r--r--core/variant/variant.h5
-rw-r--r--core/variant/variant_call.cpp22
-rw-r--r--core/variant/variant_construct.cpp538
-rw-r--r--core/variant/variant_construct.h572
-rw-r--r--core/variant/variant_op.cpp1347
-rw-r--r--core/variant/variant_op.h1316
-rw-r--r--core/variant/variant_parser.cpp79
-rw-r--r--core/variant/variant_setget.cpp283
-rw-r--r--core/variant/variant_setget.h332
-rw-r--r--core/variant/variant_utility.cpp19
-rw-r--r--doc/classes/@GlobalScope.xml15
-rw-r--r--doc/classes/AABB.xml6
-rw-r--r--doc/classes/AESContext.xml2
-rw-r--r--doc/classes/AnimatedSprite2D.xml2
-rw-r--r--doc/classes/Animation.xml4
-rw-r--r--doc/classes/AnimationNodeBlendSpace2D.xml6
-rw-r--r--doc/classes/AnimationNodeBlendTree.xml4
-rw-r--r--doc/classes/AnimationNodeStateMachine.xml2
-rw-r--r--doc/classes/Area2D.xml2
-rw-r--r--doc/classes/Area3D.xml2
-rw-r--r--doc/classes/ArrayMesh.xml4
-rw-r--r--doc/classes/AtlasTexture.xml4
-rw-r--r--doc/classes/AudioStreamSample.xml2
-rw-r--r--doc/classes/BackBufferCopy.xml2
-rw-r--r--doc/classes/BaseMaterial3D.xml16
-rw-r--r--doc/classes/Basis.xml32
-rw-r--r--doc/classes/Bone2D.xml2
-rw-r--r--doc/classes/BoxMesh.xml2
-rw-r--r--doc/classes/BoxShape3D.xml2
-rw-r--r--doc/classes/Button.xml22
-rw-r--r--doc/classes/CPUParticles2D.xml6
-rw-r--r--doc/classes/CPUParticles3D.xml10
-rw-r--r--doc/classes/CallbackTweener.xml29
-rw-r--r--doc/classes/Camera2D.xml4
-rw-r--r--doc/classes/Camera3D.xml2
-rw-r--r--doc/classes/CanvasItem.xml32
-rw-r--r--doc/classes/CanvasLayer.xml6
-rw-r--r--doc/classes/CanvasModulate.xml2
-rw-r--r--doc/classes/CanvasTexture.xml2
-rw-r--r--doc/classes/CharFXTransform.xml6
-rw-r--r--doc/classes/CharacterBody2D.xml6
-rw-r--r--doc/classes/CharacterBody3D.xml6
-rw-r--r--doc/classes/CheckBox.xml12
-rw-r--r--doc/classes/CheckButton.xml12
-rw-r--r--doc/classes/ClassDB.xml4
-rw-r--r--doc/classes/CodeEdit.xml94
-rw-r--r--doc/classes/CodeHighlighter.xml8
-rw-r--r--doc/classes/CollisionPolygon2D.xml2
-rw-r--r--doc/classes/CollisionPolygon3D.xml2
-rw-r--r--doc/classes/Color.xml336
-rw-r--r--doc/classes/ColorPicker.xml2
-rw-r--r--doc/classes/ColorPickerButton.xml12
-rw-r--r--doc/classes/ColorRect.xml2
-rw-r--r--doc/classes/ConcavePolygonShape2D.xml2
-rw-r--r--doc/classes/ConfigFile.xml2
-rw-r--r--doc/classes/ConfirmationDialog.xml4
-rw-r--r--doc/classes/Control.xml36
-rw-r--r--doc/classes/ConvexPolygonShape2D.xml2
-rw-r--r--doc/classes/ConvexPolygonShape3D.xml2
-rw-r--r--doc/classes/Curve2D.xml4
-rw-r--r--doc/classes/Curve3D.xml4
-rw-r--r--doc/classes/CylinderMesh.xml10
-rw-r--r--doc/classes/Decal.xml4
-rw-r--r--doc/classes/DisplayServer.xml8
-rw-r--r--doc/classes/EditorNode3DGizmo.xml4
-rw-r--r--doc/classes/EditorNode3DGizmoPlugin.xml2
-rw-r--r--doc/classes/EditorPlugin.xml2
-rw-r--r--doc/classes/EditorSceneImporterMesh.xml4
-rw-r--r--doc/classes/Engine.xml5
-rw-r--r--doc/classes/EngineDebugger.xml2
-rw-r--r--doc/classes/Environment.xml12
-rw-r--r--doc/classes/Expression.xml4
-rw-r--r--doc/classes/FileDialog.xml8
-rw-r--r--doc/classes/Font.xml12
-rw-r--r--doc/classes/FontData.xml4
-rw-r--r--doc/classes/GPUParticles2D.xml2
-rw-r--r--doc/classes/GPUParticles3D.xml2
-rw-r--r--doc/classes/GPUParticlesAttractorBox.xml2
-rw-r--r--doc/classes/GPUParticlesAttractorVectorField.xml2
-rw-r--r--doc/classes/GPUParticlesCollisionBox.xml2
-rw-r--r--doc/classes/GPUParticlesCollisionHeightField.xml2
-rw-r--r--doc/classes/GPUParticlesCollisionSDF.xml2
-rw-r--r--doc/classes/Gradient.xml4
-rw-r--r--doc/classes/GraphEdit.xml14
-rw-r--r--doc/classes/GraphNode.xml8
-rw-r--r--doc/classes/HTTPRequest.xml6
-rw-r--r--doc/classes/HeightMapShape3D.xml2
-rw-r--r--doc/classes/Image.xml2
-rw-r--r--doc/classes/Input.xml8
-rw-r--r--doc/classes/InputEvent.xml17
-rw-r--r--doc/classes/InputEventGesture.xml2
-rw-r--r--doc/classes/InputEventJoypadButton.xml2
-rw-r--r--doc/classes/InputEventJoypadMotion.xml2
-rw-r--r--doc/classes/InputEventMIDI.xml2
-rw-r--r--doc/classes/InputEventMouse.xml4
-rw-r--r--doc/classes/InputEventMouseButton.xml2
-rw-r--r--doc/classes/InputEventMouseMotion.xml6
-rw-r--r--doc/classes/InputEventPanGesture.xml2
-rw-r--r--doc/classes/InputEventScreenDrag.xml6
-rw-r--r--doc/classes/InputEventScreenTouch.xml2
-rw-r--r--doc/classes/InstancePlaceholder.xml2
-rw-r--r--doc/classes/IntervalTweener.xml16
-rw-r--r--doc/classes/ItemList.xml10
-rw-r--r--doc/classes/JSON.xml69
-rw-r--r--doc/classes/JSONParseResult.xml51
-rw-r--r--doc/classes/JSONParser.xml57
-rw-r--r--doc/classes/KinematicCollision2D.xml13
-rw-r--r--doc/classes/KinematicCollision3D.xml13
-rw-r--r--doc/classes/Label.xml8
-rw-r--r--doc/classes/Light2D.xml4
-rw-r--r--doc/classes/Light3D.xml6
-rw-r--r--doc/classes/Line2D.xml4
-rw-r--r--doc/classes/LineEdit.xml18
-rw-r--r--doc/classes/LineShape2D.xml4
-rw-r--r--doc/classes/LinkButton.xml10
-rw-r--r--doc/classes/MenuButton.xml10
-rw-r--r--doc/classes/Mesh.xml2
-rw-r--r--doc/classes/MeshInstance3D.xml2
-rw-r--r--doc/classes/MeshTexture.xml2
-rw-r--r--doc/classes/MethodTweener.xml43
-rw-r--r--doc/classes/MultiMesh.xml2
-rw-r--r--doc/classes/NativeExtension.xml57
-rw-r--r--doc/classes/NativeExtensionManager.xml61
-rw-r--r--doc/classes/NinePatchRect.xml2
-rw-r--r--doc/classes/Node.xml24
-rw-r--r--doc/classes/Node2D.xml4
-rw-r--r--doc/classes/Node3D.xml12
-rw-r--r--doc/classes/OS.xml27
-rw-r--r--doc/classes/Object.xml4
-rw-r--r--doc/classes/Occluder3D.xml4
-rw-r--r--doc/classes/OccluderPolygon2D.xml2
-rw-r--r--doc/classes/OptionButton.xml10
-rw-r--r--doc/classes/PackedDataContainer.xml2
-rw-r--r--doc/classes/PackedScene.xml16
-rw-r--r--doc/classes/ParallaxBackground.xml10
-rw-r--r--doc/classes/ParallaxLayer.xml6
-rw-r--r--doc/classes/ParticlesMaterial.xml6
-rw-r--r--doc/classes/Performance.xml6
-rw-r--r--doc/classes/PhysicalBone3D.xml8
-rw-r--r--doc/classes/PhysicalSkyMaterial.xml6
-rw-r--r--doc/classes/PhysicsDirectBodyState2D.xml4
-rw-r--r--doc/classes/PhysicsDirectBodyState3D.xml8
-rw-r--r--doc/classes/PhysicsDirectSpaceState2D.xml6
-rw-r--r--doc/classes/PhysicsDirectSpaceState3D.xml2
-rw-r--r--doc/classes/PhysicsServer2D.xml8
-rw-r--r--doc/classes/PhysicsServer3D.xml8
-rw-r--r--doc/classes/PhysicsShapeQueryParameters2D.xml6
-rw-r--r--doc/classes/PhysicsShapeQueryParameters3D.xml4
-rw-r--r--doc/classes/PhysicsTestMotionResult2D.xml10
-rw-r--r--doc/classes/Plane.xml22
-rw-r--r--doc/classes/PlaneMesh.xml2
-rw-r--r--doc/classes/PointLight2D.xml2
-rw-r--r--doc/classes/Polygon2D.xml18
-rw-r--r--doc/classes/PopupMenu.xml12
-rw-r--r--doc/classes/PrimitiveMesh.xml2
-rw-r--r--doc/classes/PrismMesh.xml2
-rw-r--r--doc/classes/ProceduralSkyMaterial.xml8
-rw-r--r--doc/classes/ProgressBar.xml6
-rw-r--r--doc/classes/ProjectSettings.xml28
-rw-r--r--doc/classes/PropertyTweener.xml78
-rw-r--r--doc/classes/ProximityGroup3D.xml2
-rw-r--r--doc/classes/QuadMesh.xml2
-rw-r--r--doc/classes/Quaternion.xml44
-rw-r--r--doc/classes/RDFramebufferPass.xml35
-rw-r--r--doc/classes/RDPipelineColorBlendState.xml4
-rw-r--r--doc/classes/RDPipelineMultisampleState.xml2
-rw-r--r--doc/classes/RDShaderBytecode.xml10
-rw-r--r--doc/classes/RayCast2D.xml2
-rw-r--r--doc/classes/RayCast3D.xml4
-rw-r--r--doc/classes/Rect2.xml6
-rw-r--r--doc/classes/Rect2i.xml6
-rw-r--r--doc/classes/RectangleShape2D.xml2
-rw-r--r--doc/classes/ReferenceRect.xml2
-rw-r--r--doc/classes/ReflectionProbe.xml8
-rw-r--r--doc/classes/RenderingDevice.xml78
-rw-r--r--doc/classes/RenderingServer.xml4
-rw-r--r--doc/classes/Resource.xml2
-rw-r--r--doc/classes/ResourceLoader.xml2
-rw-r--r--doc/classes/RichTextLabel.xml56
-rw-r--r--doc/classes/RigidBody2D.xml10
-rw-r--r--doc/classes/RigidBody3D.xml8
-rw-r--r--doc/classes/SceneState.xml8
-rw-r--r--doc/classes/SceneTree.xml14
-rw-r--r--doc/classes/Script.xml4
-rw-r--r--doc/classes/SegmentShape2D.xml4
-rw-r--r--doc/classes/Signal.xml2
-rw-r--r--doc/classes/Skeleton3D.xml2
-rw-r--r--doc/classes/SkeletonIK3D.xml4
-rw-r--r--doc/classes/SkeletonModification2DJiggle.xml2
-rw-r--r--doc/classes/SkeletonModification2DPhysicalBones.xml4
-rw-r--r--doc/classes/Sprite2D.xml6
-rw-r--r--doc/classes/Sprite3D.xml4
-rw-r--r--doc/classes/SpriteBase3D.xml4
-rw-r--r--doc/classes/StaticBody2D.xml2
-rw-r--r--doc/classes/StaticBody3D.xml4
-rw-r--r--doc/classes/StreamPeerBuffer.xml2
-rw-r--r--doc/classes/String.xml2
-rw-r--r--doc/classes/StyleBoxFlat.xml8
-rw-r--r--doc/classes/StyleBoxLine.xml2
-rw-r--r--doc/classes/StyleBoxTexture.xml4
-rw-r--r--doc/classes/SubViewport.xml4
-rw-r--r--doc/classes/SurfaceTool.xml10
-rw-r--r--doc/classes/TabContainer.xml8
-rw-r--r--doc/classes/Tabs.xml8
-rw-r--r--doc/classes/TextEdit.xml82
-rw-r--r--doc/classes/TextLine.xml4
-rw-r--r--doc/classes/TextParagraph.xml18
-rw-r--r--doc/classes/TextServer.xml8
-rw-r--r--doc/classes/Texture2D.xml6
-rw-r--r--doc/classes/TextureProgressBar.xml8
-rw-r--r--doc/classes/TileData.xml44
-rw-r--r--doc/classes/TileMap.xml2
-rw-r--r--doc/classes/TileSet.xml4
-rw-r--r--doc/classes/TileSetAtlasSource.xml16
-rw-r--r--doc/classes/Transform2D.xml44
-rw-r--r--doc/classes/Transform3D.xml32
-rw-r--r--doc/classes/Tree.xml40
-rw-r--r--doc/classes/TreeItem.xml8
-rw-r--r--doc/classes/Tween.xml508
-rw-r--r--doc/classes/Tweener.xml22
-rw-r--r--doc/classes/Vector2.xml38
-rw-r--r--doc/classes/Vector2i.xml36
-rw-r--r--doc/classes/Vector3.xml44
-rw-r--r--doc/classes/Vector3i.xml40
-rw-r--r--doc/classes/VisibleOnScreenNotifier2D.xml2
-rw-r--r--doc/classes/VisibleOnScreenNotifier3D.xml2
-rw-r--r--doc/classes/VisualShader.xml2
-rw-r--r--doc/classes/VisualShaderNodeColorConstant.xml2
-rw-r--r--doc/classes/VisualShaderNodeColorUniform.xml2
-rw-r--r--doc/classes/VisualShaderNodeResizableBase.xml2
-rw-r--r--doc/classes/VisualShaderNodeTransformConstant.xml2
-rw-r--r--doc/classes/VisualShaderNodeTransformUniform.xml2
-rw-r--r--doc/classes/VisualShaderNodeVec3Constant.xml2
-rw-r--r--doc/classes/VisualShaderNodeVec3Uniform.xml2
-rw-r--r--doc/classes/VoxelGI.xml2
-rw-r--r--doc/classes/Window.xml20
-rw-r--r--doc/classes/WorldEnvironment.xml2
-rw-r--r--doc/classes/WorldMarginShape3D.xml2
-rw-r--r--doc/classes/float.xml33
-rw-r--r--doc/classes/int.xml45
-rw-r--r--doc/translations/ar.po6
-rw-r--r--doc/translations/ca.po6
-rw-r--r--doc/translations/classes.pot6
-rw-r--r--doc/translations/cs.po6
-rw-r--r--doc/translations/de.po6
-rw-r--r--doc/translations/es.po8
-rw-r--r--doc/translations/fa.po6
-rw-r--r--doc/translations/fi.po6
-rw-r--r--doc/translations/fr.po6
-rw-r--r--doc/translations/id.po6
-rw-r--r--doc/translations/it.po6
-rw-r--r--doc/translations/ja.po6
-rw-r--r--doc/translations/ko.po6
-rw-r--r--doc/translations/nl.po6
-rw-r--r--doc/translations/pl.po6
-rw-r--r--doc/translations/pt_BR.po6
-rw-r--r--doc/translations/ro.po6
-rw-r--r--doc/translations/ru.po6
-rw-r--r--doc/translations/sr_Cyrl.po6
-rw-r--r--doc/translations/th.po6
-rw-r--r--doc/translations/tr.po6
-rw-r--r--doc/translations/uk.po6
-rw-r--r--doc/translations/zh_Hans.po6
-rw-r--r--doc/translations/zh_Hant.po6
-rw-r--r--drivers/png/image_loader_png.cpp2
-rw-r--r--drivers/register_driver_types.cpp2
-rw-r--r--drivers/vulkan/rendering_device_vulkan.cpp784
-rw-r--r--drivers/vulkan/rendering_device_vulkan.h109
-rw-r--r--drivers/vulkan/vulkan_context.cpp63
-rw-r--r--drivers/vulkan/vulkan_context.h6
-rw-r--r--editor/action_map_editor.cpp26
-rw-r--r--editor/animation_track_editor.cpp4
-rw-r--r--editor/audio_stream_preview.cpp2
-rw-r--r--editor/code_editor.cpp85
-rw-r--r--editor/code_editor.h9
-rw-r--r--editor/create_dialog.cpp12
-rw-r--r--editor/debugger/editor_debugger_node.cpp2
-rw-r--r--editor/debugger/editor_debugger_server.cpp2
-rw-r--r--editor/debugger/editor_network_profiler.cpp10
-rw-r--r--editor/debugger/editor_profiler.cpp10
-rw-r--r--editor/debugger/editor_visual_profiler.cpp10
-rw-r--r--editor/debugger/script_editor_debugger.cpp8
-rw-r--r--editor/dependency_editor.cpp2
-rw-r--r--editor/doc_tools.cpp6
-rw-r--r--editor/editor_atlas_packer.cpp2
-rw-r--r--editor/editor_audio_buses.cpp6
-rw-r--r--editor/editor_autoload_settings.cpp12
-rw-r--r--editor/editor_data.cpp8
-rw-r--r--editor/editor_export.cpp8
-rw-r--r--editor/editor_feature_profile.cpp53
-rw-r--r--editor/editor_file_dialog.cpp2
-rw-r--r--editor/editor_file_system.cpp11
-rw-r--r--editor/editor_file_system.h1
-rw-r--r--editor/editor_folding.cpp8
-rw-r--r--editor/editor_fonts.cpp44
-rw-r--r--editor/editor_help_search.cpp2
-rw-r--r--editor/editor_inspector.cpp6
-rw-r--r--editor/editor_inspector.h6
-rw-r--r--editor/editor_layouts_dialog.cpp2
-rw-r--r--editor/editor_log.cpp27
-rw-r--r--editor/editor_node.cpp131
-rw-r--r--editor/editor_node.h6
-rw-r--r--editor/editor_plugin_settings.cpp10
-rw-r--r--editor/editor_properties.cpp109
-rw-r--r--editor/editor_properties.h2
-rw-r--r--editor/editor_properties_array_dict.cpp8
-rw-r--r--editor/editor_resource_picker.cpp12
-rw-r--r--editor/editor_resource_preview.cpp10
-rw-r--r--editor/editor_run_native.cpp2
-rw-r--r--editor/editor_settings.cpp14
-rw-r--r--editor/editor_spin_slider.cpp2
-rw-r--r--editor/editor_themes.cpp4
-rw-r--r--editor/export_template_manager.cpp8
-rw-r--r--editor/fileserver/editor_file_server.cpp2
-rw-r--r--editor/filesystem_dock.cpp4
-rw-r--r--editor/find_in_files.cpp2
-rw-r--r--editor/icons/CenterView.svg1
-rw-r--r--editor/icons/RectangleAddRemove.svg1
-rw-r--r--editor/icons/TileChecked.svg1
-rw-r--r--editor/icons/TileUnchecked.svg1
-rw-r--r--editor/import/editor_import_collada.cpp6
-rw-r--r--editor/import/resource_importer_bitmask.cpp4
-rw-r--r--editor/import/resource_importer_csv_translation.cpp2
-rw-r--r--editor/import/resource_importer_layered_texture.cpp4
-rw-r--r--editor/import/resource_importer_obj.cpp8
-rw-r--r--editor/import/resource_importer_scene.cpp4
-rw-r--r--editor/import/resource_importer_shader_file.cpp2
-rw-r--r--editor/import/resource_importer_texture.cpp6
-rw-r--r--editor/import/resource_importer_texture_atlas.cpp16
-rw-r--r--editor/import/resource_importer_wav.cpp2
-rw-r--r--editor/import/scene_import_settings.cpp16
-rw-r--r--editor/import/scene_importer_mesh.cpp15
-rw-r--r--editor/import_dock.cpp10
-rw-r--r--editor/localization_editor.cpp2
-rw-r--r--editor/node_3d_editor_gizmos.cpp8
-rw-r--r--editor/plugins/animation_blend_space_1d_editor.cpp6
-rw-r--r--editor/plugins/animation_blend_space_2d_editor.cpp6
-rw-r--r--editor/plugins/animation_blend_tree_editor_plugin.cpp4
-rw-r--r--editor/plugins/animation_player_editor_plugin.cpp8
-rw-r--r--editor/plugins/animation_state_machine_editor.cpp8
-rw-r--r--editor/plugins/animation_tree_editor_plugin.cpp2
-rw-r--r--editor/plugins/asset_library_editor_plugin.cpp16
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp44
-rw-r--r--editor/plugins/collision_polygon_3d_editor_plugin.cpp2
-rw-r--r--editor/plugins/cpu_particles_2d_editor_plugin.cpp2
-rw-r--r--editor/plugins/curve_editor_plugin.cpp6
-rw-r--r--editor/plugins/editor_preview_plugins.cpp12
-rw-r--r--editor/plugins/font_editor_plugin.cpp4
-rw-r--r--editor/plugins/gpu_particles_2d_editor_plugin.cpp14
-rw-r--r--editor/plugins/gpu_particles_3d_editor_plugin.cpp4
-rw-r--r--editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp2
-rw-r--r--editor/plugins/gradient_editor_plugin.cpp2
-rw-r--r--editor/plugins/material_editor_plugin.cpp34
-rw-r--r--editor/plugins/mesh_editor_plugin.cpp4
-rw-r--r--editor/plugins/mesh_library_editor_plugin.cpp2
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp152
-rw-r--r--editor/plugins/node_3d_editor_plugin.h7
-rw-r--r--editor/plugins/occluder_instance_3d_editor_plugin.cpp2
-rw-r--r--editor/plugins/ot_features_plugin.cpp2
-rw-r--r--editor/plugins/path_3d_editor_plugin.cpp2
-rw-r--r--editor/plugins/polygon_2d_editor_plugin.cpp4
-rw-r--r--editor/plugins/resource_preloader_editor_plugin.cpp4
-rw-r--r--editor/plugins/script_editor_plugin.cpp26
-rw-r--r--editor/plugins/script_editor_plugin.h3
-rw-r--r--editor/plugins/script_text_editor.cpp129
-rw-r--r--editor/plugins/script_text_editor.h3
-rw-r--r--editor/plugins/shader_editor_plugin.cpp16
-rw-r--r--editor/plugins/shader_file_editor_plugin.cpp2
-rw-r--r--editor/plugins/skeleton_3d_editor_plugin.cpp2
-rw-r--r--editor/plugins/sprite_2d_editor_plugin.cpp6
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.cpp56
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.h1
-rw-r--r--editor/plugins/style_box_editor_plugin.cpp2
-rw-r--r--editor/plugins/text_editor.cpp8
-rw-r--r--editor/plugins/texture_3d_editor_plugin.cpp6
-rw-r--r--editor/plugins/texture_editor_plugin.cpp2
-rw-r--r--editor/plugins/texture_layered_editor_plugin.cpp10
-rw-r--r--editor/plugins/theme_editor_plugin.cpp37
-rw-r--r--editor/plugins/theme_editor_plugin.h4
-rw-r--r--editor/plugins/theme_editor_preview.cpp4
-rw-r--r--editor/plugins/tiles/tile_atlas_view.cpp199
-rw-r--r--editor/plugins/tiles/tile_atlas_view.h19
-rw-r--r--editor/plugins/tiles/tile_data_editors.cpp2468
-rw-r--r--editor/plugins/tiles/tile_data_editors.h359
-rw-r--r--editor/plugins/tiles/tile_map_editor.cpp55
-rw-r--r--editor/plugins/tiles/tile_set_atlas_source_editor.cpp1215
-rw-r--r--editor/plugins/tiles/tile_set_atlas_source_editor.h30
-rw-r--r--editor/plugins/tiles/tile_set_editor.cpp104
-rw-r--r--editor/plugins/tiles/tile_set_editor.h12
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp27
-rw-r--r--editor/project_export.cpp12
-rw-r--r--editor/project_manager.cpp4
-rw-r--r--editor/property_editor.cpp18
-rw-r--r--editor/scene_tree_dock.cpp104
-rw-r--r--editor/scene_tree_dock.h8
-rw-r--r--editor/scene_tree_editor.cpp2
-rw-r--r--editor/settings_config_dialog.cpp2
-rw-r--r--main/main.cpp42
-rw-r--r--modules/basis_universal/register_types.cpp2
-rw-r--r--modules/basis_universal/texture_basisu.cpp2
-rw-r--r--modules/bmp/image_loader_bmp.cpp2
-rw-r--r--modules/camera/camera_osx.mm6
-rw-r--r--modules/csg/csg_shape.cpp6
-rw-r--r--modules/csg/doc_classes/CSGBox3D.xml2
-rw-r--r--modules/csg/doc_classes/CSGPolygon3D.xml2
-rw-r--r--modules/dds/register_types.cpp2
-rw-r--r--modules/fbx/data/fbx_material.cpp12
-rw-r--r--modules/fbx/data/fbx_mesh_data.cpp6
-rw-r--r--modules/fbx/editor_scene_importer_fbx.cpp26
-rw-r--r--modules/fbx/fbx_parser/FBXParser.cpp2
-rw-r--r--modules/fbx/register_types.cpp2
-rw-r--r--modules/fbx/tools/import_utils.h10
-rw-r--r--modules/fbx/tools/validation_tools.h3
-rw-r--r--modules/gdnative/gdnative.cpp8
-rw-r--r--modules/gdnative/gdnative_library_editor_plugin.cpp4
-rw-r--r--modules/gdnative/include/gdnative/variant.h2
-rw-r--r--modules/gdnative/include/pluginscript/godot_pluginscript.h2
-rw-r--r--modules/gdnative/nativescript/api_generator.cpp2
-rw-r--r--modules/gdnative/nativescript/nativescript.cpp8
-rw-r--r--modules/gdnative/nativescript/nativescript.h4
-rw-r--r--modules/gdnative/nativescript/register_types.cpp4
-rw-r--r--modules/gdnative/pluginscript/pluginscript_language.cpp19
-rw-r--r--modules/gdnative/pluginscript/pluginscript_language.h2
-rw-r--r--modules/gdnative/pluginscript/pluginscript_script.cpp18
-rw-r--r--modules/gdnative/pluginscript/pluginscript_script.h2
-rw-r--r--modules/gdnative/register_types.cpp8
-rw-r--r--modules/gdnative/videodecoder/register_types.cpp2
-rw-r--r--modules/gdnative/videodecoder/video_stream_gdnative.cpp2
-rw-r--r--modules/gdnative/xr/xr_interface_gdnative.cpp8
-rw-r--r--modules/gdnavigation/navigation_mesh_generator.cpp10
-rw-r--r--modules/gdscript/doc_classes/@GDScript.xml2
-rw-r--r--modules/gdscript/editor/gdscript_highlighter.cpp2
-rw-r--r--modules/gdscript/gdscript.cpp16
-rw-r--r--modules/gdscript/gdscript.h10
-rw-r--r--modules/gdscript/gdscript_analyzer.cpp8
-rw-r--r--modules/gdscript/gdscript_byte_codegen.cpp8
-rw-r--r--modules/gdscript/gdscript_cache.cpp4
-rw-r--r--modules/gdscript/gdscript_compiler.cpp2
-rw-r--r--modules/gdscript/gdscript_editor.cpp24
-rw-r--r--modules/gdscript/language_server/gdscript_extend_parser.cpp10
-rw-r--r--modules/gdscript/language_server/gdscript_language_protocol.cpp11
-rw-r--r--modules/gdscript/language_server/gdscript_workspace.cpp2
-rw-r--r--modules/gdscript/register_types.cpp10
-rw-r--r--modules/gdscript/tests/gdscript_test_runner.cpp8
-rw-r--r--modules/gdscript/tests/test_gdscript.cpp2
-rw-r--r--modules/gltf/doc_classes/GLTFAccessor.xml4
-rw-r--r--modules/gltf/doc_classes/GLTFLight.xml2
-rw-r--r--modules/gltf/doc_classes/GLTFMesh.xml2
-rw-r--r--modules/gltf/doc_classes/GLTFNode.xml10
-rw-r--r--modules/gltf/doc_classes/GLTFSkeleton.xml4
-rw-r--r--modules/gltf/doc_classes/GLTFSkin.xml8
-rw-r--r--modules/gltf/doc_classes/GLTFSpecGloss.xml4
-rw-r--r--modules/gltf/doc_classes/GLTFState.xml6
-rw-r--r--modules/gltf/doc_classes/PackedSceneGLTF.xml2
-rw-r--r--modules/gltf/editor_scene_exporter_gltf_plugin.cpp2
-rw-r--r--modules/gltf/editor_scene_importer_gltf.cpp13
-rw-r--r--modules/gltf/editor_scene_importer_gltf.h1
-rw-r--r--modules/gltf/gltf_document.cpp134
-rw-r--r--modules/gltf/register_types.cpp2
-rw-r--r--modules/gridmap/doc_classes/GridMap.xml2
-rw-r--r--modules/gridmap/grid_map.cpp4
-rw-r--r--modules/gridmap/grid_map_editor_plugin.cpp10
-rw-r--r--modules/jpg/image_loader_jpegd.cpp2
-rw-r--r--modules/jsonrpc/jsonrpc.cpp13
-rw-r--r--modules/lightmapper_rd/lightmapper_rd.cpp34
-rw-r--r--modules/mbedtls/crypto_mbedtls.cpp4
-rw-r--r--modules/mbedtls/dtls_server_mbedtls.cpp4
-rw-r--r--modules/mbedtls/packet_peer_mbed_dtls.cpp2
-rw-r--r--modules/mbedtls/stream_peer_mbedtls.cpp2
-rw-r--r--modules/minimp3/audio_stream_mp3.cpp2
-rw-r--r--modules/minimp3/doc_classes/AudioStreamMP3.xml2
-rw-r--r--modules/minimp3/register_types.cpp2
-rw-r--r--modules/minimp3/resource_importer_mp3.cpp2
-rw-r--r--modules/mobile_vr/register_types.cpp2
-rw-r--r--modules/mono/class_db_api_json.cpp3
-rw-r--r--modules/mono/csharp_script.cpp11
-rw-r--r--modules/mono/csharp_script.h7
-rw-r--r--modules/mono/editor/bindings_generator.cpp6
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/PackedSceneExtensions.cs8
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs17
-rw-r--r--modules/mono/glue/base_object_glue.cpp4
-rw-r--r--modules/mono/mono_gd/gd_mono.cpp4
-rw-r--r--modules/mono/mono_gd/gd_mono_utils.cpp2
-rw-r--r--modules/mono/register_types.cpp4
-rw-r--r--modules/opensimplex/doc_classes/NoiseTexture.xml2
-rw-r--r--modules/opensimplex/doc_classes/OpenSimplexNoise.xml2
-rw-r--r--modules/opensimplex/noise_texture.cpp2
-rw-r--r--modules/pvr/image_compress_pvrtc.cpp2
-rw-r--r--modules/pvr/register_types.cpp2
-rw-r--r--modules/regex/doc_classes/RegExMatch.xml2
-rw-r--r--modules/stb_vorbis/audio_stream_ogg_vorbis.cpp2
-rw-r--r--modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml2
-rw-r--r--modules/stb_vorbis/register_types.cpp2
-rw-r--r--modules/stb_vorbis/resource_importer_ogg_vorbis.cpp2
-rw-r--r--modules/text_server_adv/dynamic_font_adv.cpp2
-rw-r--r--modules/text_server_fb/dynamic_font_fb.cpp2
-rw-r--r--modules/tga/image_loader_tga.cpp2
-rw-r--r--modules/theora/register_types.cpp2
-rw-r--r--modules/theora/video_stream_theora.cpp2
-rw-r--r--modules/upnp/upnp.cpp2
-rw-r--r--modules/visual_script/doc_classes/VisualScript.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptComment.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptFunctionState.xml2
-rw-r--r--modules/visual_script/visual_script.cpp8
-rw-r--r--modules/visual_script/visual_script.h8
-rw-r--r--modules/visual_script/visual_script_builtin_funcs.cpp2
-rw-r--r--modules/visual_script/visual_script_builtin_funcs.h2
-rw-r--r--modules/visual_script/visual_script_editor.cpp212
-rw-r--r--modules/visual_script/visual_script_editor.h3
-rw-r--r--modules/visual_script/visual_script_expression.cpp2
-rw-r--r--modules/visual_script/visual_script_expression.h2
-rw-r--r--modules/visual_script/visual_script_flow_control.cpp16
-rw-r--r--modules/visual_script/visual_script_flow_control.h14
-rw-r--r--modules/visual_script/visual_script_func_nodes.cpp16
-rw-r--r--modules/visual_script/visual_script_func_nodes.h8
-rw-r--r--modules/visual_script/visual_script_nodes.cpp260
-rw-r--r--modules/visual_script/visual_script_nodes.h56
-rw-r--r--modules/visual_script/visual_script_yield_nodes.cpp12
-rw-r--r--modules/visual_script/visual_script_yield_nodes.h4
-rw-r--r--modules/webm/register_types.cpp2
-rw-r--r--modules/webm/video_stream_webm.cpp2
-rw-r--r--modules/webp/image_loader_webp.cpp2
-rw-r--r--modules/websocket/doc_classes/WebSocketClient.xml4
-rw-r--r--modules/websocket/doc_classes/WebSocketServer.xml5
-rw-r--r--modules/websocket/websocket_client.cpp13
-rw-r--r--modules/websocket/websocket_server.cpp19
-rw-r--r--modules/websocket/websocket_server.h4
-rw-r--r--modules/websocket/wsl_client.cpp5
-rw-r--r--modules/websocket/wsl_server.cpp8
-rw-r--r--modules/websocket/wsl_server.h4
-rw-r--r--modules/webxr/register_types.cpp2
-rw-r--r--modules/webxr/webxr_interface_js.cpp2
-rw-r--r--platform/android/display_server_android.cpp54
-rw-r--r--platform/android/display_server_android.h10
-rw-r--r--platform/android/export/export.cpp56
-rw-r--r--platform/android/java/app/build.gradle14
-rw-r--r--platform/android/java/app/config.gradle33
-rw-r--r--platform/android/java/build.gradle3
-rw-r--r--platform/android/java/gradle/wrapper/gradle-wrapper.properties6
-rw-r--r--platform/android/java_godot_lib_jni.cpp8
-rw-r--r--platform/android/plugin/godot_plugin_jni.cpp2
-rw-r--r--platform/iphone/display_server_iphone.mm6
-rw-r--r--platform/iphone/export/export.cpp51
-rw-r--r--platform/iphone/plugin/godot_plugin_config.h81
-rw-r--r--platform/javascript/display_server_javascript.cpp24
-rw-r--r--platform/javascript/export/export.cpp34
-rw-r--r--platform/javascript/http_client_javascript.cpp101
-rw-r--r--platform/javascript/http_client_javascript.h108
-rw-r--r--platform/javascript/javascript_singleton.cpp11
-rw-r--r--platform/javascript/js/libs/library_godot_javascript_singleton.js15
-rw-r--r--platform/linuxbsd/SCsub1
-rw-r--r--platform/linuxbsd/detect.py9
-rw-r--r--platform/linuxbsd/display_server_x11.cpp68
-rw-r--r--platform/linuxbsd/display_server_x11.h20
-rw-r--r--platform/linuxbsd/export/export.cpp4
-rw-r--r--platform/linuxbsd/freedesktop_screensaver.cpp124
-rw-r--r--platform/linuxbsd/freedesktop_screensaver.h47
-rw-r--r--platform/linuxbsd/joypad_linux.cpp20
-rw-r--r--platform/osx/display_server_osx.h4
-rw-r--r--platform/osx/display_server_osx.mm41
-rw-r--r--platform/osx/export/export.cpp6
-rw-r--r--platform/osx/joypad_osx.cpp26
-rw-r--r--platform/uwp/app.cpp16
-rw-r--r--platform/uwp/export/export.cpp4
-rw-r--r--platform/uwp/os_uwp.cpp6
-rw-r--r--platform/uwp/os_uwp.h4
-rw-r--r--platform/windows/display_server_windows.cpp44
-rw-r--r--platform/windows/display_server_windows.h4
-rw-r--r--platform/windows/export/export.cpp16
-rw-r--r--platform/windows/joypad_windows.cpp28
-rw-r--r--scene/2d/camera_2d.cpp2
-rw-r--r--scene/2d/canvas_modulate.cpp2
-rw-r--r--scene/2d/navigation_region_2d.cpp2
-rw-r--r--scene/2d/node_2d.cpp12
-rw-r--r--scene/2d/physics_body_2d.cpp12
-rw-r--r--scene/2d/physics_body_2d.h1
-rw-r--r--scene/2d/polygon_2d.cpp4
-rw-r--r--scene/2d/touch_screen_button.cpp4
-rw-r--r--scene/3d/audio_stream_player_3d.cpp2
-rw-r--r--scene/3d/camera_3d.cpp2
-rw-r--r--scene/3d/gpu_particles_collision_3d.cpp2
-rw-r--r--scene/3d/light_3d.cpp2
-rw-r--r--scene/3d/lightmap_gi.cpp10
-rw-r--r--scene/3d/mesh_instance_3d.cpp4
-rw-r--r--scene/3d/node_3d.cpp6
-rw-r--r--scene/3d/occluder_instance_3d.cpp4
-rw-r--r--scene/3d/physics_body_3d.cpp12
-rw-r--r--scene/3d/physics_body_3d.h1
-rw-r--r--scene/3d/ray_cast_3d.cpp2
-rw-r--r--scene/3d/reflection_probe.h2
-rw-r--r--scene/3d/skeleton_3d.cpp4
-rw-r--r--scene/3d/soft_body_3d.cpp2
-rw-r--r--scene/3d/voxel_gi.cpp6
-rw-r--r--scene/3d/voxelizer.cpp6
-rw-r--r--scene/3d/world_environment.cpp2
-rw-r--r--scene/3d/xr_nodes.cpp6
-rw-r--r--scene/animation/animation_blend_tree.cpp2
-rw-r--r--scene/animation/animation_node_state_machine.cpp4
-rw-r--r--scene/animation/animation_player.cpp10
-rw-r--r--scene/animation/tween.cpp2113
-rw-r--r--scene/animation/tween.h307
-rw-r--r--scene/debugger/scene_debugger.cpp4
-rw-r--r--scene/gui/button.cpp2
-rw-r--r--scene/gui/code_edit.cpp512
-rw-r--r--scene/gui/code_edit.h34
-rw-r--r--scene/gui/color_picker.cpp8
-rw-r--r--scene/gui/control.cpp27
-rw-r--r--scene/gui/control.h3
-rw-r--r--scene/gui/graph_edit.cpp4
-rw-r--r--scene/gui/graph_edit.h1
-rw-r--r--scene/gui/graph_node.cpp2
-rw-r--r--scene/gui/item_list.cpp4
-rw-r--r--scene/gui/label.cpp1
-rw-r--r--scene/gui/link_button.cpp2
-rw-r--r--scene/gui/popup_menu.h4
-rw-r--r--scene/gui/range.cpp2
-rw-r--r--scene/gui/rich_text_label.cpp136
-rw-r--r--scene/gui/rich_text_label.h22
-rw-r--r--scene/gui/scroll_container.cpp4
-rw-r--r--scene/gui/scroll_container.h2
-rw-r--r--scene/gui/shortcut.cpp2
-rw-r--r--scene/gui/spin_box.cpp4
-rw-r--r--scene/gui/tab_container.cpp2
-rw-r--r--scene/gui/tabs.cpp2
-rw-r--r--scene/gui/text_edit.cpp551
-rw-r--r--scene/gui/text_edit.h39
-rw-r--r--scene/gui/texture_progress_bar.cpp140
-rw-r--r--scene/gui/texture_progress_bar.h3
-rw-r--r--scene/gui/tree.cpp343
-rw-r--r--scene/gui/tree.h29
-rw-r--r--scene/gui/video_player.cpp4
-rw-r--r--scene/main/canvas_item.cpp2
-rw-r--r--scene/main/canvas_layer.cpp2
-rw-r--r--scene/main/http_request.cpp5
-rw-r--r--scene/main/instance_placeholder.cpp2
-rw-r--r--scene/main/node.cpp39
-rw-r--r--scene/main/node.h5
-rw-r--r--scene/main/scene_tree.cpp69
-rw-r--r--scene/main/scene_tree.h5
-rw-r--r--scene/main/timer.cpp4
-rw-r--r--scene/main/viewport.cpp28
-rw-r--r--scene/register_scene_types.cpp28
-rw-r--r--scene/resources/audio_stream_sample.cpp2
-rw-r--r--scene/resources/bit_map.cpp8
-rw-r--r--scene/resources/default_theme/default_theme.cpp8
-rw-r--r--scene/resources/font.cpp14
-rw-r--r--scene/resources/line_shape_2d.h3
-rw-r--r--scene/resources/material.cpp22
-rw-r--r--scene/resources/mesh.cpp4
-rw-r--r--scene/resources/multimesh.cpp8
-rw-r--r--scene/resources/packed_scene.cpp73
-rw-r--r--scene/resources/packed_scene.h8
-rw-r--r--scene/resources/primitive_meshes.cpp6
-rw-r--r--scene/resources/resource_format_text.cpp12
-rw-r--r--scene/resources/shader.cpp2
-rw-r--r--scene/resources/sprite_frames.cpp2
-rw-r--r--scene/resources/surface_tool.cpp2
-rw-r--r--scene/resources/texture.cpp27
-rw-r--r--scene/resources/tile_set.cpp2377
-rw-r--r--scene/resources/tile_set.h86
-rw-r--r--scene/resources/visual_shader.cpp14
-rw-r--r--scene/resources/visual_shader.h4
-rw-r--r--scene/resources/world_2d.cpp8
-rw-r--r--scene/resources/world_3d.cpp8
-rw-r--r--scene/scene_string_names.cpp1
-rw-r--r--scene/scene_string_names.h1
-rw-r--r--servers/audio/audio_effect.h2
-rw-r--r--servers/audio/audio_stream.cpp4
-rw-r--r--servers/audio/effects/audio_effect_amplify.cpp4
-rw-r--r--servers/audio/effects/audio_effect_amplify.h2
-rw-r--r--servers/audio/effects/audio_effect_capture.cpp4
-rw-r--r--servers/audio/effects/audio_effect_capture.h2
-rw-r--r--servers/audio/effects/audio_effect_chorus.cpp4
-rw-r--r--servers/audio/effects/audio_effect_chorus.h2
-rw-r--r--servers/audio/effects/audio_effect_compressor.cpp4
-rw-r--r--servers/audio/effects/audio_effect_compressor.h2
-rw-r--r--servers/audio/effects/audio_effect_delay.cpp4
-rw-r--r--servers/audio/effects/audio_effect_delay.h2
-rw-r--r--servers/audio/effects/audio_effect_distortion.cpp4
-rw-r--r--servers/audio/effects/audio_effect_distortion.h2
-rw-r--r--servers/audio/effects/audio_effect_eq.cpp4
-rw-r--r--servers/audio/effects/audio_effect_eq.h2
-rw-r--r--servers/audio/effects/audio_effect_filter.cpp4
-rw-r--r--servers/audio/effects/audio_effect_filter.h2
-rw-r--r--servers/audio/effects/audio_effect_limiter.cpp4
-rw-r--r--servers/audio/effects/audio_effect_limiter.h2
-rw-r--r--servers/audio/effects/audio_effect_panner.cpp4
-rw-r--r--servers/audio/effects/audio_effect_panner.h2
-rw-r--r--servers/audio/effects/audio_effect_phaser.cpp4
-rw-r--r--servers/audio/effects/audio_effect_phaser.h2
-rw-r--r--servers/audio/effects/audio_effect_pitch_shift.cpp4
-rw-r--r--servers/audio/effects/audio_effect_pitch_shift.h2
-rw-r--r--servers/audio/effects/audio_effect_record.cpp6
-rw-r--r--servers/audio/effects/audio_effect_record.h2
-rw-r--r--servers/audio/effects/audio_effect_reverb.cpp4
-rw-r--r--servers/audio/effects/audio_effect_reverb.h2
-rw-r--r--servers/audio/effects/audio_effect_spectrum_analyzer.cpp4
-rw-r--r--servers/audio/effects/audio_effect_spectrum_analyzer.h2
-rw-r--r--servers/audio/effects/audio_effect_stereo_enhance.cpp4
-rw-r--r--servers/audio/effects/audio_effect_stereo_enhance.h2
-rw-r--r--servers/audio/effects/audio_stream_generator.cpp2
-rw-r--r--servers/audio_server.cpp6
-rw-r--r--servers/display_server.cpp4
-rw-r--r--servers/display_server.h2
-rw-r--r--servers/register_server_types.cpp26
-rw-r--r--servers/rendering/renderer_rd/effects_rd.cpp54
-rw-r--r--servers/rendering/renderer_rd/effects_rd.h10
-rw-r--r--servers/rendering/renderer_rd/pipeline_cache_rd.cpp7
-rw-r--r--servers/rendering/renderer_rd/pipeline_cache_rd.h9
-rw-r--r--servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp5
-rw-r--r--servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp4
-rw-r--r--servers/rendering/renderer_rd/renderer_scene_render_rd.cpp10
-rw-r--r--servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp106
-rw-r--r--servers/rendering/renderer_rd/renderer_scene_sky_rd.h108
-rw-r--r--servers/rendering/renderer_rd/renderer_storage_rd.cpp12
-rw-r--r--servers/rendering/renderer_rd/shaders/canvas.glsl2
-rw-r--r--servers/rendering/renderer_scene_cull.cpp7
-rw-r--r--servers/rendering/renderer_scene_cull.h2
-rw-r--r--servers/rendering/renderer_scene_occlusion_cull.cpp2
-rw-r--r--servers/rendering/renderer_scene_render.cpp4
-rw-r--r--servers/rendering/rendering_device.cpp74
-rw-r--r--servers/rendering/rendering_device.h30
-rw-r--r--servers/rendering/rendering_device_binds.cpp4
-rw-r--r--servers/rendering/rendering_device_binds.h28
-rw-r--r--servers/rendering/shader_language.cpp2
-rw-r--r--servers/text_server.cpp10
-rw-r--r--tests/test_aabb.h16
-rw-r--r--tests/test_config_file.h4
-rw-r--r--tests/test_curve.h8
-rw-r--r--tests/test_json.h61
-rw-r--r--tests/test_string.h2
-rw-r--r--thirdparty/enet/godot.cpp4
-rw-r--r--thirdparty/misc/easing_equations.cpp4
804 files changed, 19827 insertions, 11999 deletions
diff --git a/.github/workflows/linux_builds.yml b/.github/workflows/linux_builds.yml
index b4bbaaacb1..ace1ce3fec 100644
--- a/.github/workflows/linux_builds.yml
+++ b/.github/workflows/linux_builds.yml
@@ -26,7 +26,7 @@ jobs:
- name: Configure dependencies
run: |
sudo apt-get install build-essential pkg-config libx11-dev libxcursor-dev \
- libxinerama-dev libgl1-mesa-dev libglu-dev libasound2-dev libpulse-dev libudev-dev libxi-dev libxrandr-dev yasm
+ libxinerama-dev libgl1-mesa-dev libglu-dev libasound2-dev libpulse-dev libdbus-1-dev libudev-dev libxi-dev libxrandr-dev yasm
# Upload cache on completion and check it out now
- name: Load .scons_cache directory
@@ -111,7 +111,7 @@ jobs:
- name: Configure dependencies
run: |
sudo apt-get install build-essential pkg-config libx11-dev libxcursor-dev \
- libxinerama-dev libgl1-mesa-dev libglu-dev libasound2-dev libpulse-dev libudev-dev libxi-dev libxrandr-dev yasm \
+ libxinerama-dev libgl1-mesa-dev libglu-dev libasound2-dev libpulse-dev libdbus-1-dev libudev-dev libxi-dev libxrandr-dev yasm \
xvfb wget unzip
# Upload cache on completion and check it out now
@@ -204,7 +204,7 @@ jobs:
- name: Configure dependencies
run: |
sudo apt-get install build-essential pkg-config libx11-dev libxcursor-dev \
- libxinerama-dev libgl1-mesa-dev libglu-dev libasound2-dev libpulse-dev libudev-dev libxi-dev libxrandr-dev yasm
+ libxinerama-dev libgl1-mesa-dev libglu-dev libasound2-dev libpulse-dev libdbus-1-dev libudev-dev libxi-dev libxrandr-dev yasm
# Upload cache on completion and check it out now
- name: Load .scons_cache directory
diff --git a/SConstruct b/SConstruct
index f8e3a68edd..e5646a7d0a 100644
--- a/SConstruct
+++ b/SConstruct
@@ -551,11 +551,10 @@ if selected_platform in platform_list:
if env["target"] == "release":
if env["tools"]:
- print("Tools can only be built with targets 'debug' and 'release_debug'.")
+ print("Error: The editor can only be built with `target=debug` or `target=release_debug`.")
Exit(255)
suffix += ".opt"
env.Append(CPPDEFINES=["NDEBUG"])
-
elif env["target"] == "release_debug":
if env["tools"]:
suffix += ".opt.tools"
@@ -563,8 +562,14 @@ if selected_platform in platform_list:
suffix += ".opt.debug"
else:
if env["tools"]:
+ print(
+ "Note: Building a debug binary (which will run slowly). Use `target=release_debug` to build an optimized release binary."
+ )
suffix += ".tools"
else:
+ print(
+ "Note: Building a debug binary (which will run slowly). Use `target=release` to build an optimized release binary."
+ )
suffix += ".debug"
if env["arch"] != "":
diff --git a/core/SCsub b/core/SCsub
index e3ba46be02..d9167b8f83 100644
--- a/core/SCsub
+++ b/core/SCsub
@@ -186,6 +186,7 @@ SConscript("io/SCsub")
SConscript("debugger/SCsub")
SConscript("input/SCsub")
SConscript("variant/SCsub")
+SConscript("extension/SCsub")
SConscript("object/SCsub")
SConscript("templates/SCsub")
SConscript("string/SCsub")
diff --git a/core/config/engine.cpp b/core/config/engine.cpp
index 99ec1aeb5b..ad31966a65 100644
--- a/core/config/engine.cpp
+++ b/core/config/engine.cpp
@@ -190,6 +190,14 @@ bool Engine::is_validation_layers_enabled() const {
return use_validation_layers;
}
+void Engine::set_print_error_messages(bool p_enabled) {
+ _print_error_enabled = p_enabled;
+}
+
+bool Engine::is_printing_error_messages() const {
+ return _print_error_enabled;
+}
+
void Engine::add_singleton(const Singleton &p_singleton) {
singletons.push_back(p_singleton);
singleton_ptrs[p_singleton.name] = p_singleton.ptr;
@@ -228,9 +236,10 @@ Engine::Engine() {
singleton = this;
}
-Engine::Singleton::Singleton(const StringName &p_name, Object *p_ptr) :
+Engine::Singleton::Singleton(const StringName &p_name, Object *p_ptr, const StringName &p_class_name) :
name(p_name),
- ptr(p_ptr) {
+ ptr(p_ptr),
+ class_name(p_class_name) {
#ifdef DEBUG_ENABLED
RefCounted *rc = Object::cast_to<RefCounted>(p_ptr);
if (rc && !rc->is_referenced()) {
diff --git a/core/config/engine.h b/core/config/engine.h
index 276da1c7ea..970cfb03e8 100644
--- a/core/config/engine.h
+++ b/core/config/engine.h
@@ -41,7 +41,8 @@ public:
struct Singleton {
StringName name;
Object *ptr;
- Singleton(const StringName &p_name = StringName(), Object *p_ptr = nullptr);
+ StringName class_name; //used for binding generation hinting
+ Singleton(const StringName &p_name = StringName(), Object *p_ptr = nullptr, const StringName &p_class_name = StringName());
};
private:
@@ -100,6 +101,9 @@ public:
void set_time_scale(float p_scale);
float get_time_scale() const;
+ void set_print_error_messages(bool p_enabled);
+ bool is_printing_error_messages() const;
+
void set_frame_delay(uint32_t p_msec);
uint32_t get_frame_delay() const;
diff --git a/core/core_bind.cpp b/core/core_bind.cpp
index 60759cd71c..a3349444c4 100644
--- a/core/core_bind.cpp
+++ b/core/core_bind.cpp
@@ -35,7 +35,6 @@
#include "core/debugger/engine_debugger.h"
#include "core/io/file_access_compressed.h"
#include "core/io/file_access_encrypted.h"
-#include "core/io/json.h"
#include "core/io/marshalls.h"
#include "core/math/geometry_2d.h"
#include "core/math/geometry_3d.h"
@@ -426,6 +425,21 @@ String _OS::get_external_data_dir() const {
return OS::get_singleton()->get_external_data_dir();
}
+String _OS::get_config_dir() const {
+ // Exposed as `get_config_dir()` instead of `get_config_path()` for consistency with other exposed OS methods.
+ return OS::get_singleton()->get_config_path();
+}
+
+String _OS::get_data_dir() const {
+ // Exposed as `get_data_dir()` instead of `get_data_path()` for consistency with other exposed OS methods.
+ return OS::get_singleton()->get_data_path();
+}
+
+String _OS::get_cache_dir() const {
+ // Exposed as `get_cache_dir()` instead of `get_cache_path()` for consistency with other exposed OS methods.
+ return OS::get_singleton()->get_cache_path();
+}
+
bool _OS::is_debug_build() const {
#ifdef DEBUG_ENABLED
return true;
@@ -518,6 +532,9 @@ void _OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_user_data_dir"), &_OS::get_user_data_dir);
ClassDB::bind_method(D_METHOD("get_external_data_dir"), &_OS::get_external_data_dir);
ClassDB::bind_method(D_METHOD("get_system_dir", "dir"), &_OS::get_system_dir);
+ ClassDB::bind_method(D_METHOD("get_config_dir"), &_OS::get_config_dir);
+ ClassDB::bind_method(D_METHOD("get_data_dir"), &_OS::get_data_dir);
+ ClassDB::bind_method(D_METHOD("get_cache_dir"), &_OS::get_cache_dir);
ClassDB::bind_method(D_METHOD("get_unique_id"), &_OS::get_unique_id);
ClassDB::bind_method(D_METHOD("print_all_textures_by_size"), &_OS::print_all_textures_by_size);
@@ -1833,12 +1850,12 @@ bool _ClassDB::is_parent_class(const StringName &p_class, const StringName &p_in
return ClassDB::is_parent_class(p_class, p_inherits);
}
-bool _ClassDB::can_instance(const StringName &p_class) const {
- return ClassDB::can_instance(p_class);
+bool _ClassDB::can_instantiate(const StringName &p_class) const {
+ return ClassDB::can_instantiate(p_class);
}
-Variant _ClassDB::instance(const StringName &p_class) const {
- Object *obj = ClassDB::instance(p_class);
+Variant _ClassDB::instantiate(const StringName &p_class) const {
+ Object *obj = ClassDB::instantiate(p_class);
if (!obj) {
return Variant();
}
@@ -1967,8 +1984,8 @@ void _ClassDB::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_parent_class", "class"), &_ClassDB::get_parent_class);
ClassDB::bind_method(D_METHOD("class_exists", "class"), &_ClassDB::class_exists);
ClassDB::bind_method(D_METHOD("is_parent_class", "class", "inherits"), &_ClassDB::is_parent_class);
- ClassDB::bind_method(D_METHOD("can_instance", "class"), &_ClassDB::can_instance);
- ClassDB::bind_method(D_METHOD("instance", "class"), &_ClassDB::instance);
+ ClassDB::bind_method(D_METHOD("can_instantiate", "class"), &_ClassDB::can_instantiate);
+ ClassDB::bind_method(D_METHOD("instantiate", "class"), &_ClassDB::instantiate);
ClassDB::bind_method(D_METHOD("class_has_signal", "class", "signal"), &_ClassDB::has_signal);
ClassDB::bind_method(D_METHOD("class_get_signal", "class", "signal"), &_ClassDB::get_signal);
@@ -2094,6 +2111,14 @@ bool _Engine::is_editor_hint() const {
return Engine::get_singleton()->is_editor_hint();
}
+void _Engine::set_print_error_messages(bool p_enabled) {
+ Engine::get_singleton()->set_print_error_messages(p_enabled);
+}
+
+bool _Engine::is_printing_error_messages() const {
+ return Engine::get_singleton()->is_printing_error_messages();
+}
+
void _Engine::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_iterations_per_second", "iterations_per_second"), &_Engine::set_iterations_per_second);
ClassDB::bind_method(D_METHOD("get_iterations_per_second"), &_Engine::get_iterations_per_second);
@@ -2128,7 +2153,11 @@ void _Engine::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_editor_hint", "enabled"), &_Engine::set_editor_hint);
ClassDB::bind_method(D_METHOD("is_editor_hint"), &_Engine::is_editor_hint);
+ ClassDB::bind_method(D_METHOD("set_print_error_messages", "enabled"), &_Engine::set_print_error_messages);
+ ClassDB::bind_method(D_METHOD("is_printing_error_messages"), &_Engine::is_printing_error_messages);
+
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editor_hint"), "set_editor_hint", "is_editor_hint");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "print_error_messages"), "set_print_error_messages", "is_printing_error_messages");
ADD_PROPERTY(PropertyInfo(Variant::INT, "iterations_per_second"), "set_iterations_per_second", "get_iterations_per_second");
ADD_PROPERTY(PropertyInfo(Variant::INT, "target_fps"), "set_target_fps", "get_target_fps");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "time_scale"), "set_time_scale", "get_time_scale");
@@ -2137,80 +2166,6 @@ void _Engine::_bind_methods() {
_Engine *_Engine::singleton = nullptr;
-////// _JSON //////
-
-void JSONParseResult::_bind_methods() {
- ClassDB::bind_method(D_METHOD("get_error"), &JSONParseResult::get_error);
- ClassDB::bind_method(D_METHOD("get_error_string"), &JSONParseResult::get_error_string);
- ClassDB::bind_method(D_METHOD("get_error_line"), &JSONParseResult::get_error_line);
- ClassDB::bind_method(D_METHOD("get_result"), &JSONParseResult::get_result);
-
- ClassDB::bind_method(D_METHOD("set_error", "error"), &JSONParseResult::set_error);
- ClassDB::bind_method(D_METHOD("set_error_string", "error_string"), &JSONParseResult::set_error_string);
- ClassDB::bind_method(D_METHOD("set_error_line", "error_line"), &JSONParseResult::set_error_line);
- ClassDB::bind_method(D_METHOD("set_result", "result"), &JSONParseResult::set_result);
-
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "error", PROPERTY_HINT_NONE, "Error", PROPERTY_USAGE_CLASS_IS_ENUM), "set_error", "get_error");
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "error_string"), "set_error_string", "get_error_string");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "error_line"), "set_error_line", "get_error_line");
- ADD_PROPERTY(PropertyInfo(Variant::NIL, "result", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NIL_IS_VARIANT), "set_result", "get_result");
-}
-
-void JSONParseResult::set_error(Error p_error) {
- error = p_error;
-}
-
-Error JSONParseResult::get_error() const {
- return error;
-}
-
-void JSONParseResult::set_error_string(const String &p_error_string) {
- error_string = p_error_string;
-}
-
-String JSONParseResult::get_error_string() const {
- return error_string;
-}
-
-void JSONParseResult::set_error_line(int p_error_line) {
- error_line = p_error_line;
-}
-
-int JSONParseResult::get_error_line() const {
- return error_line;
-}
-
-void JSONParseResult::set_result(const Variant &p_result) {
- result = p_result;
-}
-
-Variant JSONParseResult::get_result() const {
- return result;
-}
-
-void _JSON::_bind_methods() {
- ClassDB::bind_method(D_METHOD("print", "value", "indent", "sort_keys", "full_precision"), &_JSON::print, DEFVAL(String()), DEFVAL(false), DEFVAL(false));
- ClassDB::bind_method(D_METHOD("parse", "json"), &_JSON::parse);
-}
-
-String _JSON::print(const Variant &p_value, const String &p_indent, bool p_sort_keys, bool p_full_precision) {
- return JSON::print(p_value, p_indent, p_sort_keys, p_full_precision);
-}
-
-Ref<JSONParseResult> _JSON::parse(const String &p_json) {
- Ref<JSONParseResult> result;
- result.instance();
-
- result->error = JSON::parse(p_json, result->result, result->error_string, result->error_line);
-
- if (result->error != OK) {
- ERR_PRINT(vformat("Error parsing JSON at line %s: %s", result->error_line, result->error_string));
- }
- return result;
-}
-
-_JSON *_JSON::singleton = nullptr;
-
////// _EngineDebugger //////
void _EngineDebugger::_bind_methods() {
diff --git a/core/core_bind.h b/core/core_bind.h
index b161effe95..673dbe32c4 100644
--- a/core/core_bind.h
+++ b/core/core_bind.h
@@ -230,6 +230,9 @@ public:
String get_user_data_dir() const;
String get_external_data_dir() const;
+ String get_config_dir() const;
+ String get_data_dir() const;
+ String get_cache_dir() const;
Error set_thread_name(const String &p_name);
Thread::ID get_thread_caller_id() const;
@@ -582,8 +585,8 @@ public:
StringName get_parent_class(const StringName &p_class) const;
bool class_exists(const StringName &p_class) const;
bool is_parent_class(const StringName &p_class, const StringName &p_inherits) const;
- bool can_instance(const StringName &p_class) const;
- Variant instance(const StringName &p_class) const;
+ bool can_instantiate(const StringName &p_class) const;
+ Variant instantiate(const StringName &p_class) const;
bool has_signal(StringName p_class, StringName p_signal) const;
Dictionary get_signal(StringName p_class, StringName p_signal) const;
@@ -653,55 +656,10 @@ public:
void set_editor_hint(bool p_enabled);
bool is_editor_hint() const;
- _Engine() { singleton = this; }
-};
-
-class _JSON;
-
-class JSONParseResult : public RefCounted {
- GDCLASS(JSONParseResult, RefCounted);
-
- friend class _JSON;
-
- Error error;
- String error_string;
- int error_line = -1;
-
- Variant result;
-
-protected:
- static void _bind_methods();
-
-public:
- void set_error(Error p_error);
- Error get_error() const;
-
- void set_error_string(const String &p_error_string);
- String get_error_string() const;
+ void set_print_error_messages(bool p_enabled);
+ bool is_printing_error_messages() const;
- void set_error_line(int p_error_line);
- int get_error_line() const;
-
- void set_result(const Variant &p_result);
- Variant get_result() const;
-
- JSONParseResult() {}
-};
-
-class _JSON : public Object {
- GDCLASS(_JSON, Object);
-
-protected:
- static void _bind_methods();
- static _JSON *singleton;
-
-public:
- static _JSON *get_singleton() { return singleton; }
-
- String print(const Variant &p_value, const String &p_indent = "", bool p_sort_keys = false, bool p_full_precision = false);
- Ref<JSONParseResult> parse(const String &p_json);
-
- _JSON() { singleton = this; }
+ _Engine() { singleton = this; }
};
class _EngineDebugger : public Object {
diff --git a/core/core_constants.cpp b/core/core_constants.cpp
index 7fc09fc3a6..9f5f8f733f 100644
--- a/core/core_constants.cpp
+++ b/core/core_constants.cpp
@@ -106,10 +106,6 @@ static Vector<_CoreConstant> _global_constants;
VARIANT_ENUM_CAST(Key);
VARIANT_ENUM_CAST(KeyModifierMask);
-VARIANT_ENUM_CAST(MouseButton);
-VARIANT_ENUM_CAST(JoyButton);
-VARIANT_ENUM_CAST(JoyAxis);
-VARIANT_ENUM_CAST(MIDIMessage);
void register_global_constants() {
BIND_CORE_ENUM_CONSTANT(SIDE_LEFT);
diff --git a/core/debugger/remote_debugger_peer.cpp b/core/debugger/remote_debugger_peer.cpp
index 39113eda14..ea5e32203c 100644
--- a/core/debugger/remote_debugger_peer.cpp
+++ b/core/debugger/remote_debugger_peer.cpp
@@ -84,7 +84,7 @@ RemoteDebuggerPeerTCP::RemoteDebuggerPeerTCP(Ref<StreamPeerTCP> p_tcp) {
thread.start(_thread_func, this);
#endif
} else {
- tcp_client.instance();
+ tcp_client.instantiate();
}
}
diff --git a/core/extension/SCsub b/core/extension/SCsub
new file mode 100644
index 0000000000..a3a54250c1
--- /dev/null
+++ b/core/extension/SCsub
@@ -0,0 +1,7 @@
+#!/usr/bin/env python
+
+Import("env")
+
+env_extension = env.Clone()
+
+env_extension.add_source_files(env.core_sources, "*.cpp")
diff --git a/core/extension/extension_api_dump.cpp b/core/extension/extension_api_dump.cpp
new file mode 100644
index 0000000000..3c132a619d
--- /dev/null
+++ b/core/extension/extension_api_dump.cpp
@@ -0,0 +1,805 @@
+/*************************************************************************/
+/* extension_api_dump.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "extension_api_dump.h"
+#include "core/config/engine.h"
+#include "core/core_constants.h"
+#include "core/io/file_access.h"
+#include "core/io/json.h"
+#include "core/templates/pair.h"
+#include "core/version.h"
+
+#ifdef TOOLS_ENABLED
+
+Dictionary NativeExtensionAPIDump::generate_extension_api() {
+ Dictionary api_dump;
+
+ {
+ //header
+ Dictionary header;
+ header["version_major"] = VERSION_MAJOR;
+ header["version_minor"] = VERSION_MINOR;
+#if VERSION_PATCH
+ header["version_patch"] = VERSION_PATCH;
+#else
+ header["version_patch"] = 0;
+#endif
+ header["version_status"] = VERSION_STATUS;
+ header["version_build"] = VERSION_BUILD;
+ header["version_full_name"] = VERSION_FULL_NAME;
+
+ api_dump["header"] = header;
+ }
+
+ const uint32_t vec3_elems = 3;
+ const uint32_t ptrsize_32 = 4;
+ const uint32_t ptrsize_64 = 4;
+ static const char *build_config_name[4] = { "float_32", "float_64", "double_32", "double_64" };
+
+ {
+ //type sizes
+ struct {
+ Variant::Type type;
+ uint32_t size_32_bits_real_float;
+ uint32_t size_64_bits_real_float;
+ uint32_t size_32_bits_real_double;
+ uint32_t size_64_bits_real_double;
+ } type_size_array[Variant::VARIANT_MAX + 1] = {
+ { Variant::NIL, 0, 0, 0, 0 },
+ { Variant::BOOL, sizeof(uint32_t), sizeof(uint32_t), sizeof(uint32_t), sizeof(uint32_t) },
+ { Variant::INT, sizeof(int64_t), sizeof(int64_t), sizeof(int64_t), sizeof(int64_t) },
+ { Variant::FLOAT, sizeof(double), sizeof(double), sizeof(double), sizeof(double) },
+ { Variant::STRING, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 },
+ { Variant::VECTOR2, 2 * sizeof(float), 2 * sizeof(float), 2 * sizeof(double), 2 * sizeof(double) },
+ { Variant::VECTOR2I, 2 * sizeof(int32_t), 2 * sizeof(int32_t), 2 * sizeof(int32_t), 2 * sizeof(int32_t) },
+ { Variant::RECT2, 4 * sizeof(float), 4 * sizeof(float), 4 * sizeof(double), 4 * sizeof(double) },
+ { Variant::RECT2I, 4 * sizeof(int32_t), 4 * sizeof(int32_t), 4 * sizeof(int32_t), 4 * sizeof(int32_t) },
+ { Variant::VECTOR3, vec3_elems * sizeof(float), vec3_elems * sizeof(float), vec3_elems * sizeof(double), vec3_elems * sizeof(double) },
+ { Variant::VECTOR3I, 3 * sizeof(int32_t), 3 * sizeof(int32_t), 3 * sizeof(int32_t), 3 * sizeof(int32_t) },
+ { Variant::TRANSFORM2D, 6 * sizeof(float), 6 * sizeof(float), 6 * sizeof(double), 6 * sizeof(double) },
+ { Variant::PLANE, (vec3_elems + 1) * sizeof(float), (vec3_elems + 1) * sizeof(float), (vec3_elems + 1) * sizeof(double), (vec3_elems + 1) * sizeof(double) },
+ { Variant::QUATERNION, 4 * sizeof(float), 4 * sizeof(float), 4 * sizeof(double), 4 * sizeof(double) },
+ { Variant::AABB, (vec3_elems * 2) * sizeof(float), (vec3_elems * 2) * sizeof(float), (vec3_elems * 2) * sizeof(double), (vec3_elems * 2) * sizeof(double) },
+ { Variant::BASIS, (vec3_elems * 3) * sizeof(float), (vec3_elems * 3) * sizeof(float), (vec3_elems * 3) * sizeof(double), (vec3_elems * 3) * sizeof(double) },
+ { Variant::TRANSFORM3D, (vec3_elems * 4) * sizeof(float), (vec3_elems * 4) * sizeof(float), (vec3_elems * 4) * sizeof(double), (vec3_elems * 4) * sizeof(double) },
+ { Variant::COLOR, 4 * sizeof(float), 4 * sizeof(float), 4 * sizeof(float), 4 * sizeof(float) },
+ { Variant::STRING_NAME, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 },
+ { Variant::NODE_PATH, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 },
+ { Variant::RID, sizeof(uint64_t), sizeof(uint64_t), sizeof(uint64_t), sizeof(uint64_t) },
+ { Variant::OBJECT, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 },
+ { Variant::CALLABLE, sizeof(Callable), sizeof(Callable), sizeof(Callable), sizeof(Callable) }, //harcoded align
+ { Variant::SIGNAL, sizeof(Signal), sizeof(Signal), sizeof(Signal), sizeof(Signal) }, //harcoded align
+ { Variant::DICTIONARY, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 },
+ { Variant::ARRAY, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 },
+ { Variant::PACKED_BYTE_ARRAY, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 },
+ { Variant::PACKED_INT32_ARRAY, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 },
+ { Variant::PACKED_INT64_ARRAY, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 },
+ { Variant::PACKED_FLOAT32_ARRAY, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 },
+ { Variant::PACKED_FLOAT64_ARRAY, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 },
+ { Variant::PACKED_STRING_ARRAY, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 },
+ { Variant::PACKED_VECTOR2_ARRAY, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 },
+ { Variant::PACKED_VECTOR3_ARRAY, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 },
+ { Variant::PACKED_COLOR_ARRAY, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 },
+ { Variant::VARIANT_MAX, sizeof(uint64_t) + sizeof(float) * 4, sizeof(uint64_t) + sizeof(float) * 4, sizeof(uint64_t) + sizeof(double) * 4, sizeof(uint64_t) + sizeof(double) * 4 },
+ };
+
+ Array core_type_sizes;
+
+ for (int i = 0; i < 4; i++) {
+ Dictionary d;
+ d["build_configuration"] = build_config_name[i];
+ Array sizes;
+ for (int j = 0; j < Variant::VARIANT_MAX; j++) {
+ Variant::Type t = type_size_array[j].type;
+ String name = t == Variant::VARIANT_MAX ? String("Variant") : Variant::get_type_name(t);
+ Dictionary d2;
+ d2["name"] = name;
+ uint32_t size;
+ switch (i) {
+ case 0:
+ size = type_size_array[j].size_32_bits_real_float;
+ break;
+ case 1:
+ size = type_size_array[j].size_64_bits_real_float;
+ break;
+ case 2:
+ size = type_size_array[j].size_32_bits_real_double;
+ break;
+ case 3:
+ size = type_size_array[j].size_64_bits_real_double;
+ break;
+ }
+ d2["size"] = size;
+ sizes.push_back(d2);
+ }
+ d["sizes"] = sizes;
+ core_type_sizes.push_back(d);
+ }
+ api_dump["builtin_class_sizes"] = core_type_sizes;
+ }
+
+ {
+ //member offsets sizes
+ struct {
+ Variant::Type type;
+ const char *member;
+ uint32_t offset_32_bits_real_float;
+ uint32_t offset_64_bits_real_float;
+ uint32_t offset_32_bits_real_double;
+ uint32_t offset_64_bits_real_double;
+ } member_offset_array[] = {
+ { Variant::VECTOR2, "x", 0, 0, 0, 0 },
+ { Variant::VECTOR2, "y", sizeof(float), sizeof(float), sizeof(double), sizeof(double) },
+ { Variant::VECTOR2I, "x", 0, 0, 0, 0 },
+ { Variant::VECTOR2I, "y", sizeof(int32_t), sizeof(int32_t), sizeof(int32_t), sizeof(int32_t) },
+ { Variant::RECT2, "position", 0, 0, 0, 0 },
+ { Variant::RECT2, "size", 2 * sizeof(Vector2), 2 * sizeof(float), 2 * sizeof(double), 2 * sizeof(double) },
+ { Variant::RECT2I, "position", 0, 0, 0, 0 },
+ { Variant::RECT2I, "size", 2 * sizeof(int32_t), 2 * sizeof(int32_t), 2 * sizeof(int32_t), 2 * sizeof(int32_t) },
+ { Variant::VECTOR3, "x", 0, 0, 0, 0 },
+ { Variant::VECTOR3, "y", sizeof(float), sizeof(float), sizeof(double), sizeof(double) },
+ { Variant::VECTOR3, "z", 2 * sizeof(float), 2 * sizeof(float), 2 * sizeof(double), 2 * sizeof(double) },
+ { Variant::VECTOR3I, "x", 0, 0, 0, 0 },
+ { Variant::VECTOR3I, "y", sizeof(int32_t), sizeof(int32_t), sizeof(int32_t), sizeof(int32_t) },
+ { Variant::VECTOR3I, "z", 2 * sizeof(int32_t), 2 * sizeof(int32_t), 2 * sizeof(int32_t), 2 * sizeof(int32_t) },
+ { Variant::TRANSFORM2D, "x", 0, 0, 0, 0 },
+ { Variant::TRANSFORM2D, "y", 2 * sizeof(float), 2 * sizeof(float), 2 * sizeof(double), 2 * sizeof(double) },
+ { Variant::TRANSFORM2D, "origin", 4 * sizeof(float), 4 * sizeof(float), 4 * sizeof(double), 4 * sizeof(double) },
+ { Variant::PLANE, "normal", 0, 0, 0, 0 },
+ { Variant::PLANE, "d", vec3_elems * sizeof(float), vec3_elems * sizeof(float), vec3_elems * sizeof(double), vec3_elems * sizeof(double) },
+ { Variant::QUATERNION, "x", 0, 0, 0, 0 },
+ { Variant::QUATERNION, "y", sizeof(float), sizeof(float), sizeof(double), sizeof(double) },
+ { Variant::QUATERNION, "z", 2 * sizeof(float), 2 * sizeof(float), 2 * sizeof(double), 2 * sizeof(double) },
+ { Variant::QUATERNION, "w", 3 * sizeof(float), 3 * sizeof(float), 3 * sizeof(double), 3 * sizeof(double) },
+ { Variant::AABB, "position", 0, 0, 0, 0 },
+ { Variant::AABB, "size", vec3_elems * sizeof(float), vec3_elems * sizeof(float), vec3_elems * sizeof(double), vec3_elems * sizeof(double) },
+ //rememer that basis vectors are flipped!
+ { Variant::BASIS, "x", 0, 0, 0, 0 },
+ { Variant::BASIS, "y", vec3_elems * sizeof(float), vec3_elems * sizeof(float), vec3_elems * sizeof(double), vec3_elems * sizeof(double) },
+ { Variant::BASIS, "z", vec3_elems * 2 * sizeof(float), vec3_elems * 2 * sizeof(float), vec3_elems * 2 * sizeof(double), vec3_elems * 2 * sizeof(double) },
+ { Variant::TRANSFORM3D, "basis", 0, 0, 0, 0 },
+ { Variant::TRANSFORM3D, "origin", (vec3_elems * 3) * sizeof(float), (vec3_elems * 3) * sizeof(float), (vec3_elems * 3) * sizeof(double), (vec3_elems * 3) * sizeof(double) },
+ { Variant::COLOR, "x", 0, 0, 0, 0 },
+ { Variant::COLOR, "y", sizeof(float), sizeof(float), sizeof(float), sizeof(float) },
+ { Variant::COLOR, "z", 2 * sizeof(float), 2 * sizeof(float), 2 * sizeof(float), 2 * sizeof(float) },
+ { Variant::COLOR, "w", 3 * sizeof(float), 3 * sizeof(float), 3 * sizeof(float), 3 * sizeof(float) },
+ { Variant::NIL, nullptr, 0, 0, 0, 0 },
+ };
+
+ Array core_type_member_offsets;
+
+ for (int i = 0; i < 4; i++) {
+ Dictionary d;
+ d["build_configuration"] = build_config_name[i];
+ Array type_offsets;
+ uint32_t idx = 0;
+
+ Variant::Type last_type = Variant::NIL;
+
+ Dictionary d2;
+ Array members;
+
+ while (true) {
+ Variant::Type t = member_offset_array[idx].type;
+ if (t != last_type) {
+ if (last_type != Variant::NIL) {
+ d2["members"] = members;
+ type_offsets.push_back(d2);
+ }
+ if (t == Variant::NIL) {
+ break;
+ }
+
+ String name = t == Variant::VARIANT_MAX ? String("Variant") : Variant::get_type_name(t);
+ d2 = Dictionary();
+ members = Array();
+ d2["name"] = name;
+ last_type = t;
+ }
+ Dictionary d3;
+ uint32_t offset;
+ switch (i) {
+ case 0:
+ offset = member_offset_array[idx].offset_32_bits_real_float;
+ break;
+ case 1:
+ offset = member_offset_array[idx].offset_64_bits_real_float;
+ break;
+ case 2:
+ offset = member_offset_array[idx].offset_32_bits_real_double;
+ break;
+ case 3:
+ offset = member_offset_array[idx].offset_64_bits_real_double;
+ break;
+ }
+ d3["member"] = member_offset_array[idx].member;
+ d3["offset"] = offset;
+ members.push_back(d3);
+ idx++;
+ }
+ d["classes"] = type_offsets;
+ core_type_member_offsets.push_back(d);
+ }
+ api_dump["builtin_class_member_offsets"] = core_type_member_offsets;
+ }
+
+ {
+ // global enums and constants
+ Array constants;
+ Map<String, List<Pair<String, int>>> enum_list;
+
+ for (int i = 0; i < CoreConstants::get_global_constant_count(); i++) {
+ int value = CoreConstants::get_global_constant_value(i);
+ String enum_name = CoreConstants::get_global_constant_enum(i);
+ String name = CoreConstants::get_global_constant_name(i);
+ if (enum_name != String()) {
+ enum_list[enum_name].push_back(Pair<String, int>(name, value));
+ } else {
+ Dictionary d;
+ d["name"] = name;
+ d["value"] = value;
+ constants.push_back(d);
+ }
+ }
+
+ api_dump["global_constants"] = constants;
+
+ Array enums;
+ for (Map<String, List<Pair<String, int>>>::Element *E = enum_list.front(); E; E = E->next()) {
+ Dictionary d1;
+ d1["name"] = E->key();
+ Array values;
+ for (List<Pair<String, int>>::Element *F = E->get().front(); F; F = F->next()) {
+ Dictionary d2;
+ d2["name"] = F->get().first;
+ d2["value"] = F->get().second;
+ values.push_back(d2);
+ }
+ d1["values"] = values;
+ enums.push_back(d1);
+ }
+
+ api_dump["global_enums"] = enums;
+ }
+ {
+ Array utility_funcs;
+
+ List<StringName> utility_func_names;
+ Variant::get_utility_function_list(&utility_func_names);
+
+ for (List<StringName>::Element *E = utility_func_names.front(); E; E = E->next()) {
+ StringName name = E->get();
+ Dictionary func;
+ func["name"] = String(name);
+ if (Variant::has_utility_function_return_value(name)) {
+ Variant::Type rt = Variant::get_utility_function_return_type(name);
+ func["return_type"] = rt == Variant::NIL ? String("Variant") : Variant::get_type_name(rt);
+ }
+ switch (Variant::get_utility_function_type(name)) {
+ case Variant::UTILITY_FUNC_TYPE_MATH:
+ func["category"] = "math";
+ break;
+ case Variant::UTILITY_FUNC_TYPE_RANDOM:
+ func["category"] = "random";
+ break;
+ case Variant::UTILITY_FUNC_TYPE_GENERAL:
+ func["category"] = "general";
+ break;
+ }
+ bool vararg = Variant::is_utility_function_vararg(name);
+ func["is_vararg"] = Variant::is_utility_function_vararg(name);
+ func["hash"] = Variant::get_utility_function_hash(name);
+ Array arguments;
+ int argcount = Variant::get_utility_function_argument_count(name);
+ for (int i = 0; i < argcount; i++) {
+ Dictionary arg;
+ String argname = vararg ? "arg" + itos(i + 1) : Variant::get_utility_function_argument_name(name, i);
+ arg["name"] = argname;
+ Variant::Type argtype = Variant::get_utility_function_argument_type(name, i);
+ arg["type"] = argtype == Variant::NIL ? String("Variant") : Variant::get_type_name(argtype);
+ //no default value support in utility functions
+ arguments.push_back(arg);
+ }
+
+ if (arguments.size()) {
+ func["arguments"] = arguments;
+ }
+
+ utility_funcs.push_back(func);
+ }
+
+ api_dump["utility_functions"] = utility_funcs;
+ }
+
+ {
+ // builtin types
+
+ Array builtins;
+
+ for (int i = 0; i < Variant::VARIANT_MAX; i++) {
+ if (i == Variant::OBJECT) {
+ continue;
+ }
+
+ Variant::Type type = Variant::Type(i);
+
+ Dictionary d;
+ d["name"] = Variant::get_type_name(type);
+ if (Variant::has_indexing(type)) {
+ Variant::Type index_type = Variant::get_indexed_element_type(type);
+ d["indexing_return_type"] = index_type == Variant::NIL ? String("Variant") : Variant::get_type_name(index_type);
+ }
+
+ {
+ //members
+ Array members;
+
+ List<StringName> member_names;
+ Variant::get_member_list(type, &member_names);
+ for (List<StringName>::Element *E = member_names.front(); E; E = E->next()) {
+ StringName member_name = E->get();
+ Dictionary d2;
+ d2["name"] = String(member_name);
+ d2["type"] = Variant::get_type_name(Variant::get_member_type(type, member_name));
+ members.push_back(d2);
+ }
+ if (members.size()) {
+ d["members"] = members;
+ }
+ }
+ {
+ //constants
+ Array constants;
+
+ List<StringName> constant_names;
+ Variant::get_constants_for_type(type, &constant_names);
+ for (List<StringName>::Element *E = constant_names.front(); E; E = E->next()) {
+ StringName constant_name = E->get();
+ Dictionary d2;
+ d2["name"] = String(constant_name);
+ Variant constant = Variant::get_constant_value(type, constant_name);
+ d2["type"] = Variant::get_type_name(constant.get_type());
+ d2["value"] = constant.get_construct_string();
+ constants.push_back(d2);
+ }
+ if (constants.size()) {
+ d["constants"] = constants;
+ }
+ }
+ {
+ //operators
+ Array operators;
+
+ for (int j = 0; j < Variant::VARIANT_MAX; j++) {
+ for (int k = 0; k < Variant::OP_MAX; k++) {
+ Variant::Type rt = Variant::get_operator_return_type(Variant::Operator(k), type, Variant::Type(j));
+ if (rt != Variant::NIL) {
+ Dictionary d2;
+ d2["name"] = Variant::get_operator_name(Variant::Operator(k));
+ if (k != Variant::OP_NEGATE && k != Variant::OP_POSITIVE && k != Variant::OP_NOT && k != Variant::OP_BIT_NEGATE) {
+ d2["right_type"] = Variant::get_type_name(Variant::Type(j));
+ }
+ operators.push_back(d2);
+ }
+ }
+ }
+ if (operators.size()) {
+ d["operators"] = operators;
+ }
+ }
+ {
+ //methods
+ Array methods;
+
+ List<StringName> method_names;
+ Variant::get_builtin_method_list(type, &method_names);
+ for (List<StringName>::Element *E = method_names.front(); E; E = E->next()) {
+ StringName method_name = E->get();
+ Dictionary d2;
+ d2["name"] = String(method_name);
+ if (Variant::has_builtin_method_return_value(type, method_name)) {
+ Variant::Type ret_type = Variant::get_builtin_method_return_type(type, method_name);
+ d2["return_type"] = ret_type == Variant::NIL ? String("Variant") : Variant::get_type_name(ret_type);
+ }
+ d2["is_vararg"] = Variant::is_builtin_method_vararg(type, method_name);
+ d2["is_const"] = Variant::is_builtin_method_const(type, method_name);
+ d2["is_static"] = Variant::is_builtin_method_static(type, method_name);
+ d2["hash"] = Variant::get_builtin_method_hash(type, method_name);
+
+ Vector<Variant> default_args = Variant::get_builtin_method_default_arguments(type, method_name);
+
+ Array arguments;
+ int argcount = Variant::get_builtin_method_argument_count(type, method_name);
+ for (int j = 0; j < argcount; j++) {
+ Dictionary d3;
+ d3["name"] = Variant::get_builtin_method_argument_name(type, method_name, j);
+ Variant::Type argtype = Variant::get_builtin_method_argument_type(type, method_name, j);
+ d3["type"] = argtype == Variant::NIL ? String("Variant") : Variant::get_type_name(argtype);
+
+ if (j >= (argcount - default_args.size())) {
+ int dargidx = j - (argcount - default_args.size());
+ d3["default_value"] = default_args[dargidx].get_construct_string();
+ }
+ arguments.push_back(d3);
+ }
+
+ if (arguments.size()) {
+ d2["arguments"] = arguments;
+ }
+
+ methods.push_back(d2);
+ }
+ if (methods.size()) {
+ d["methods"] = methods;
+ }
+ }
+ {
+ //constructors
+ Array constructors;
+
+ for (int j = 0; j < Variant::get_constructor_count(type); j++) {
+ Dictionary d2;
+ d2["index"] = j;
+
+ Array arguments;
+ int argcount = Variant::get_constructor_argument_count(type, j);
+ for (int k = 0; k < argcount; k++) {
+ Dictionary d3;
+ d3["name"] = Variant::get_constructor_argument_name(type, j, k);
+ d3["type"] = Variant::get_type_name(Variant::get_constructor_argument_type(type, j, k));
+ arguments.push_back(d3);
+ }
+ if (arguments.size()) {
+ d2["arguments"] = arguments;
+ }
+ constructors.push_back(d2);
+ }
+
+ if (constructors.size()) {
+ d["constructors"] = constructors;
+ }
+ }
+
+ builtins.push_back(d);
+ }
+
+ api_dump["builtin_classes"] = builtins;
+ }
+
+ {
+ // classes
+ Array classes;
+
+ List<StringName> class_list;
+
+ ClassDB::get_class_list(&class_list);
+
+ class_list.sort_custom<StringName::AlphCompare>();
+
+ for (List<StringName>::Element *E = class_list.front(); E; E = E->next()) {
+ Dictionary d;
+ StringName class_name = E->get();
+ d["name"] = String(class_name);
+ d["is_refcounted"] = ClassDB::is_parent_class(class_name, "RefCounted");
+ d["is_instantiable"] = ClassDB::can_instantiate(class_name);
+ StringName parent_class = ClassDB::get_parent_class(class_name);
+ if (parent_class != StringName()) {
+ d["inherits"] = String(parent_class);
+ }
+
+ {
+ ClassDB::APIType api = ClassDB::get_api_type(class_name);
+ static const char *api_type[5] = { "core", "editor", "extension", "editor_extension" };
+ d["api_type"] = api_type[api];
+ }
+
+ {
+ //constants
+ Array constants;
+ List<String> constant_list;
+ ClassDB::get_integer_constant_list(class_name, &constant_list, true);
+ for (List<String>::Element *F = constant_list.front(); F; F = F->next()) {
+ StringName enum_name = ClassDB::get_integer_constant_enum(class_name, F->get());
+ if (enum_name != StringName()) {
+ continue; //enums will be handled on their own
+ }
+
+ Dictionary d2;
+ d2["name"] = String(F->get());
+ d2["value"] = ClassDB::get_integer_constant(class_name, F->get());
+
+ constants.push_back(d2);
+ }
+
+ if (constants.size()) {
+ d["constants"] = constants;
+ }
+ }
+ {
+ //enum
+ Array enums;
+ List<StringName> enum_list;
+ ClassDB::get_enum_list(class_name, &enum_list, true);
+ for (List<StringName>::Element *F = enum_list.front(); F; F = F->next()) {
+ Dictionary d2;
+ d2["name"] = String(F->get());
+
+ Array values;
+ List<StringName> enum_constant_list;
+ ClassDB::get_enum_constants(class_name, F->get(), &enum_constant_list, true);
+ for (List<StringName>::Element *G = enum_constant_list.front(); G; G = G->next()) {
+ Dictionary d3;
+ d3["name"] = String(G->get());
+ d3["value"] = ClassDB::get_integer_constant(class_name, G->get());
+ values.push_back(d3);
+ }
+
+ d2["values"] = values;
+
+ enums.push_back(d2);
+ }
+
+ if (enums.size()) {
+ d["enums"] = enums;
+ }
+ }
+ {
+ //methods
+ Array methods;
+ List<MethodInfo> method_list;
+ ClassDB::get_method_list(class_name, &method_list, true);
+ for (List<MethodInfo>::Element *F = method_list.front(); F; F = F->next()) {
+ StringName method_name = F->get().name;
+ if (F->get().flags & METHOD_FLAG_VIRTUAL) {
+ //virtual method
+ const MethodInfo &mi = F->get();
+ Dictionary d2;
+ d2["name"] = String(method_name);
+ d2["is_const"] = (F->get().flags & METHOD_FLAG_CONST) ? true : false;
+ d2["is_vararg"] = false;
+ d2["is_virtual"] = true;
+ // virtual functions have no hash since no MethodBind is involved
+ bool has_return = mi.return_val.type != Variant::NIL || (mi.return_val.usage & PROPERTY_USAGE_NIL_IS_VARIANT);
+ Array arguments;
+ for (int i = (has_return ? -1 : 0); i < mi.arguments.size(); i++) {
+ PropertyInfo pinfo = i == -1 ? mi.return_val : mi.arguments[i];
+ Dictionary d3;
+
+ if (i >= 0) {
+ d3["name"] = pinfo.name;
+ }
+ if (pinfo.class_name != StringName()) {
+ d3["type"] = String(pinfo.class_name);
+ } else {
+ Variant::Type type = pinfo.type;
+ if (type == Variant::NIL) {
+ d3["type"] = "Variant";
+ } else {
+ d3["type"] = Variant::get_type_name(type);
+ }
+ }
+
+ if (i == -1) {
+ d2["return_value"] = d3;
+ } else {
+ arguments.push_back(d3);
+ }
+ }
+
+ if (arguments.size()) {
+ d2["arguments"] = arguments;
+ }
+
+ methods.push_back(d2);
+
+ } else if (F->get().name.begins_with("_")) {
+ //hidden method, ignore
+
+ } else {
+ Dictionary d2;
+ d2["name"] = String(method_name);
+
+ MethodBind *method = ClassDB::get_method(class_name, method_name);
+ if (!method) {
+ continue;
+ }
+
+ d2["is_const"] = method->is_const();
+ d2["is_vararg"] = method->is_vararg();
+ d2["is_virtual"] = false;
+ d2["hash"] = method->get_hash();
+
+ Vector<Variant> default_args = method->get_default_arguments();
+
+ Array arguments;
+ for (int i = (method->has_return() ? -1 : 0); i < method->get_argument_count(); i++) {
+ PropertyInfo pinfo = i == -1 ? method->get_return_info() : method->get_argument_info(i);
+ Dictionary d3;
+
+ if (i >= 0) {
+ d3["name"] = pinfo.name;
+ }
+ if (pinfo.class_name != StringName()) {
+ d3["type"] = String(pinfo.class_name);
+ } else {
+ Variant::Type type = pinfo.type;
+ if (type == Variant::NIL) {
+ d3["type"] = "Variant";
+ } else {
+ d3["type"] = Variant::get_type_name(type);
+ }
+ }
+
+ if (method->get_argument_meta(i) > 0) {
+ static const char *argmeta[11] = { "none", "int8", "int16", "int32", "int64", "uint8", "uint16", "uint32", "uint64", "float", "double" };
+ d3["meta"] = argmeta[method->get_argument_meta(i)];
+ }
+
+ if (i >= 0 && i >= (method->get_argument_count() - default_args.size())) {
+ int dargidx = i - (method->get_argument_count() - default_args.size());
+ d3["default_value"] = default_args[dargidx].get_construct_string();
+ }
+
+ if (i == -1) {
+ d2["return_value"] = d3;
+ } else {
+ arguments.push_back(d3);
+ }
+ }
+
+ if (arguments.size()) {
+ d2["arguments"] = arguments;
+ }
+
+ methods.push_back(d2);
+ }
+ }
+
+ if (methods.size()) {
+ d["methods"] = methods;
+ }
+ }
+
+ {
+ //signals
+ Array signals;
+ List<MethodInfo> signal_list;
+ ClassDB::get_signal_list(class_name, &signal_list, true);
+ for (List<MethodInfo>::Element *F = signal_list.front(); F; F = F->next()) {
+ StringName signal_name = F->get().name;
+ Dictionary d2;
+ d2["name"] = String(signal_name);
+
+ Array arguments;
+
+ for (int i = 0; i < F->get().arguments.size(); i++) {
+ Dictionary d3;
+ d3["name"] = F->get().arguments[i].name;
+ Variant::Type type = F->get().arguments[i].type;
+ if (F->get().arguments[i].class_name != StringName()) {
+ d3["type"] = String(F->get().arguments[i].class_name);
+ } else if (type == Variant::NIL) {
+ d3["type"] = "Variant";
+ } else {
+ d3["type"] = Variant::get_type_name(type);
+ }
+ arguments.push_back(d3);
+ }
+ if (arguments.size()) {
+ d2["arguments"] = arguments;
+ }
+
+ signals.push_back(d2);
+ }
+
+ if (signals.size()) {
+ d["signals"] = signals;
+ }
+ }
+ {
+ //properties
+ Array properties;
+ List<PropertyInfo> property_list;
+ ClassDB::get_property_list(class_name, &property_list, true);
+ for (List<PropertyInfo>::Element *F = property_list.front(); F; F = F->next()) {
+ if (F->get().usage & PROPERTY_USAGE_CATEGORY || F->get().usage & PROPERTY_USAGE_GROUP || F->get().usage & PROPERTY_USAGE_SUBGROUP) {
+ continue; //not real properties
+ }
+ if (F->get().name.begins_with("_")) {
+ continue; //hidden property
+ }
+ StringName property_name = F->get().name;
+ Dictionary d2;
+ d2["name"] = String(property_name);
+
+ if (F->get().class_name != StringName()) {
+ d2["type"] = String(F->get().class_name);
+ } else if (F->get().type == Variant::NIL && F->get().usage & PROPERTY_USAGE_NIL_IS_VARIANT) {
+ d2["type"] = "Variant";
+ } else {
+ d2["type"] = Variant::get_type_name(F->get().type);
+ }
+
+ d2["setter"] = ClassDB::get_property_setter(class_name, F->get().name);
+ d2["getter"] = ClassDB::get_property_getter(class_name, F->get().name);
+ d2["index"] = ClassDB::get_property_index(class_name, F->get().name);
+ properties.push_back(d2);
+ }
+
+ if (properties.size()) {
+ d["properties"] = properties;
+ }
+ }
+
+ classes.push_back(d);
+ }
+
+ api_dump["classes"] = classes;
+ }
+
+ {
+ // singletons
+
+ Array singletons;
+ List<Engine::Singleton> singleton_list;
+ Engine::get_singleton()->get_singletons(&singleton_list);
+
+ for (List<Engine::Singleton>::Element *E = singleton_list.front(); E; E = E->next()) {
+ const Engine::Singleton &s = E->get();
+ Dictionary d;
+ d["name"] = s.name;
+ if (s.class_name != StringName()) {
+ d["type"] = String(s.class_name);
+ } else {
+ d["type"] = String(s.ptr->get_class());
+ }
+ singletons.push_back(d);
+ }
+
+ if (singletons.size()) {
+ api_dump["singletons"] = singletons;
+ }
+ }
+
+ return api_dump;
+}
+
+void NativeExtensionAPIDump::generate_extension_json_file(const String &p_path) {
+ Dictionary api = generate_extension_api();
+ Ref<JSON> json;
+ json.instantiate();
+
+ String text = json->stringify(api, "\t", false);
+ FileAccessRef fa = FileAccess::open(p_path, FileAccess::WRITE);
+ CharString cs = text.ascii();
+ fa->store_buffer((const uint8_t *)cs.ptr(), cs.length());
+ fa->close();
+}
+#endif
diff --git a/platform/javascript/http_client.h.inc b/core/extension/extension_api_dump.h
index 6544d41c98..a7825c10a9 100644
--- a/platform/javascript/http_client.h.inc
+++ b/core/extension/extension_api_dump.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* http_client.h.inc */
+/* extension_api_dump.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,24 +28,18 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-// HTTPClient's additional private members in the javascript platform
+#ifndef API_DUMP_H
+#define API_DUMP_H
-Error make_request(Method p_method, const String &p_url, const Vector<String> &p_headers, const uint8_t *p_body, int p_body_len);
-static void _parse_headers(int p_len, const char **p_headers, void *p_ref);
+#include "core/extension/native_extension.h"
-int js_id = 0;
-// 64 KiB by default (favors fast download speeds at the cost of memory usage).
-int read_limit = 65536;
-Status status = STATUS_DISCONNECTED;
+#ifdef TOOLS_ENABLED
-String host;
-int port = -1;
-bool use_tls = false;
-
-int polled_response_code = 0;
-Vector<String> response_headers;
-Vector<uint8_t> response_buffer;
-
-#ifdef DEBUG_ENABLED
-uint64_t last_polling_frame = 0;
+class NativeExtensionAPIDump {
+public:
+ static Dictionary generate_extension_api();
+ static void generate_extension_json_file(const String &p_path);
+};
#endif
+
+#endif // API_DUMP_H
diff --git a/core/extension/gdnative_interface.cpp b/core/extension/gdnative_interface.cpp
new file mode 100644
index 0000000000..324933d7b7
--- /dev/null
+++ b/core/extension/gdnative_interface.cpp
@@ -0,0 +1,688 @@
+/*************************************************************************/
+/* gdnative_interface.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "gdnative_interface.h"
+
+#include "core/config/engine.h"
+#include "core/object/class_db.h"
+#include "core/os/memory.h"
+#include "core/variant/variant.h"
+#include "core/version.h"
+
+// Memory Functions
+static void *gdnative_alloc(size_t p_size) {
+ return memalloc(p_size);
+}
+
+static void *gdnative_realloc(void *p_mem, size_t p_size) {
+ return memrealloc(p_mem, p_size);
+}
+
+static void gdnative_free(void *p_mem) {
+ memfree(p_mem);
+}
+
+// Helper print functions.
+static void gdnative_print_error(const char *p_description, const char *p_function, const char *p_file, int32_t p_line) {
+ _err_print_error(p_function, p_file, p_line, p_description, ERR_HANDLER_ERROR);
+}
+static void gdnative_print_warning(const char *p_description, const char *p_function, const char *p_file, int32_t p_line) {
+ _err_print_error(p_function, p_file, p_line, p_description, ERR_HANDLER_WARNING);
+}
+static void gdnative_print_script_error(const char *p_description, const char *p_function, const char *p_file, int32_t p_line) {
+ _err_print_error(p_function, p_file, p_line, p_description, ERR_HANDLER_SCRIPT);
+}
+
+// Variant functions
+
+static void gdnative_variant_new_copy(GDNativeVariantPtr r_dest, const GDNativeVariantPtr p_src) {
+ memnew_placement(reinterpret_cast<Variant *>(r_dest), Variant(*reinterpret_cast<Variant *>(p_src)));
+}
+static void gdnative_variant_new_nil(GDNativeVariantPtr r_dest) {
+ memnew_placement(reinterpret_cast<Variant *>(r_dest), Variant);
+}
+static void gdnative_variant_destroy(GDNativeVariantPtr p_self) {
+ reinterpret_cast<Variant *>(p_self)->~Variant();
+}
+
+// variant type
+
+#define memnew_placement_custom(m_placement, m_class, m_constr) _post_initialize(new (m_placement, sizeof(m_class), "") m_constr)
+
+static void gdnative_variant_call(GDNativeVariantPtr p_self, const GDNativeStringNamePtr p_method, const GDNativeVariantPtr *p_args, const GDNativeInt p_argcount, GDNativeVariantPtr r_return, GDNativeCallError *r_error) {
+ Variant *self = (Variant *)p_self;
+ const StringName *method = (const StringName *)p_method;
+ const Variant **args = (const Variant **)p_args;
+ Variant ret;
+ Callable::CallError error;
+ self->call(*method, args, p_argcount, ret, error);
+ memnew_placement_custom(r_return, Variant, Variant(ret));
+
+ if (r_error) {
+ r_error->error = (GDNativeCallErrorType)(error.error);
+ r_error->argument = error.argument;
+ r_error->expected = error.expected;
+ }
+}
+
+static void gdnative_variant_call_static(GDNativeVariantType p_type, const GDNativeStringNamePtr p_method, const GDNativeVariantPtr *p_args, const GDNativeInt p_argcount, GDNativeVariantPtr r_return, GDNativeCallError *r_error) {
+ Variant::Type type = (Variant::Type)p_type;
+ const StringName *method = (const StringName *)p_method;
+ const Variant **args = (const Variant **)p_args;
+ Variant ret;
+ Callable::CallError error;
+ Variant::call_static(type, *method, args, p_argcount, ret, error);
+ memnew_placement_custom(r_return, Variant, Variant(ret));
+
+ if (r_error) {
+ r_error->error = (GDNativeCallErrorType)error.error;
+ r_error->argument = error.argument;
+ r_error->expected = error.expected;
+ }
+}
+
+static void gdnative_variant_evaluate(GDNativeVariantOperator p_op, const GDNativeVariantPtr p_a, const GDNativeVariantPtr p_b, GDNativeVariantPtr r_return, GDNativeBool *r_valid) {
+ Variant::Operator op = (Variant::Operator)p_op;
+ const Variant *a = (const Variant *)p_a;
+ const Variant *b = (const Variant *)p_b;
+ Variant *ret = (Variant *)r_return;
+ bool valid;
+ Variant::evaluate(op, *a, *b, *ret, valid);
+ *r_valid = valid;
+}
+
+static void gdnative_variant_set(GDNativeVariantPtr p_self, const GDNativeVariantPtr p_key, const GDNativeVariantPtr p_value, GDNativeBool *r_valid) {
+ Variant *self = (Variant *)p_self;
+ const Variant *key = (const Variant *)p_key;
+ const Variant *value = (const Variant *)p_value;
+
+ bool valid;
+ self->set(*key, *value, &valid);
+ *r_valid = valid;
+}
+
+static void gdnative_variant_set_named(GDNativeVariantPtr p_self, const GDNativeStringNamePtr p_key, const GDNativeVariantPtr p_value, GDNativeBool *r_valid) {
+ Variant *self = (Variant *)p_self;
+ const StringName *key = (const StringName *)p_key;
+ const Variant *value = (const Variant *)p_value;
+
+ bool valid;
+ self->set_named(*key, *value, valid);
+ *r_valid = valid;
+}
+
+static void gdnative_variant_set_keyed(GDNativeVariantPtr p_self, const GDNativeVariantPtr p_key, const GDNativeVariantPtr p_value, GDNativeBool *r_valid) {
+ Variant *self = (Variant *)p_self;
+ const Variant *key = (const Variant *)p_key;
+ const Variant *value = (const Variant *)p_value;
+
+ bool valid;
+ self->set_keyed(*key, *value, valid);
+ *r_valid = valid;
+}
+
+static void gdnative_variant_set_indexed(GDNativeVariantPtr p_self, GDNativeInt p_index, const GDNativeVariantPtr p_value, GDNativeBool *r_valid, GDNativeBool *r_oob) {
+ Variant *self = (Variant *)p_self;
+ const Variant *value = (const Variant *)p_value;
+
+ bool valid;
+ bool oob;
+ self->set_indexed(p_index, value, valid, oob);
+ *r_valid = valid;
+ *r_oob = oob;
+}
+
+static void gdnative_variant_get(const GDNativeVariantPtr p_self, const GDNativeVariantPtr p_key, GDNativeVariantPtr r_ret, GDNativeBool *r_valid) {
+ const Variant *self = (const Variant *)p_self;
+ const Variant *key = (const Variant *)p_key;
+
+ bool valid;
+ memnew_placement_custom(r_ret, Variant, Variant(self->get(*key, &valid)));
+ *r_valid = valid;
+}
+
+static void gdnative_variant_get_named(const GDNativeVariantPtr p_self, const GDNativeStringNamePtr p_key, GDNativeVariantPtr r_ret, GDNativeBool *r_valid) {
+ const Variant *self = (const Variant *)p_self;
+ const StringName *key = (const StringName *)p_key;
+
+ bool valid;
+ memnew_placement_custom(r_ret, Variant, Variant(self->get_named(*key, valid)));
+ *r_valid = valid;
+}
+
+static void gdnative_variant_get_keyed(const GDNativeVariantPtr p_self, const GDNativeVariantPtr p_key, GDNativeVariantPtr r_ret, GDNativeBool *r_valid) {
+ const Variant *self = (const Variant *)p_self;
+ const Variant *key = (const Variant *)p_key;
+
+ bool valid;
+ memnew_placement_custom(r_ret, Variant, Variant(self->get_keyed(*key, valid)));
+ *r_valid = valid;
+}
+
+static void gdnative_variant_get_indexed(const GDNativeVariantPtr p_self, GDNativeInt p_index, GDNativeVariantPtr r_ret, GDNativeBool *r_valid, GDNativeBool *r_oob) {
+ const Variant *self = (const Variant *)p_self;
+
+ bool valid;
+ bool oob;
+ memnew_placement_custom(r_ret, Variant, Variant(self->get_indexed(p_index, valid, oob)));
+ *r_valid = valid;
+ *r_oob = oob;
+}
+
+/// Iteration.
+static GDNativeBool gdnative_variant_iter_init(const GDNativeVariantPtr p_self, GDNativeVariantPtr r_iter, GDNativeBool *r_valid) {
+ const Variant *self = (const Variant *)p_self;
+ Variant *iter = (Variant *)r_iter;
+
+ bool valid;
+ bool ret = self->iter_init(*iter, valid);
+ *r_valid = valid;
+ return ret;
+}
+
+static GDNativeBool gdnative_variant_iter_next(const GDNativeVariantPtr p_self, GDNativeVariantPtr r_iter, GDNativeBool *r_valid) {
+ const Variant *self = (const Variant *)p_self;
+ Variant *iter = (Variant *)r_iter;
+
+ bool valid;
+ bool ret = self->iter_next(*iter, valid);
+ *r_valid = valid;
+ return ret;
+}
+
+static void gdnative_variant_iter_get(const GDNativeVariantPtr p_self, GDNativeVariantPtr r_iter, GDNativeVariantPtr r_ret, GDNativeBool *r_valid) {
+ const Variant *self = (const Variant *)p_self;
+ Variant *iter = (Variant *)r_iter;
+
+ bool valid;
+ memnew_placement_custom(r_ret, Variant, Variant(self->iter_next(*iter, valid)));
+ *r_valid = valid;
+}
+
+/// Variant functions.
+static GDNativeBool gdnative_variant_hash_compare(const GDNativeVariantPtr p_self, const GDNativeVariantPtr p_other) {
+ const Variant *self = (const Variant *)p_self;
+ const Variant *other = (const Variant *)p_other;
+ return self->hash_compare(*other);
+}
+
+static GDNativeBool gdnative_variant_booleanize(const GDNativeVariantPtr p_self) {
+ const Variant *self = (const Variant *)p_self;
+ return self->booleanize();
+}
+
+static void gdnative_variant_blend(const GDNativeVariantPtr p_a, const GDNativeVariantPtr p_b, float p_c, GDNativeVariantPtr r_dst) {
+ const Variant *a = (const Variant *)p_a;
+ const Variant *b = (const Variant *)p_b;
+ memnew_placement(r_dst, Variant);
+ Variant::blend(*a, *b, p_c, *(Variant *)r_dst);
+}
+
+static void gdnative_variant_interpolate(const GDNativeVariantPtr p_a, const GDNativeVariantPtr p_b, float p_c, GDNativeVariantPtr r_dst) {
+ const Variant *a = (const Variant *)p_a;
+ const Variant *b = (const Variant *)p_b;
+ memnew_placement(r_dst, Variant);
+ Variant::interpolate(*a, *b, p_c, *(Variant *)r_dst);
+}
+
+static void gdnative_variant_duplicate(const GDNativeVariantPtr p_self, GDNativeVariantPtr r_ret, GDNativeBool p_deep) {
+ const Variant *self = (const Variant *)p_self;
+ memnew_placement_custom(r_ret, Variant, Variant(self->duplicate(p_deep)));
+}
+
+static void gdnative_variant_stringify(const GDNativeVariantPtr p_self, GDNativeStringPtr r_ret) {
+ const Variant *self = (const Variant *)p_self;
+ memnew_placement_custom(r_ret, String, String(*self));
+}
+
+static GDNativeVariantType gdnative_variant_get_type(const GDNativeVariantPtr p_self) {
+ const Variant *self = (const Variant *)p_self;
+ return (GDNativeVariantType)self->get_type();
+}
+
+static GDNativeBool gdnative_variant_has_method(const GDNativeVariantPtr p_self, const GDNativeStringNamePtr p_method) {
+ const Variant *self = (const Variant *)p_self;
+ const StringName *method = (const StringName *)p_method;
+ return self->has_method(*method);
+}
+
+static GDNativeBool gdnative_variant_has_member(GDNativeVariantType p_type, const GDNativeStringNamePtr p_member) {
+ return Variant::has_member((Variant::Type)p_type, *((const StringName *)p_member));
+}
+
+static GDNativeBool gdnative_variant_has_key(const GDNativeVariantPtr p_self, const GDNativeVariantPtr p_key, GDNativeBool *r_valid) {
+ const Variant *self = (const Variant *)p_self;
+ const Variant *key = (const Variant *)p_key;
+ bool valid;
+ return self->has_key(*key, valid);
+ *r_valid = valid;
+}
+
+static void gdnative_variant_get_type_name(GDNativeVariantType p_type, GDNativeStringPtr r_ret) {
+ String name = Variant::get_type_name((Variant::Type)p_type);
+ memnew_placement_custom(r_ret, String, String(name));
+}
+
+static GDNativeBool gdnative_variant_can_convert(GDNativeVariantType p_from, GDNativeVariantType p_to) {
+ return Variant::can_convert((Variant::Type)p_from, (Variant::Type)p_to);
+}
+
+static GDNativeBool gdnative_variant_can_convert_strict(GDNativeVariantType p_from, GDNativeVariantType p_to) {
+ return Variant::can_convert_strict((Variant::Type)p_from, (Variant::Type)p_to);
+}
+
+// ptrcalls
+static GDNativePtrOperatorEvaluator gdnative_variant_get_ptr_operator_evaluator(GDNativeVariantOperator p_operator, GDNativeVariantType p_type_a, GDNativeVariantType p_type_b) {
+ return (GDNativePtrOperatorEvaluator)Variant::get_ptr_operator_evaluator(Variant::Operator(p_operator), Variant::Type(p_type_a), Variant::Type(p_type_b));
+}
+static GDNativePtrBuiltInMethod gdnative_variant_get_ptr_builtin_method(GDNativeVariantType p_type, const char *p_method, GDNativeInt p_hash) {
+ StringName method = p_method;
+ uint32_t hash = Variant::get_builtin_method_hash(Variant::Type(p_type), method);
+ if (hash != p_hash) {
+ ERR_PRINT_ONCE("Error getting method " + String(method) + ", hash mismatch.");
+ return nullptr;
+ }
+
+ return (GDNativePtrBuiltInMethod)Variant::get_ptr_builtin_method(Variant::Type(p_type), method);
+}
+static GDNativePtrConstructor gdnative_variant_get_ptr_constructor(GDNativeVariantType p_type, int32_t p_constructor) {
+ return (GDNativePtrConstructor)Variant::get_ptr_constructor(Variant::Type(p_type), p_constructor);
+}
+static void gdnative_variant_construct(GDNativeVariantType p_type, GDNativeVariantPtr p_base, const GDNativeVariantPtr *p_args, int32_t p_argument_count, GDNativeCallError *r_error) {
+ memnew_placement(p_base, Variant);
+
+ Callable::CallError error;
+ Variant::construct(Variant::Type(p_type), *(Variant *)p_base, (const Variant **)p_args, p_argument_count, error);
+
+ if (r_error) {
+ r_error->error = (GDNativeCallErrorType)(error.error);
+ r_error->argument = error.argument;
+ r_error->expected = error.expected;
+ }
+}
+static GDNativePtrSetter gdnative_variant_get_ptr_setter(GDNativeVariantType p_type, const char *p_member) {
+ return (GDNativePtrSetter)Variant::get_member_ptr_setter(Variant::Type(p_type), p_member);
+}
+static GDNativePtrGetter gdnative_variant_get_ptr_getter(GDNativeVariantType p_type, const char *p_member) {
+ return (GDNativePtrGetter)Variant::get_member_ptr_getter(Variant::Type(p_type), p_member);
+}
+static GDNativePtrIndexedSetter gdnative_variant_get_ptr_indexed_setter(GDNativeVariantType p_type) {
+ return (GDNativePtrIndexedSetter)Variant::get_member_ptr_indexed_setter(Variant::Type(p_type));
+}
+static GDNativePtrIndexedGetter gdnative_variant_get_ptr_indexed_getter(GDNativeVariantType p_type) {
+ return (GDNativePtrIndexedGetter)Variant::get_member_ptr_indexed_getter(Variant::Type(p_type));
+}
+static GDNativePtrKeyedSetter gdnative_variant_get_ptr_keyed_setter(GDNativeVariantType p_type) {
+ return (GDNativePtrKeyedSetter)Variant::get_member_ptr_keyed_setter(Variant::Type(p_type));
+}
+static GDNativePtrKeyedGetter gdnative_variant_get_ptr_keyed_getter(GDNativeVariantType p_type) {
+ return (GDNativePtrKeyedGetter)Variant::get_member_ptr_keyed_getter(Variant::Type(p_type));
+}
+static GDNativePtrKeyedChecker gdnative_variant_get_ptr_keyed_checker(GDNativeVariantType p_type) {
+ return (GDNativePtrKeyedChecker)Variant::get_member_ptr_keyed_checker(Variant::Type(p_type));
+}
+static void gdnative_variant_get_constant_value(GDNativeVariantType p_type, const char *p_constant, GDNativeVariantPtr r_ret) {
+ memnew_placement_custom(r_ret, Variant, Variant(Variant::get_constant_value(Variant::Type(p_type), p_constant)));
+}
+static GDNativePtrUtilityFunction gdnative_variant_get_ptr_utility_function(const char *p_function, GDNativeInt p_hash) {
+ StringName function = p_function;
+ uint32_t hash = Variant::get_utility_function_hash(function);
+ if (hash != p_hash) {
+ ERR_PRINT_ONCE("Error getting utility function " + String(function) + ", hash mismatch.");
+ return nullptr;
+ }
+ return (GDNativePtrUtilityFunction)Variant::get_ptr_utility_function(function);
+}
+
+//string helpers
+
+static void gdnative_string_new_with_latin1_chars(GDNativeStringPtr r_dest, const char *p_contents) {
+ String *dest = (String *)r_dest;
+ memnew_placement(dest, String);
+ *dest = String(p_contents);
+}
+
+static void gdnative_string_new_with_utf8_chars(GDNativeStringPtr r_dest, const char *p_contents) {
+ String *dest = (String *)r_dest;
+ memnew_placement(dest, String);
+ dest->parse_utf8(p_contents);
+}
+
+static void gdnative_string_new_with_utf16_chars(GDNativeStringPtr r_dest, const char16_t *p_contents) {
+ String *dest = (String *)r_dest;
+ memnew_placement(dest, String);
+ dest->parse_utf16(p_contents);
+}
+
+static void gdnative_string_new_with_utf32_chars(GDNativeStringPtr r_dest, const char32_t *p_contents) {
+ String *dest = (String *)r_dest;
+ memnew_placement(dest, String);
+ *dest = String((const char32_t *)p_contents);
+}
+
+static void gdnative_string_new_with_wide_chars(GDNativeStringPtr r_dest, const wchar_t *p_contents) {
+ String *dest = (String *)r_dest;
+ if (sizeof(wchar_t) == 2) {
+ // wchar_t is 16 bit, parse.
+ memnew_placement(dest, String);
+ dest->parse_utf16((const char16_t *)p_contents);
+ } else {
+ // wchar_t is 32 bit, copy.
+ memnew_placement(dest, String);
+ *dest = String((const char32_t *)p_contents);
+ }
+}
+
+static void gdnative_string_new_with_latin1_chars_and_len(GDNativeStringPtr r_dest, const char *p_contents, const GDNativeInt p_size) {
+ String *dest = (String *)r_dest;
+ memnew_placement(dest, String);
+ *dest = String(p_contents, p_size);
+}
+
+static void gdnative_string_new_with_utf8_chars_and_len(GDNativeStringPtr r_dest, const char *p_contents, const GDNativeInt p_size) {
+ String *dest = (String *)r_dest;
+ memnew_placement(dest, String);
+ dest->parse_utf8(p_contents, p_size);
+}
+
+static void gdnative_string_new_with_utf16_chars_and_len(GDNativeStringPtr r_dest, const char16_t *p_contents, const GDNativeInt p_size) {
+ String *dest = (String *)r_dest;
+ memnew_placement(dest, String);
+ dest->parse_utf16(p_contents, p_size);
+}
+
+static void gdnative_string_new_with_utf32_chars_and_len(GDNativeStringPtr r_dest, const char32_t *p_contents, const GDNativeInt p_size) {
+ String *dest = (String *)r_dest;
+ memnew_placement(dest, String);
+ *dest = String((const char32_t *)p_contents, p_size);
+}
+
+static void gdnative_string_new_with_wide_chars_and_len(GDNativeStringPtr r_dest, const wchar_t *p_contents, const GDNativeInt p_size) {
+ String *dest = (String *)r_dest;
+ if (sizeof(wchar_t) == 2) {
+ // wchar_t is 16 bit, parse.
+ memnew_placement(dest, String);
+ dest->parse_utf16((const char16_t *)p_contents, p_size);
+ } else {
+ // wchar_t is 32 bit, copy.
+ memnew_placement(dest, String);
+ *dest = String((const char32_t *)p_contents, p_size);
+ }
+}
+
+static GDNativeInt gdnative_string_to_latin1_chars(const GDNativeStringPtr p_self, char *r_text, GDNativeInt p_max_write_length) {
+ String *self = (String *)p_self;
+ CharString cs = self->ascii(true);
+ GDNativeInt len = cs.length();
+ if (r_text) {
+ const char *s_text = cs.ptr();
+ for (GDNativeInt i = 0; i < MIN(len, p_max_write_length); i++) {
+ r_text[i] = s_text[i];
+ }
+ }
+ return len;
+}
+static GDNativeInt gdnative_string_to_utf8_chars(const GDNativeStringPtr p_self, char *r_text, GDNativeInt p_max_write_length) {
+ String *self = (String *)p_self;
+ CharString cs = self->utf8();
+ GDNativeInt len = cs.length();
+ if (r_text) {
+ const char *s_text = cs.ptr();
+ for (GDNativeInt i = 0; i < MIN(len, p_max_write_length); i++) {
+ r_text[i] = s_text[i];
+ }
+ }
+ return len;
+}
+static GDNativeInt gdnative_string_to_utf16_chars(const GDNativeStringPtr p_self, char16_t *r_text, GDNativeInt p_max_write_length) {
+ String *self = (String *)p_self;
+ Char16String cs = self->utf16();
+ GDNativeInt len = cs.length();
+ if (r_text) {
+ const char16_t *s_text = cs.ptr();
+ for (GDNativeInt i = 0; i < MIN(len, p_max_write_length); i++) {
+ r_text[i] = s_text[i];
+ }
+ }
+ return len;
+}
+static GDNativeInt gdnative_string_to_utf32_chars(const GDNativeStringPtr p_self, char32_t *r_text, GDNativeInt p_max_write_length) {
+ String *self = (String *)p_self;
+ GDNativeInt len = self->length();
+ if (r_text) {
+ const char32_t *s_text = self->ptr();
+ for (GDNativeInt i = 0; i < MIN(len, p_max_write_length); i++) {
+ r_text[i] = s_text[i];
+ }
+ }
+ return len;
+}
+static GDNativeInt gdnative_string_to_wide_chars(const GDNativeStringPtr p_self, wchar_t *r_text, GDNativeInt p_max_write_length) {
+ if (sizeof(wchar_t) == 4) {
+ return gdnative_string_to_utf32_chars(p_self, (char32_t *)r_text, p_max_write_length);
+ } else {
+ return gdnative_string_to_utf16_chars(p_self, (char16_t *)r_text, p_max_write_length);
+ }
+}
+
+static char32_t *gdnative_string_operator_index(GDNativeStringPtr p_self, GDNativeInt p_index) {
+ String *self = (String *)p_self;
+ ERR_FAIL_INDEX_V(p_index, self->length() + 1, nullptr);
+ return &self->ptrw()[p_index];
+}
+
+static const char32_t *gdnative_string_operator_index_const(const GDNativeStringPtr p_self, GDNativeInt p_index) {
+ const String *self = (const String *)p_self;
+ ERR_FAIL_INDEX_V(p_index, self->length() + 1, nullptr);
+ return &self->ptr()[p_index];
+}
+
+/* OBJECT API */
+
+static void gdnative_object_method_bind_ptrcall(GDNativeMethodBindPtr p_method_bind, GDNativeObjectPtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr p_ret) {
+ MethodBind *mb = (MethodBind *)p_method_bind;
+ Object *o = (Object *)p_instance;
+ mb->ptrcall(o, (const void **)p_args, p_ret);
+}
+
+static void gdnative_object_destroy(GDNativeObjectPtr p_o) {
+ memdelete((Object *)p_o);
+}
+
+static GDNativeObjectPtr gdnative_global_get_singleton(const char *p_name) {
+ return (GDNativeObjectPtr)Engine::get_singleton()->get_singleton_object(String(p_name));
+}
+
+static GDNativeObjectPtr gdnative_object_get_instance_from_id(GDObjectInstanceID p_instance_id) {
+ return (GDNativeObjectPtr)ObjectDB::get_instance(ObjectID(p_instance_id));
+}
+
+static GDNativeObjectPtr gdnative_object_cast_to(const GDNativeObjectPtr p_object, void *p_class_tag) {
+ if (!p_object) {
+ return nullptr;
+ }
+ Object *o = (Object *)p_object;
+
+ return o->is_class_ptr(p_class_tag) ? (GDNativeObjectPtr)o : (GDNativeObjectPtr) nullptr;
+}
+
+static GDObjectInstanceID gdnative_object_get_instance_id(const GDNativeObjectPtr p_object) {
+ const Object *o = (const Object *)p_object;
+ return (GDObjectInstanceID)o->get_instance_id();
+}
+
+static GDNativeMethodBindPtr gdnative_classdb_get_method_bind(const char *p_classname, const char *p_methodname, GDNativeInt p_hash) {
+ MethodBind *mb = ClassDB::get_method(StringName(p_classname), StringName(p_methodname));
+ ERR_FAIL_COND_V(!mb, nullptr);
+ if (mb->get_hash() != p_hash) {
+ ERR_PRINT_ONCE("Hash mismatch for method '" + String(p_classname) + "." + String(p_methodname) + "'.");
+ return nullptr;
+ }
+ // MethodBind *mb = ClassDB::get_method("Node", "get_name");
+ return (GDNativeMethodBindPtr)mb;
+}
+
+static GDNativeClassConstructor gdnative_classdb_get_constructor(const char *p_classname) {
+ ClassDB::ClassInfo *class_info = ClassDB::classes.getptr(StringName(p_classname));
+ if (class_info) {
+ return (GDNativeClassConstructor)class_info->creation_func;
+ }
+ return nullptr;
+}
+
+static void *gdnative_classdb_get_class_tag(const char *p_classname) {
+ ClassDB::ClassInfo *class_info = ClassDB::classes.getptr(p_classname);
+ return class_info ? class_info->class_ptr : nullptr;
+}
+
+void gdnative_setup_interface(GDNativeInterface *p_interface) {
+ GDNativeInterface &gdni = *p_interface;
+
+ gdni.version_major = VERSION_MAJOR;
+ gdni.version_minor = VERSION_MINOR;
+#if VERSION_PATCH
+ gdni.version_patch = VERSION_PATCH;
+#else
+ gdni.version_patch = 0;
+#endif
+ gdni.version_string = VERSION_FULL_NAME;
+
+ /* GODOT CORE */
+
+ gdni.mem_alloc = gdnative_alloc;
+ gdni.mem_realloc = gdnative_realloc;
+ gdni.mem_free = gdnative_free;
+
+ gdni.print_error = gdnative_print_error;
+ gdni.print_warning = gdnative_print_warning;
+ gdni.print_script_error = gdnative_print_script_error;
+
+ /* GODOT VARIANT */
+
+ // variant general
+ gdni.variant_new_copy = gdnative_variant_new_copy;
+ gdni.variant_new_nil = gdnative_variant_new_nil;
+ gdni.variant_destroy = gdnative_variant_destroy;
+
+ gdni.variant_call = gdnative_variant_call;
+ gdni.variant_call_static = gdnative_variant_call_static;
+ gdni.variant_evaluate = gdnative_variant_evaluate;
+ gdni.variant_set = gdnative_variant_set;
+ gdni.variant_set_named = gdnative_variant_set_named;
+ gdni.variant_set_keyed = gdnative_variant_set_keyed;
+ gdni.variant_set_indexed = gdnative_variant_set_indexed;
+ gdni.variant_get = gdnative_variant_get;
+ gdni.variant_get_named = gdnative_variant_get_named;
+ gdni.variant_get_keyed = gdnative_variant_get_keyed;
+ gdni.variant_get_indexed = gdnative_variant_get_indexed;
+ gdni.variant_iter_init = gdnative_variant_iter_init;
+ gdni.variant_iter_next = gdnative_variant_iter_next;
+ gdni.variant_iter_get = gdnative_variant_iter_get;
+ gdni.variant_hash_compare = gdnative_variant_hash_compare;
+ gdni.variant_booleanize = gdnative_variant_booleanize;
+ gdni.variant_blend = gdnative_variant_blend;
+ gdni.variant_interpolate = gdnative_variant_interpolate;
+ gdni.variant_duplicate = gdnative_variant_duplicate;
+ gdni.variant_stringify = gdnative_variant_stringify;
+
+ gdni.variant_get_type = gdnative_variant_get_type;
+ gdni.variant_has_method = gdnative_variant_has_method;
+ gdni.variant_has_member = gdnative_variant_has_member;
+ gdni.variant_has_key = gdnative_variant_has_key;
+ gdni.variant_get_type_name = gdnative_variant_get_type_name;
+ gdni.variant_can_convert = gdnative_variant_can_convert;
+ gdni.variant_can_convert_strict = gdnative_variant_can_convert_strict;
+
+ //ptrcalls
+#if 0
+ GDNativeVariantFromTypeConstructorFunc (*get_variant_from_type_constructor)(GDNativeVariantType p_type);
+ GDNativeTypeFromVariantConstructorFunc (*get_variant_to_type_constructor)(GDNativeVariantType p_type);
+#endif
+
+ gdni.variant_get_ptr_operator_evaluator = gdnative_variant_get_ptr_operator_evaluator;
+ gdni.variant_get_ptr_builtin_method = gdnative_variant_get_ptr_builtin_method;
+ gdni.variant_get_ptr_constructor = gdnative_variant_get_ptr_constructor;
+ gdni.variant_construct = gdnative_variant_construct;
+ gdni.variant_get_ptr_setter = gdnative_variant_get_ptr_setter;
+ gdni.variant_get_ptr_getter = gdnative_variant_get_ptr_getter;
+ gdni.variant_get_ptr_indexed_setter = gdnative_variant_get_ptr_indexed_setter;
+ gdni.variant_get_ptr_indexed_getter = gdnative_variant_get_ptr_indexed_getter;
+ gdni.variant_get_ptr_keyed_setter = gdnative_variant_get_ptr_keyed_setter;
+ gdni.variant_get_ptr_keyed_getter = gdnative_variant_get_ptr_keyed_getter;
+ gdni.variant_get_ptr_keyed_checker = gdnative_variant_get_ptr_keyed_checker;
+ gdni.variant_get_constant_value = gdnative_variant_get_constant_value;
+ gdni.variant_get_ptr_utility_function = gdnative_variant_get_ptr_utility_function;
+
+ // extra utilities
+
+ gdni.string_new_with_latin1_chars = gdnative_string_new_with_latin1_chars;
+ gdni.string_new_with_utf8_chars = gdnative_string_new_with_utf8_chars;
+ gdni.string_new_with_utf16_chars = gdnative_string_new_with_utf16_chars;
+ gdni.string_new_with_utf32_chars = gdnative_string_new_with_utf32_chars;
+ gdni.string_new_with_wide_chars = gdnative_string_new_with_wide_chars;
+ gdni.string_new_with_latin1_chars_and_len = gdnative_string_new_with_latin1_chars_and_len;
+ gdni.string_new_with_utf8_chars_and_len = gdnative_string_new_with_utf8_chars_and_len;
+ gdni.string_new_with_utf16_chars_and_len = gdnative_string_new_with_utf16_chars_and_len;
+ gdni.string_new_with_utf32_chars_and_len = gdnative_string_new_with_utf32_chars_and_len;
+ gdni.string_new_with_wide_chars_and_len = gdnative_string_new_with_wide_chars_and_len;
+ gdni.string_to_latin1_chars = gdnative_string_to_latin1_chars;
+ gdni.string_to_utf8_chars = gdnative_string_to_utf8_chars;
+ gdni.string_to_utf16_chars = gdnative_string_to_utf16_chars;
+ gdni.string_to_utf32_chars = gdnative_string_to_utf32_chars;
+ gdni.string_to_wide_chars = gdnative_string_to_wide_chars;
+ gdni.string_operator_index = gdnative_string_operator_index;
+ gdni.string_operator_index_const = gdnative_string_operator_index_const;
+
+ /* OBJECT */
+
+ gdni.object_method_bind_ptrcall = gdnative_object_method_bind_ptrcall;
+ gdni.object_destroy = gdnative_object_destroy;
+ gdni.global_get_singleton = gdnative_global_get_singleton;
+
+ gdni.object_cast_to = gdnative_object_cast_to;
+ gdni.object_get_instance_from_id = gdnative_object_get_instance_from_id;
+ gdni.object_get_instance_id = gdnative_object_get_instance_id;
+
+ /* CLASSDB */
+
+ gdni.classdb_get_constructor = gdnative_classdb_get_constructor;
+ gdni.classdb_get_method_bind = gdnative_classdb_get_method_bind;
+ gdni.classdb_get_class_tag = gdnative_classdb_get_class_tag;
+
+ /* CLASSDB EXTENSION */
+
+ //these are filled by implementation, since it will want to keep track of registered classes
+ gdni.classdb_register_extension_class = nullptr;
+ gdni.classdb_register_extension_class_method = nullptr;
+ gdni.classdb_register_extension_class_integer_constant = nullptr;
+ gdni.classdb_register_extension_class_property = nullptr;
+ gdni.classdb_register_extension_class_signal = nullptr;
+ gdni.classdb_unregister_extension_class = nullptr;
+}
diff --git a/core/extension/gdnative_interface.h b/core/extension/gdnative_interface.h
new file mode 100644
index 0000000000..318912e889
--- /dev/null
+++ b/core/extension/gdnative_interface.h
@@ -0,0 +1,427 @@
+/*************************************************************************/
+/* gdnative_interface.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef GDNATIVE_INTERFACE_H
+#define GDNATIVE_INTERFACE_H
+
+/* This is a C class header, you can copy it and use it directly in your own binders.
+ * Together with the JSON file, you should be able to generate any binder.
+ */
+
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* VARIANT TYPES */
+
+typedef enum {
+ GDNATIVE_VARIANT_TYPE_NIL,
+
+ /* atomic types */
+ GDNATIVE_VARIANT_TYPE_BOOL,
+ GDNATIVE_VARIANT_TYPE_INT,
+ GDNATIVE_VARIANT_TYPE_FLOAT,
+ GDNATIVE_VARIANT_TYPE_STRING,
+
+ /* math types */
+ GDNATIVE_VARIANT_TYPE_VECTOR2,
+ GDNATIVE_VARIANT_TYPE_VECTOR2I,
+ GDNATIVE_VARIANT_TYPE_RECT2,
+ GDNATIVE_VARIANT_TYPE_RECT2I,
+ GDNATIVE_VARIANT_TYPE_VECTOR3,
+ GDNATIVE_VARIANT_TYPE_VECTOR3I,
+ GDNATIVE_VARIANT_TYPE_TRANSFORM2D,
+ GDNATIVE_VARIANT_TYPE_PLANE,
+ GDNATIVE_VARIANT_TYPE_QUATERNION,
+ GDNATIVE_VARIANT_TYPE_AABB,
+ GDNATIVE_VARIANT_TYPE_BASIS,
+ GDNATIVE_VARIANT_TYPE_TRANSFORM3D,
+
+ /* misc types */
+ GDNATIVE_VARIANT_TYPE_COLOR,
+ GDNATIVE_VARIANT_TYPE_STRING_NAME,
+ GDNATIVE_VARIANT_TYPE_NODE_PATH,
+ GDNATIVE_VARIANT_TYPE_RID,
+ GDNATIVE_VARIANT_TYPE_OBJECT,
+ GDNATIVE_VARIANT_TYPE_CALLABLE,
+ GDNATIVE_VARIANT_TYPE_SIGNAL,
+ GDNATIVE_VARIANT_TYPE_DICTIONARY,
+ GDNATIVE_VARIANT_TYPE_ARRAY,
+
+ /* typed arrays */
+ GDNATIVE_VARIANT_TYPE_PACKED_BYTE_ARRAY,
+ GDNATIVE_VARIANT_TYPE_PACKED_INT32_ARRAY,
+ GDNATIVE_VARIANT_TYPE_PACKED_INT64_ARRAY,
+ GDNATIVE_VARIANT_TYPE_PACKED_FLOAT32_ARRAY,
+ GDNATIVE_VARIANT_TYPE_PACKED_FLOAT64_ARRAY,
+ GDNATIVE_VARIANT_TYPE_PACKED_STRING_ARRAY,
+ GDNATIVE_VARIANT_TYPE_PACKED_VECTOR2_ARRAY,
+ GDNATIVE_VARIANT_TYPE_PACKED_VECTOR3_ARRAY,
+ GDNATIVE_VARIANT_TYPE_PACKED_COLOR_ARRAY,
+
+ GDNATIVE_VARIANT_TYPE_VARIANT_MAX
+} GDNativeVariantType;
+
+typedef enum {
+ /* comparison */
+ GDNATIVE_VARIANT_OP_EQUAL,
+ GDNATIVE_VARIANT_OP_NOT_EQUAL,
+ GDNATIVE_VARIANT_OP_LESS,
+ GDNATIVE_VARIANT_OP_LESS_EQUAL,
+ GDNATIVE_VARIANT_OP_GREATER,
+ GDNATIVE_VARIANT_OP_GREATER_EQUAL,
+ /* mathematic */
+ GDNATIVE_VARIANT_OP_ADD,
+ GDNATIVE_VARIANT_OP_SUBTRACT,
+ GDNATIVE_VARIANT_OP_MULTIPLY,
+ GDNATIVE_VARIANT_OP_DIVIDE,
+ GDNATIVE_VARIANT_OP_NEGATE,
+ GDNATIVE_VARIANT_OP_POSITIVE,
+ GDNATIVE_VARIANT_OP_MODULE,
+ /* bitwise */
+ GDNATIVE_VARIANT_OP_SHIFT_LEFT,
+ GDNATIVE_VARIANT_OP_SHIFT_RIGHT,
+ GDNATIVE_VARIANT_OP_BIT_AND,
+ GDNATIVE_VARIANT_OP_BIT_OR,
+ GDNATIVE_VARIANT_OP_BIT_XOR,
+ GDNATIVE_VARIANT_OP_BIT_NEGATE,
+ /* logic */
+ GDNATIVE_VARIANT_OP_AND,
+ GDNATIVE_VARIANT_OP_OR,
+ GDNATIVE_VARIANT_OP_XOR,
+ GDNATIVE_VARIANT_OP_NOT,
+ /* containment */
+ GDNATIVE_VARIANT_OP_IN,
+ GDNATIVE_VARIANT_OP_MAX
+
+} GDNativeVariantOperator;
+
+typedef void *GDNativeVariantPtr;
+typedef void *GDNativeStringNamePtr;
+typedef void *GDNativeStringPtr;
+typedef void *GDNativeObjectPtr;
+typedef void *GDNativeTypePtr;
+typedef void *GDNativeMethodBindPtr;
+typedef int64_t GDNativeInt;
+typedef uint32_t GDNativeBool;
+typedef uint64_t GDObjectInstanceID;
+
+/* VARIANT DATA I/O */
+
+typedef enum {
+ NATIVE_CALL_OK,
+ NATIVE_CALL_ERROR_INVALID_METHOD,
+ NATIVE_CALL_ERROR_INVALID_ARGUMENT, /* expected is variant type */
+ NATIVE_CALL_ERROR_TOO_MANY_ARGUMENTS, /* expected is number of arguments */
+ NATIVE_CALL_ERROR_TOO_FEW_ARGUMENTS, /* expected is number of arguments */
+ NATIVE_CALL_ERROR_INSTANCE_IS_NULL,
+
+} GDNativeCallErrorType;
+
+typedef struct {
+ GDNativeCallErrorType error;
+ int32_t argument;
+ int32_t expected;
+} GDNativeCallError;
+
+typedef void (*GDNativeVariantFromTypeConstructorFunc)(GDNativeVariantPtr, GDNativeTypePtr);
+typedef void (*GDNativeTypeFromVariantConstructorFunc)(GDNativeTypePtr, GDNativeVariantPtr);
+typedef void (*GDNativePtrOperatorEvaluator)(const GDNativeTypePtr p_left, const GDNativeTypePtr p_right, GDNativeTypePtr r_result);
+typedef void (*GDNativePtrBuiltInMethod)(GDNativeTypePtr p_base, const GDNativeTypePtr *p_args, GDNativeTypePtr r_return, int p_argument_count);
+typedef void (*GDNativePtrConstructor)(GDNativeTypePtr p_base, const GDNativeTypePtr *p_args);
+typedef void (*GDNativePtrSetter)(GDNativeTypePtr p_base, const GDNativeTypePtr p_value);
+typedef void (*GDNativePtrGetter)(const GDNativeTypePtr p_base, GDNativeTypePtr r_value);
+typedef void (*GDNativePtrIndexedSetter)(GDNativeTypePtr p_base, GDNativeInt p_index, const GDNativeTypePtr p_value);
+typedef void (*GDNativePtrIndexedGetter)(const GDNativeTypePtr p_base, GDNativeInt p_index, GDNativeTypePtr r_value);
+typedef void (*GDNativePtrKeyedSetter)(GDNativeTypePtr p_base, const GDNativeTypePtr p_key, const GDNativeTypePtr p_value);
+typedef void (*GDNativePtrKeyedGetter)(const GDNativeTypePtr p_base, const GDNativeTypePtr p_key, GDNativeTypePtr r_value);
+typedef uint32_t (*GDNativePtrKeyedChecker)(const GDNativeVariantPtr p_base, const GDNativeVariantPtr p_key);
+typedef void (*GDNativePtrUtilityFunction)(GDNativeTypePtr r_return, const GDNativeTypePtr *p_arguments, int p_argument_count);
+
+typedef GDNativeObjectPtr (*GDNativeClassConstructor)();
+
+/* EXTENSION CLASSES */
+
+typedef void *GDExtensionClassInstancePtr;
+
+typedef GDNativeBool (*GDNativeExtensionClassSet)(GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name, const GDNativeVariantPtr p_value);
+typedef GDNativeBool (*GDNativeExtensionClassGet)(GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name, GDNativeVariantPtr r_ret);
+
+typedef struct {
+ uint32_t type;
+ const char *name;
+ const char *class_name;
+ uint32_t hint;
+ const char *hint_string;
+ uint32_t usage;
+} GDNativePropertyInfo;
+
+typedef const GDNativePropertyInfo *(*GDNativeExtensionClassGetPropertyList)(GDExtensionClassInstancePtr p_instance, uint32_t *r_count);
+typedef void (*GDNativeExtensionClassFreePropertyList)(GDExtensionClassInstancePtr p_instance, const GDNativePropertyInfo *p_list);
+typedef void (*GDNativeExtensionClassNotification)(GDExtensionClassInstancePtr p_instance, int32_t p_what);
+typedef const char *(*GDNativeExtensionClassToString)(GDExtensionClassInstancePtr p_instance);
+typedef void (*GDNativeExtensionClassReference)(GDExtensionClassInstancePtr p_instance);
+typedef void (*GDNativeExtensionClassUnreference)(GDExtensionClassInstancePtr p_instance);
+typedef void (*GDNativeExtensionClassCallVirtual)(GDExtensionClassInstancePtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr r_ret);
+typedef GDExtensionClassInstancePtr (*GDNativeExtensionClassCreateInstance)(void *p_userdata);
+typedef void (*GDNativeExtensionClassFreeInstance)(void *p_userdata, GDExtensionClassInstancePtr p_instance);
+typedef GDNativeExtensionClassCallVirtual (*GDNativeExtensionClassGetVirtual)(void *p_userdata, const char *p_name);
+
+typedef struct {
+ GDNativeExtensionClassSet set_func;
+ GDNativeExtensionClassGet get_func;
+ GDNativeExtensionClassGetPropertyList get_property_list_func;
+ GDNativeExtensionClassFreePropertyList free_property_list_func;
+ GDNativeExtensionClassNotification notification_func;
+ GDNativeExtensionClassToString to_string_func;
+ GDNativeExtensionClassReference reference_func;
+ GDNativeExtensionClassUnreference unreference_func;
+ GDNativeExtensionClassCreateInstance create_instance_func; /* this one is mandatory */
+ GDNativeExtensionClassFreeInstance free_instance_func; /* this one is mandatory */
+ GDNativeExtensionClassGetVirtual get_firtual_func;
+ void *class_userdata;
+} GDNativeExtensionClassCreationInfo;
+
+typedef void *GDNativeExtensionClassLibraryPtr;
+
+typedef const GDNativePropertyInfo *(*GDNativeExtensionClassGetPropertyList)(GDExtensionClassInstancePtr p_instance, uint32_t *r_count);
+
+/* Method */
+
+typedef enum {
+ GDNATIVE_EXTENSION_METHOD_FLAG_NORMAL = 1,
+ GDNATIVE_EXTENSION_METHOD_FLAG_EDITOR = 2,
+ GDNATIVE_EXTENSION_METHOD_FLAG_NOSCRIPT = 4,
+ GDNATIVE_EXTENSION_METHOD_FLAG_CONST = 8,
+ GDNATIVE_EXTENSION_METHOD_FLAG_REVERSE = 16, /* used for events */
+ GDNATIVE_EXTENSION_METHOD_FLAG_VIRTUAL = 32,
+ GDNATIVE_EXTENSION_METHOD_FLAG_FROM_SCRIPT = 64,
+ GDNATIVE_EXTENSION_METHOD_FLAG_VARARG = 128,
+ GDNATIVE_EXTENSION_METHOD_FLAG_STATIC = 256,
+ GDNATIVE_EXTENSION_METHOD_FLAGS_DEFAULT = GDNATIVE_EXTENSION_METHOD_FLAG_NORMAL,
+} GDNativeExtensionClassMethodFlags;
+
+typedef enum {
+ GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_NONE,
+ GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT8,
+ GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT16,
+ GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT32,
+ GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT64,
+ GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT8,
+ GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT16,
+ GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT32,
+ GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT64,
+ GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_REAL_IS_FLOAT,
+ GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_REAL_IS_DOUBLE
+} GDNativeExtensionClassMethodArgumentMetadata;
+
+typedef void (*GDNativeExtensionClassMethodCall)(GDExtensionClassInstancePtr p_instance, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeVariantPtr r_return, GDNativeCallError *r_error);
+typedef void (*GDNativeExtensionClassMethodPtrCall)(GDExtensionClassInstancePtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr r_ret);
+
+/* passing -1 as argument in the following functions refers to the return type */
+typedef GDNativeVariantType (*GDNativeExtensionClassMethodGetArgumentType)(void *p_method_userdata, int32_t p_argument);
+typedef void (*GDNativeExtensionClassMethodGetArgumentInfo)(void *p_method_userdata, int32_t p_argument, GDNativePropertyInfo *r_info);
+typedef GDNativeExtensionClassMethodArgumentMetadata (*GDNativeExtensionClassMethodGetArgumentMetadata)(void *p_method_userdata, int32_t p_argument);
+
+typedef struct {
+ const char *name;
+ void *method_userdata;
+ GDNativeExtensionClassMethodCall call_func;
+ GDNativeExtensionClassMethodPtrCall ptrcall_func;
+ uint32_t method_flags; /* GDNativeExtensionClassMethodFlags */
+ uint32_t argument_count;
+ GDNativeBool has_return_value;
+ GDNativeExtensionClassMethodGetArgumentType get_argument_type_func;
+ GDNativeExtensionClassMethodGetArgumentInfo get_argument_info_func; /* name and hint information for the argument can be omitted in release builds. Class name should always be present if it applies. */
+ GDNativeExtensionClassMethodGetArgumentMetadata get_argument_metadata_func;
+ uint32_t default_argument_count;
+ GDNativeVariantPtr *default_arguments;
+} GDNativeExtensionClassMethodInfo;
+
+/* INTERFACE */
+
+typedef struct {
+ uint32_t version_major;
+ uint32_t version_minor;
+ uint32_t version_patch;
+ const char *version_string;
+
+ /* GODOT CORE */
+ void *(*mem_alloc)(size_t p_bytes);
+ void *(*mem_realloc)(void *p_ptr, size_t p_bytes);
+ void (*mem_free)(void *p_ptr);
+
+ void (*print_error)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line);
+ void (*print_warning)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line);
+ void (*print_script_error)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line);
+
+ /* GODOT VARIANT */
+
+ /* variant general */
+ void (*variant_new_copy)(GDNativeVariantPtr r_dest, const GDNativeVariantPtr p_src);
+ void (*variant_new_nil)(GDNativeVariantPtr r_dest);
+ void (*variant_destroy)(GDNativeVariantPtr p_self);
+
+ /* variant type */
+ void (*variant_call)(GDNativeVariantPtr p_self, const GDNativeStringNamePtr p_method, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeVariantPtr r_return, GDNativeCallError *r_error);
+ void (*variant_call_static)(GDNativeVariantType p_type, const GDNativeStringNamePtr p_method, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeVariantPtr r_return, GDNativeCallError *r_error);
+ void (*variant_evaluate)(GDNativeVariantOperator p_op, const GDNativeVariantPtr p_a, const GDNativeVariantPtr p_b, GDNativeVariantPtr r_return, GDNativeBool *r_valid);
+ void (*variant_set)(GDNativeVariantPtr p_self, const GDNativeVariantPtr p_key, const GDNativeVariantPtr p_value, GDNativeBool *r_valid);
+ void (*variant_set_named)(GDNativeVariantPtr p_self, const GDNativeStringNamePtr p_key, const GDNativeVariantPtr p_value, GDNativeBool *r_valid);
+ void (*variant_set_keyed)(GDNativeVariantPtr p_self, const GDNativeVariantPtr p_key, const GDNativeVariantPtr p_value, GDNativeBool *r_valid);
+ void (*variant_set_indexed)(GDNativeVariantPtr p_self, GDNativeInt p_index, const GDNativeVariantPtr p_value, GDNativeBool *r_valid, GDNativeBool *r_oob);
+ void (*variant_get)(const GDNativeVariantPtr p_self, const GDNativeVariantPtr p_key, GDNativeVariantPtr r_ret, GDNativeBool *r_valid);
+ void (*variant_get_named)(const GDNativeVariantPtr p_self, const GDNativeStringNamePtr p_key, GDNativeVariantPtr r_ret, GDNativeBool *r_valid);
+ void (*variant_get_keyed)(const GDNativeVariantPtr p_self, const GDNativeVariantPtr p_key, GDNativeVariantPtr r_ret, GDNativeBool *r_valid);
+ void (*variant_get_indexed)(const GDNativeVariantPtr p_self, GDNativeInt p_index, GDNativeVariantPtr r_ret, GDNativeBool *r_valid, GDNativeBool *r_oob);
+ GDNativeBool (*variant_iter_init)(const GDNativeVariantPtr p_self, GDNativeVariantPtr r_iter, GDNativeBool *r_valid);
+ GDNativeBool (*variant_iter_next)(const GDNativeVariantPtr p_self, GDNativeVariantPtr r_iter, GDNativeBool *r_valid);
+ void (*variant_iter_get)(const GDNativeVariantPtr p_self, GDNativeVariantPtr r_iter, GDNativeVariantPtr r_ret, GDNativeBool *r_valid);
+ GDNativeBool (*variant_hash_compare)(const GDNativeVariantPtr p_self, const GDNativeVariantPtr p_other);
+ GDNativeBool (*variant_booleanize)(const GDNativeVariantPtr p_self);
+ void (*variant_blend)(const GDNativeVariantPtr p_a, const GDNativeVariantPtr p_b, float p_c, GDNativeVariantPtr r_dst);
+ void (*variant_interpolate)(const GDNativeVariantPtr p_a, const GDNativeVariantPtr p_b, float p_c, GDNativeVariantPtr r_dst);
+ void (*variant_duplicate)(const GDNativeVariantPtr p_self, GDNativeVariantPtr r_ret, GDNativeBool p_deep);
+ void (*variant_stringify)(const GDNativeVariantPtr p_self, GDNativeStringPtr r_ret);
+
+ GDNativeVariantType (*variant_get_type)(const GDNativeVariantPtr p_self);
+ GDNativeBool (*variant_has_method)(const GDNativeVariantPtr p_self, const GDNativeStringNamePtr p_method);
+ GDNativeBool (*variant_has_member)(GDNativeVariantType p_type, const GDNativeStringNamePtr p_member);
+ GDNativeBool (*variant_has_key)(const GDNativeVariantPtr p_self, const GDNativeVariantPtr p_key, GDNativeBool *r_valid);
+ void (*variant_get_type_name)(GDNativeVariantType p_type, GDNativeStringPtr r_name);
+ GDNativeBool (*variant_can_convert)(GDNativeVariantType p_from, GDNativeVariantType p_to);
+ GDNativeBool (*variant_can_convert_strict)(GDNativeVariantType p_from, GDNativeVariantType p_to);
+
+ /* ptrcalls */
+ GDNativeVariantFromTypeConstructorFunc (*get_variant_from_type_constructor)(GDNativeVariantType p_type);
+ GDNativeTypeFromVariantConstructorFunc (*get_variant_to_type_constructor)(GDNativeVariantType p_type);
+ GDNativePtrOperatorEvaluator (*variant_get_ptr_operator_evaluator)(GDNativeVariantOperator p_operator, GDNativeVariantType p_type_a, GDNativeVariantType p_type_b);
+ GDNativePtrBuiltInMethod (*variant_get_ptr_builtin_method)(GDNativeVariantType p_type, const char *p_method, GDNativeInt p_hash);
+ GDNativePtrConstructor (*variant_get_ptr_constructor)(GDNativeVariantType p_type, int32_t p_constructor);
+ void (*variant_construct)(GDNativeVariantType p_type, GDNativeVariantPtr p_base, const GDNativeVariantPtr *p_args, int32_t p_argument_count, GDNativeCallError *r_error);
+ GDNativePtrSetter (*variant_get_ptr_setter)(GDNativeVariantType p_type, const char *p_member);
+ GDNativePtrGetter (*variant_get_ptr_getter)(GDNativeVariantType p_type, const char *p_member);
+ GDNativePtrIndexedSetter (*variant_get_ptr_indexed_setter)(GDNativeVariantType p_type);
+ GDNativePtrIndexedGetter (*variant_get_ptr_indexed_getter)(GDNativeVariantType p_type);
+ GDNativePtrKeyedSetter (*variant_get_ptr_keyed_setter)(GDNativeVariantType p_type);
+ GDNativePtrKeyedGetter (*variant_get_ptr_keyed_getter)(GDNativeVariantType p_type);
+ GDNativePtrKeyedChecker (*variant_get_ptr_keyed_checker)(GDNativeVariantType p_type);
+ void (*variant_get_constant_value)(GDNativeVariantType p_type, const char *p_constant, GDNativeVariantPtr r_ret);
+ GDNativePtrUtilityFunction (*variant_get_ptr_utility_function)(const char *p_function, GDNativeInt p_hash);
+
+ /* extra utilities */
+
+ void (*string_new_with_latin1_chars)(GDNativeStringPtr r_dest, const char *p_contents);
+ void (*string_new_with_utf8_chars)(GDNativeStringPtr r_dest, const char *p_contents);
+ void (*string_new_with_utf16_chars)(GDNativeStringPtr r_dest, const char16_t *p_contents);
+ void (*string_new_with_utf32_chars)(GDNativeStringPtr r_dest, const char32_t *p_contents);
+ void (*string_new_with_wide_chars)(GDNativeStringPtr r_dest, const wchar_t *p_contents);
+ void (*string_new_with_latin1_chars_and_len)(GDNativeStringPtr r_dest, const char *p_contents, const GDNativeInt p_size);
+ void (*string_new_with_utf8_chars_and_len)(GDNativeStringPtr r_dest, const char *p_contents, const GDNativeInt p_size);
+ void (*string_new_with_utf16_chars_and_len)(GDNativeStringPtr r_dest, const char16_t *p_contents, const GDNativeInt p_size);
+ void (*string_new_with_utf32_chars_and_len)(GDNativeStringPtr r_dest, const char32_t *p_contents, const GDNativeInt p_size);
+ void (*string_new_with_wide_chars_and_len)(GDNativeStringPtr r_dest, const wchar_t *p_contents, const GDNativeInt p_size);
+ /* Information about the following functions:
+ * - The return value is the resulting encoded string length.
+ * - The length returned is in characters, not in bytes. It also does not include a trailing zero.
+ * - These functions also do not write trailing zero, If you need it, write it yourself at the position indicated by the length (and make sure to allocate it).
+ * - Passing NULL in r_text means only the length is computed (again, without including trailing zero).
+ * - p_max_write_length argument is in characters, not bytes. It will be ignored if r_text is NULL.
+ * - p_max_write_length argument does not affect the return value, it's only to cap write length.
+ */
+ GDNativeInt (*string_to_latin1_chars)(const GDNativeStringPtr p_self, char *r_text, GDNativeInt p_max_write_length);
+ GDNativeInt (*string_to_utf8_chars)(const GDNativeStringPtr p_self, char *r_text, GDNativeInt p_max_write_length);
+ GDNativeInt (*string_to_utf16_chars)(const GDNativeStringPtr p_self, char16_t *r_text, GDNativeInt p_max_write_length);
+ GDNativeInt (*string_to_utf32_chars)(const GDNativeStringPtr p_self, char32_t *r_text, GDNativeInt p_max_write_length);
+ GDNativeInt (*string_to_wide_chars)(const GDNativeStringPtr p_self, wchar_t *r_text, GDNativeInt p_max_write_length);
+ char32_t *(*string_operator_index)(GDNativeStringPtr p_self, GDNativeInt p_index);
+ const char32_t *(*string_operator_index_const)(const GDNativeStringPtr p_self, GDNativeInt p_index);
+
+ /* OBJECT */
+
+ void (*object_method_bind_ptrcall)(GDNativeMethodBindPtr p_method_bind, GDNativeObjectPtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr r_ret);
+ void (*object_destroy)(GDNativeObjectPtr p_o);
+ GDNativeObjectPtr (*global_get_singleton)(const char *p_name);
+
+ GDNativeObjectPtr (*object_cast_to)(const GDNativeObjectPtr p_object, void *p_class_tag);
+ GDNativeObjectPtr (*object_get_instance_from_id)(GDObjectInstanceID p_instance_id);
+ GDObjectInstanceID (*object_get_instance_id)(const GDNativeObjectPtr p_object);
+
+ /* CLASSDB */
+
+ GDNativeClassConstructor (*classdb_get_constructor)(const char *p_classname);
+ GDNativeMethodBindPtr (*classdb_get_method_bind)(const char *p_classname, const char *p_methodname, GDNativeInt p_hash);
+ void *(*classdb_get_class_tag)(const char *p_classname);
+
+ /* CLASSDB EXTENSION */
+
+ void (*classdb_register_extension_class)(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const char *p_parent_class_name, const GDNativeExtensionClassCreationInfo *p_extension_funcs);
+ void (*classdb_register_extension_class_method)(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const GDNativeExtensionClassMethodInfo *p_method_info);
+ void (*classdb_register_extension_class_integer_constant)(const GDNativeExtensionClassLibraryPtr p_library, const char *p_enum_name, const char *p_class_name, const char *p_constant_name, uint32_t p_constant_value);
+ void (*classdb_register_extension_class_property)(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const GDNativePropertyInfo *p_info, const char *p_setter, const char *p_getter);
+ void (*classdb_register_extension_class_signal)(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const char *p_signal_name, const GDNativePropertyInfo *p_argument_info, GDNativeInt p_argument_count);
+ void (*classdb_unregister_extension_class)(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name); /* Unregistering a parent class before a class that inherits it will result in failure. Inheritors must be unregistered first. */
+} GDNativeInterface;
+
+/* INITIALIZATION */
+
+typedef enum {
+ GDNATIVE_INITIALIZATION_CORE,
+ GDNATIVE_INITIALIZATION_SERVERS,
+ GDNATIVE_INITIALIZATION_SCENE,
+ GDNATIVE_INITIALIZATION_EDITOR,
+} GDNativeInitializationLevel;
+
+typedef struct {
+ /* Minimum initialization level required.
+ * If Core or Servers, the extension needs editor or game restart to take effect */
+ GDNativeInitializationLevel minimum_initialization_level;
+ /* Up to the user to supply when initializing */
+ void *userdata;
+ /* This function will be called multiple times for each initialization level. */
+ void (*initialize)(void *userdata, GDNativeInitializationLevel p_level);
+ void (*deinitialize)(void *userdata, GDNativeInitializationLevel p_level);
+} GDNativeInitialization;
+
+/* Define a C function prototype that implements the function below and expose it to dlopen() (or similar).
+ * It will be called on initialization. The name must be an unique one specified in the .gdextension config file.
+ */
+
+typedef GDNativeBool (*GDNativeInitializationFunction)(const GDNativeInterface *p_interface, const GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/core/extension/native_extension.cpp b/core/extension/native_extension.cpp
new file mode 100644
index 0000000000..65718a7507
--- /dev/null
+++ b/core/extension/native_extension.cpp
@@ -0,0 +1,411 @@
+/*************************************************************************/
+/* native_extension.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "native_extension.h"
+#include "core/io/config_file.h"
+#include "core/object/class_db.h"
+#include "core/object/method_bind.h"
+#include "core/os/os.h"
+
+class NativeExtensionMethodBind : public MethodBind {
+ GDNativeExtensionClassMethodCall call_func;
+ GDNativeExtensionClassMethodPtrCall ptrcall_func;
+ GDNativeExtensionClassMethodGetArgumentType get_argument_type_func;
+ GDNativeExtensionClassMethodGetArgumentInfo get_argument_info_func;
+ GDNativeExtensionClassMethodGetArgumentMetadata get_argument_metadata_func;
+ void *method_userdata;
+ bool vararg;
+
+protected:
+ virtual Variant::Type _gen_argument_type(int p_arg) const {
+ return Variant::Type(get_argument_type_func(method_userdata, p_arg));
+ }
+ virtual PropertyInfo _gen_argument_type_info(int p_arg) const {
+ GDNativePropertyInfo pinfo;
+ get_argument_info_func(method_userdata, p_arg, &pinfo);
+ PropertyInfo ret;
+ ret.type = Variant::Type(pinfo.type);
+ ret.name = pinfo.name;
+ ret.class_name = pinfo.class_name;
+ ret.hint = PropertyHint(pinfo.hint);
+ ret.usage = pinfo.usage;
+ ret.class_name = pinfo.class_name;
+ return ret;
+ }
+
+public:
+ virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const {
+ return GodotTypeInfo::Metadata(get_argument_metadata_func(method_userdata, p_arg));
+ }
+
+ virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) {
+ Variant ret;
+ GDExtensionClassInstancePtr extension_instance = p_object->_get_extension_instance();
+ GDNativeCallError ce;
+ call_func(extension_instance, (const GDNativeVariantPtr *)p_args, p_arg_count, (GDNativeVariantPtr)&ret, &ce);
+ r_error.error = Callable::CallError::Error(ce.error);
+ r_error.argument = ce.argument;
+ r_error.expected = ce.expected;
+ return ret;
+ }
+ virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) {
+ ERR_FAIL_COND_MSG(vararg, "Vararg methods don't have ptrcall support. This is most likely an engine bug.");
+ GDExtensionClassInstancePtr extension_instance = p_object->_get_extension_instance();
+ ptrcall_func(extension_instance, (const GDNativeTypePtr *)p_args, (GDNativeTypePtr)r_ret);
+ }
+
+ virtual bool is_vararg() const {
+ return false;
+ }
+ NativeExtensionMethodBind(const GDNativeExtensionClassMethodInfo *p_method_info) {
+ method_userdata = p_method_info->method_userdata;
+ call_func = p_method_info->call_func;
+ ptrcall_func = p_method_info->ptrcall_func;
+ get_argument_type_func = p_method_info->get_argument_type_func;
+ get_argument_info_func = p_method_info->get_argument_info_func;
+ get_argument_metadata_func = p_method_info->get_argument_metadata_func;
+
+ vararg = p_method_info->method_flags & GDNATIVE_EXTENSION_METHOD_FLAG_VARARG;
+
+ _set_returns(p_method_info->has_return_value);
+ _set_const(p_method_info->method_flags & GDNATIVE_EXTENSION_METHOD_FLAG_CONST);
+#ifdef DEBUG_METHODS_ENABLED
+ _generate_argument_types(p_method_info->argument_count);
+#endif
+ set_argument_count(p_method_info->argument_count);
+ }
+};
+
+static GDNativeInterface gdnative_interface;
+
+void NativeExtension::_register_extension_class(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const char *p_parent_class_name, const GDNativeExtensionClassCreationInfo *p_extension_funcs) {
+ NativeExtension *self = (NativeExtension *)p_library;
+
+ StringName class_name = p_class_name;
+ ERR_FAIL_COND_MSG(String(class_name).is_valid_identifier(), "Attempt to register extension clas '" + class_name + "', which is not a valid class identifier.");
+ ERR_FAIL_COND_MSG(ClassDB::class_exists(class_name), "Attempt to register extension class '" + class_name + "', which appears to be already registered.");
+
+ Extension *parent_extension = nullptr;
+ StringName parent_class_name = p_parent_class_name;
+
+ if (self->extension_classes.has(parent_class_name)) {
+ parent_extension = &self->extension_classes[parent_class_name];
+ } else if (ClassDB::class_exists(parent_class_name)) {
+ if (ClassDB::get_api_type(parent_class_name) == ClassDB::API_EXTENSION || ClassDB::get_api_type(parent_class_name) == ClassDB::API_EDITOR_EXTENSION) {
+ ERR_PRINT("Unimplemented yet");
+ //inheriting from another extension
+ } else {
+ //inheriting from engine class
+ }
+ } else {
+ ERR_FAIL_MSG("Attempt to register an extension class '" + String(class_name) + "' using non-existing parent class '" + String(parent_class_name) + "'");
+ }
+
+ self->extension_classes[class_name] = Extension();
+
+ Extension *extension = &self->extension_classes[class_name];
+
+ if (parent_extension) {
+ extension->native_extension.parent = &parent_extension->native_extension;
+ parent_extension->native_extension.children.push_back(&extension->native_extension);
+ }
+
+ extension->native_extension.parent_class_name = parent_class_name;
+ extension->native_extension.class_name = class_name;
+ extension->native_extension.editor_class = self->level_initialized == INITIALIZATION_LEVEL_EDITOR;
+ extension->native_extension.set = p_extension_funcs->set_func;
+ extension->native_extension.get = p_extension_funcs->get_func;
+ extension->native_extension.get_property_list = p_extension_funcs->get_property_list_func;
+ extension->native_extension.free_property_list = p_extension_funcs->free_property_list_func;
+ extension->native_extension.notification = p_extension_funcs->notification_func;
+ extension->native_extension.to_string = p_extension_funcs->to_string_func;
+ extension->native_extension.reference = p_extension_funcs->reference_func;
+ extension->native_extension.unreference = p_extension_funcs->unreference_func;
+ extension->native_extension.class_userdata = p_extension_funcs->class_userdata;
+ extension->native_extension.create_instance = p_extension_funcs->create_instance_func;
+ extension->native_extension.free_instance = p_extension_funcs->free_instance_func;
+
+ ClassDB::register_extension_class(&extension->native_extension);
+}
+void NativeExtension::_register_extension_class_method(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const GDNativeExtensionClassMethodInfo *p_method_info) {
+ NativeExtension *self = (NativeExtension *)p_library;
+
+ StringName class_name = p_class_name;
+ StringName method_name = p_method_info->name;
+ ERR_FAIL_COND_MSG(self->extension_classes.has(class_name), "Attempt to register extension method '" + String(method_name) + "' for unexisting class '" + class_name + "'.");
+
+ //Extension *extension = &self->extension_classes[class_name];
+
+ NativeExtensionMethodBind *method = memnew(NativeExtensionMethodBind(p_method_info));
+
+ ClassDB::bind_method_custom(class_name, method);
+}
+void NativeExtension::_register_extension_class_integer_constant(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const char *p_enum_name, const char *p_constant_name, uint32_t p_constant_value) {
+ NativeExtension *self = (NativeExtension *)p_library;
+
+ StringName class_name = p_class_name;
+ ERR_FAIL_COND_MSG(self->extension_classes.has(class_name), "Attempt to register extension constant '" + String(p_constant_name) + "' for unexisting class '" + class_name + "'.");
+
+ //Extension *extension = &self->extension_classes[class_name];
+
+ ClassDB::bind_integer_constant(class_name, p_enum_name, p_constant_name, p_constant_value);
+}
+void NativeExtension::_register_extension_class_property(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const GDNativePropertyInfo *p_info, const char *p_setter, const char *p_getter) {
+ NativeExtension *self = (NativeExtension *)p_library;
+
+ StringName class_name = p_class_name;
+ ERR_FAIL_COND_MSG(self->extension_classes.has(class_name), "Attempt to register extension class property '" + String(p_info->name) + "' for unexisting class '" + class_name + "'.");
+
+ //Extension *extension = &self->extension_classes[class_name];
+ PropertyInfo pinfo;
+ pinfo.type = Variant::Type(p_info->type);
+ pinfo.name = p_info->name;
+ pinfo.class_name = p_info->class_name;
+ pinfo.hint = PropertyHint(p_info->hint);
+ pinfo.hint_string = p_info->hint_string;
+ pinfo.usage = p_info->usage;
+
+ ClassDB::add_property(class_name, pinfo, p_setter, p_getter);
+}
+
+void NativeExtension::_register_extension_class_signal(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const char *p_signal_name, const GDNativePropertyInfo *p_argument_info, GDNativeInt p_argument_count) {
+ NativeExtension *self = (NativeExtension *)p_library;
+
+ StringName class_name = p_class_name;
+ ERR_FAIL_COND_MSG(self->extension_classes.has(class_name), "Attempt to register extension class signal '" + String(p_signal_name) + "' for unexisting class '" + class_name + "'.");
+
+ MethodInfo s;
+ s.name = p_signal_name;
+ for (int i = 0; i < p_argument_count; i++) {
+ PropertyInfo arg;
+ arg.type = Variant::Type(p_argument_info[i].type);
+ arg.name = p_argument_info[i].name;
+ arg.class_name = p_argument_info[i].class_name;
+ arg.hint = PropertyHint(p_argument_info[i].hint);
+ arg.hint_string = p_argument_info[i].hint_string;
+ arg.usage = p_argument_info[i].usage;
+ s.arguments.push_back(arg);
+ }
+ ClassDB::add_signal(class_name, s);
+}
+
+void NativeExtension::_unregister_extension_class(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name) {
+ NativeExtension *self = (NativeExtension *)p_library;
+
+ StringName class_name = p_class_name;
+ ERR_FAIL_COND_MSG(self->extension_classes.has(class_name), "Attempt to unregister unexisting extension class '" + class_name + "'.");
+ Extension *ext = &self->extension_classes[class_name];
+ ERR_FAIL_COND_MSG(ext->native_extension.children.size(), "Attempt to unregister class '" + class_name + "' while other extension classes inherit from it.");
+
+ ClassDB::unregister_extension_class(class_name);
+ if (ext->native_extension.parent != nullptr) {
+ ext->native_extension.parent->children.erase(&ext->native_extension);
+ }
+ self->extension_classes.erase(class_name);
+}
+
+Error NativeExtension::open_library(const String &p_path, const String &p_entry_symbol) {
+ Error err = OS::get_singleton()->open_dynamic_library(p_path, library, true);
+ if (err != OK) {
+ return err;
+ }
+
+ void *entry_funcptr = nullptr;
+
+ err = OS::get_singleton()->get_dynamic_library_symbol_handle(library, p_entry_symbol, entry_funcptr, false);
+
+ if (err != OK) {
+ OS::get_singleton()->close_dynamic_library(library);
+ return err;
+ }
+
+ GDNativeInitializationFunction initialization_function = (GDNativeInitializationFunction)entry_funcptr;
+
+ initialization_function(&gdnative_interface, this, &initialization);
+ level_initialized = -1;
+ return OK;
+}
+
+void NativeExtension::close_library() {
+ ERR_FAIL_COND(library == nullptr);
+ OS::get_singleton()->close_dynamic_library(library);
+
+ library = nullptr;
+}
+
+bool NativeExtension::is_library_open() const {
+ return library != nullptr;
+}
+
+NativeExtension::InitializationLevel NativeExtension::get_minimum_library_initialization_level() const {
+ ERR_FAIL_COND_V(library == nullptr, INITIALIZATION_LEVEL_CORE);
+ return InitializationLevel(initialization.minimum_initialization_level);
+}
+void NativeExtension::initialize_library(InitializationLevel p_level) {
+ ERR_FAIL_COND(library == nullptr);
+ ERR_FAIL_COND(p_level <= int32_t(level_initialized));
+
+ level_initialized = int32_t(p_level);
+
+ ERR_FAIL_COND(initialization.initialize == nullptr);
+
+ initialization.initialize(initialization.userdata, GDNativeInitializationLevel(p_level));
+}
+void NativeExtension::deinitialize_library(InitializationLevel p_level) {
+ ERR_FAIL_COND(library == nullptr);
+ ERR_FAIL_COND(p_level > int32_t(level_initialized));
+
+ level_initialized = int32_t(p_level) - 1;
+ initialization.deinitialize(initialization.userdata, GDNativeInitializationLevel(p_level));
+}
+
+void NativeExtension::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("open_library", "path", "entry_symbol"), &NativeExtension::open_library);
+ ClassDB::bind_method(D_METHOD("close_library"), &NativeExtension::close_library);
+ ClassDB::bind_method(D_METHOD("is_library_open"), &NativeExtension::is_library_open);
+
+ ClassDB::bind_method(D_METHOD("get_minimum_library_initialization_level"), &NativeExtension::get_minimum_library_initialization_level);
+ ClassDB::bind_method(D_METHOD("initialize_library", "level"), &NativeExtension::initialize_library);
+
+ BIND_ENUM_CONSTANT(INITIALIZATION_LEVEL_CORE);
+ BIND_ENUM_CONSTANT(INITIALIZATION_LEVEL_SERVERS);
+ BIND_ENUM_CONSTANT(INITIALIZATION_LEVEL_SCENE);
+ BIND_ENUM_CONSTANT(INITIALIZATION_LEVEL_EDITOR);
+}
+
+NativeExtension::NativeExtension() {
+}
+
+NativeExtension::~NativeExtension() {
+ if (library != nullptr) {
+ close_library();
+ }
+}
+
+extern void gdnative_setup_interface(GDNativeInterface *p_interface);
+
+void NativeExtension::initialize_native_extensions() {
+ gdnative_setup_interface(&gdnative_interface);
+
+ gdnative_interface.classdb_register_extension_class = _register_extension_class;
+ gdnative_interface.classdb_register_extension_class_method = _register_extension_class_method;
+ gdnative_interface.classdb_register_extension_class_integer_constant = _register_extension_class_integer_constant;
+ gdnative_interface.classdb_register_extension_class_property = _register_extension_class_property;
+ gdnative_interface.classdb_register_extension_class_signal = _register_extension_class_signal;
+ gdnative_interface.classdb_unregister_extension_class = _unregister_extension_class;
+}
+
+RES NativeExtensionResourceLoader::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_cache_mode) {
+ Ref<ConfigFile> config;
+ config.instantiate();
+
+ Error err = config->load(p_path);
+
+ if (r_error) {
+ *r_error = err;
+ }
+
+ if (err != OK) {
+ return RES();
+ }
+
+ if (!config->has_section_key("configuration", "entry_symbol")) {
+ if (r_error) {
+ *r_error = ERR_INVALID_DATA;
+ }
+ return RES();
+ }
+
+ String entry_symbol = config->get_value("configuration", "entry_symbol");
+
+ List<String> libraries;
+
+ config->get_section_keys("libraries", &libraries);
+
+ String library_path;
+
+ for (List<String>::Element *E = libraries.front(); E; E = E->next()) {
+ Vector<String> tags = E->get().split(".");
+ bool all_tags_met = true;
+ for (int i = 0; i < tags.size(); i++) {
+ String tag = tags[i].strip_edges();
+ if (!OS::get_singleton()->has_feature(tag)) {
+ all_tags_met = false;
+ break;
+ }
+ }
+
+ if (all_tags_met) {
+ library_path = config->get_value("libraries", E->get());
+ break;
+ }
+ }
+
+ if (library_path != String()) {
+ if (r_error) {
+ *r_error = ERR_FILE_NOT_FOUND;
+ }
+ return RES();
+ }
+
+ if (!library_path.is_resource_file()) {
+ library_path = p_path.get_base_dir().plus_file(library_path);
+ }
+
+ Ref<NativeExtension> lib;
+ lib.instantiate();
+ err = lib->open_library(library_path, entry_symbol);
+
+ if (r_error) {
+ *r_error = err;
+ }
+
+ if (err != OK) {
+ return RES();
+ }
+
+ return lib;
+}
+
+void NativeExtensionResourceLoader::get_recognized_extensions(List<String> *p_extensions) const {
+ p_extensions->push_back("gdextension");
+}
+
+bool NativeExtensionResourceLoader::handles_type(const String &p_type) const {
+ return p_type == "NativeExtension";
+}
+
+String NativeExtensionResourceLoader::get_resource_type(const String &p_path) const {
+ String el = p_path.get_extension().to_lower();
+ if (el == "gdextension") {
+ return "NativeExtension";
+ }
+ return "";
+}
diff --git a/core/extension/native_extension.h b/core/extension/native_extension.h
new file mode 100644
index 0000000000..0a23848eb2
--- /dev/null
+++ b/core/extension/native_extension.h
@@ -0,0 +1,94 @@
+/*************************************************************************/
+/* native_extension.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef NATIVE_EXTENSION_H
+#define NATIVE_EXTENSION_H
+
+#include "core/extension/gdnative_interface.h"
+#include "core/io/resource_loader.h"
+#include "core/object/ref_counted.h"
+
+class NativeExtension : public RefCounted {
+ GDCLASS(NativeExtension, RefCounted)
+
+ void *library = nullptr; // pointer if valid,
+
+ struct Extension {
+ ObjectNativeExtension native_extension;
+ };
+
+ Map<StringName, Extension> extension_classes;
+
+ static void _register_extension_class(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const char *p_parent_class_name, const GDNativeExtensionClassCreationInfo *p_extension_funcs);
+ static void _register_extension_class_method(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const GDNativeExtensionClassMethodInfo *p_method_info);
+ static void _register_extension_class_integer_constant(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const char *p_enum_name, const char *p_constant_name, uint32_t p_constant_value);
+ static void _register_extension_class_property(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const GDNativePropertyInfo *p_info, const char *p_setter, const char *p_getter);
+ static void _register_extension_class_signal(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const char *p_signal_name, const GDNativePropertyInfo *p_argument_info, GDNativeInt p_argument_count);
+ static void _unregister_extension_class(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name);
+
+ GDNativeInitialization initialization;
+ int32_t level_initialized = -1;
+
+protected:
+ static void _bind_methods();
+
+public:
+ Error open_library(const String &p_path, const String &p_entry_symbol);
+ void close_library();
+
+ enum InitializationLevel {
+ INITIALIZATION_LEVEL_CORE,
+ INITIALIZATION_LEVEL_SERVERS,
+ INITIALIZATION_LEVEL_SCENE,
+ INITIALIZATION_LEVEL_EDITOR,
+ };
+
+ bool is_library_open() const;
+
+ InitializationLevel get_minimum_library_initialization_level() const;
+ void initialize_library(InitializationLevel p_level);
+ void deinitialize_library(InitializationLevel p_level);
+
+ static void initialize_native_extensions();
+ NativeExtension();
+ ~NativeExtension();
+};
+
+VARIANT_ENUM_CAST(NativeExtension::InitializationLevel)
+
+class NativeExtensionResourceLoader : public ResourceFormatLoader {
+public:
+ virtual RES load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads = false, float *r_progress = nullptr, CacheMode p_cache_mode = CACHE_MODE_REUSE);
+ virtual void get_recognized_extensions(List<String> *p_extensions) const;
+ virtual bool handles_type(const String &p_type) const;
+ virtual String get_resource_type(const String &p_path) const;
+};
+
+#endif // NATIVEEXTENSION_H
diff --git a/core/extension/native_extension_manager.cpp b/core/extension/native_extension_manager.cpp
new file mode 100644
index 0000000000..7be2593845
--- /dev/null
+++ b/core/extension/native_extension_manager.cpp
@@ -0,0 +1,130 @@
+/*************************************************************************/
+/* native_extension_manager.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "native_extension_manager.h"
+
+NativeExtensionManager::LoadStatus NativeExtensionManager::load_extension(const String &p_path) {
+ if (native_extension_map.has(p_path)) {
+ return LOAD_STATUS_ALREADY_LOADED;
+ }
+ Ref<NativeExtension> extension = ResourceLoader::load(p_path);
+ if (extension.is_null()) {
+ return LOAD_STATUS_FAILED;
+ }
+
+ if (level >= 0) { //already initialized up to some level
+ int32_t minimum_level = extension->get_minimum_library_initialization_level();
+ if (minimum_level < MIN(level, NativeExtension::INITIALIZATION_LEVEL_SCENE)) {
+ return LOAD_STATUS_NEEDS_RESTART;
+ }
+ //initialize up to current level
+ for (int32_t i = minimum_level; i < level; i++) {
+ extension->initialize_library(NativeExtension::InitializationLevel(level));
+ }
+ }
+ native_extension_map[p_path] = extension;
+ return LOAD_STATUS_OK;
+}
+
+NativeExtensionManager::LoadStatus NativeExtensionManager::reload_extension(const String &p_path) {
+ return LOAD_STATUS_OK; //TODO
+}
+NativeExtensionManager::LoadStatus NativeExtensionManager::unload_extension(const String &p_path) {
+ if (!native_extension_map.has(p_path)) {
+ return LOAD_STATUS_NOT_LOADED;
+ }
+
+ Ref<NativeExtension> extension = native_extension_map[p_path];
+
+ if (level >= 0) { //already initialized up to some level
+ int32_t minimum_level = extension->get_minimum_library_initialization_level();
+ if (minimum_level < MIN(level, NativeExtension::INITIALIZATION_LEVEL_SCENE)) {
+ return LOAD_STATUS_NEEDS_RESTART;
+ }
+ //initialize up to current level
+ for (int32_t i = level; i >= minimum_level; i--) {
+ extension->deinitialize_library(NativeExtension::InitializationLevel(level));
+ }
+ }
+ native_extension_map.erase(p_path);
+ return LOAD_STATUS_OK;
+}
+Vector<String> NativeExtensionManager::get_loaded_extensions() const {
+ Vector<String> ret;
+ for (const Map<String, Ref<NativeExtension>>::Element *E = native_extension_map.front(); E; E = E->next()) {
+ ret.push_back(E->key());
+ }
+ return ret;
+}
+Ref<NativeExtension> NativeExtensionManager::get_extension(const String &p_path) {
+ Map<String, Ref<NativeExtension>>::Element *E = native_extension_map.find(p_path);
+ ERR_FAIL_COND_V(!E, Ref<NativeExtension>());
+ return E->get();
+}
+
+void NativeExtensionManager::initialize_extensions(NativeExtension::InitializationLevel p_level) {
+ ERR_FAIL_COND(int32_t(p_level) - 1 != level);
+ for (Map<String, Ref<NativeExtension>>::Element *E = native_extension_map.front(); E; E = E->next()) {
+ E->get()->initialize_library(p_level);
+ }
+ level = p_level;
+}
+
+void NativeExtensionManager::deinitialize_extensions(NativeExtension::InitializationLevel p_level) {
+ ERR_FAIL_COND(int32_t(p_level) != level);
+ for (Map<String, Ref<NativeExtension>>::Element *E = native_extension_map.front(); E; E = E->next()) {
+ E->get()->deinitialize_library(p_level);
+ }
+ level = int32_t(p_level) - 1;
+}
+
+NativeExtensionManager *NativeExtensionManager::get_singleton() {
+ return singleton;
+}
+void NativeExtensionManager::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("load_extension", "path"), &NativeExtensionManager::load_extension);
+ ClassDB::bind_method(D_METHOD("reload_extension", "path"), &NativeExtensionManager::reload_extension);
+ ClassDB::bind_method(D_METHOD("unload_extension", "path"), &NativeExtensionManager::unload_extension);
+ ClassDB::bind_method(D_METHOD("get_loaded_extensions"), &NativeExtensionManager::get_loaded_extensions);
+ ClassDB::bind_method(D_METHOD("get_extension", "path"), &NativeExtensionManager::get_extension);
+
+ BIND_ENUM_CONSTANT(LOAD_STATUS_OK);
+ BIND_ENUM_CONSTANT(LOAD_STATUS_FAILED);
+ BIND_ENUM_CONSTANT(LOAD_STATUS_ALREADY_LOADED);
+ BIND_ENUM_CONSTANT(LOAD_STATUS_NOT_LOADED);
+ BIND_ENUM_CONSTANT(LOAD_STATUS_NEEDS_RESTART);
+}
+
+NativeExtensionManager *NativeExtensionManager::singleton = nullptr;
+
+NativeExtensionManager::NativeExtensionManager() {
+ ERR_FAIL_COND(singleton != nullptr);
+ singleton = this;
+}
diff --git a/core/extension/native_extension_manager.h b/core/extension/native_extension_manager.h
new file mode 100644
index 0000000000..78465bd5cf
--- /dev/null
+++ b/core/extension/native_extension_manager.h
@@ -0,0 +1,71 @@
+/*************************************************************************/
+/* native_extension_manager.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef NATIVE_EXTENSION_MANAGER_H
+#define NATIVE_EXTENSION_MANAGER_H
+
+#include "core/extension/native_extension.h"
+
+class NativeExtensionManager : public Object {
+ GDCLASS(NativeExtensionManager, Object);
+
+ int32_t level = -1;
+ Map<String, Ref<NativeExtension>> native_extension_map;
+
+ static void _bind_methods();
+
+ static NativeExtensionManager *singleton;
+
+public:
+ enum LoadStatus {
+ LOAD_STATUS_OK,
+ LOAD_STATUS_FAILED,
+ LOAD_STATUS_ALREADY_LOADED,
+ LOAD_STATUS_NOT_LOADED,
+ LOAD_STATUS_NEEDS_RESTART,
+ };
+
+ LoadStatus load_extension(const String &p_path);
+ LoadStatus reload_extension(const String &p_path);
+ LoadStatus unload_extension(const String &p_path);
+ Vector<String> get_loaded_extensions() const;
+ Ref<NativeExtension> get_extension(const String &p_path);
+
+ void initialize_extensions(NativeExtension::InitializationLevel p_level);
+ void deinitialize_extensions(NativeExtension::InitializationLevel p_level);
+
+ static NativeExtensionManager *get_singleton();
+
+ NativeExtensionManager();
+};
+
+VARIANT_ENUM_CAST(NativeExtensionManager::LoadStatus)
+
+#endif // NATIVEEXTENSIONMANAGER_H
diff --git a/core/input/input.cpp b/core/input/input.cpp
index 6e98b596d7..a712394b35 100644
--- a/core/input/input.cpp
+++ b/core/input/input.cpp
@@ -227,7 +227,7 @@ bool Input::is_key_pressed(int p_keycode) const {
return keys_pressed.has(p_keycode);
}
-bool Input::is_mouse_button_pressed(int p_button) const {
+bool Input::is_mouse_button_pressed(MouseButton p_button) const {
_THREAD_SAFE_METHOD_
return (mouse_button_mask & (1 << (p_button - 1))) != 0;
}
@@ -236,7 +236,7 @@ static int _combine_device(int p_value, int p_device) {
return p_value | (p_device << 20);
}
-bool Input::is_joy_button_pressed(int p_device, int p_button) const {
+bool Input::is_joy_button_pressed(int p_device, JoyButton p_button) const {
_THREAD_SAFE_METHOD_
return joy_buttons_pressed.has(_combine_device(p_button, p_device));
}
@@ -352,7 +352,7 @@ Vector2 Input::get_vector(const StringName &p_negative_x, const StringName &p_po
return vector;
}
-float Input::get_joy_axis(int p_device, int p_axis) const {
+float Input::get_joy_axis(int p_device, JoyAxis p_axis) const {
_THREAD_SAFE_METHOD_
int c = _combine_device(p_axis, p_device);
if (_joy_axis.has(c)) {
@@ -433,7 +433,7 @@ void Input::joy_connection_changed(int p_idx, bool p_connected, String p_name, S
joy_buttons_pressed.erase(c);
}
for (int i = 0; i < JOY_AXIS_MAX; i++) {
- set_joy_axis(p_idx, i, 0.0f);
+ set_joy_axis(p_idx, (JoyAxis)i, 0.0f);
}
}
joy_names[p_idx] = js;
@@ -488,9 +488,9 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
if (mb.is_valid()) {
if (mb->is_pressed()) {
- mouse_button_mask |= (1 << (mb->get_button_index() - 1));
+ mouse_button_mask |= (MouseButton)(1 << (mb->get_button_index() - 1));
} else {
- mouse_button_mask &= ~(1 << (mb->get_button_index() - 1));
+ mouse_button_mask &= (MouseButton) ~(1 << (mb->get_button_index() - 1));
}
Point2 pos = mb->get_global_position();
@@ -500,7 +500,7 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
if (event_dispatch_function && emulate_touch_from_mouse && !p_is_emulated && mb->get_button_index() == 1) {
Ref<InputEventScreenTouch> touch_event;
- touch_event.instance();
+ touch_event.instantiate();
touch_event->set_pressed(mb->is_pressed());
touch_event->set_position(mb->get_position());
event_dispatch_function(touch_event);
@@ -517,7 +517,7 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
if (event_dispatch_function && emulate_touch_from_mouse && !p_is_emulated && mm->get_button_mask() & 1) {
Ref<InputEventScreenDrag> drag_event;
- drag_event.instance();
+ drag_event.instantiate();
drag_event->set_position(mm->get_position());
drag_event->set_relative(mm->get_relative());
@@ -555,7 +555,7 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
if (translate) {
Ref<InputEventMouseButton> button_event;
- button_event.instance();
+ button_event.instantiate();
button_event->set_device(InputEvent::DEVICE_ID_TOUCH_MOUSE);
button_event->set_position(st->get_position());
@@ -563,9 +563,9 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
button_event->set_pressed(st->is_pressed());
button_event->set_button_index(MOUSE_BUTTON_LEFT);
if (st->is_pressed()) {
- button_event->set_button_mask(mouse_button_mask | (1 << (MOUSE_BUTTON_LEFT - 1)));
+ button_event->set_button_mask(MouseButton(mouse_button_mask | MOUSE_BUTTON_MASK_LEFT));
} else {
- button_event->set_button_mask(mouse_button_mask & ~(1 << (MOUSE_BUTTON_LEFT - 1)));
+ button_event->set_button_mask(MouseButton(mouse_button_mask & ~MOUSE_BUTTON_MASK_LEFT));
}
_parse_input_event_impl(button_event, true);
@@ -582,7 +582,7 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
if (emulate_mouse_from_touch && sd->get_index() == mouse_from_touch_index) {
Ref<InputEventMouseMotion> motion_event;
- motion_event.instance();
+ motion_event.instantiate();
motion_event->set_device(InputEvent::DEVICE_ID_TOUCH_MOUSE);
motion_event->set_position(sd->get_position());
@@ -644,7 +644,7 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
}
}
-void Input::set_joy_axis(int p_device, int p_axis, float p_value) {
+void Input::set_joy_axis(int p_device, JoyAxis p_axis, float p_value) {
_THREAD_SAFE_METHOD_
int c = _combine_device(p_axis, p_device);
_joy_axis[c] = p_value;
@@ -787,14 +787,14 @@ void Input::ensure_touch_mouse_raised() {
mouse_from_touch_index = -1;
Ref<InputEventMouseButton> button_event;
- button_event.instance();
+ button_event.instantiate();
button_event->set_device(InputEvent::DEVICE_ID_TOUCH_MOUSE);
button_event->set_position(mouse_pos);
button_event->set_global_position(mouse_pos);
button_event->set_pressed(false);
button_event->set_button_index(MOUSE_BUTTON_LEFT);
- button_event->set_button_mask(mouse_button_mask & ~(1 << (MOUSE_BUTTON_LEFT - 1)));
+ button_event->set_button_mask(MouseButton(mouse_button_mask & ~MOUSE_BUTTON_MASK_LEFT));
_parse_input_event_impl(button_event, true);
}
@@ -821,7 +821,7 @@ void Input::set_default_cursor_shape(CursorShape p_shape) {
// The default shape is set in Viewport::_gui_input_event. To instantly
// see the shape in the viewport we need to trigger a mouse motion event.
Ref<InputEventMouseMotion> mm;
- mm.instance();
+ mm.instantiate();
mm->set_position(mouse_pos);
mm->set_global_position(mouse_pos);
parse_input_event(mm);
@@ -882,7 +882,7 @@ void Input::set_event_dispatch_function(EventDispatchFunc p_function) {
event_dispatch_function = p_function;
}
-void Input::joy_button(int p_device, int p_button, bool p_pressed) {
+void Input::joy_button(int p_device, JoyButton p_button, bool p_pressed) {
_THREAD_SAFE_METHOD_;
Joypad &joy = joy_names[p_device];
//printf("got button %i, mapping is %i\n", p_button, joy.mapping);
@@ -898,17 +898,17 @@ void Input::joy_button(int p_device, int p_button, bool p_pressed) {
JoyEvent map = _get_mapped_button_event(map_db[joy.mapping], p_button);
if (map.type == TYPE_BUTTON) {
- _button_event(p_device, map.index, p_pressed);
+ _button_event(p_device, (JoyButton)map.index, p_pressed);
return;
}
if (map.type == TYPE_AXIS) {
- _axis_event(p_device, map.index, p_pressed ? map.value : 0.0);
+ _axis_event(p_device, (JoyAxis)map.index, p_pressed ? map.value : 0.0);
}
// no event?
}
-void Input::joy_axis(int p_device, int p_axis, const JoyAxisValue &p_value) {
+void Input::joy_axis(int p_device, JoyAxis p_axis, const JoyAxisValue &p_value) {
_THREAD_SAFE_METHOD_;
ERR_FAIL_INDEX(p_axis, JOY_AXIS_MAX);
@@ -949,7 +949,7 @@ void Input::joy_axis(int p_device, int p_axis, const JoyAxisValue &p_value) {
// Button already pressed or released; so ignore.
return;
}
- _button_event(p_device, map.index, pressed);
+ _button_event(p_device, (JoyButton)map.index, pressed);
// Ensure opposite D-Pad button is also released.
switch (map.index) {
@@ -981,7 +981,7 @@ void Input::joy_axis(int p_device, int p_axis, const JoyAxisValue &p_value) {
}
if (map.type == TYPE_AXIS) {
- _axis_event(p_device, map.index, map.value);
+ _axis_event(p_device, (JoyAxis)map.index, map.value);
return;
}
//printf("invalid mapping\n");
@@ -993,24 +993,24 @@ void Input::joy_hat(int p_device, int p_val) {
JoyEvent map[HAT_MAX];
- map[HAT_UP].type = TYPE_BUTTON;
- map[HAT_UP].index = JOY_BUTTON_DPAD_UP;
- map[HAT_UP].value = 0;
+ map[HatDir::HAT_UP].type = TYPE_BUTTON;
+ map[HatDir::HAT_UP].index = JOY_BUTTON_DPAD_UP;
+ map[HatDir::HAT_UP].value = 0;
- map[HAT_RIGHT].type = TYPE_BUTTON;
- map[HAT_RIGHT].index = JOY_BUTTON_DPAD_RIGHT;
- map[HAT_RIGHT].value = 0;
+ map[HatDir::HAT_RIGHT].type = TYPE_BUTTON;
+ map[HatDir::HAT_RIGHT].index = JOY_BUTTON_DPAD_RIGHT;
+ map[HatDir::HAT_RIGHT].value = 0;
- map[HAT_DOWN].type = TYPE_BUTTON;
- map[HAT_DOWN].index = JOY_BUTTON_DPAD_DOWN;
- map[HAT_DOWN].value = 0;
+ map[HatDir::HAT_DOWN].type = TYPE_BUTTON;
+ map[HatDir::HAT_DOWN].index = JOY_BUTTON_DPAD_DOWN;
+ map[HatDir::HAT_DOWN].value = 0;
- map[HAT_LEFT].type = TYPE_BUTTON;
- map[HAT_LEFT].index = JOY_BUTTON_DPAD_LEFT;
- map[HAT_LEFT].value = 0;
+ map[HatDir::HAT_LEFT].type = TYPE_BUTTON;
+ map[HatDir::HAT_LEFT].index = JOY_BUTTON_DPAD_LEFT;
+ map[HatDir::HAT_LEFT].value = 0;
if (joy.mapping != -1) {
- _get_mapped_hat_events(map_db[joy.mapping], 0, map);
+ _get_mapped_hat_events(map_db[joy.mapping], (HatDir)0, map);
}
int cur_val = joy_names[p_device].hat_current;
@@ -1018,10 +1018,10 @@ void Input::joy_hat(int p_device, int p_val) {
for (int hat_direction = 0, hat_mask = 1; hat_direction < HAT_MAX; hat_direction++, hat_mask <<= 1) {
if ((p_val & hat_mask) != (cur_val & hat_mask)) {
if (map[hat_direction].type == TYPE_BUTTON) {
- _button_event(p_device, map[hat_direction].index, p_val & hat_mask);
+ _button_event(p_device, (JoyButton)map[hat_direction].index, p_val & hat_mask);
}
if (map[hat_direction].type == TYPE_AXIS) {
- _axis_event(p_device, map[hat_direction].index, (p_val & hat_mask) ? map[hat_direction].value : 0.0);
+ _axis_event(p_device, (JoyAxis)map[hat_direction].index, (p_val & hat_mask) ? map[hat_direction].value : 0.0);
}
}
}
@@ -1029,9 +1029,9 @@ void Input::joy_hat(int p_device, int p_val) {
joy_names[p_device].hat_current = p_val;
}
-void Input::_button_event(int p_device, int p_index, bool p_pressed) {
+void Input::_button_event(int p_device, JoyButton p_index, bool p_pressed) {
Ref<InputEventJoypadButton> ievent;
- ievent.instance();
+ ievent.instantiate();
ievent->set_device(p_device);
ievent->set_button_index(p_index);
ievent->set_pressed(p_pressed);
@@ -1039,9 +1039,9 @@ void Input::_button_event(int p_device, int p_index, bool p_pressed) {
parse_input_event(ievent);
}
-void Input::_axis_event(int p_device, int p_axis, float p_value) {
+void Input::_axis_event(int p_device, JoyAxis p_axis, float p_value) {
Ref<InputEventJoypadMotion> ievent;
- ievent.instance();
+ ievent.instantiate();
ievent->set_device(p_device);
ievent->set_axis(p_axis);
ievent->set_axis_value(p_value);
@@ -1049,7 +1049,7 @@ void Input::_axis_event(int p_device, int p_axis, float p_value) {
parse_input_event(ievent);
}
-Input::JoyEvent Input::_get_mapped_button_event(const JoyDeviceMapping &mapping, int p_button) {
+Input::JoyEvent Input::_get_mapped_button_event(const JoyDeviceMapping &mapping, JoyButton p_button) {
JoyEvent event;
event.type = TYPE_MAX;
@@ -1085,7 +1085,7 @@ Input::JoyEvent Input::_get_mapped_button_event(const JoyDeviceMapping &mapping,
return event;
}
-Input::JoyEvent Input::_get_mapped_axis_event(const JoyDeviceMapping &mapping, int p_axis, float p_value) {
+Input::JoyEvent Input::_get_mapped_axis_event(const JoyDeviceMapping &mapping, JoyAxis p_axis, float p_value) {
JoyEvent event;
event.type = TYPE_MAX;
@@ -1156,23 +1156,23 @@ Input::JoyEvent Input::_get_mapped_axis_event(const JoyDeviceMapping &mapping, i
return event;
}
-void Input::_get_mapped_hat_events(const JoyDeviceMapping &mapping, int p_hat, JoyEvent r_events[]) {
+void Input::_get_mapped_hat_events(const JoyDeviceMapping &mapping, HatDir p_hat, JoyEvent r_events[]) {
for (int i = 0; i < mapping.bindings.size(); i++) {
const JoyBinding binding = mapping.bindings[i];
if (binding.inputType == TYPE_HAT && binding.input.hat.hat == p_hat) {
int hat_direction;
switch (binding.input.hat.hat_mask) {
- case HAT_MASK_UP:
- hat_direction = HAT_UP;
+ case HatMask::HAT_MASK_UP:
+ hat_direction = HatDir::HAT_UP;
break;
- case HAT_MASK_RIGHT:
- hat_direction = HAT_RIGHT;
+ case HatMask::HAT_MASK_RIGHT:
+ hat_direction = HatDir::HAT_RIGHT;
break;
- case HAT_MASK_DOWN:
- hat_direction = HAT_DOWN;
+ case HatMask::HAT_MASK_DOWN:
+ hat_direction = HatDir::HAT_DOWN;
break;
- case HAT_MASK_LEFT:
- hat_direction = HAT_LEFT;
+ case HatMask::HAT_MASK_LEFT:
+ hat_direction = HatDir::HAT_LEFT;
break;
default:
ERR_PRINT_ONCE("Joypad button mapping error.");
@@ -1300,11 +1300,11 @@ void Input::parse_mapping(String p_mapping) {
switch (input[0]) {
case 'b':
binding.inputType = TYPE_BUTTON;
- binding.input.button = input.substr(1).to_int();
+ binding.input.button = (JoyButton)input.substr(1).to_int();
break;
case 'a':
binding.inputType = TYPE_AXIS;
- binding.input.axis.axis = input.substr(1).to_int();
+ binding.input.axis.axis = (JoyAxis)input.substr(1).to_int();
binding.input.axis.range = input_range;
binding.input.axis.invert = invert_axis;
break;
@@ -1312,7 +1312,7 @@ void Input::parse_mapping(String p_mapping) {
ERR_CONTINUE_MSG(input.length() != 4 || input[2] != '.',
String(entry[idx] + "\nInvalid hat input: " + input));
binding.inputType = TYPE_HAT;
- binding.input.hat.hat = input.substr(1, 1).to_int();
+ binding.input.hat.hat = (HatDir)input.substr(1, 1).to_int();
binding.input.hat.hat_mask = static_cast<HatMask>(input.substr(3).to_int());
break;
default:
diff --git a/core/input/input.h b/core/input/input.h
index ecb4981b13..fbcd5836ea 100644
--- a/core/input/input.h
+++ b/core/input/input.h
@@ -72,22 +72,6 @@ public:
CURSOR_MAX
};
- enum HatMask {
- HAT_MASK_CENTER = 0,
- HAT_MASK_UP = 1,
- HAT_MASK_RIGHT = 2,
- HAT_MASK_DOWN = 4,
- HAT_MASK_LEFT = 8,
- };
-
- enum HatDir {
- HAT_UP,
- HAT_RIGHT,
- HAT_DOWN,
- HAT_LEFT,
- HAT_MAX,
- };
-
enum {
JOYPADS_MAX = 16,
};
@@ -149,7 +133,7 @@ private:
bool connected = false;
bool last_buttons[JOY_BUTTON_MAX] = { false };
float last_axis[JOY_AXIS_MAX] = { 0.0f };
- int last_hat = HAT_MASK_CENTER;
+ int last_hat = HatMask::HAT_MASK_CENTER;
int mapping = -1;
int hat_current = 0;
};
@@ -183,16 +167,16 @@ private:
struct JoyBinding {
JoyType inputType;
union {
- int button;
+ JoyButton button;
struct {
- int axis;
+ JoyAxis axis;
JoyAxisRange range;
bool invert;
} axis;
struct {
- int hat;
+ HatDir hat;
HatMask hat_mask;
} hat;
@@ -218,13 +202,13 @@ private:
Vector<JoyDeviceMapping> map_db;
- JoyEvent _get_mapped_button_event(const JoyDeviceMapping &mapping, int p_button);
- JoyEvent _get_mapped_axis_event(const JoyDeviceMapping &mapping, int p_axis, float p_value);
- void _get_mapped_hat_events(const JoyDeviceMapping &mapping, int p_hat, JoyEvent r_events[HAT_MAX]);
+ JoyEvent _get_mapped_button_event(const JoyDeviceMapping &mapping, JoyButton p_button);
+ JoyEvent _get_mapped_axis_event(const JoyDeviceMapping &mapping, JoyAxis p_axis, float p_value);
+ void _get_mapped_hat_events(const JoyDeviceMapping &mapping, HatDir p_hat, JoyEvent r_events[HAT_MAX]);
JoyButton _get_output_button(String output);
JoyAxis _get_output_axis(String output);
- void _button_event(int p_device, int p_index, bool p_pressed);
- void _axis_event(int p_device, int p_axis, float p_value);
+ void _button_event(int p_device, JoyButton p_index, bool p_pressed);
+ void _axis_event(int p_device, JoyAxis p_axis, float p_value);
void _parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_emulated);
@@ -261,8 +245,8 @@ public:
static Input *get_singleton();
bool is_key_pressed(int p_keycode) const;
- bool is_mouse_button_pressed(int p_button) const;
- bool is_joy_button_pressed(int p_device, int p_button) const;
+ bool is_mouse_button_pressed(MouseButton p_button) const;
+ bool is_joy_button_pressed(int p_device, JoyButton p_button) const;
bool is_action_pressed(const StringName &p_action, bool p_exact = false) const;
bool is_action_just_pressed(const StringName &p_action, bool p_exact = false) const;
bool is_action_just_released(const StringName &p_action, bool p_exact = false) const;
@@ -272,7 +256,7 @@ public:
float get_axis(const StringName &p_negative_action, const StringName &p_positive_action) const;
Vector2 get_vector(const StringName &p_negative_x, const StringName &p_positive_x, const StringName &p_negative_y, const StringName &p_positive_y, float p_deadzone = -1.0f) const;
- float get_joy_axis(int p_device, int p_axis) const;
+ float get_joy_axis(int p_device, JoyAxis p_axis) const;
String get_joy_name(int p_idx);
Array get_connected_joypads();
Vector2 get_joy_vibration_strength(int p_device);
@@ -299,7 +283,7 @@ public:
void set_accelerometer(const Vector3 &p_accel);
void set_magnetometer(const Vector3 &p_magnetometer);
void set_gyroscope(const Vector3 &p_gyroscope);
- void set_joy_axis(int p_device, int p_axis, float p_value);
+ void set_joy_axis(int p_device, JoyAxis p_axis, float p_value);
void start_joy_vibration(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration = 0);
void stop_joy_vibration(int p_device);
@@ -325,8 +309,8 @@ public:
void set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape = Input::CURSOR_ARROW, const Vector2 &p_hotspot = Vector2());
void parse_mapping(String p_mapping);
- void joy_button(int p_device, int p_button, bool p_pressed);
- void joy_axis(int p_device, int p_axis, const JoyAxisValue &p_value);
+ void joy_button(int p_device, JoyButton p_button, bool p_pressed);
+ void joy_axis(int p_device, JoyAxis p_axis, const JoyAxisValue &p_value);
void joy_hat(int p_device, int p_val);
void add_joy_mapping(String p_mapping, bool p_update_existing = false);
diff --git a/core/input/input_enums.h b/core/input/input_enums.h
new file mode 100644
index 0000000000..4479a85bfe
--- /dev/null
+++ b/core/input/input_enums.h
@@ -0,0 +1,126 @@
+/*************************************************************************/
+/* input_enums.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef INPUT_ENUMS_H
+#define INPUT_ENUMS_H
+
+enum HatDir {
+ HAT_UP = 0,
+ HAT_RIGHT = 1,
+ HAT_DOWN = 2,
+ HAT_LEFT = 3,
+ HAT_MAX = 4,
+};
+
+enum HatMask {
+ HAT_MASK_CENTER = 0,
+ HAT_MASK_UP = 1,
+ HAT_MASK_RIGHT = 2,
+ HAT_MASK_DOWN = 4,
+ HAT_MASK_LEFT = 8,
+};
+
+enum JoyAxis {
+ JOY_AXIS_INVALID = -1,
+ JOY_AXIS_LEFT_X = 0,
+ JOY_AXIS_LEFT_Y = 1,
+ JOY_AXIS_RIGHT_X = 2,
+ JOY_AXIS_RIGHT_Y = 3,
+ JOY_AXIS_TRIGGER_LEFT = 4,
+ JOY_AXIS_TRIGGER_RIGHT = 5,
+ JOY_AXIS_SDL_MAX = 6,
+ JOY_AXIS_MAX = 10, // OpenVR supports up to 5 Joysticks making a total of 10 axes.
+};
+
+enum JoyButton {
+ JOY_BUTTON_INVALID = -1,
+ JOY_BUTTON_A = 0,
+ JOY_BUTTON_B = 1,
+ JOY_BUTTON_X = 2,
+ JOY_BUTTON_Y = 3,
+ JOY_BUTTON_BACK = 4,
+ JOY_BUTTON_GUIDE = 5,
+ JOY_BUTTON_START = 6,
+ JOY_BUTTON_LEFT_STICK = 7,
+ JOY_BUTTON_RIGHT_STICK = 8,
+ JOY_BUTTON_LEFT_SHOULDER = 9,
+ JOY_BUTTON_RIGHT_SHOULDER = 10,
+ JOY_BUTTON_DPAD_UP = 11,
+ JOY_BUTTON_DPAD_DOWN = 12,
+ JOY_BUTTON_DPAD_LEFT = 13,
+ JOY_BUTTON_DPAD_RIGHT = 14,
+ JOY_BUTTON_MISC1 = 15,
+ JOY_BUTTON_PADDLE1 = 16,
+ JOY_BUTTON_PADDLE2 = 17,
+ JOY_BUTTON_PADDLE3 = 18,
+ JOY_BUTTON_PADDLE4 = 19,
+ JOY_BUTTON_TOUCHPAD = 20,
+ JOY_BUTTON_SDL_MAX = 21,
+ JOY_BUTTON_MAX = 36, // Android supports up to 36 buttons.
+};
+
+enum MIDIMessage {
+ MIDI_MESSAGE_NONE = 0,
+ MIDI_MESSAGE_NOTE_OFF = 0x8,
+ MIDI_MESSAGE_NOTE_ON = 0x9,
+ MIDI_MESSAGE_AFTERTOUCH = 0xA,
+ MIDI_MESSAGE_CONTROL_CHANGE = 0xB,
+ MIDI_MESSAGE_PROGRAM_CHANGE = 0xC,
+ MIDI_MESSAGE_CHANNEL_PRESSURE = 0xD,
+ MIDI_MESSAGE_PITCH_BEND = 0xE,
+};
+
+enum MouseButton {
+ MOUSE_BUTTON_NONE = 0,
+ MOUSE_BUTTON_LEFT = 1,
+ MOUSE_BUTTON_RIGHT = 2,
+ MOUSE_BUTTON_MIDDLE = 3,
+ MOUSE_BUTTON_WHEEL_UP = 4,
+ MOUSE_BUTTON_WHEEL_DOWN = 5,
+ MOUSE_BUTTON_WHEEL_LEFT = 6,
+ MOUSE_BUTTON_WHEEL_RIGHT = 7,
+ MOUSE_BUTTON_XBUTTON1 = 8,
+ MOUSE_BUTTON_XBUTTON2 = 9,
+ MOUSE_BUTTON_MASK_LEFT = (1 << (MOUSE_BUTTON_LEFT - 1)),
+ MOUSE_BUTTON_MASK_RIGHT = (1 << (MOUSE_BUTTON_RIGHT - 1)),
+ MOUSE_BUTTON_MASK_MIDDLE = (1 << (MOUSE_BUTTON_MIDDLE - 1)),
+ MOUSE_BUTTON_MASK_XBUTTON1 = (1 << (MOUSE_BUTTON_XBUTTON1 - 1)),
+ MOUSE_BUTTON_MASK_XBUTTON2 = (1 << (MOUSE_BUTTON_XBUTTON2 - 1)),
+};
+
+inline MouseButton &operator|=(MouseButton &a, MouseButton b) {
+ return (MouseButton &)((int &)a |= (int)b);
+}
+
+inline MouseButton &operator&=(MouseButton &a, MouseButton b) {
+ return (MouseButton &)((int &)a &= (int)b);
+}
+
+#endif // INPUT_ENUMS_H
diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp
index 9c1cf15342..52a6c5d64f 100644
--- a/core/input/input_event.cpp
+++ b/core/input/input_event.cpp
@@ -88,7 +88,7 @@ bool InputEvent::action_match(const Ref<InputEvent> &p_event, bool *p_pressed, f
return false;
}
-bool InputEvent::shortcut_match(const Ref<InputEvent> &p_event) const {
+bool InputEvent::is_match(const Ref<InputEvent> &p_event, bool p_exact_match) const {
return false;
}
@@ -110,7 +110,7 @@ void InputEvent::_bind_methods() {
ClassDB::bind_method(D_METHOD("as_text"), &InputEvent::as_text);
- ClassDB::bind_method(D_METHOD("shortcut_match", "event"), &InputEvent::shortcut_match);
+ ClassDB::bind_method(D_METHOD("is_match", "event", "exact_match"), &InputEvent::is_match, DEFVAL(true));
ClassDB::bind_method(D_METHOD("is_action_type"), &InputEvent::is_action_type);
@@ -194,6 +194,23 @@ void InputEventWithModifiers::set_modifiers_from_event(const InputEventWithModif
set_meta_pressed(event->is_meta_pressed());
}
+uint32_t InputEventWithModifiers::get_modifiers_mask() const {
+ uint32_t mask = 0;
+ if (is_ctrl_pressed()) {
+ mask |= KEY_MASK_CTRL;
+ }
+ if (is_shift_pressed()) {
+ mask |= KEY_MASK_SHIFT;
+ }
+ if (is_alt_pressed()) {
+ mask |= KEY_MASK_ALT;
+ }
+ if (is_meta_pressed()) {
+ mask |= KEY_MASK_META;
+ }
+ return mask;
+}
+
String InputEventWithModifiers::as_text() const {
Vector<String> mod_names;
@@ -313,39 +330,11 @@ bool InputEventKey::is_echo() const {
}
uint32_t InputEventKey::get_keycode_with_modifiers() const {
- uint32_t sc = keycode;
- if (is_ctrl_pressed()) {
- sc |= KEY_MASK_CTRL;
- }
- if (is_alt_pressed()) {
- sc |= KEY_MASK_ALT;
- }
- if (is_shift_pressed()) {
- sc |= KEY_MASK_SHIFT;
- }
- if (is_meta_pressed()) {
- sc |= KEY_MASK_META;
- }
-
- return sc;
+ return keycode | get_modifiers_mask();
}
uint32_t InputEventKey::get_physical_keycode_with_modifiers() const {
- uint32_t sc = physical_keycode;
- if (is_ctrl_pressed()) {
- sc |= KEY_MASK_CTRL;
- }
- if (is_alt_pressed()) {
- sc |= KEY_MASK_ALT;
- }
- if (is_shift_pressed()) {
- sc |= KEY_MASK_SHIFT;
- }
- if (is_meta_pressed()) {
- sc |= KEY_MASK_META;
- }
-
- return sc;
+ return physical_keycode | get_modifiers_mask();
}
String InputEventKey::as_text() const {
@@ -386,7 +375,7 @@ String InputEventKey::to_string() {
Ref<InputEventKey> InputEventKey::create_reference(uint32_t p_keycode) {
Ref<InputEventKey> ie;
- ie.instance();
+ ie.instantiate();
ie->set_keycode(p_keycode & KEY_CODE_MASK);
ie->set_unicode(p_keycode & KEY_CODE_MASK);
@@ -442,16 +431,14 @@ bool InputEventKey::action_match(const Ref<InputEvent> &p_event, bool *p_pressed
return match;
}
-bool InputEventKey::shortcut_match(const Ref<InputEvent> &p_event) const {
+bool InputEventKey::is_match(const Ref<InputEvent> &p_event, bool p_exact_match) const {
Ref<InputEventKey> key = p_event;
if (key.is_null()) {
return false;
}
- uint32_t code = get_keycode_with_modifiers();
- uint32_t event_code = key->get_keycode_with_modifiers();
-
- return code == event_code;
+ return keycode == key->keycode &&
+ (!p_exact_match || get_modifiers_mask() == key->get_modifiers_mask());
}
void InputEventKey::_bind_methods() {
@@ -529,11 +516,11 @@ float InputEventMouseButton::get_factor() const {
return factor;
}
-void InputEventMouseButton::set_button_index(int p_index) {
+void InputEventMouseButton::set_button_index(MouseButton p_index) {
button_index = p_index;
}
-int InputEventMouseButton::get_button_index() const {
+MouseButton InputEventMouseButton::get_button_index() const {
return button_index;
}
@@ -558,7 +545,7 @@ Ref<InputEvent> InputEventMouseButton::xformed_by(const Transform2D &p_xform, co
Vector2 l = p_xform.xform(get_position() + p_local_ofs);
Ref<InputEventMouseButton> mb;
- mb.instance();
+ mb.instantiate();
mb->set_device(get_device());
mb->set_window_id(get_window_id());
@@ -599,6 +586,16 @@ bool InputEventMouseButton::action_match(const Ref<InputEvent> &p_event, bool *p
return match;
}
+bool InputEventMouseButton::is_match(const Ref<InputEvent> &p_event, bool p_exact_match) const {
+ Ref<InputEventMouseButton> mb = p_event;
+ if (mb.is_null()) {
+ return false;
+ }
+
+ return button_index == mb->button_index &&
+ (!p_exact_match || get_modifiers_mask() == mb->get_modifiers_mask());
+}
+
static const char *_mouse_button_descriptions[9] = {
TTRC("Left Mouse Button"),
TTRC("Right Mouse Button"),
@@ -734,7 +731,7 @@ Ref<InputEvent> InputEventMouseMotion::xformed_by(const Transform2D &p_xform, co
Vector2 s = p_xform.basis_xform(get_speed());
Ref<InputEventMouseMotion> mm;
- mm.instance();
+ mm.instantiate();
mm->set_device(get_device());
mm->set_window_id(get_window_id());
@@ -848,11 +845,11 @@ void InputEventMouseMotion::_bind_methods() {
///////////////////////////////////
-void InputEventJoypadMotion::set_axis(int p_axis) {
+void InputEventJoypadMotion::set_axis(JoyAxis p_axis) {
axis = p_axis;
}
-int InputEventJoypadMotion::get_axis() const {
+JoyAxis InputEventJoypadMotion::get_axis() const {
return axis;
}
@@ -904,6 +901,16 @@ bool InputEventJoypadMotion::action_match(const Ref<InputEvent> &p_event, bool *
return match;
}
+bool InputEventJoypadMotion::is_match(const Ref<InputEvent> &p_event, bool p_exact_match) const {
+ Ref<InputEventJoypadMotion> jm = p_event;
+ if (jm.is_null()) {
+ return false;
+ }
+
+ return axis == jm->axis &&
+ (!p_exact_match || ((axis_value < 0) == (jm->axis_value < 0)));
+}
+
static const char *_joy_axis_descriptions[JOY_AXIS_MAX] = {
TTRC("Left Stick X-Axis, Joystick 0 X-Axis"),
TTRC("Left Stick Y-Axis, Joystick 0 Y-Axis"),
@@ -940,11 +947,11 @@ void InputEventJoypadMotion::_bind_methods() {
///////////////////////////////////
-void InputEventJoypadButton::set_button_index(int p_index) {
+void InputEventJoypadButton::set_button_index(JoyButton p_index) {
button_index = p_index;
}
-int InputEventJoypadButton::get_button_index() const {
+JoyButton InputEventJoypadButton::get_button_index() const {
return button_index;
}
@@ -987,7 +994,7 @@ bool InputEventJoypadButton::action_match(const Ref<InputEvent> &p_event, bool *
return match;
}
-bool InputEventJoypadButton::shortcut_match(const Ref<InputEvent> &p_event) const {
+bool InputEventJoypadButton::is_match(const Ref<InputEvent> &p_event, bool p_exact_match) const {
Ref<InputEventJoypadButton> button = p_event;
if (button.is_null()) {
return false;
@@ -1039,9 +1046,9 @@ String InputEventJoypadButton::to_string() {
return vformat("InputEventJoypadButton: button_index=%d, pressed=%s, pressure=%.2f", button_index, p, pressure);
}
-Ref<InputEventJoypadButton> InputEventJoypadButton::create_reference(int p_btn_index) {
+Ref<InputEventJoypadButton> InputEventJoypadButton::create_reference(JoyButton p_btn_index) {
Ref<InputEventJoypadButton> ie;
- ie.instance();
+ ie.instantiate();
ie->set_button_index(p_btn_index);
return ie;
@@ -1090,7 +1097,7 @@ bool InputEventScreenTouch::is_pressed() const {
Ref<InputEvent> InputEventScreenTouch::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const {
Ref<InputEventScreenTouch> st;
- st.instance();
+ st.instantiate();
st->set_device(get_device());
st->set_window_id(get_window_id());
st->set_index(index);
@@ -1163,7 +1170,7 @@ Vector2 InputEventScreenDrag::get_speed() const {
Ref<InputEvent> InputEventScreenDrag::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const {
Ref<InputEventScreenDrag> sd;
- sd.instance();
+ sd.instantiate();
sd->set_device(get_device());
sd->set_window_id(get_window_id());
@@ -1229,7 +1236,7 @@ float InputEventAction::get_strength() const {
return strength;
}
-bool InputEventAction::shortcut_match(const Ref<InputEvent> &p_event) const {
+bool InputEventAction::is_match(const Ref<InputEvent> &p_event, bool p_exact_match) const {
if (p_event.is_null()) {
return false;
}
@@ -1318,7 +1325,7 @@ real_t InputEventMagnifyGesture::get_factor() const {
Ref<InputEvent> InputEventMagnifyGesture::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const {
Ref<InputEventMagnifyGesture> ev;
- ev.instance();
+ ev.instantiate();
ev->set_device(get_device());
ev->set_window_id(get_window_id());
@@ -1358,7 +1365,7 @@ Vector2 InputEventPanGesture::get_delta() const {
Ref<InputEvent> InputEventPanGesture::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const {
Ref<InputEventPanGesture> ev;
- ev.instance();
+ ev.instantiate();
ev->set_device(get_device());
ev->set_window_id(get_window_id());
@@ -1396,11 +1403,11 @@ int InputEventMIDI::get_channel() const {
return channel;
}
-void InputEventMIDI::set_message(const int p_message) {
+void InputEventMIDI::set_message(const MIDIMessage p_message) {
message = p_message;
}
-int InputEventMIDI::get_message() const {
+MIDIMessage InputEventMIDI::get_message() const {
return message;
}
diff --git a/core/input/input_event.h b/core/input/input_event.h
index eed0d79326..76a45c04a4 100644
--- a/core/input/input_event.h
+++ b/core/input/input_event.h
@@ -31,6 +31,7 @@
#ifndef INPUT_EVENT_H
#define INPUT_EVENT_H
+#include "core/input/input_enums.h"
#include "core/io/resource.h"
#include "core/math/transform_2d.h"
#include "core/string/ustring.h"
@@ -41,72 +42,6 @@
* The events are pretty obvious.
*/
-enum MouseButton {
- MOUSE_BUTTON_LEFT = 1,
- MOUSE_BUTTON_RIGHT = 2,
- MOUSE_BUTTON_MIDDLE = 3,
- MOUSE_BUTTON_WHEEL_UP = 4,
- MOUSE_BUTTON_WHEEL_DOWN = 5,
- MOUSE_BUTTON_WHEEL_LEFT = 6,
- MOUSE_BUTTON_WHEEL_RIGHT = 7,
- MOUSE_BUTTON_XBUTTON1 = 8,
- MOUSE_BUTTON_XBUTTON2 = 9,
- MOUSE_BUTTON_MASK_LEFT = (1 << (MOUSE_BUTTON_LEFT - 1)),
- MOUSE_BUTTON_MASK_RIGHT = (1 << (MOUSE_BUTTON_RIGHT - 1)),
- MOUSE_BUTTON_MASK_MIDDLE = (1 << (MOUSE_BUTTON_MIDDLE - 1)),
- MOUSE_BUTTON_MASK_XBUTTON1 = (1 << (MOUSE_BUTTON_XBUTTON1 - 1)),
- MOUSE_BUTTON_MASK_XBUTTON2 = (1 << (MOUSE_BUTTON_XBUTTON2 - 1))
-};
-
-enum JoyButton {
- JOY_BUTTON_INVALID = -1,
- JOY_BUTTON_A = 0,
- JOY_BUTTON_B = 1,
- JOY_BUTTON_X = 2,
- JOY_BUTTON_Y = 3,
- JOY_BUTTON_BACK = 4,
- JOY_BUTTON_GUIDE = 5,
- JOY_BUTTON_START = 6,
- JOY_BUTTON_LEFT_STICK = 7,
- JOY_BUTTON_RIGHT_STICK = 8,
- JOY_BUTTON_LEFT_SHOULDER = 9,
- JOY_BUTTON_RIGHT_SHOULDER = 10,
- JOY_BUTTON_DPAD_UP = 11,
- JOY_BUTTON_DPAD_DOWN = 12,
- JOY_BUTTON_DPAD_LEFT = 13,
- JOY_BUTTON_DPAD_RIGHT = 14,
- JOY_BUTTON_MISC1 = 15,
- JOY_BUTTON_PADDLE1 = 16,
- JOY_BUTTON_PADDLE2 = 17,
- JOY_BUTTON_PADDLE3 = 18,
- JOY_BUTTON_PADDLE4 = 19,
- JOY_BUTTON_TOUCHPAD = 20,
- JOY_BUTTON_SDL_MAX = 21,
- JOY_BUTTON_MAX = 36, // Android supports up to 36 buttons.
-};
-
-enum JoyAxis {
- JOY_AXIS_INVALID = -1,
- JOY_AXIS_LEFT_X = 0,
- JOY_AXIS_LEFT_Y = 1,
- JOY_AXIS_RIGHT_X = 2,
- JOY_AXIS_RIGHT_Y = 3,
- JOY_AXIS_TRIGGER_LEFT = 4,
- JOY_AXIS_TRIGGER_RIGHT = 5,
- JOY_AXIS_SDL_MAX = 6,
- JOY_AXIS_MAX = 10, // OpenVR supports up to 5 Joysticks making a total of 10 axes.
-};
-
-enum MIDIMessage {
- MIDI_MESSAGE_NOTE_OFF = 0x8,
- MIDI_MESSAGE_NOTE_ON = 0x9,
- MIDI_MESSAGE_AFTERTOUCH = 0xA,
- MIDI_MESSAGE_CONTROL_CHANGE = 0xB,
- MIDI_MESSAGE_PROGRAM_CHANGE = 0xC,
- MIDI_MESSAGE_CHANNEL_PRESSURE = 0xD,
- MIDI_MESSAGE_PITCH_BEND = 0xE,
-};
-
/**
* Input Modifier Status
* for keyboard/mouse events.
@@ -142,7 +77,8 @@ public:
virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const;
virtual bool action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float *p_raw_strength, float p_deadzone) const;
- virtual bool shortcut_match(const Ref<InputEvent> &p_event) const;
+ virtual bool is_match(const Ref<InputEvent> &p_event, bool p_exact_match = true) const;
+
virtual bool is_action_type() const;
virtual bool accumulate(const Ref<InputEvent> &p_event) { return false; }
@@ -212,6 +148,8 @@ public:
void set_modifiers_from_event(const InputEventWithModifiers *event);
+ uint32_t get_modifiers_mask() const;
+
virtual String as_text() const override;
virtual String to_string() override;
@@ -252,7 +190,7 @@ public:
uint32_t get_physical_keycode_with_modifiers() const;
virtual bool action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float *p_raw_strength, float p_deadzone) const override;
- virtual bool shortcut_match(const Ref<InputEvent> &p_event) const override;
+ virtual bool is_match(const Ref<InputEvent> &p_event, bool p_exact_match = true) const override;
virtual bool is_action_type() const override { return true; }
@@ -292,7 +230,7 @@ class InputEventMouseButton : public InputEventMouse {
GDCLASS(InputEventMouseButton, InputEventMouse);
float factor = 1;
- int button_index = 0;
+ MouseButton button_index = MOUSE_BUTTON_NONE;
bool pressed = false; //otherwise released
bool double_click = false; //last even less than double click time
@@ -303,8 +241,8 @@ public:
void set_factor(float p_factor);
float get_factor() const;
- void set_button_index(int p_index);
- int get_button_index() const;
+ void set_button_index(MouseButton p_index);
+ MouseButton get_button_index() const;
void set_pressed(bool p_pressed);
virtual bool is_pressed() const override;
@@ -313,7 +251,9 @@ public:
bool is_double_click() const;
virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const override;
+
virtual bool action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float *p_raw_strength, float p_deadzone) const override;
+ virtual bool is_match(const Ref<InputEvent> &p_event, bool p_exact_match = true) const override;
virtual bool is_action_type() const override { return true; }
virtual String as_text() const override;
@@ -357,15 +297,15 @@ public:
class InputEventJoypadMotion : public InputEvent {
GDCLASS(InputEventJoypadMotion, InputEvent);
- int axis = 0; ///< Joypad axis
+ JoyAxis axis = (JoyAxis)0; ///< Joypad axis
float axis_value = 0; ///< -1 to 1
protected:
static void _bind_methods();
public:
- void set_axis(int p_axis);
- int get_axis() const;
+ void set_axis(JoyAxis p_axis);
+ JoyAxis get_axis() const;
void set_axis_value(float p_value);
float get_axis_value() const;
@@ -373,6 +313,7 @@ public:
virtual bool is_pressed() const override;
virtual bool action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float *p_raw_strength, float p_deadzone) const override;
+ virtual bool is_match(const Ref<InputEvent> &p_event, bool p_exact_match = true) const override;
virtual bool is_action_type() const override { return true; }
virtual String as_text() const override;
@@ -384,15 +325,15 @@ public:
class InputEventJoypadButton : public InputEvent {
GDCLASS(InputEventJoypadButton, InputEvent);
- int button_index = 0;
+ JoyButton button_index = (JoyButton)0;
bool pressed = false;
float pressure = 0; //0 to 1
protected:
static void _bind_methods();
public:
- void set_button_index(int p_index);
- int get_button_index() const;
+ void set_button_index(JoyButton p_index);
+ JoyButton get_button_index() const;
void set_pressed(bool p_pressed);
virtual bool is_pressed() const override;
@@ -401,13 +342,14 @@ public:
float get_pressure() const;
virtual bool action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float *p_raw_strength, float p_deadzone) const override;
- virtual bool shortcut_match(const Ref<InputEvent> &p_event) const override;
+ virtual bool is_match(const Ref<InputEvent> &p_event, bool p_exact_match = true) const override;
virtual bool is_action_type() const override { return true; }
+
virtual String as_text() const override;
virtual String to_string() override;
- static Ref<InputEventJoypadButton> create_reference(int p_btn_index);
+ static Ref<InputEventJoypadButton> create_reference(JoyButton p_btn_index);
InputEventJoypadButton() {}
};
@@ -491,9 +433,10 @@ public:
virtual bool is_action(const StringName &p_action) const;
virtual bool action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float *p_raw_strength, float p_deadzone) const override;
+ virtual bool is_match(const Ref<InputEvent> &p_event, bool p_exact_match = true) const override;
- virtual bool shortcut_match(const Ref<InputEvent> &p_event) const override;
virtual bool is_action_type() const override { return true; }
+
virtual String as_text() const override;
virtual String to_string() override;
@@ -553,7 +496,7 @@ class InputEventMIDI : public InputEvent {
GDCLASS(InputEventMIDI, InputEvent);
int channel = 0;
- int message = 0;
+ MIDIMessage message = MIDI_MESSAGE_NONE;
int pitch = 0;
int velocity = 0;
int instrument = 0;
@@ -568,8 +511,8 @@ public:
void set_channel(const int p_channel);
int get_channel() const;
- void set_message(const int p_message);
- int get_message() const;
+ void set_message(const MIDIMessage p_message);
+ MIDIMessage get_message() const;
void set_pitch(const int p_pitch);
int get_pitch() const;
diff --git a/core/input/input_map.cpp b/core/input/input_map.cpp
index c43fd64561..52dc561546 100644
--- a/core/input/input_map.cpp
+++ b/core/input/input_map.cpp
@@ -130,12 +130,9 @@ List<Ref<InputEvent>>::Element *InputMap::_find_event(Action &p_action, const Re
for (List<Ref<InputEvent>>::Element *E = p_action.inputs.front(); E; E = E->next()) {
const Ref<InputEvent> e = E->get();
- //if (e.type != Ref<InputEvent>::KEY && e.device != p_event.device) -- unsure about the KEY comparison, why is this here?
- // continue;
-
int device = e->get_device();
if (device == ALL_DEVICES || device == p_event->get_device()) {
- if (p_exact_match && e->shortcut_match(p_event)) {
+ if (p_exact_match && e->is_match(p_event, true)) {
return E;
} else if (!p_exact_match && e->action_match(p_event, p_pressed, p_strength, p_raw_strength, p_action.deadzone)) {
return E;
diff --git a/core/io/file_access_network.cpp b/core/io/file_access_network.cpp
index 63a8f9c5b6..9ee3876c2f 100644
--- a/core/io/file_access_network.cpp
+++ b/core/io/file_access_network.cpp
@@ -210,7 +210,7 @@ FileAccessNetworkClient *FileAccessNetworkClient::singleton = nullptr;
FileAccessNetworkClient::FileAccessNetworkClient() {
singleton = this;
- client.instance();
+ client.instantiate();
}
FileAccessNetworkClient::~FileAccessNetworkClient() {
diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp
index 0cf870e7e7..8000dd4290 100644
--- a/core/io/http_client.cpp
+++ b/core/io/http_client.cpp
@@ -30,9 +30,6 @@
#include "http_client.h"
-#include "core/io/stream_peer_ssl.h"
-#include "core/version.h"
-
const char *HTTPClient::_methods[METHOD_MAX] = {
"GET",
"HEAD",
@@ -45,698 +42,23 @@ const char *HTTPClient::_methods[METHOD_MAX] = {
"PATCH"
};
-#ifndef JAVASCRIPT_ENABLED
-Error HTTPClient::connect_to_host(const String &p_host, int p_port, bool p_ssl, bool p_verify_host) {
- close();
-
- conn_port = p_port;
- conn_host = p_host;
-
- ssl = p_ssl;
- ssl_verify_host = p_verify_host;
-
- String host_lower = conn_host.to_lower();
- if (host_lower.begins_with("http://")) {
- conn_host = conn_host.substr(7, conn_host.length() - 7);
- } else if (host_lower.begins_with("https://")) {
- ssl = true;
- conn_host = conn_host.substr(8, conn_host.length() - 8);
- }
-
- ERR_FAIL_COND_V(conn_host.length() < HOST_MIN_LEN, ERR_INVALID_PARAMETER);
-
- if (conn_port < 0) {
- if (ssl) {
- conn_port = PORT_HTTPS;
- } else {
- conn_port = PORT_HTTP;
- }
- }
-
- connection = tcp_connection;
-
- if (conn_host.is_valid_ip_address()) {
- // Host contains valid IP
- Error err = tcp_connection->connect_to_host(IPAddress(conn_host), p_port);
- if (err) {
- status = STATUS_CANT_CONNECT;
- return err;
- }
-
- status = STATUS_CONNECTING;
- } else {
- // Host contains hostname and needs to be resolved to IP
- resolving = IP::get_singleton()->resolve_hostname_queue_item(conn_host);
- status = STATUS_RESOLVING;
+HTTPClient *HTTPClient::create() {
+ if (_create) {
+ return _create();
}
-
- return OK;
+ return nullptr;
}
-void HTTPClient::set_connection(const Ref<StreamPeer> &p_connection) {
- ERR_FAIL_COND_MSG(p_connection.is_null(), "Connection is not a reference to a valid StreamPeer object.");
-
- if (ssl) {
- ERR_FAIL_NULL_MSG(Object::cast_to<StreamPeerSSL>(p_connection.ptr()),
- "Connection is not a reference to a valid StreamPeerSSL object.");
- }
-
- if (connection == p_connection) {
- return;
- }
-
- close();
- connection = p_connection;
- status = STATUS_CONNECTED;
+Error HTTPClient::_request_raw(Method p_method, const String &p_url, const Vector<String> &p_headers, const Vector<uint8_t> &p_body) {
+ int size = p_body.size();
+ return request(p_method, p_url, p_headers, size > 0 ? p_body.ptr() : nullptr, size);
}
-Ref<StreamPeer> HTTPClient::get_connection() const {
- return connection;
+Error HTTPClient::_request(Method p_method, const String &p_url, const Vector<String> &p_headers, const String &p_body) {
+ int size = p_body.length();
+ return request(p_method, p_url, p_headers, size > 0 ? (const uint8_t *)p_body.utf8().get_data() : nullptr, size);
}
-static bool _check_request_url(HTTPClient::Method p_method, const String &p_url) {
- switch (p_method) {
- case HTTPClient::METHOD_CONNECT: {
- // Authority in host:port format, as in RFC7231
- int pos = p_url.find_char(':');
- return 0 < pos && pos < p_url.length() - 1;
- }
- case HTTPClient::METHOD_OPTIONS: {
- if (p_url == "*") {
- return true;
- }
- [[fallthrough]];
- }
- default:
- // Absolute path or absolute URL
- return p_url.begins_with("/") || p_url.begins_with("http://") || p_url.begins_with("https://");
- }
-}
-
-Error HTTPClient::request_raw(Method p_method, const String &p_url, const Vector<String> &p_headers, const Vector<uint8_t> &p_body) {
- ERR_FAIL_INDEX_V(p_method, METHOD_MAX, ERR_INVALID_PARAMETER);
- ERR_FAIL_COND_V(!_check_request_url(p_method, p_url), ERR_INVALID_PARAMETER);
- ERR_FAIL_COND_V(status != STATUS_CONNECTED, ERR_INVALID_PARAMETER);
- ERR_FAIL_COND_V(connection.is_null(), ERR_INVALID_DATA);
-
- String request = String(_methods[p_method]) + " " + p_url + " HTTP/1.1\r\n";
- bool add_host = true;
- bool add_clen = p_body.size() > 0;
- bool add_uagent = true;
- bool add_accept = true;
- for (int i = 0; i < p_headers.size(); i++) {
- request += p_headers[i] + "\r\n";
- if (add_host && p_headers[i].findn("Host:") == 0) {
- add_host = false;
- }
- if (add_clen && p_headers[i].findn("Content-Length:") == 0) {
- add_clen = false;
- }
- if (add_uagent && p_headers[i].findn("User-Agent:") == 0) {
- add_uagent = false;
- }
- if (add_accept && p_headers[i].findn("Accept:") == 0) {
- add_accept = false;
- }
- }
- if (add_host) {
- if ((ssl && conn_port == PORT_HTTPS) || (!ssl && conn_port == PORT_HTTP)) {
- // Don't append the standard ports
- request += "Host: " + conn_host + "\r\n";
- } else {
- request += "Host: " + conn_host + ":" + itos(conn_port) + "\r\n";
- }
- }
- if (add_clen) {
- request += "Content-Length: " + itos(p_body.size()) + "\r\n";
- // Should it add utf8 encoding?
- }
- if (add_uagent) {
- request += "User-Agent: GodotEngine/" + String(VERSION_FULL_BUILD) + " (" + OS::get_singleton()->get_name() + ")\r\n";
- }
- if (add_accept) {
- request += "Accept: */*\r\n";
- }
- request += "\r\n";
- CharString cs = request.utf8();
-
- Vector<uint8_t> data;
- data.resize(cs.length());
- {
- uint8_t *data_write = data.ptrw();
- for (int i = 0; i < cs.length(); i++) {
- data_write[i] = cs[i];
- }
- }
-
- data.append_array(p_body);
-
- const uint8_t *r = data.ptr();
- Error err = connection->put_data(&r[0], data.size());
-
- if (err) {
- close();
- status = STATUS_CONNECTION_ERROR;
- return err;
- }
-
- status = STATUS_REQUESTING;
- head_request = p_method == METHOD_HEAD;
-
- return OK;
-}
-
-Error HTTPClient::request(Method p_method, const String &p_url, const Vector<String> &p_headers, const String &p_body) {
- ERR_FAIL_INDEX_V(p_method, METHOD_MAX, ERR_INVALID_PARAMETER);
- ERR_FAIL_COND_V(!_check_request_url(p_method, p_url), ERR_INVALID_PARAMETER);
- ERR_FAIL_COND_V(status != STATUS_CONNECTED, ERR_INVALID_PARAMETER);
- ERR_FAIL_COND_V(connection.is_null(), ERR_INVALID_DATA);
-
- String request = String(_methods[p_method]) + " " + p_url + " HTTP/1.1\r\n";
- bool add_host = true;
- bool add_uagent = true;
- bool add_accept = true;
- bool add_clen = p_body.length() > 0;
- for (int i = 0; i < p_headers.size(); i++) {
- request += p_headers[i] + "\r\n";
- if (add_host && p_headers[i].findn("Host:") == 0) {
- add_host = false;
- }
- if (add_clen && p_headers[i].findn("Content-Length:") == 0) {
- add_clen = false;
- }
- if (add_uagent && p_headers[i].findn("User-Agent:") == 0) {
- add_uagent = false;
- }
- if (add_accept && p_headers[i].findn("Accept:") == 0) {
- add_accept = false;
- }
- }
- if (add_host) {
- if ((ssl && conn_port == PORT_HTTPS) || (!ssl && conn_port == PORT_HTTP)) {
- // Don't append the standard ports
- request += "Host: " + conn_host + "\r\n";
- } else {
- request += "Host: " + conn_host + ":" + itos(conn_port) + "\r\n";
- }
- }
- if (add_clen) {
- request += "Content-Length: " + itos(p_body.utf8().length()) + "\r\n";
- // Should it add utf8 encoding?
- }
- if (add_uagent) {
- request += "User-Agent: GodotEngine/" + String(VERSION_FULL_BUILD) + " (" + OS::get_singleton()->get_name() + ")\r\n";
- }
- if (add_accept) {
- request += "Accept: */*\r\n";
- }
- request += "\r\n";
- request += p_body;
-
- CharString cs = request.utf8();
- Error err = connection->put_data((const uint8_t *)cs.ptr(), cs.length());
- if (err) {
- close();
- status = STATUS_CONNECTION_ERROR;
- return err;
- }
-
- status = STATUS_REQUESTING;
- head_request = p_method == METHOD_HEAD;
-
- return OK;
-}
-
-bool HTTPClient::has_response() const {
- return response_headers.size() != 0;
-}
-
-bool HTTPClient::is_response_chunked() const {
- return chunked;
-}
-
-int HTTPClient::get_response_code() const {
- return response_num;
-}
-
-Error HTTPClient::get_response_headers(List<String> *r_response) {
- if (!response_headers.size()) {
- return ERR_INVALID_PARAMETER;
- }
-
- for (int i = 0; i < response_headers.size(); i++) {
- r_response->push_back(response_headers[i]);
- }
-
- response_headers.clear();
-
- return OK;
-}
-
-void HTTPClient::close() {
- if (tcp_connection->get_status() != StreamPeerTCP::STATUS_NONE) {
- tcp_connection->disconnect_from_host();
- }
-
- connection.unref();
- status = STATUS_DISCONNECTED;
- head_request = false;
- if (resolving != IP::RESOLVER_INVALID_ID) {
- IP::get_singleton()->erase_resolve_item(resolving);
- resolving = IP::RESOLVER_INVALID_ID;
- }
-
- response_headers.clear();
- response_str.clear();
- body_size = -1;
- body_left = 0;
- chunk_left = 0;
- chunk_trailer_part = false;
- read_until_eof = false;
- response_num = 0;
- handshaking = false;
-}
-
-Error HTTPClient::poll() {
- switch (status) {
- case STATUS_RESOLVING: {
- ERR_FAIL_COND_V(resolving == IP::RESOLVER_INVALID_ID, ERR_BUG);
-
- IP::ResolverStatus rstatus = IP::get_singleton()->get_resolve_item_status(resolving);
- switch (rstatus) {
- case IP::RESOLVER_STATUS_WAITING:
- return OK; // Still resolving
-
- case IP::RESOLVER_STATUS_DONE: {
- IPAddress host = IP::get_singleton()->get_resolve_item_address(resolving);
- Error err = tcp_connection->connect_to_host(host, conn_port);
- IP::get_singleton()->erase_resolve_item(resolving);
- resolving = IP::RESOLVER_INVALID_ID;
- if (err) {
- status = STATUS_CANT_CONNECT;
- return err;
- }
-
- status = STATUS_CONNECTING;
- } break;
- case IP::RESOLVER_STATUS_NONE:
- case IP::RESOLVER_STATUS_ERROR: {
- IP::get_singleton()->erase_resolve_item(resolving);
- resolving = IP::RESOLVER_INVALID_ID;
- close();
- status = STATUS_CANT_RESOLVE;
- return ERR_CANT_RESOLVE;
- } break;
- }
- } break;
- case STATUS_CONNECTING: {
- StreamPeerTCP::Status s = tcp_connection->get_status();
- switch (s) {
- case StreamPeerTCP::STATUS_CONNECTING: {
- return OK;
- } break;
- case StreamPeerTCP::STATUS_CONNECTED: {
- if (ssl) {
- Ref<StreamPeerSSL> ssl;
- if (!handshaking) {
- // Connect the StreamPeerSSL and start handshaking
- ssl = Ref<StreamPeerSSL>(StreamPeerSSL::create());
- ssl->set_blocking_handshake_enabled(false);
- Error err = ssl->connect_to_stream(tcp_connection, ssl_verify_host, conn_host);
- if (err != OK) {
- close();
- status = STATUS_SSL_HANDSHAKE_ERROR;
- return ERR_CANT_CONNECT;
- }
- connection = ssl;
- handshaking = true;
- } else {
- // We are already handshaking, which means we can use your already active SSL connection
- ssl = static_cast<Ref<StreamPeerSSL>>(connection);
- if (ssl.is_null()) {
- close();
- status = STATUS_SSL_HANDSHAKE_ERROR;
- return ERR_CANT_CONNECT;
- }
-
- ssl->poll(); // Try to finish the handshake
- }
-
- if (ssl->get_status() == StreamPeerSSL::STATUS_CONNECTED) {
- // Handshake has been successful
- handshaking = false;
- status = STATUS_CONNECTED;
- return OK;
- } else if (ssl->get_status() != StreamPeerSSL::STATUS_HANDSHAKING) {
- // Handshake has failed
- close();
- status = STATUS_SSL_HANDSHAKE_ERROR;
- return ERR_CANT_CONNECT;
- }
- // ... we will need to poll more for handshake to finish
- } else {
- status = STATUS_CONNECTED;
- }
- return OK;
- } break;
- case StreamPeerTCP::STATUS_ERROR:
- case StreamPeerTCP::STATUS_NONE: {
- close();
- status = STATUS_CANT_CONNECT;
- return ERR_CANT_CONNECT;
- } break;
- }
- } break;
- case STATUS_BODY:
- case STATUS_CONNECTED: {
- // Check if we are still connected
- if (ssl) {
- Ref<StreamPeerSSL> tmp = connection;
- tmp->poll();
- if (tmp->get_status() != StreamPeerSSL::STATUS_CONNECTED) {
- status = STATUS_CONNECTION_ERROR;
- return ERR_CONNECTION_ERROR;
- }
- } else if (tcp_connection->get_status() != StreamPeerTCP::STATUS_CONNECTED) {
- status = STATUS_CONNECTION_ERROR;
- return ERR_CONNECTION_ERROR;
- }
- // Connection established, requests can now be made
- return OK;
- } break;
- case STATUS_REQUESTING: {
- while (true) {
- uint8_t byte;
- int rec = 0;
- Error err = _get_http_data(&byte, 1, rec);
- if (err != OK) {
- close();
- status = STATUS_CONNECTION_ERROR;
- return ERR_CONNECTION_ERROR;
- }
-
- if (rec == 0) {
- return OK; // Still requesting, keep trying!
- }
-
- response_str.push_back(byte);
- int rs = response_str.size();
- if (
- (rs >= 2 && response_str[rs - 2] == '\n' && response_str[rs - 1] == '\n') ||
- (rs >= 4 && response_str[rs - 4] == '\r' && response_str[rs - 3] == '\n' && response_str[rs - 2] == '\r' && response_str[rs - 1] == '\n')) {
- // End of response, parse.
- response_str.push_back(0);
- String response;
- response.parse_utf8((const char *)response_str.ptr());
- Vector<String> responses = response.split("\n");
- body_size = -1;
- chunked = false;
- body_left = 0;
- chunk_left = 0;
- chunk_trailer_part = false;
- read_until_eof = false;
- response_str.clear();
- response_headers.clear();
- response_num = RESPONSE_OK;
-
- // Per the HTTP 1.1 spec, keep-alive is the default.
- // Not following that specification breaks standard implementations.
- // Broken web servers should be fixed.
- bool keep_alive = true;
-
- for (int i = 0; i < responses.size(); i++) {
- String header = responses[i].strip_edges();
- String s = header.to_lower();
- if (s.length() == 0) {
- continue;
- }
- if (s.begins_with("content-length:")) {
- body_size = s.substr(s.find(":") + 1, s.length()).strip_edges().to_int();
- body_left = body_size;
-
- } else if (s.begins_with("transfer-encoding:")) {
- String encoding = header.substr(header.find(":") + 1, header.length()).strip_edges();
- if (encoding == "chunked") {
- chunked = true;
- }
- } else if (s.begins_with("connection: close")) {
- keep_alive = false;
- }
-
- if (i == 0 && responses[i].begins_with("HTTP")) {
- String num = responses[i].get_slicec(' ', 1);
- response_num = num.to_int();
- } else {
- response_headers.push_back(header);
- }
- }
-
- // This is a HEAD request, we won't receive anything.
- if (head_request) {
- body_size = 0;
- body_left = 0;
- }
-
- if (body_size != -1 || chunked) {
- status = STATUS_BODY;
- } else if (!keep_alive) {
- read_until_eof = true;
- status = STATUS_BODY;
- } else {
- status = STATUS_CONNECTED;
- }
- return OK;
- }
- }
- } break;
- case STATUS_DISCONNECTED: {
- return ERR_UNCONFIGURED;
- } break;
- case STATUS_CONNECTION_ERROR:
- case STATUS_SSL_HANDSHAKE_ERROR: {
- return ERR_CONNECTION_ERROR;
- } break;
- case STATUS_CANT_CONNECT: {
- return ERR_CANT_CONNECT;
- } break;
- case STATUS_CANT_RESOLVE: {
- return ERR_CANT_RESOLVE;
- } break;
- }
-
- return OK;
-}
-
-int HTTPClient::get_response_body_length() const {
- return body_size;
-}
-
-PackedByteArray HTTPClient::read_response_body_chunk() {
- ERR_FAIL_COND_V(status != STATUS_BODY, PackedByteArray());
-
- PackedByteArray ret;
- Error err = OK;
-
- if (chunked) {
- while (true) {
- if (chunk_trailer_part) {
- // We need to consume the trailer part too or keep-alive will break
- uint8_t b;
- int rec = 0;
- err = _get_http_data(&b, 1, rec);
-
- if (rec == 0) {
- break;
- }
-
- chunk.push_back(b);
- int cs = chunk.size();
- if ((cs >= 2 && chunk[cs - 2] == '\r' && chunk[cs - 1] == '\n')) {
- if (cs == 2) {
- // Finally over
- chunk_trailer_part = false;
- status = STATUS_CONNECTED;
- chunk.clear();
- break;
- } else {
- // We do not process nor return the trailer data
- chunk.clear();
- }
- }
- } else if (chunk_left == 0) {
- // Reading length
- uint8_t b;
- int rec = 0;
- err = _get_http_data(&b, 1, rec);
-
- if (rec == 0) {
- break;
- }
-
- chunk.push_back(b);
-
- if (chunk.size() > 32) {
- ERR_PRINT("HTTP Invalid chunk hex len");
- status = STATUS_CONNECTION_ERROR;
- break;
- }
-
- if (chunk.size() > 2 && chunk[chunk.size() - 2] == '\r' && chunk[chunk.size() - 1] == '\n') {
- int len = 0;
- for (int i = 0; i < chunk.size() - 2; i++) {
- char c = chunk[i];
- int v = 0;
- if (c >= '0' && c <= '9') {
- v = c - '0';
- } else if (c >= 'a' && c <= 'f') {
- v = c - 'a' + 10;
- } else if (c >= 'A' && c <= 'F') {
- v = c - 'A' + 10;
- } else {
- ERR_PRINT("HTTP Chunk len not in hex!!");
- status = STATUS_CONNECTION_ERROR;
- break;
- }
- len <<= 4;
- len |= v;
- if (len > (1 << 24)) {
- ERR_PRINT("HTTP Chunk too big!! >16mb");
- status = STATUS_CONNECTION_ERROR;
- break;
- }
- }
-
- if (len == 0) {
- // End reached!
- chunk_trailer_part = true;
- chunk.clear();
- break;
- }
-
- chunk_left = len + 2;
- chunk.resize(chunk_left);
- }
- } else {
- int rec = 0;
- err = _get_http_data(&chunk.write[chunk.size() - chunk_left], chunk_left, rec);
- if (rec == 0) {
- break;
- }
- chunk_left -= rec;
-
- if (chunk_left == 0) {
- if (chunk[chunk.size() - 2] != '\r' || chunk[chunk.size() - 1] != '\n') {
- ERR_PRINT("HTTP Invalid chunk terminator (not \\r\\n)");
- status = STATUS_CONNECTION_ERROR;
- break;
- }
-
- ret.resize(chunk.size() - 2);
- uint8_t *w = ret.ptrw();
- memcpy(w, chunk.ptr(), chunk.size() - 2);
- chunk.clear();
- }
-
- break;
- }
- }
-
- } else {
- int to_read = !read_until_eof ? MIN(body_left, read_chunk_size) : read_chunk_size;
- ret.resize(to_read);
- int _offset = 0;
- while (to_read > 0) {
- int rec = 0;
- {
- uint8_t *w = ret.ptrw();
- err = _get_http_data(w + _offset, to_read, rec);
- }
- if (rec <= 0) { // Ended up reading less
- ret.resize(_offset);
- break;
- } else {
- _offset += rec;
- to_read -= rec;
- if (!read_until_eof) {
- body_left -= rec;
- }
- }
- if (err != OK) {
- break;
- }
- }
- }
-
- if (err != OK) {
- close();
-
- if (err == ERR_FILE_EOF) {
- status = STATUS_DISCONNECTED; // Server disconnected
- } else {
- status = STATUS_CONNECTION_ERROR;
- }
- } else if (body_left == 0 && !chunked && !read_until_eof) {
- status = STATUS_CONNECTED;
- }
-
- return ret;
-}
-
-HTTPClient::Status HTTPClient::get_status() const {
- return status;
-}
-
-void HTTPClient::set_blocking_mode(bool p_enable) {
- blocking = p_enable;
-}
-
-bool HTTPClient::is_blocking_mode_enabled() const {
- return blocking;
-}
-
-Error HTTPClient::_get_http_data(uint8_t *p_buffer, int p_bytes, int &r_received) {
- if (blocking) {
- // We can't use StreamPeer.get_data, since when reaching EOF we will get an
- // error without knowing how many bytes we received.
- Error err = ERR_FILE_EOF;
- int read = 0;
- int left = p_bytes;
- r_received = 0;
- while (left > 0) {
- err = connection->get_partial_data(p_buffer + r_received, left, read);
- if (err == OK) {
- r_received += read;
- } else if (err == ERR_FILE_EOF) {
- r_received += read;
- return err;
- } else {
- return err;
- }
- left -= read;
- }
- return err;
- } else {
- return connection->get_partial_data(p_buffer, p_bytes, r_received);
- }
-}
-
-void HTTPClient::set_read_chunk_size(int p_size) {
- ERR_FAIL_COND(p_size < 256 || p_size > (1 << 24));
- read_chunk_size = p_size;
-}
-
-int HTTPClient::get_read_chunk_size() const {
- return read_chunk_size;
-}
-
-HTTPClient::HTTPClient() {
- tcp_connection.instance();
-}
-
-HTTPClient::~HTTPClient() {}
-
-#endif // #ifndef JAVASCRIPT_ENABLED
-
String HTTPClient::query_string_from_dict(const Dictionary &p_dict) {
String query = "";
Array keys = p_dict.keys();
@@ -802,8 +124,8 @@ void HTTPClient::_bind_methods() {
ClassDB::bind_method(D_METHOD("connect_to_host", "host", "port", "use_ssl", "verify_host"), &HTTPClient::connect_to_host, DEFVAL(-1), DEFVAL(false), DEFVAL(true));
ClassDB::bind_method(D_METHOD("set_connection", "connection"), &HTTPClient::set_connection);
ClassDB::bind_method(D_METHOD("get_connection"), &HTTPClient::get_connection);
- ClassDB::bind_method(D_METHOD("request_raw", "method", "url", "headers", "body"), &HTTPClient::request_raw);
- ClassDB::bind_method(D_METHOD("request", "method", "url", "headers", "body"), &HTTPClient::request, DEFVAL(String()));
+ ClassDB::bind_method(D_METHOD("request_raw", "method", "url", "headers", "body"), &HTTPClient::_request_raw);
+ ClassDB::bind_method(D_METHOD("request", "method", "url", "headers", "body"), &HTTPClient::_request, DEFVAL(String()));
ClassDB::bind_method(D_METHOD("close"), &HTTPClient::close);
ClassDB::bind_method(D_METHOD("has_response"), &HTTPClient::has_response);
@@ -825,7 +147,7 @@ void HTTPClient::_bind_methods() {
ClassDB::bind_method(D_METHOD("query_string_from_dict", "fields"), &HTTPClient::query_string_from_dict);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "blocking_mode_enabled"), "set_blocking_mode", "is_blocking_mode_enabled");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "connection", PROPERTY_HINT_RESOURCE_TYPE, "StreamPeer", 0), "set_connection", "get_connection");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "connection", PROPERTY_HINT_RESOURCE_TYPE, "StreamPeer", PROPERTY_USAGE_NONE), "set_connection", "get_connection");
ADD_PROPERTY(PropertyInfo(Variant::INT, "read_chunk_size", PROPERTY_HINT_RANGE, "256,16777216"), "set_read_chunk_size", "get_read_chunk_size");
BIND_ENUM_CONSTANT(METHOD_GET);
diff --git a/core/io/http_client.h b/core/io/http_client.h
index f70999836f..718c3a905e 100644
--- a/core/io/http_client.h
+++ b/core/io/http_client.h
@@ -142,7 +142,7 @@ public:
};
-private:
+protected:
static const char *_methods[METHOD_MAX];
static const int HOST_MIN_LEN = 4;
@@ -152,79 +152,48 @@ private:
};
-#ifndef JAVASCRIPT_ENABLED
- Status status = STATUS_DISCONNECTED;
- IP::ResolverID resolving = IP::RESOLVER_INVALID_ID;
- int conn_port = -1;
- String conn_host;
- bool ssl = false;
- bool ssl_verify_host = false;
- bool blocking = false;
- bool handshaking = false;
- bool head_request = false;
-
- Vector<uint8_t> response_str;
-
- bool chunked = false;
- Vector<uint8_t> chunk;
- int chunk_left = 0;
- bool chunk_trailer_part = false;
- int body_size = -1;
- int body_left = 0;
- bool read_until_eof = false;
-
- Ref<StreamPeerTCP> tcp_connection;
- Ref<StreamPeer> connection;
-
- int response_num = 0;
- Vector<String> response_headers;
- // 64 KiB by default (favors fast download speeds at the cost of memory usage).
- int read_chunk_size = 65536;
-
- Error _get_http_data(uint8_t *p_buffer, int p_bytes, int &r_received);
-
-#else
-#include "platform/javascript/http_client.h.inc"
-#endif
-
PackedStringArray _get_response_headers();
Dictionary _get_response_headers_as_dictionary();
+ Error _request_raw(Method p_method, const String &p_url, const Vector<String> &p_headers, const Vector<uint8_t> &p_body);
+ Error _request(Method p_method, const String &p_url, const Vector<String> &p_headers, const String &p_body = String());
+
+ static HTTPClient *(*_create)();
static void _bind_methods();
public:
- Error connect_to_host(const String &p_host, int p_port = -1, bool p_ssl = false, bool p_verify_host = true);
+ static HTTPClient *create();
- void set_connection(const Ref<StreamPeer> &p_connection);
- Ref<StreamPeer> get_connection() const;
+ String query_string_from_dict(const Dictionary &p_dict);
- Error request_raw(Method p_method, const String &p_url, const Vector<String> &p_headers, const Vector<uint8_t> &p_body);
- Error request(Method p_method, const String &p_url, const Vector<String> &p_headers, const String &p_body = String());
+ virtual Error request(Method p_method, const String &p_url, const Vector<String> &p_headers, const uint8_t *p_body, int p_body_size) = 0;
+ virtual Error connect_to_host(const String &p_host, int p_port = -1, bool p_ssl = false, bool p_verify_host = true) = 0;
- void close();
+ virtual void set_connection(const Ref<StreamPeer> &p_connection) = 0;
+ virtual Ref<StreamPeer> get_connection() const = 0;
- Status get_status() const;
+ virtual void close() = 0;
- bool has_response() const;
- bool is_response_chunked() const;
- int get_response_code() const;
- Error get_response_headers(List<String> *r_response);
- int get_response_body_length() const;
+ virtual Status get_status() const = 0;
- PackedByteArray read_response_body_chunk(); // Can't get body as partial text because of most encodings UTF8, gzip, etc.
+ virtual bool has_response() const = 0;
+ virtual bool is_response_chunked() const = 0;
+ virtual int get_response_code() const = 0;
+ virtual Error get_response_headers(List<String> *r_response) = 0;
+ virtual int get_response_body_length() const = 0;
- void set_blocking_mode(bool p_enable); // Useful mostly if running in a thread
- bool is_blocking_mode_enabled() const;
+ virtual PackedByteArray read_response_body_chunk() = 0; // Can't get body as partial text because of most encodings UTF8, gzip, etc.
- void set_read_chunk_size(int p_size);
- int get_read_chunk_size() const;
+ virtual void set_blocking_mode(bool p_enable) = 0; // Useful mostly if running in a thread
+ virtual bool is_blocking_mode_enabled() const = 0;
- Error poll();
+ virtual void set_read_chunk_size(int p_size) = 0;
+ virtual int get_read_chunk_size() const = 0;
- String query_string_from_dict(const Dictionary &p_dict);
+ virtual Error poll() = 0;
- HTTPClient();
- ~HTTPClient();
+ HTTPClient() {}
+ virtual ~HTTPClient() {}
};
VARIANT_ENUM_CAST(HTTPClient::ResponseCode)
diff --git a/core/io/http_client_tcp.cpp b/core/io/http_client_tcp.cpp
new file mode 100644
index 0000000000..f9b3165a07
--- /dev/null
+++ b/core/io/http_client_tcp.cpp
@@ -0,0 +1,666 @@
+/*************************************************************************/
+/* http_client_tcp.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef JAVASCRIPT_ENABLED
+
+#include "http_client_tcp.h"
+
+#include "core/io/stream_peer_ssl.h"
+#include "core/version.h"
+
+HTTPClient *HTTPClientTCP::_create_func() {
+ return memnew(HTTPClientTCP);
+}
+
+Error HTTPClientTCP::connect_to_host(const String &p_host, int p_port, bool p_ssl, bool p_verify_host) {
+ close();
+
+ conn_port = p_port;
+ conn_host = p_host;
+
+ ssl = p_ssl;
+ ssl_verify_host = p_verify_host;
+
+ String host_lower = conn_host.to_lower();
+ if (host_lower.begins_with("http://")) {
+ conn_host = conn_host.substr(7, conn_host.length() - 7);
+ } else if (host_lower.begins_with("https://")) {
+ ssl = true;
+ conn_host = conn_host.substr(8, conn_host.length() - 8);
+ }
+
+ ERR_FAIL_COND_V(conn_host.length() < HOST_MIN_LEN, ERR_INVALID_PARAMETER);
+
+ if (conn_port < 0) {
+ if (ssl) {
+ conn_port = PORT_HTTPS;
+ } else {
+ conn_port = PORT_HTTP;
+ }
+ }
+
+ connection = tcp_connection;
+
+ if (conn_host.is_valid_ip_address()) {
+ // Host contains valid IP
+ Error err = tcp_connection->connect_to_host(IPAddress(conn_host), p_port);
+ if (err) {
+ status = STATUS_CANT_CONNECT;
+ return err;
+ }
+
+ status = STATUS_CONNECTING;
+ } else {
+ // Host contains hostname and needs to be resolved to IP
+ resolving = IP::get_singleton()->resolve_hostname_queue_item(conn_host);
+ status = STATUS_RESOLVING;
+ }
+
+ return OK;
+}
+
+void HTTPClientTCP::set_connection(const Ref<StreamPeer> &p_connection) {
+ ERR_FAIL_COND_MSG(p_connection.is_null(), "Connection is not a reference to a valid StreamPeer object.");
+
+ if (ssl) {
+ ERR_FAIL_NULL_MSG(Object::cast_to<StreamPeerSSL>(p_connection.ptr()),
+ "Connection is not a reference to a valid StreamPeerSSL object.");
+ }
+
+ if (connection == p_connection) {
+ return;
+ }
+
+ close();
+ connection = p_connection;
+ status = STATUS_CONNECTED;
+}
+
+Ref<StreamPeer> HTTPClientTCP::get_connection() const {
+ return connection;
+}
+
+static bool _check_request_url(HTTPClientTCP::Method p_method, const String &p_url) {
+ switch (p_method) {
+ case HTTPClientTCP::METHOD_CONNECT: {
+ // Authority in host:port format, as in RFC7231
+ int pos = p_url.find_char(':');
+ return 0 < pos && pos < p_url.length() - 1;
+ }
+ case HTTPClientTCP::METHOD_OPTIONS: {
+ if (p_url == "*") {
+ return true;
+ }
+ [[fallthrough]];
+ }
+ default:
+ // Absolute path or absolute URL
+ return p_url.begins_with("/") || p_url.begins_with("http://") || p_url.begins_with("https://");
+ }
+}
+
+Error HTTPClientTCP::request(Method p_method, const String &p_url, const Vector<String> &p_headers, const uint8_t *p_body, int p_body_size) {
+ ERR_FAIL_INDEX_V(p_method, METHOD_MAX, ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V(!_check_request_url(p_method, p_url), ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V(status != STATUS_CONNECTED, ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V(connection.is_null(), ERR_INVALID_DATA);
+
+ String request = String(_methods[p_method]) + " " + p_url + " HTTP/1.1\r\n";
+ bool add_host = true;
+ bool add_clen = p_body_size > 0;
+ bool add_uagent = true;
+ bool add_accept = true;
+ for (int i = 0; i < p_headers.size(); i++) {
+ request += p_headers[i] + "\r\n";
+ if (add_host && p_headers[i].findn("Host:") == 0) {
+ add_host = false;
+ }
+ if (add_clen && p_headers[i].findn("Content-Length:") == 0) {
+ add_clen = false;
+ }
+ if (add_uagent && p_headers[i].findn("User-Agent:") == 0) {
+ add_uagent = false;
+ }
+ if (add_accept && p_headers[i].findn("Accept:") == 0) {
+ add_accept = false;
+ }
+ }
+ if (add_host) {
+ if ((ssl && conn_port == PORT_HTTPS) || (!ssl && conn_port == PORT_HTTP)) {
+ // Don't append the standard ports
+ request += "Host: " + conn_host + "\r\n";
+ } else {
+ request += "Host: " + conn_host + ":" + itos(conn_port) + "\r\n";
+ }
+ }
+ if (add_clen) {
+ request += "Content-Length: " + itos(p_body_size) + "\r\n";
+ // Should it add utf8 encoding?
+ }
+ if (add_uagent) {
+ request += "User-Agent: GodotEngine/" + String(VERSION_FULL_BUILD) + " (" + OS::get_singleton()->get_name() + ")\r\n";
+ }
+ if (add_accept) {
+ request += "Accept: */*\r\n";
+ }
+ request += "\r\n";
+ CharString cs = request.utf8();
+
+ Vector<uint8_t> data;
+ data.resize(cs.length() + p_body_size);
+ memcpy(data.ptrw(), cs.get_data(), cs.length());
+ if (p_body_size > 0) {
+ memcpy(data.ptrw() + cs.length(), p_body, p_body_size);
+ }
+
+ // TODO Implement non-blocking requests.
+ Error err = connection->put_data(data.ptr(), data.size());
+
+ if (err) {
+ close();
+ status = STATUS_CONNECTION_ERROR;
+ return err;
+ }
+
+ status = STATUS_REQUESTING;
+ head_request = p_method == METHOD_HEAD;
+
+ return OK;
+}
+
+bool HTTPClientTCP::has_response() const {
+ return response_headers.size() != 0;
+}
+
+bool HTTPClientTCP::is_response_chunked() const {
+ return chunked;
+}
+
+int HTTPClientTCP::get_response_code() const {
+ return response_num;
+}
+
+Error HTTPClientTCP::get_response_headers(List<String> *r_response) {
+ if (!response_headers.size()) {
+ return ERR_INVALID_PARAMETER;
+ }
+
+ for (int i = 0; i < response_headers.size(); i++) {
+ r_response->push_back(response_headers[i]);
+ }
+
+ response_headers.clear();
+
+ return OK;
+}
+
+void HTTPClientTCP::close() {
+ if (tcp_connection->get_status() != StreamPeerTCP::STATUS_NONE) {
+ tcp_connection->disconnect_from_host();
+ }
+
+ connection.unref();
+ status = STATUS_DISCONNECTED;
+ head_request = false;
+ if (resolving != IP::RESOLVER_INVALID_ID) {
+ IP::get_singleton()->erase_resolve_item(resolving);
+ resolving = IP::RESOLVER_INVALID_ID;
+ }
+
+ response_headers.clear();
+ response_str.clear();
+ body_size = -1;
+ body_left = 0;
+ chunk_left = 0;
+ chunk_trailer_part = false;
+ read_until_eof = false;
+ response_num = 0;
+ handshaking = false;
+}
+
+Error HTTPClientTCP::poll() {
+ switch (status) {
+ case STATUS_RESOLVING: {
+ ERR_FAIL_COND_V(resolving == IP::RESOLVER_INVALID_ID, ERR_BUG);
+
+ IP::ResolverStatus rstatus = IP::get_singleton()->get_resolve_item_status(resolving);
+ switch (rstatus) {
+ case IP::RESOLVER_STATUS_WAITING:
+ return OK; // Still resolving
+
+ case IP::RESOLVER_STATUS_DONE: {
+ IPAddress host = IP::get_singleton()->get_resolve_item_address(resolving);
+ Error err = tcp_connection->connect_to_host(host, conn_port);
+ IP::get_singleton()->erase_resolve_item(resolving);
+ resolving = IP::RESOLVER_INVALID_ID;
+ if (err) {
+ status = STATUS_CANT_CONNECT;
+ return err;
+ }
+
+ status = STATUS_CONNECTING;
+ } break;
+ case IP::RESOLVER_STATUS_NONE:
+ case IP::RESOLVER_STATUS_ERROR: {
+ IP::get_singleton()->erase_resolve_item(resolving);
+ resolving = IP::RESOLVER_INVALID_ID;
+ close();
+ status = STATUS_CANT_RESOLVE;
+ return ERR_CANT_RESOLVE;
+ } break;
+ }
+ } break;
+ case STATUS_CONNECTING: {
+ StreamPeerTCP::Status s = tcp_connection->get_status();
+ switch (s) {
+ case StreamPeerTCP::STATUS_CONNECTING: {
+ return OK;
+ } break;
+ case StreamPeerTCP::STATUS_CONNECTED: {
+ if (ssl) {
+ Ref<StreamPeerSSL> ssl;
+ if (!handshaking) {
+ // Connect the StreamPeerSSL and start handshaking
+ ssl = Ref<StreamPeerSSL>(StreamPeerSSL::create());
+ ssl->set_blocking_handshake_enabled(false);
+ Error err = ssl->connect_to_stream(tcp_connection, ssl_verify_host, conn_host);
+ if (err != OK) {
+ close();
+ status = STATUS_SSL_HANDSHAKE_ERROR;
+ return ERR_CANT_CONNECT;
+ }
+ connection = ssl;
+ handshaking = true;
+ } else {
+ // We are already handshaking, which means we can use your already active SSL connection
+ ssl = static_cast<Ref<StreamPeerSSL>>(connection);
+ if (ssl.is_null()) {
+ close();
+ status = STATUS_SSL_HANDSHAKE_ERROR;
+ return ERR_CANT_CONNECT;
+ }
+
+ ssl->poll(); // Try to finish the handshake
+ }
+
+ if (ssl->get_status() == StreamPeerSSL::STATUS_CONNECTED) {
+ // Handshake has been successful
+ handshaking = false;
+ status = STATUS_CONNECTED;
+ return OK;
+ } else if (ssl->get_status() != StreamPeerSSL::STATUS_HANDSHAKING) {
+ // Handshake has failed
+ close();
+ status = STATUS_SSL_HANDSHAKE_ERROR;
+ return ERR_CANT_CONNECT;
+ }
+ // ... we will need to poll more for handshake to finish
+ } else {
+ status = STATUS_CONNECTED;
+ }
+ return OK;
+ } break;
+ case StreamPeerTCP::STATUS_ERROR:
+ case StreamPeerTCP::STATUS_NONE: {
+ close();
+ status = STATUS_CANT_CONNECT;
+ return ERR_CANT_CONNECT;
+ } break;
+ }
+ } break;
+ case STATUS_BODY:
+ case STATUS_CONNECTED: {
+ // Check if we are still connected
+ if (ssl) {
+ Ref<StreamPeerSSL> tmp = connection;
+ tmp->poll();
+ if (tmp->get_status() != StreamPeerSSL::STATUS_CONNECTED) {
+ status = STATUS_CONNECTION_ERROR;
+ return ERR_CONNECTION_ERROR;
+ }
+ } else if (tcp_connection->get_status() != StreamPeerTCP::STATUS_CONNECTED) {
+ status = STATUS_CONNECTION_ERROR;
+ return ERR_CONNECTION_ERROR;
+ }
+ // Connection established, requests can now be made
+ return OK;
+ } break;
+ case STATUS_REQUESTING: {
+ while (true) {
+ uint8_t byte;
+ int rec = 0;
+ Error err = _get_http_data(&byte, 1, rec);
+ if (err != OK) {
+ close();
+ status = STATUS_CONNECTION_ERROR;
+ return ERR_CONNECTION_ERROR;
+ }
+
+ if (rec == 0) {
+ return OK; // Still requesting, keep trying!
+ }
+
+ response_str.push_back(byte);
+ int rs = response_str.size();
+ if (
+ (rs >= 2 && response_str[rs - 2] == '\n' && response_str[rs - 1] == '\n') ||
+ (rs >= 4 && response_str[rs - 4] == '\r' && response_str[rs - 3] == '\n' && response_str[rs - 2] == '\r' && response_str[rs - 1] == '\n')) {
+ // End of response, parse.
+ response_str.push_back(0);
+ String response;
+ response.parse_utf8((const char *)response_str.ptr());
+ Vector<String> responses = response.split("\n");
+ body_size = -1;
+ chunked = false;
+ body_left = 0;
+ chunk_left = 0;
+ chunk_trailer_part = false;
+ read_until_eof = false;
+ response_str.clear();
+ response_headers.clear();
+ response_num = RESPONSE_OK;
+
+ // Per the HTTP 1.1 spec, keep-alive is the default.
+ // Not following that specification breaks standard implementations.
+ // Broken web servers should be fixed.
+ bool keep_alive = true;
+
+ for (int i = 0; i < responses.size(); i++) {
+ String header = responses[i].strip_edges();
+ String s = header.to_lower();
+ if (s.length() == 0) {
+ continue;
+ }
+ if (s.begins_with("content-length:")) {
+ body_size = s.substr(s.find(":") + 1, s.length()).strip_edges().to_int();
+ body_left = body_size;
+
+ } else if (s.begins_with("transfer-encoding:")) {
+ String encoding = header.substr(header.find(":") + 1, header.length()).strip_edges();
+ if (encoding == "chunked") {
+ chunked = true;
+ }
+ } else if (s.begins_with("connection: close")) {
+ keep_alive = false;
+ }
+
+ if (i == 0 && responses[i].begins_with("HTTP")) {
+ String num = responses[i].get_slicec(' ', 1);
+ response_num = num.to_int();
+ } else {
+ response_headers.push_back(header);
+ }
+ }
+
+ // This is a HEAD request, we won't receive anything.
+ if (head_request) {
+ body_size = 0;
+ body_left = 0;
+ }
+
+ if (body_size != -1 || chunked) {
+ status = STATUS_BODY;
+ } else if (!keep_alive) {
+ read_until_eof = true;
+ status = STATUS_BODY;
+ } else {
+ status = STATUS_CONNECTED;
+ }
+ return OK;
+ }
+ }
+ } break;
+ case STATUS_DISCONNECTED: {
+ return ERR_UNCONFIGURED;
+ } break;
+ case STATUS_CONNECTION_ERROR:
+ case STATUS_SSL_HANDSHAKE_ERROR: {
+ return ERR_CONNECTION_ERROR;
+ } break;
+ case STATUS_CANT_CONNECT: {
+ return ERR_CANT_CONNECT;
+ } break;
+ case STATUS_CANT_RESOLVE: {
+ return ERR_CANT_RESOLVE;
+ } break;
+ }
+
+ return OK;
+}
+
+int HTTPClientTCP::get_response_body_length() const {
+ return body_size;
+}
+
+PackedByteArray HTTPClientTCP::read_response_body_chunk() {
+ ERR_FAIL_COND_V(status != STATUS_BODY, PackedByteArray());
+
+ PackedByteArray ret;
+ Error err = OK;
+
+ if (chunked) {
+ while (true) {
+ if (chunk_trailer_part) {
+ // We need to consume the trailer part too or keep-alive will break
+ uint8_t b;
+ int rec = 0;
+ err = _get_http_data(&b, 1, rec);
+
+ if (rec == 0) {
+ break;
+ }
+
+ chunk.push_back(b);
+ int cs = chunk.size();
+ if ((cs >= 2 && chunk[cs - 2] == '\r' && chunk[cs - 1] == '\n')) {
+ if (cs == 2) {
+ // Finally over
+ chunk_trailer_part = false;
+ status = STATUS_CONNECTED;
+ chunk.clear();
+ break;
+ } else {
+ // We do not process nor return the trailer data
+ chunk.clear();
+ }
+ }
+ } else if (chunk_left == 0) {
+ // Reading length
+ uint8_t b;
+ int rec = 0;
+ err = _get_http_data(&b, 1, rec);
+
+ if (rec == 0) {
+ break;
+ }
+
+ chunk.push_back(b);
+
+ if (chunk.size() > 32) {
+ ERR_PRINT("HTTP Invalid chunk hex len");
+ status = STATUS_CONNECTION_ERROR;
+ break;
+ }
+
+ if (chunk.size() > 2 && chunk[chunk.size() - 2] == '\r' && chunk[chunk.size() - 1] == '\n') {
+ int len = 0;
+ for (int i = 0; i < chunk.size() - 2; i++) {
+ char c = chunk[i];
+ int v = 0;
+ if (c >= '0' && c <= '9') {
+ v = c - '0';
+ } else if (c >= 'a' && c <= 'f') {
+ v = c - 'a' + 10;
+ } else if (c >= 'A' && c <= 'F') {
+ v = c - 'A' + 10;
+ } else {
+ ERR_PRINT("HTTP Chunk len not in hex!!");
+ status = STATUS_CONNECTION_ERROR;
+ break;
+ }
+ len <<= 4;
+ len |= v;
+ if (len > (1 << 24)) {
+ ERR_PRINT("HTTP Chunk too big!! >16mb");
+ status = STATUS_CONNECTION_ERROR;
+ break;
+ }
+ }
+
+ if (len == 0) {
+ // End reached!
+ chunk_trailer_part = true;
+ chunk.clear();
+ break;
+ }
+
+ chunk_left = len + 2;
+ chunk.resize(chunk_left);
+ }
+ } else {
+ int rec = 0;
+ err = _get_http_data(&chunk.write[chunk.size() - chunk_left], chunk_left, rec);
+ if (rec == 0) {
+ break;
+ }
+ chunk_left -= rec;
+
+ if (chunk_left == 0) {
+ if (chunk[chunk.size() - 2] != '\r' || chunk[chunk.size() - 1] != '\n') {
+ ERR_PRINT("HTTP Invalid chunk terminator (not \\r\\n)");
+ status = STATUS_CONNECTION_ERROR;
+ break;
+ }
+
+ ret.resize(chunk.size() - 2);
+ uint8_t *w = ret.ptrw();
+ memcpy(w, chunk.ptr(), chunk.size() - 2);
+ chunk.clear();
+ }
+
+ break;
+ }
+ }
+
+ } else {
+ int to_read = !read_until_eof ? MIN(body_left, read_chunk_size) : read_chunk_size;
+ ret.resize(to_read);
+ int _offset = 0;
+ while (to_read > 0) {
+ int rec = 0;
+ {
+ uint8_t *w = ret.ptrw();
+ err = _get_http_data(w + _offset, to_read, rec);
+ }
+ if (rec <= 0) { // Ended up reading less
+ ret.resize(_offset);
+ break;
+ } else {
+ _offset += rec;
+ to_read -= rec;
+ if (!read_until_eof) {
+ body_left -= rec;
+ }
+ }
+ if (err != OK) {
+ break;
+ }
+ }
+ }
+
+ if (err != OK) {
+ close();
+
+ if (err == ERR_FILE_EOF) {
+ status = STATUS_DISCONNECTED; // Server disconnected
+ } else {
+ status = STATUS_CONNECTION_ERROR;
+ }
+ } else if (body_left == 0 && !chunked && !read_until_eof) {
+ status = STATUS_CONNECTED;
+ }
+
+ return ret;
+}
+
+HTTPClientTCP::Status HTTPClientTCP::get_status() const {
+ return status;
+}
+
+void HTTPClientTCP::set_blocking_mode(bool p_enable) {
+ blocking = p_enable;
+}
+
+bool HTTPClientTCP::is_blocking_mode_enabled() const {
+ return blocking;
+}
+
+Error HTTPClientTCP::_get_http_data(uint8_t *p_buffer, int p_bytes, int &r_received) {
+ if (blocking) {
+ // We can't use StreamPeer.get_data, since when reaching EOF we will get an
+ // error without knowing how many bytes we received.
+ Error err = ERR_FILE_EOF;
+ int read = 0;
+ int left = p_bytes;
+ r_received = 0;
+ while (left > 0) {
+ err = connection->get_partial_data(p_buffer + r_received, left, read);
+ if (err == OK) {
+ r_received += read;
+ } else if (err == ERR_FILE_EOF) {
+ r_received += read;
+ return err;
+ } else {
+ return err;
+ }
+ left -= read;
+ }
+ return err;
+ } else {
+ return connection->get_partial_data(p_buffer, p_bytes, r_received);
+ }
+}
+
+void HTTPClientTCP::set_read_chunk_size(int p_size) {
+ ERR_FAIL_COND(p_size < 256 || p_size > (1 << 24));
+ read_chunk_size = p_size;
+}
+
+int HTTPClientTCP::get_read_chunk_size() const {
+ return read_chunk_size;
+}
+
+HTTPClientTCP::HTTPClientTCP() {
+ tcp_connection.instantiate();
+}
+
+HTTPClient *(*HTTPClient::_create)() = HTTPClientTCP::_create_func;
+
+#endif // #ifndef JAVASCRIPT_ENABLED
diff --git a/core/io/http_client_tcp.h b/core/io/http_client_tcp.h
new file mode 100644
index 0000000000..e178399fbe
--- /dev/null
+++ b/core/io/http_client_tcp.h
@@ -0,0 +1,92 @@
+/*************************************************************************/
+/* http_client_tcp.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef HTTP_CLIENT_TCP_H
+#define HTTP_CLIENT_TCP_H
+
+#include "http_client.h"
+
+class HTTPClientTCP : public HTTPClient {
+private:
+ Status status = STATUS_DISCONNECTED;
+ IP::ResolverID resolving = IP::RESOLVER_INVALID_ID;
+ int conn_port = -1;
+ String conn_host;
+ bool ssl = false;
+ bool ssl_verify_host = false;
+ bool blocking = false;
+ bool handshaking = false;
+ bool head_request = false;
+
+ Vector<uint8_t> response_str;
+
+ bool chunked = false;
+ Vector<uint8_t> chunk;
+ int chunk_left = 0;
+ bool chunk_trailer_part = false;
+ int body_size = -1;
+ int body_left = 0;
+ bool read_until_eof = false;
+
+ Ref<StreamPeerTCP> tcp_connection;
+ Ref<StreamPeer> connection;
+
+ int response_num = 0;
+ Vector<String> response_headers;
+ // 64 KiB by default (favors fast download speeds at the cost of memory usage).
+ int read_chunk_size = 65536;
+
+ Error _get_http_data(uint8_t *p_buffer, int p_bytes, int &r_received);
+
+public:
+ static HTTPClient *_create_func();
+
+ Error request(Method p_method, const String &p_url, const Vector<String> &p_headers, const uint8_t *p_body, int p_body_size) override;
+
+ Error connect_to_host(const String &p_host, int p_port = -1, bool p_ssl = false, bool p_verify_host = true) override;
+ void set_connection(const Ref<StreamPeer> &p_connection) override;
+ Ref<StreamPeer> get_connection() const override;
+ void close() override;
+ Status get_status() const override;
+ bool has_response() const override;
+ bool is_response_chunked() const override;
+ int get_response_code() const override;
+ Error get_response_headers(List<String> *r_response) override;
+ int get_response_body_length() const override;
+ PackedByteArray read_response_body_chunk() override;
+ void set_blocking_mode(bool p_enable) override;
+ bool is_blocking_mode_enabled() const override;
+ void set_read_chunk_size(int p_size) override;
+ int get_read_chunk_size() const override;
+ Error poll() override;
+ HTTPClientTCP();
+};
+
+#endif // HTTP_CLIENT_TCP_H
diff --git a/core/io/image.cpp b/core/io/image.cpp
index 9cd0ea7b5d..3e79b7efbc 100644
--- a/core/io/image.cpp
+++ b/core/io/image.cpp
@@ -1945,7 +1945,7 @@ Error Image::generate_mipmap_roughness(RoughnessChannel p_roughness_channel, con
memcpy(wr.ptr(), ptr, size);
wr = uint8_t*();
Ref<Image> im;
- im.instance();
+ im.instantiate();
im->create(w, h, false, format, imgdata);
im->save_png("res://mipmap_" + itos(i) + ".png");
}
@@ -1985,6 +1985,7 @@ void Image::create(int p_width, int p_height, bool p_use_mipmaps, Format p_forma
ERR_FAIL_COND_MSG(p_width > MAX_WIDTH, "Image width cannot be greater than " + itos(MAX_WIDTH) + ".");
ERR_FAIL_COND_MSG(p_height > MAX_HEIGHT, "Image height cannot be greater than " + itos(MAX_HEIGHT) + ".");
ERR_FAIL_COND_MSG(p_width * p_height > MAX_PIXELS, "Too many pixels for image, maximum is " + itos(MAX_PIXELS));
+ ERR_FAIL_INDEX_MSG(p_format, FORMAT_MAX, "Image format out of range, please see Image's Format enum.");
int mm = 0;
int size = _get_dst_image_size(p_width, p_height, p_format, mm, p_use_mipmaps ? -1 : 0);
@@ -2007,6 +2008,7 @@ void Image::create(int p_width, int p_height, bool p_use_mipmaps, Format p_forma
ERR_FAIL_COND_MSG(p_width > MAX_WIDTH, "Image width cannot be greater than " + itos(MAX_WIDTH) + ".");
ERR_FAIL_COND_MSG(p_height > MAX_HEIGHT, "Image height cannot be greater than " + itos(MAX_HEIGHT) + ".");
ERR_FAIL_COND_MSG(p_width * p_height > MAX_PIXELS, "Too many pixels for image, maximum is " + itos(MAX_PIXELS));
+ ERR_FAIL_INDEX_MSG(p_format, FORMAT_MAX, "Image format out of range, please see Image's Format enum.");
int mm;
int size = _get_dst_image_size(p_width, p_height, p_format, mm, p_use_mipmaps ? -1 : 0);
@@ -2997,6 +2999,8 @@ void Image::set_pixel(int p_x, int p_y, const Color &p_color) {
}
void Image::adjust_bcs(float p_brightness, float p_contrast, float p_saturation) {
+ ERR_FAIL_COND_MSG(!_can_modify(format), "Cannot adjust_bcs in compressed or custom image formats.");
+
uint8_t *w = data.ptrw();
uint32_t pixel_size = get_format_pixel_size(format);
uint32_t pixel_count = data.size() / pixel_size;
@@ -3280,7 +3284,7 @@ Ref<Image> Image::rgbe_to_srgb() {
ERR_FAIL_COND_V(format != FORMAT_RGBE9995, Ref<Image>());
Ref<Image> new_image;
- new_image.instance();
+ new_image.instantiate();
new_image->create(width, height, false, Image::FORMAT_RGB8);
for (int row = 0; row < height; row++) {
@@ -3310,7 +3314,7 @@ Ref<Image> Image::get_image_from_mipmap(int p_mipamp) const {
}
Ref<Image> image;
- image.instance();
+ image.instantiate();
image->width = w;
image->height = h;
image->format = format;
@@ -3627,7 +3631,7 @@ Image::Image(const uint8_t *p_mem_png_jpg, int p_len) {
Ref<Resource> Image::duplicate(bool p_subresources) const {
Ref<Image> copy;
- copy.instance();
+ copy.instantiate();
copy->_copy_internals_from(*this);
return copy;
}
diff --git a/core/io/image_loader.cpp b/core/io/image_loader.cpp
index 7de038e6fe..b45e9d26b1 100644
--- a/core/io/image_loader.cpp
+++ b/core/io/image_loader.cpp
@@ -163,7 +163,7 @@ RES ResourceFormatLoaderImage::load(const String &p_path, const String &p_origin
}
Ref<Image> image;
- image.instance();
+ image.instantiate();
Error err = ImageLoader::loader[idx]->load_image(image, f, false, 1.0);
diff --git a/core/io/json.cpp b/core/io/json.cpp
index 82ef2a6894..b3a2498212 100644
--- a/core/io/json.cpp
+++ b/core/io/json.cpp
@@ -45,7 +45,7 @@ const char *JSON::tk_name[TK_MAX] = {
"EOF",
};
-static String _make_indent(const String &p_indent, int p_size) {
+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++) {
@@ -55,7 +55,7 @@ static String _make_indent(const String &p_indent, int p_size) {
return indent_text;
}
-String JSON::_print_var(const Variant &p_var, const String &p_indent, int p_cur_indent, bool p_sort_keys, Set<const void *> &p_markers, bool p_full_precision) {
+String JSON::_stringify(const Variant &p_var, const String &p_indent, int p_cur_indent, bool p_sort_keys, Set<const void *> &p_markers, bool p_full_precision) {
String colon = ":";
String end_statement = "";
@@ -100,7 +100,7 @@ String JSON::_print_var(const Variant &p_var, const String &p_indent, int p_cur_
s += ",";
s += end_statement;
}
- s += _make_indent(p_indent, p_cur_indent + 1) + _print_var(a[i], p_indent, p_cur_indent + 1, p_sort_keys, p_markers);
+ s += _make_indent(p_indent, p_cur_indent + 1) + _stringify(a[i], p_indent, p_cur_indent + 1, p_sort_keys, p_markers);
}
s += end_statement + _make_indent(p_indent, p_cur_indent) + "]";
p_markers.erase(a.id());
@@ -126,9 +126,9 @@ String JSON::_print_var(const Variant &p_var, const String &p_indent, int p_cur_
s += ",";
s += end_statement;
}
- s += _make_indent(p_indent, p_cur_indent + 1) + _print_var(String(E->get()), p_indent, p_cur_indent + 1, p_sort_keys, p_markers);
+ s += _make_indent(p_indent, p_cur_indent + 1) + _stringify(String(E->get()), p_indent, p_cur_indent + 1, p_sort_keys, p_markers);
s += colon;
- s += _print_var(d[E->get()], p_indent, p_cur_indent + 1, p_sort_keys, p_markers);
+ s += _stringify(d[E->get()], p_indent, p_cur_indent + 1, p_sort_keys, p_markers);
}
s += end_statement + _make_indent(p_indent, p_cur_indent) + "}";
@@ -140,11 +140,6 @@ String JSON::_print_var(const Variant &p_var, const String &p_indent, int p_cur_
}
}
-String JSON::print(const Variant &p_var, const String &p_indent, bool p_sort_keys, bool p_full_precision) {
- Set<const void *> markers;
- return _print_var(p_var, p_indent, 0, p_sort_keys, markers, p_full_precision);
-}
-
Error JSON::_get_token(const char32_t *p_str, int &index, int p_len, Token &r_token, int &line, String &r_err_str) {
while (p_len > 0) {
switch (p_str[index]) {
@@ -499,7 +494,7 @@ Error JSON::_parse_object(Dictionary &object, const char32_t *p_str, int &index,
return ERR_PARSE_ERROR;
}
-Error JSON::parse(const String &p_json, Variant &r_ret, String &r_err_str, int &r_err_line) {
+Error JSON::_parse_string(const String &p_json, Variant &r_ret, String &r_err_str, int &r_err_line) {
const char32_t *str = p_json.ptr();
int idx = 0;
int len = p_json.length();
@@ -530,34 +525,24 @@ Error JSON::parse(const String &p_json, Variant &r_ret, String &r_err_str, int &
return err;
}
-Error JSONParser::parse_string(const String &p_json_string) {
- return JSON::parse(p_json_string, data, err_text, err_line);
-}
-String JSONParser::get_error_text() const {
- return err_text;
-}
-int JSONParser::get_error_line() const {
- return err_line;
-}
-Variant JSONParser::get_data() const {
- return data;
+String JSON::stringify(const Variant &p_var, const String &p_indent, bool p_sort_keys, bool p_full_precision) {
+ Set<const void *> markers;
+ return _stringify(p_var, p_indent, 0, p_sort_keys, markers, p_full_precision);
}
-Error JSONParser::decode_data(const Variant &p_data, const String &p_indent, bool p_sort_keys) {
- string = JSON::print(p_data, p_indent, p_sort_keys);
- data = p_data;
- return OK;
+Error JSON::parse(const String &p_json_string) {
+ Error err = _parse_string(p_json_string, data, err_str, err_line);
+ if (err == Error::OK) {
+ err_line = 0;
+ }
+ return err;
}
-String JSONParser::get_string() const {
- return string;
-}
+void JSON::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("stringify", "data", "indent", "sort_keys", "full_precision"), &JSON::stringify, DEFVAL(""), DEFVAL(true), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("parse", "json_string"), &JSON::parse);
-void JSONParser::_bind_methods() {
- ClassDB::bind_method(D_METHOD("parse_string", "json_string"), &JSONParser::parse_string);
- ClassDB::bind_method(D_METHOD("get_error_text"), &JSONParser::get_error_text);
- ClassDB::bind_method(D_METHOD("get_error_line"), &JSONParser::get_error_line);
- ClassDB::bind_method(D_METHOD("get_data"), &JSONParser::get_data);
- ClassDB::bind_method(D_METHOD("decode_data", "data", "indent", "sort_keys"), &JSONParser::decode_data, DEFVAL(""), DEFVAL(true));
- ClassDB::bind_method(D_METHOD("get_string"), &JSONParser::get_string);
+ ClassDB::bind_method(D_METHOD("get_data"), &JSON::get_data);
+ ClassDB::bind_method(D_METHOD("get_error_line"), &JSON::get_error_line);
+ ClassDB::bind_method(D_METHOD("get_error_message"), &JSON::get_error_message);
}
diff --git a/core/io/json.h b/core/io/json.h
index 5be8cc1e86..f20c97f540 100644
--- a/core/io/json.h
+++ b/core/io/json.h
@@ -33,7 +33,10 @@
#include "core/object/ref_counted.h"
#include "core/variant/variant.h"
-class JSON {
+
+class JSON : public RefCounted {
+ GDCLASS(JSON, RefCounted);
+
enum TokenType {
TK_CURLY_BRACKET_OPEN,
TK_CURLY_BRACKET_CLOSE,
@@ -60,39 +63,30 @@ class JSON {
Variant value;
};
- static const char *tk_name[TK_MAX];
+ Variant data;
+ String err_str;
+ int err_line = 0;
- static String _print_var(const Variant &p_var, const String &p_indent, int p_cur_indent, bool p_sort_keys, Set<const void *> &p_markers, bool p_full_precision = false);
+ static const char *tk_name[];
+ static String _make_indent(const String &p_indent, int p_size);
+ static String _stringify(const Variant &p_var, const String &p_indent, int p_cur_indent, bool p_sort_keys, Set<const void *> &p_markers, bool p_full_precision = false);
static Error _get_token(const char32_t *p_str, int &index, int p_len, Token &r_token, int &line, String &r_err_str);
static Error _parse_value(Variant &value, Token &token, const char32_t *p_str, int &index, int p_len, int &line, String &r_err_str);
static Error _parse_array(Array &array, const char32_t *p_str, int &index, int p_len, int &line, String &r_err_str);
static Error _parse_object(Dictionary &object, const char32_t *p_str, int &index, int p_len, int &line, String &r_err_str);
-
-public:
- static String print(const Variant &p_var, const String &p_indent = "", bool p_sort_keys = true, bool p_full_precision = false);
- static Error parse(const String &p_json, Variant &r_ret, String &r_err_str, int &r_err_line);
-};
-
-class JSONParser : public RefCounted {
- GDCLASS(JSONParser, RefCounted);
-
- Variant data;
- String string;
- String err_text;
- int err_line = 0;
+ static Error _parse_string(const String &p_json, Variant &r_ret, String &r_err_str, int &r_err_line);
protected:
static void _bind_methods();
public:
- Error parse_string(const String &p_json_string);
- String get_error_text() const;
- int get_error_line() const;
- Variant get_data() const;
+ String stringify(const Variant &p_var, const String &p_indent = "", bool p_sort_keys = true, bool p_full_precision = false);
+ Error parse(const String &p_json_string);
- Error decode_data(const Variant &p_data, const String &p_indent = "", bool p_sort_keys = true);
- String get_string() const;
+ inline Variant get_data() const { return data; }
+ inline int get_error_line() const { return err_line; }
+ inline String get_error_message() const { return err_str; }
};
#endif // JSON_H
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp
index 4c58c84c14..f342db2dad 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -111,6 +111,9 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
*r_len = 4;
}
+ // Note: We cannot use sizeof(real_t) for decoding, in case a different size is encoded.
+ // Decoding math types always checks for the encoded size, while encoding always uses compilation setting.
+ // This does lead to some code duplication for decoding, but compatibility is the priority.
switch (type & ENCODE_MASK) {
case Variant::NIL: {
r_variant = Variant();
@@ -144,18 +147,18 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
} break;
case Variant::FLOAT: {
if (type & ENCODE_FLAG_64) {
- ERR_FAIL_COND_V(len < 8, ERR_INVALID_DATA);
+ ERR_FAIL_COND_V((size_t)len < sizeof(double), ERR_INVALID_DATA);
double val = decode_double(buf);
r_variant = val;
if (r_len) {
- (*r_len) += 8;
+ (*r_len) += sizeof(double);
}
} else {
- ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
+ ERR_FAIL_COND_V((size_t)len < sizeof(float), ERR_INVALID_DATA);
float val = decode_float(buf);
r_variant = val;
if (r_len) {
- (*r_len) += 4;
+ (*r_len) += sizeof(float);
}
}
@@ -172,15 +175,25 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
// math types
case Variant::VECTOR2: {
- ERR_FAIL_COND_V(len < 4 * 2, ERR_INVALID_DATA);
Vector2 val;
- val.x = decode_float(&buf[0]);
- val.y = decode_float(&buf[4]);
- r_variant = val;
+ if (type & ENCODE_FLAG_64) {
+ ERR_FAIL_COND_V((size_t)len < sizeof(double) * 2, ERR_INVALID_DATA);
+ val.x = decode_double(&buf[0]);
+ val.y = decode_double(&buf[sizeof(double)]);
- if (r_len) {
- (*r_len) += 4 * 2;
+ if (r_len) {
+ (*r_len) += sizeof(double) * 2;
+ }
+ } else {
+ ERR_FAIL_COND_V((size_t)len < sizeof(float) * 2, ERR_INVALID_DATA);
+ val.x = decode_float(&buf[0]);
+ val.y = decode_float(&buf[sizeof(float)]);
+
+ if (r_len) {
+ (*r_len) += sizeof(float) * 2;
+ }
}
+ r_variant = val;
} break;
case Variant::VECTOR2I: {
@@ -196,17 +209,29 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
} break;
case Variant::RECT2: {
- ERR_FAIL_COND_V(len < 4 * 4, ERR_INVALID_DATA);
Rect2 val;
- val.position.x = decode_float(&buf[0]);
- val.position.y = decode_float(&buf[4]);
- val.size.x = decode_float(&buf[8]);
- val.size.y = decode_float(&buf[12]);
- r_variant = val;
+ if (type & ENCODE_FLAG_64) {
+ ERR_FAIL_COND_V((size_t)len < sizeof(double) * 4, ERR_INVALID_DATA);
+ val.position.x = decode_double(&buf[0]);
+ val.position.y = decode_double(&buf[sizeof(double)]);
+ val.size.x = decode_double(&buf[sizeof(double) * 2]);
+ val.size.y = decode_double(&buf[sizeof(double) * 3]);
- if (r_len) {
- (*r_len) += 4 * 4;
+ if (r_len) {
+ (*r_len) += sizeof(double) * 4;
+ }
+ } else {
+ ERR_FAIL_COND_V((size_t)len < sizeof(float) * 4, ERR_INVALID_DATA);
+ val.position.x = decode_float(&buf[0]);
+ val.position.y = decode_float(&buf[sizeof(float)]);
+ val.size.x = decode_float(&buf[sizeof(float) * 2]);
+ val.size.y = decode_float(&buf[sizeof(float) * 3]);
+
+ if (r_len) {
+ (*r_len) += sizeof(float) * 4;
+ }
}
+ r_variant = val;
} break;
case Variant::RECT2I: {
@@ -224,16 +249,27 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
} break;
case Variant::VECTOR3: {
- ERR_FAIL_COND_V(len < 4 * 3, ERR_INVALID_DATA);
Vector3 val;
- val.x = decode_float(&buf[0]);
- val.y = decode_float(&buf[4]);
- val.z = decode_float(&buf[8]);
- r_variant = val;
+ if (type & ENCODE_FLAG_64) {
+ ERR_FAIL_COND_V((size_t)len < sizeof(double) * 3, ERR_INVALID_DATA);
+ val.x = decode_double(&buf[0]);
+ val.y = decode_double(&buf[sizeof(double)]);
+ val.z = decode_double(&buf[sizeof(double) * 2]);
- if (r_len) {
- (*r_len) += 4 * 3;
+ if (r_len) {
+ (*r_len) += sizeof(double) * 3;
+ }
+ } else {
+ ERR_FAIL_COND_V((size_t)len < sizeof(float) * 3, ERR_INVALID_DATA);
+ val.x = decode_float(&buf[0]);
+ val.y = decode_float(&buf[sizeof(float)]);
+ val.z = decode_float(&buf[sizeof(float) * 2]);
+
+ if (r_len) {
+ (*r_len) += sizeof(float) * 3;
+ }
}
+ r_variant = val;
} break;
case Variant::VECTOR3I: {
@@ -250,101 +286,177 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
} break;
case Variant::TRANSFORM2D: {
- ERR_FAIL_COND_V(len < 4 * 6, ERR_INVALID_DATA);
Transform2D val;
- for (int i = 0; i < 3; i++) {
- for (int j = 0; j < 2; j++) {
- val.elements[i][j] = decode_float(&buf[(i * 2 + j) * 4]);
+ if (type & ENCODE_FLAG_64) {
+ ERR_FAIL_COND_V((size_t)len < sizeof(double) * 6, ERR_INVALID_DATA);
+ for (int i = 0; i < 3; i++) {
+ for (int j = 0; j < 2; j++) {
+ val.elements[i][j] = decode_double(&buf[(i * 2 + j) * sizeof(double)]);
+ }
}
- }
- r_variant = val;
+ if (r_len) {
+ (*r_len) += sizeof(double) * 6;
+ }
+ } else {
+ ERR_FAIL_COND_V((size_t)len < sizeof(float) * 6, ERR_INVALID_DATA);
+ for (int i = 0; i < 3; i++) {
+ for (int j = 0; j < 2; j++) {
+ val.elements[i][j] = decode_float(&buf[(i * 2 + j) * sizeof(float)]);
+ }
+ }
- if (r_len) {
- (*r_len) += 4 * 6;
+ if (r_len) {
+ (*r_len) += sizeof(float) * 6;
+ }
}
+ r_variant = val;
} break;
case Variant::PLANE: {
- ERR_FAIL_COND_V(len < 4 * 4, ERR_INVALID_DATA);
Plane val;
- val.normal.x = decode_float(&buf[0]);
- val.normal.y = decode_float(&buf[4]);
- val.normal.z = decode_float(&buf[8]);
- val.d = decode_float(&buf[12]);
- r_variant = val;
+ if (type & ENCODE_FLAG_64) {
+ ERR_FAIL_COND_V((size_t)len < sizeof(double) * 4, ERR_INVALID_DATA);
+ val.normal.x = decode_double(&buf[0]);
+ val.normal.y = decode_double(&buf[sizeof(double)]);
+ val.normal.z = decode_double(&buf[sizeof(double) * 2]);
+ val.d = decode_double(&buf[sizeof(double) * 3]);
- if (r_len) {
- (*r_len) += 4 * 4;
+ if (r_len) {
+ (*r_len) += sizeof(double) * 4;
+ }
+ } else {
+ ERR_FAIL_COND_V((size_t)len < sizeof(float) * 4, ERR_INVALID_DATA);
+ val.normal.x = decode_float(&buf[0]);
+ val.normal.y = decode_float(&buf[sizeof(float)]);
+ val.normal.z = decode_float(&buf[sizeof(float) * 2]);
+ val.d = decode_float(&buf[sizeof(float) * 3]);
+
+ if (r_len) {
+ (*r_len) += sizeof(float) * 4;
+ }
}
+ r_variant = val;
} break;
case Variant::QUATERNION: {
- ERR_FAIL_COND_V(len < 4 * 4, ERR_INVALID_DATA);
Quaternion val;
- val.x = decode_float(&buf[0]);
- val.y = decode_float(&buf[4]);
- val.z = decode_float(&buf[8]);
- val.w = decode_float(&buf[12]);
- r_variant = val;
+ if (type & ENCODE_FLAG_64) {
+ ERR_FAIL_COND_V((size_t)len < sizeof(double) * 4, ERR_INVALID_DATA);
+ val.x = decode_double(&buf[0]);
+ val.y = decode_double(&buf[sizeof(double)]);
+ val.z = decode_double(&buf[sizeof(double) * 2]);
+ val.w = decode_double(&buf[sizeof(double) * 3]);
- if (r_len) {
- (*r_len) += 4 * 4;
+ if (r_len) {
+ (*r_len) += sizeof(double) * 4;
+ }
+ } else {
+ ERR_FAIL_COND_V((size_t)len < sizeof(float) * 4, ERR_INVALID_DATA);
+ val.x = decode_float(&buf[0]);
+ val.y = decode_float(&buf[sizeof(float)]);
+ val.z = decode_float(&buf[sizeof(float) * 2]);
+ val.w = decode_float(&buf[sizeof(float) * 3]);
+
+ if (r_len) {
+ (*r_len) += sizeof(float) * 4;
+ }
}
+ r_variant = val;
} break;
case Variant::AABB: {
- ERR_FAIL_COND_V(len < 4 * 6, ERR_INVALID_DATA);
AABB val;
- val.position.x = decode_float(&buf[0]);
- val.position.y = decode_float(&buf[4]);
- val.position.z = decode_float(&buf[8]);
- val.size.x = decode_float(&buf[12]);
- val.size.y = decode_float(&buf[16]);
- val.size.z = decode_float(&buf[20]);
- r_variant = val;
+ if (type & ENCODE_FLAG_64) {
+ ERR_FAIL_COND_V((size_t)len < sizeof(double) * 6, ERR_INVALID_DATA);
+ val.position.x = decode_double(&buf[0]);
+ val.position.y = decode_double(&buf[sizeof(double)]);
+ val.position.z = decode_double(&buf[sizeof(double) * 2]);
+ val.size.x = decode_double(&buf[sizeof(double) * 3]);
+ val.size.y = decode_double(&buf[sizeof(double) * 4]);
+ val.size.z = decode_double(&buf[sizeof(double) * 5]);
- if (r_len) {
- (*r_len) += 4 * 6;
+ if (r_len) {
+ (*r_len) += sizeof(double) * 6;
+ }
+ } else {
+ ERR_FAIL_COND_V((size_t)len < sizeof(float) * 6, ERR_INVALID_DATA);
+ val.position.x = decode_float(&buf[0]);
+ val.position.y = decode_float(&buf[sizeof(float)]);
+ val.position.z = decode_float(&buf[sizeof(float) * 2]);
+ val.size.x = decode_float(&buf[sizeof(float) * 3]);
+ val.size.y = decode_float(&buf[sizeof(float) * 4]);
+ val.size.z = decode_float(&buf[sizeof(float) * 5]);
+
+ if (r_len) {
+ (*r_len) += sizeof(float) * 6;
+ }
}
+ r_variant = val;
} break;
case Variant::BASIS: {
- ERR_FAIL_COND_V(len < 4 * 9, ERR_INVALID_DATA);
Basis val;
- for (int i = 0; i < 3; i++) {
- for (int j = 0; j < 3; j++) {
- val.elements[i][j] = decode_float(&buf[(i * 3 + j) * 4]);
+ if (type & ENCODE_FLAG_64) {
+ ERR_FAIL_COND_V((size_t)len < sizeof(double) * 9, ERR_INVALID_DATA);
+ for (int i = 0; i < 3; i++) {
+ for (int j = 0; j < 3; j++) {
+ val.elements[i][j] = decode_double(&buf[(i * 3 + j) * sizeof(double)]);
+ }
}
- }
- r_variant = val;
+ if (r_len) {
+ (*r_len) += sizeof(double) * 9;
+ }
+ } else {
+ ERR_FAIL_COND_V((size_t)len < sizeof(float) * 9, ERR_INVALID_DATA);
+ for (int i = 0; i < 3; i++) {
+ for (int j = 0; j < 3; j++) {
+ val.elements[i][j] = decode_float(&buf[(i * 3 + j) * sizeof(float)]);
+ }
+ }
- if (r_len) {
- (*r_len) += 4 * 9;
+ if (r_len) {
+ (*r_len) += sizeof(float) * 9;
+ }
}
+ r_variant = val;
} break;
case Variant::TRANSFORM3D: {
- ERR_FAIL_COND_V(len < 4 * 12, ERR_INVALID_DATA);
Transform3D val;
- for (int i = 0; i < 3; i++) {
- for (int j = 0; j < 3; j++) {
- val.basis.elements[i][j] = decode_float(&buf[(i * 3 + j) * 4]);
+ if (type & ENCODE_FLAG_64) {
+ ERR_FAIL_COND_V((size_t)len < sizeof(double) * 12, ERR_INVALID_DATA);
+ for (int i = 0; i < 3; i++) {
+ for (int j = 0; j < 3; j++) {
+ val.basis.elements[i][j] = decode_double(&buf[(i * 3 + j) * sizeof(double)]);
+ }
}
- }
- val.origin[0] = decode_float(&buf[36]);
- val.origin[1] = decode_float(&buf[40]);
- val.origin[2] = decode_float(&buf[44]);
+ val.origin[0] = decode_double(&buf[sizeof(double) * 9]);
+ val.origin[1] = decode_double(&buf[sizeof(double) * 10]);
+ val.origin[2] = decode_double(&buf[sizeof(double) * 11]);
- r_variant = val;
+ if (r_len) {
+ (*r_len) += sizeof(double) * 12;
+ }
+ } else {
+ ERR_FAIL_COND_V((size_t)len < sizeof(float) * 12, ERR_INVALID_DATA);
+ for (int i = 0; i < 3; i++) {
+ for (int j = 0; j < 3; j++) {
+ val.basis.elements[i][j] = decode_float(&buf[(i * 3 + j) * sizeof(float)]);
+ }
+ }
+ val.origin[0] = decode_float(&buf[sizeof(float) * 9]);
+ val.origin[1] = decode_float(&buf[sizeof(float) * 10]);
+ val.origin[2] = decode_float(&buf[sizeof(float) * 11]);
- if (r_len) {
- (*r_len) += 4 * 12;
+ if (r_len) {
+ (*r_len) += sizeof(float) * 12;
+ }
}
+ r_variant = val;
} break;
-
// misc types
case Variant::COLOR: {
ERR_FAIL_COND_V(len < 4 * 4, ERR_INVALID_DATA);
@@ -356,9 +468,8 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
r_variant = val;
if (r_len) {
- (*r_len) += 4 * 4;
+ (*r_len) += 4 * 4; // Colors should always be in single-precision.
}
-
} break;
case Variant::STRING_NAME: {
String str;
@@ -436,7 +547,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
r_variant = (Object *)nullptr;
} else {
Ref<EncodedObjectAsID> obj_as_id;
- obj_as_id.instance();
+ obj_as_id.instantiate();
obj_as_id->set_object_id(val);
r_variant = obj_as_id;
@@ -454,7 +565,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
if (str == String()) {
r_variant = (Object *)nullptr;
} else {
- Object *obj = ClassDB::instance(str);
+ Object *obj = ClassDB::instantiate(str);
ERR_FAIL_COND_V(!obj, ERR_UNAVAILABLE);
ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
@@ -463,7 +574,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
buf += 4;
len -= 4;
if (r_len) {
- (*r_len) += 4;
+ (*r_len) += 4; // Size of count number.
}
for (int i = 0; i < count; i++) {
@@ -516,7 +627,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
len -= 4;
if (r_len) {
- (*r_len) += 4;
+ (*r_len) += 4; // Size of count number.
}
Dictionary d;
@@ -559,7 +670,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
len -= 4;
if (r_len) {
- (*r_len) += 4;
+ (*r_len) += 4; // Size of count number.
}
Array varr;
@@ -716,9 +827,8 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
len -= 4;
if (r_len) {
- (*r_len) += 4;
+ (*r_len) += 4; // Size of count number.
}
- //printf("string count: %i\n",count);
for (int32_t i = 0; i < count; i++) {
String str;
@@ -739,30 +849,57 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
buf += 4;
len -= 4;
- ERR_FAIL_MUL_OF(count, 4 * 2, ERR_INVALID_DATA);
- ERR_FAIL_COND_V(count < 0 || count * 4 * 2 > len, ERR_INVALID_DATA);
Vector<Vector2> varray;
- if (r_len) {
- (*r_len) += 4;
- }
-
- if (count) {
- varray.resize(count);
- Vector2 *w = varray.ptrw();
+ if (type & ENCODE_FLAG_64) {
+ ERR_FAIL_MUL_OF(count, sizeof(double) * 2, ERR_INVALID_DATA);
+ ERR_FAIL_COND_V(count < 0 || count * sizeof(double) * 2 > (size_t)len, ERR_INVALID_DATA);
- for (int32_t i = 0; i < count; i++) {
- w[i].x = decode_float(buf + i * 4 * 2 + 4 * 0);
- w[i].y = decode_float(buf + i * 4 * 2 + 4 * 1);
+ if (r_len) {
+ (*r_len) += 4; // Size of count number.
}
- int adv = 4 * 2 * count;
+ if (count) {
+ varray.resize(count);
+ Vector2 *w = varray.ptrw();
+
+ for (int32_t i = 0; i < count; i++) {
+ w[i].x = decode_double(buf + i * sizeof(double) * 2 + sizeof(double) * 0);
+ w[i].y = decode_double(buf + i * sizeof(double) * 2 + sizeof(double) * 1);
+ }
+
+ int adv = sizeof(double) * 2 * count;
+
+ if (r_len) {
+ (*r_len) += adv;
+ }
+ len -= adv;
+ buf += adv;
+ }
+ } else {
+ ERR_FAIL_MUL_OF(count, sizeof(float) * 2, ERR_INVALID_DATA);
+ ERR_FAIL_COND_V(count < 0 || count * sizeof(float) * 2 > (size_t)len, ERR_INVALID_DATA);
if (r_len) {
- (*r_len) += adv;
+ (*r_len) += 4; // Size of count number.
}
- }
+ if (count) {
+ varray.resize(count);
+ Vector2 *w = varray.ptrw();
+
+ for (int32_t i = 0; i < count; i++) {
+ w[i].x = decode_float(buf + i * sizeof(float) * 2 + sizeof(float) * 0);
+ w[i].y = decode_float(buf + i * sizeof(float) * 2 + sizeof(float) * 1);
+ }
+
+ int adv = sizeof(float) * 2 * count;
+
+ if (r_len) {
+ (*r_len) += adv;
+ }
+ }
+ }
r_variant = varray;
} break;
@@ -772,32 +909,61 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
buf += 4;
len -= 4;
- ERR_FAIL_MUL_OF(count, 4 * 3, ERR_INVALID_DATA);
- ERR_FAIL_COND_V(count < 0 || count * 4 * 3 > len, ERR_INVALID_DATA);
-
Vector<Vector3> varray;
- if (r_len) {
- (*r_len) += 4;
- }
-
- if (count) {
- varray.resize(count);
- Vector3 *w = varray.ptrw();
+ if (type & ENCODE_FLAG_64) {
+ ERR_FAIL_MUL_OF(count, sizeof(double) * 3, ERR_INVALID_DATA);
+ ERR_FAIL_COND_V(count < 0 || count * sizeof(double) * 3 > (size_t)len, ERR_INVALID_DATA);
- for (int32_t i = 0; i < count; i++) {
- w[i].x = decode_float(buf + i * 4 * 3 + 4 * 0);
- w[i].y = decode_float(buf + i * 4 * 3 + 4 * 1);
- w[i].z = decode_float(buf + i * 4 * 3 + 4 * 2);
+ if (r_len) {
+ (*r_len) += 4; // Size of count number.
}
- int adv = 4 * 3 * count;
+ if (count) {
+ varray.resize(count);
+ Vector3 *w = varray.ptrw();
+
+ for (int32_t i = 0; i < count; i++) {
+ w[i].x = decode_double(buf + i * sizeof(double) * 3 + sizeof(double) * 0);
+ w[i].y = decode_double(buf + i * sizeof(double) * 3 + sizeof(double) * 1);
+ w[i].z = decode_double(buf + i * sizeof(double) * 3 + sizeof(double) * 2);
+ }
+
+ int adv = sizeof(double) * 3 * count;
+
+ if (r_len) {
+ (*r_len) += adv;
+ }
+ len -= adv;
+ buf += adv;
+ }
+ } else {
+ ERR_FAIL_MUL_OF(count, sizeof(float) * 3, ERR_INVALID_DATA);
+ ERR_FAIL_COND_V(count < 0 || count * sizeof(float) * 3 > (size_t)len, ERR_INVALID_DATA);
if (r_len) {
- (*r_len) += adv;
+ (*r_len) += 4; // Size of count number.
}
- }
+ if (count) {
+ varray.resize(count);
+ Vector3 *w = varray.ptrw();
+
+ for (int32_t i = 0; i < count; i++) {
+ w[i].x = decode_float(buf + i * sizeof(float) * 3 + sizeof(float) * 0);
+ w[i].y = decode_float(buf + i * sizeof(float) * 3 + sizeof(float) * 1);
+ w[i].z = decode_float(buf + i * sizeof(float) * 3 + sizeof(float) * 2);
+ }
+
+ int adv = sizeof(float) * 3 * count;
+
+ if (r_len) {
+ (*r_len) += adv;
+ }
+ len -= adv;
+ buf += adv;
+ }
+ }
r_variant = varray;
} break;
@@ -813,7 +979,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
Vector<Color> carray;
if (r_len) {
- (*r_len) += 4;
+ (*r_len) += 4; // Size of count number.
}
if (count) {
@@ -821,6 +987,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
Color *w = carray.ptrw();
for (int32_t i = 0; i < count; i++) {
+ // Colors should always be in single-precision.
w[i].r = decode_float(buf + i * 4 * 4 + 4 * 0);
w[i].g = decode_float(buf + i * 4 * 4 + 4 * 1);
w[i].b = decode_float(buf + i * 4 * 4 + 4 * 2);
@@ -882,7 +1049,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
double d = p_variant;
float f = d;
if (double(f) != d) {
- flags |= ENCODE_FLAG_64; //always encode real as double
+ flags |= ENCODE_FLAG_64;
}
} break;
case Variant::OBJECT: {
@@ -1013,11 +1180,11 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
case Variant::VECTOR2: {
if (buf) {
Vector2 v2 = p_variant;
- encode_float(v2.x, &buf[0]);
- encode_float(v2.y, &buf[4]);
+ encode_real(v2.x, &buf[0]);
+ encode_real(v2.y, &buf[sizeof(real_t)]);
}
- r_len += 2 * 4;
+ r_len += 2 * sizeof(real_t);
} break;
case Variant::VECTOR2I: {
@@ -1033,12 +1200,12 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
case Variant::RECT2: {
if (buf) {
Rect2 r2 = p_variant;
- encode_float(r2.position.x, &buf[0]);
- encode_float(r2.position.y, &buf[4]);
- encode_float(r2.size.x, &buf[8]);
- encode_float(r2.size.y, &buf[12]);
+ encode_real(r2.position.x, &buf[0]);
+ encode_real(r2.position.y, &buf[sizeof(real_t)]);
+ encode_real(r2.size.x, &buf[sizeof(real_t) * 2]);
+ encode_real(r2.size.y, &buf[sizeof(real_t) * 3]);
}
- r_len += 4 * 4;
+ r_len += 4 * sizeof(real_t);
} break;
case Variant::RECT2I: {
@@ -1055,12 +1222,12 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
case Variant::VECTOR3: {
if (buf) {
Vector3 v3 = p_variant;
- encode_float(v3.x, &buf[0]);
- encode_float(v3.y, &buf[4]);
- encode_float(v3.z, &buf[8]);
+ encode_real(v3.x, &buf[0]);
+ encode_real(v3.y, &buf[sizeof(real_t)]);
+ encode_real(v3.z, &buf[sizeof(real_t) * 2]);
}
- r_len += 3 * 4;
+ r_len += 3 * sizeof(real_t);
} break;
case Variant::VECTOR3I: {
@@ -1079,50 +1246,50 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
Transform2D val = p_variant;
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 2; j++) {
- memcpy(&buf[(i * 2 + j) * 4], &val.elements[i][j], sizeof(float));
+ memcpy(&buf[(i * 2 + j) * sizeof(real_t)], &val.elements[i][j], sizeof(real_t));
}
}
}
- r_len += 6 * 4;
+ r_len += 6 * sizeof(real_t);
} break;
case Variant::PLANE: {
if (buf) {
Plane p = p_variant;
- encode_float(p.normal.x, &buf[0]);
- encode_float(p.normal.y, &buf[4]);
- encode_float(p.normal.z, &buf[8]);
- encode_float(p.d, &buf[12]);
+ encode_real(p.normal.x, &buf[0]);
+ encode_real(p.normal.y, &buf[sizeof(real_t)]);
+ encode_real(p.normal.z, &buf[sizeof(real_t) * 2]);
+ encode_real(p.d, &buf[sizeof(real_t) * 3]);
}
- r_len += 4 * 4;
+ r_len += 4 * sizeof(real_t);
} break;
case Variant::QUATERNION: {
if (buf) {
Quaternion q = p_variant;
- encode_float(q.x, &buf[0]);
- encode_float(q.y, &buf[4]);
- encode_float(q.z, &buf[8]);
- encode_float(q.w, &buf[12]);
+ encode_real(q.x, &buf[0]);
+ encode_real(q.y, &buf[sizeof(real_t)]);
+ encode_real(q.z, &buf[sizeof(real_t) * 2]);
+ encode_real(q.w, &buf[sizeof(real_t) * 3]);
}
- r_len += 4 * 4;
+ r_len += 4 * sizeof(real_t);
} break;
case Variant::AABB: {
if (buf) {
AABB aabb = p_variant;
- encode_float(aabb.position.x, &buf[0]);
- encode_float(aabb.position.y, &buf[4]);
- encode_float(aabb.position.z, &buf[8]);
- encode_float(aabb.size.x, &buf[12]);
- encode_float(aabb.size.y, &buf[16]);
- encode_float(aabb.size.z, &buf[20]);
+ encode_real(aabb.position.x, &buf[0]);
+ encode_real(aabb.position.y, &buf[sizeof(real_t)]);
+ encode_real(aabb.position.z, &buf[sizeof(real_t) * 2]);
+ encode_real(aabb.size.x, &buf[sizeof(real_t) * 3]);
+ encode_real(aabb.size.y, &buf[sizeof(real_t) * 4]);
+ encode_real(aabb.size.z, &buf[sizeof(real_t) * 5]);
}
- r_len += 6 * 4;
+ r_len += 6 * sizeof(real_t);
} break;
case Variant::BASIS: {
@@ -1130,12 +1297,12 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
Basis val = p_variant;
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
- memcpy(&buf[(i * 3 + j) * 4], &val.elements[i][j], sizeof(float));
+ memcpy(&buf[(i * 3 + j) * sizeof(real_t)], &val.elements[i][j], sizeof(real_t));
}
}
}
- r_len += 9 * 4;
+ r_len += 9 * sizeof(real_t);
} break;
case Variant::TRANSFORM3D: {
@@ -1143,16 +1310,16 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
Transform3D val = p_variant;
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
- memcpy(&buf[(i * 3 + j) * 4], &val.basis.elements[i][j], sizeof(float));
+ memcpy(&buf[(i * 3 + j) * sizeof(real_t)], &val.basis.elements[i][j], sizeof(real_t));
}
}
- encode_float(val.origin.x, &buf[36]);
- encode_float(val.origin.y, &buf[40]);
- encode_float(val.origin.z, &buf[44]);
+ encode_real(val.origin.x, &buf[sizeof(real_t) * 9]);
+ encode_real(val.origin.y, &buf[sizeof(real_t) * 10]);
+ encode_real(val.origin.z, &buf[sizeof(real_t) * 11]);
}
- r_len += 12 * 4;
+ r_len += 12 * sizeof(real_t);
} break;
@@ -1166,7 +1333,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
encode_float(c.a, &buf[12]);
}
- r_len += 4 * 4;
+ r_len += 4 * 4; // Colors should always be in single-precision.
} break;
case Variant::RID: {
@@ -1441,13 +1608,13 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
for (int i = 0; i < len; i++) {
Vector2 v = data.get(i);
- encode_float(v.x, &buf[0]);
- encode_float(v.y, &buf[4]);
- buf += 4 * 2;
+ encode_real(v.x, &buf[0]);
+ encode_real(v.y, &buf[sizeof(real_t)]);
+ buf += sizeof(real_t) * 2;
}
}
- r_len += 4 * 2 * len;
+ r_len += sizeof(real_t) * 2 * len;
} break;
case Variant::PACKED_VECTOR3_ARRAY: {
@@ -1465,14 +1632,14 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
for (int i = 0; i < len; i++) {
Vector3 v = data.get(i);
- encode_float(v.x, &buf[0]);
- encode_float(v.y, &buf[4]);
- encode_float(v.z, &buf[8]);
- buf += 4 * 3;
+ encode_real(v.x, &buf[0]);
+ encode_real(v.y, &buf[sizeof(real_t)]);
+ encode_real(v.z, &buf[sizeof(real_t) * 2]);
+ buf += sizeof(real_t) * 3;
}
}
- r_len += 4 * 3 * len;
+ r_len += sizeof(real_t) * 3 * len;
} break;
case Variant::PACKED_COLOR_ARRAY: {
@@ -1494,7 +1661,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
encode_float(c.g, &buf[4]);
encode_float(c.b, &buf[8]);
encode_float(c.a, &buf[12]);
- buf += 4 * 4;
+ buf += 4 * 4; // Colors should always be in single-precision.
}
}
diff --git a/core/io/marshalls.h b/core/io/marshalls.h
index 7fac708f97..3ebed914a3 100644
--- a/core/io/marshalls.h
+++ b/core/io/marshalls.h
@@ -31,10 +31,18 @@
#ifndef MARSHALLS_H
#define MARSHALLS_H
+#include "core/math/math_defs.h"
#include "core/object/ref_counted.h"
#include "core/typedefs.h"
#include "core/variant/variant.h"
+// uintr_t is only for pairing with real_t, and we only need it in here.
+#ifdef REAL_T_IS_DOUBLE
+typedef uint64_t uintr_t;
+#else
+typedef uint32_t uintr_t;
+#endif
+
/**
* Miscellaneous helpers for marshalling data types, and encoding
* in an endian independent way
@@ -50,6 +58,12 @@ union MarshallDouble {
double d; ///< double
};
+// Behaves like one of the above, depending on compilation setting.
+union MarshallReal {
+ uintr_t i;
+ real_t r;
+};
+
static inline unsigned int encode_uint16(uint16_t p_uint, uint8_t *p_arr) {
for (int i = 0; i < 2; i++) {
*p_arr = p_uint & 0xFF;
@@ -96,6 +110,24 @@ static inline unsigned int encode_double(double p_double, uint8_t *p_arr) {
return sizeof(uint64_t);
}
+static inline unsigned int encode_uintr(uintr_t p_uint, uint8_t *p_arr) {
+ for (size_t i = 0; i < sizeof(uintr_t); i++) {
+ *p_arr = p_uint & 0xFF;
+ p_arr++;
+ p_uint >>= 8;
+ }
+
+ return sizeof(uintr_t);
+}
+
+static inline unsigned int encode_real(real_t p_real, uint8_t *p_arr) {
+ MarshallReal mr;
+ mr.r = p_real;
+ encode_uintr(mr.i, p_arr);
+
+ return sizeof(uintr_t);
+}
+
static inline int encode_cstring(const char *p_string, uint8_t *p_data) {
int len = 0;
diff --git a/core/io/multiplayer_api.cpp b/core/io/multiplayer_api.cpp
index 78ec7ea21a..51ba8800e4 100644
--- a/core/io/multiplayer_api.cpp
+++ b/core/io/multiplayer_api.cpp
@@ -1123,8 +1123,8 @@ void MultiplayerAPI::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_object_decoding"), "set_allow_object_decoding", "is_object_decoding_allowed");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "refuse_new_network_connections"), "set_refuse_new_network_connections", "is_refusing_new_network_connections");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "network_peer", PROPERTY_HINT_RESOURCE_TYPE, "NetworkedMultiplayerPeer", 0), "set_network_peer", "get_network_peer");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "root_node", PROPERTY_HINT_RESOURCE_TYPE, "Node", 0), "set_root_node", "get_root_node");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "network_peer", PROPERTY_HINT_RESOURCE_TYPE, "NetworkedMultiplayerPeer", PROPERTY_USAGE_NONE), "set_network_peer", "get_network_peer");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "root_node", PROPERTY_HINT_RESOURCE_TYPE, "Node", PROPERTY_USAGE_NONE), "set_root_node", "get_root_node");
ADD_PROPERTY_DEFAULT("refuse_new_network_connections", false);
ADD_SIGNAL(MethodInfo("network_peer_connected", PropertyInfo(Variant::INT, "id")));
diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp
index 318fd10243..8da44fd290 100644
--- a/core/io/packet_peer.cpp
+++ b/core/io/packet_peer.cpp
@@ -161,7 +161,7 @@ void PacketPeerStream::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "input_buffer_max_size"), "set_input_buffer_max_size", "get_input_buffer_max_size");
ADD_PROPERTY(PropertyInfo(Variant::INT, "output_buffer_max_size"), "set_output_buffer_max_size", "get_output_buffer_max_size");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "stream_peer", PROPERTY_HINT_RESOURCE_TYPE, "StreamPeer", 0), "set_stream_peer", "get_stream_peer");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "stream_peer", PROPERTY_HINT_RESOURCE_TYPE, "StreamPeer", PROPERTY_USAGE_NONE), "set_stream_peer", "get_stream_peer");
}
Error PacketPeerStream::_poll_buffer() const {
diff --git a/core/io/resource.cpp b/core/io/resource.cpp
index b970e85c99..efa622d976 100644
--- a/core/io/resource.cpp
+++ b/core/io/resource.cpp
@@ -164,7 +164,7 @@ Ref<Resource> Resource::duplicate_for_local_scene(Node *p_for_scene, Map<Ref<Res
List<PropertyInfo> plist;
get_property_list(&plist);
- Ref<Resource> r = Object::cast_to<Resource>(ClassDB::instance(get_class()));
+ Ref<Resource> r = Object::cast_to<Resource>(ClassDB::instantiate(get_class()));
ERR_FAIL_COND_V(r.is_null(), Ref<Resource>());
r->local_scene = p_for_scene;
@@ -224,7 +224,7 @@ Ref<Resource> Resource::duplicate(bool p_subresources) const {
List<PropertyInfo> plist;
get_property_list(&plist);
- Ref<Resource> r = (Resource *)ClassDB::instance(get_class());
+ Ref<Resource> r = (Resource *)ClassDB::instantiate(get_class());
ERR_FAIL_COND_V(r.is_null(), Ref<Resource>());
for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index f83ba30514..0e9815245f 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -704,7 +704,7 @@ Error ResourceLoaderBinary::load() {
if (res.is_null()) {
//did not replace
- Object *obj = ClassDB::instance(t);
+ Object *obj = ClassDB::instantiate(t);
if (!obj) {
error = ERR_FILE_CORRUPT;
ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, local_path + ":Resource of unrecognized type in file: " + t + ".");
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index 1700766cbf..c5dfe1f2b0 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -1045,7 +1045,7 @@ bool ResourceLoader::add_custom_resource_format_loader(String script_path) {
bool valid_type = ClassDB::is_parent_class(ibt, "ResourceFormatLoader");
ERR_FAIL_COND_V_MSG(!valid_type, false, "Script does not inherit a CustomResourceLoader: " + script_path + ".");
- Object *obj = ClassDB::instance(ibt);
+ Object *obj = ClassDB::instantiate(ibt);
ERR_FAIL_COND_V_MSG(obj == nullptr, false, "Cannot instance script as custom resource loader, expected 'ResourceFormatLoader' inheritance, got: " + String(ibt) + ".");
diff --git a/core/io/resource_saver.cpp b/core/io/resource_saver.cpp
index 389a4fdbbd..80cb85fba3 100644
--- a/core/io/resource_saver.cpp
+++ b/core/io/resource_saver.cpp
@@ -210,7 +210,7 @@ bool ResourceSaver::add_custom_resource_format_saver(String script_path) {
bool valid_type = ClassDB::is_parent_class(ibt, "ResourceFormatSaver");
ERR_FAIL_COND_V_MSG(!valid_type, false, "Script does not inherit a CustomResourceSaver: " + script_path + ".");
- Object *obj = ClassDB::instance(ibt);
+ Object *obj = ClassDB::instantiate(ibt);
ERR_FAIL_COND_V_MSG(obj == nullptr, false, "Cannot instance script as custom resource saver, expected 'ResourceFormatSaver' inheritance, got: " + String(ibt) + ".");
diff --git a/core/io/stream_peer.cpp b/core/io/stream_peer.cpp
index ee5e9eca0c..27f8d4e88f 100644
--- a/core/io/stream_peer.cpp
+++ b/core/io/stream_peer.cpp
@@ -512,7 +512,7 @@ void StreamPeerBuffer::clear() {
Ref<StreamPeerBuffer> StreamPeerBuffer::duplicate() const {
Ref<StreamPeerBuffer> spb;
- spb.instance();
+ spb.instantiate();
spb->data = data;
return spb;
}
diff --git a/core/math/basis.h b/core/math/basis.h
index 3736047dd3..2889a4aa5e 100644
--- a/core/math/basis.h
+++ b/core/math/basis.h
@@ -158,8 +158,8 @@ public:
_FORCE_INLINE_ Basis operator+(const Basis &p_matrix) const;
_FORCE_INLINE_ void operator-=(const Basis &p_matrix);
_FORCE_INLINE_ Basis operator-(const Basis &p_matrix) const;
- _FORCE_INLINE_ void operator*=(real_t p_val);
- _FORCE_INLINE_ Basis operator*(real_t p_val) const;
+ _FORCE_INLINE_ void operator*=(const real_t p_val);
+ _FORCE_INLINE_ Basis operator*(const real_t p_val) const;
int get_orthogonal_index() const;
void set_orthogonal_index(int p_index);
@@ -298,13 +298,13 @@ _FORCE_INLINE_ Basis Basis::operator-(const Basis &p_matrix) const {
return ret;
}
-_FORCE_INLINE_ void Basis::operator*=(real_t p_val) {
+_FORCE_INLINE_ void Basis::operator*=(const real_t p_val) {
elements[0] *= p_val;
elements[1] *= p_val;
elements[2] *= p_val;
}
-_FORCE_INLINE_ Basis Basis::operator*(real_t p_val) const {
+_FORCE_INLINE_ Basis Basis::operator*(const real_t p_val) const {
Basis ret(*this);
ret *= p_val;
return ret;
diff --git a/core/math/geometry_2d.h b/core/math/geometry_2d.h
index 4958b5ac6a..a2894bc1d3 100644
--- a/core/math/geometry_2d.h
+++ b/core/math/geometry_2d.h
@@ -362,6 +362,19 @@ public:
return (intersections & 1);
}
+ static bool is_segment_intersecting_polygon(const Vector2 &p_from, const Vector2 &p_to, const Vector<Vector2> &p_polygon) {
+ int c = p_polygon.size();
+ const Vector2 *p = p_polygon.ptr();
+ for (int i = 0; i < c; i++) {
+ const Vector2 &v1 = p[i];
+ const Vector2 &v2 = p[(i + 1) % c];
+ if (segment_intersects_segment(p_from, p_to, v1, v2, nullptr)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
static real_t vec2_cross(const Point2 &O, const Point2 &A, const Point2 &B) {
return (real_t)(A.x - O.x) * (B.y - O.y) - (real_t)(A.y - O.y) * (B.x - O.x);
}
diff --git a/core/math/quaternion.cpp b/core/math/quaternion.cpp
index 7037db7112..3f1d2c58e5 100644
--- a/core/math/quaternion.cpp
+++ b/core/math/quaternion.cpp
@@ -33,6 +33,11 @@
#include "core/math/basis.h"
#include "core/string/print_string.h"
+real_t Quaternion::angle_to(const Quaternion &p_to) const {
+ real_t d = dot(p_to);
+ return Math::acos(CLAMP(d * d * 2 - 1, -1, 1));
+}
+
// get_euler_xyz returns a vector containing the Euler angles in the format
// (ax,ay,az), where ax is the angle of rotation around x axis,
// and similar for other axes.
diff --git a/core/math/quaternion.h b/core/math/quaternion.h
index 796214b79e..35324323b3 100644
--- a/core/math/quaternion.h
+++ b/core/math/quaternion.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef QUAT_H
-#define QUAT_H
+#ifndef QUATERNION_H
+#define QUATERNION_H
#include "core/math/math_defs.h"
#include "core/math/math_funcs.h"
@@ -62,6 +62,7 @@ public:
bool is_normalized() const;
Quaternion inverse() const;
_FORCE_INLINE_ real_t dot(const Quaternion &p_q) const;
+ real_t angle_to(const Quaternion &p_to) const;
Vector3 get_euler_xyz() const;
Vector3 get_euler_yxz() const;
@@ -235,4 +236,4 @@ _FORCE_INLINE_ Quaternion operator*(const real_t &p_real, const Quaternion &p_qu
return p_quaternion * p_real;
}
-#endif // QUAT_H
+#endif // QUATERNION_H
diff --git a/core/math/transform_2d.cpp b/core/math/transform_2d.cpp
index 0140f31b8a..16934d67df 100644
--- a/core/math/transform_2d.cpp
+++ b/core/math/transform_2d.cpp
@@ -276,6 +276,18 @@ Transform2D Transform2D::interpolate_with(const Transform2D &p_transform, real_t
return res;
}
+void Transform2D::operator*=(const real_t p_val) {
+ elements[0] *= p_val;
+ elements[1] *= p_val;
+ elements[2] *= p_val;
+}
+
+Transform2D Transform2D::operator*(const real_t p_val) const {
+ Transform2D ret(*this);
+ ret *= p_val;
+ return ret;
+}
+
Transform2D::operator String() const {
return "[X: " + elements[0].operator String() +
", Y: " + elements[1].operator String() +
diff --git a/core/math/transform_2d.h b/core/math/transform_2d.h
index 715f013701..34cfd0c1a9 100644
--- a/core/math/transform_2d.h
+++ b/core/math/transform_2d.h
@@ -107,6 +107,8 @@ struct Transform2D {
void operator*=(const Transform2D &p_transform);
Transform2D operator*(const Transform2D &p_transform) const;
+ void operator*=(const real_t p_val);
+ Transform2D operator*(const real_t p_val) const;
Transform2D interpolate_with(const Transform2D &p_transform, real_t p_c) const;
diff --git a/core/math/transform_3d.cpp b/core/math/transform_3d.cpp
index a34d998dde..51766b39f4 100644
--- a/core/math/transform_3d.cpp
+++ b/core/math/transform_3d.cpp
@@ -190,6 +190,17 @@ Transform3D Transform3D::operator*(const Transform3D &p_transform) const {
return t;
}
+void Transform3D::operator*=(const real_t p_val) {
+ origin *= p_val;
+ basis *= p_val;
+}
+
+Transform3D Transform3D::operator*(const real_t p_val) const {
+ Transform3D ret(*this);
+ ret *= p_val;
+ return ret;
+}
+
Transform3D::operator String() const {
return "[X: " + basis.get_axis(0).operator String() +
", Y: " + basis.get_axis(1).operator String() +
diff --git a/core/math/transform_3d.h b/core/math/transform_3d.h
index 078a2ca11a..3d8e70cec7 100644
--- a/core/math/transform_3d.h
+++ b/core/math/transform_3d.h
@@ -88,6 +88,8 @@ public:
void operator*=(const Transform3D &p_transform);
Transform3D operator*(const Transform3D &p_transform) const;
+ void operator*=(const real_t p_val);
+ Transform3D operator*(const real_t p_val) const;
Transform3D interpolate_with(const Transform3D &p_transform, real_t p_c) const;
diff --git a/core/object/SCsub b/core/object/SCsub
index 5d429960e5..dc116aeb19 100644
--- a/core/object/SCsub
+++ b/core/object/SCsub
@@ -2,6 +2,11 @@
Import("env")
+import make_virtuals
+from platform_methods import run_in_subprocess
+
+env.CommandNoCache(["gdvirtual.gen.inc"], "make_virtuals.py", run_in_subprocess(make_virtuals.run))
+
env_object = env.Clone()
env_object.add_source_files(env.core_sources, "*.cpp")
diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp
index 5bf874ccae..a10405dfae 100644
--- a/core/object/class_db.cpp
+++ b/core/object/class_db.cpp
@@ -503,9 +503,9 @@ void ClassDB::add_compatibility_class(const StringName &p_class, const StringNam
thread_local bool initializing_with_extension = false;
thread_local ObjectNativeExtension *initializing_extension = nullptr;
-thread_local void *initializing_extension_instance = nullptr;
+thread_local GDExtensionClassInstancePtr initializing_extension_instance = nullptr;
-void ClassDB::instance_get_native_extension_data(ObjectNativeExtension **r_extension, void **r_extension_instance) {
+void ClassDB::instance_get_native_extension_data(ObjectNativeExtension **r_extension, GDExtensionClassInstancePtr *r_extension_instance) {
if (initializing_with_extension) {
*r_extension = initializing_extension;
*r_extension_instance = initializing_extension_instance;
@@ -516,7 +516,7 @@ void ClassDB::instance_get_native_extension_data(ObjectNativeExtension **r_exten
}
}
-Object *ClassDB::instance(const StringName &p_class) {
+Object *ClassDB::instantiate(const StringName &p_class) {
ClassInfo *ti;
{
OBJTYPE_RLOCK;
@@ -539,12 +539,12 @@ Object *ClassDB::instance(const StringName &p_class) {
if (ti->native_extension) {
initializing_with_extension = true;
initializing_extension = ti->native_extension;
- initializing_extension_instance = ti->native_extension->create_instance(ti->native_extension->create_instance_userdata);
+ initializing_extension_instance = ti->native_extension->create_instance(ti->native_extension->class_userdata);
}
return ti->creation_func();
}
-bool ClassDB::can_instance(const StringName &p_class) {
+bool ClassDB::can_instantiate(const StringName &p_class) {
OBJTYPE_RLOCK;
ClassInfo *ti = classes.getptr(p_class);
@@ -1522,8 +1522,8 @@ Variant ClassDB::class_get_default_property_value(const StringName &p_class, con
if (Engine::get_singleton()->has_singleton(p_class)) {
c = Engine::get_singleton()->get_singleton_object(p_class);
cleanup_c = false;
- } else if (ClassDB::can_instance(p_class)) {
- c = ClassDB::instance(p_class);
+ } else if (ClassDB::can_instantiate(p_class)) {
+ c = ClassDB::instantiate(p_class);
cleanup_c = true;
}
@@ -1603,6 +1603,11 @@ void ClassDB::register_extension_class(ObjectNativeExtension *p_extension) {
classes[p_extension->class_name] = c;
}
+void ClassDB::unregister_extension_class(const StringName &p_class) {
+ ERR_FAIL_COND(!classes.has(p_class));
+ classes.erase(p_class);
+}
+
RWLock ClassDB::lock;
void ClassDB::cleanup_defaults() {
diff --git a/core/object/class_db.h b/core/object/class_db.h
index 4355c9b0ea..af528bfde7 100644
--- a/core/object/class_db.h
+++ b/core/object/class_db.h
@@ -204,6 +204,7 @@ public:
}
static void register_extension_class(ObjectNativeExtension *p_extension);
+ static void unregister_extension_class(const StringName &p_class);
template <class T>
static Object *_create_ptr_func() {
@@ -230,9 +231,10 @@ public:
static StringName get_compatibility_remapped_class(const StringName &p_class);
static bool class_exists(const StringName &p_class);
static bool is_parent_class(const StringName &p_class, const StringName &p_inherits);
- static bool can_instance(const StringName &p_class);
- static Object *instance(const StringName &p_class);
- static void instance_get_native_extension_data(ObjectNativeExtension **r_extension, void **r_extension_instance);
+ static bool can_instantiate(const StringName &p_class);
+ static Object *instantiate(const StringName &p_class);
+ static void instance_get_native_extension_data(ObjectNativeExtension **r_extension, GDExtensionClassInstancePtr *r_extension_instance);
+
static APIType get_api_type(const StringName &p_class);
static uint64_t get_api_hash(APIType p_api);
diff --git a/core/object/make_virtuals.py b/core/object/make_virtuals.py
new file mode 100644
index 0000000000..2c6b8cddc9
--- /dev/null
+++ b/core/object/make_virtuals.py
@@ -0,0 +1,152 @@
+proto = """
+#define GDVIRTUAL$VER($RET m_name $ARG) \\
+GDNativeExtensionClassCallVirtual _gdvirtual_##m_name = (_get_extension() && _get_extension()->get_virtual) ? _get_extension()->get_virtual(_get_extension()->class_userdata, #m_name) : (GDNativeExtensionClassCallVirtual) nullptr;\\
+StringName _gdvirtual_##m_name##_sn = #m_name;\\
+bool _gdvirtual_##m_name##_call($CALLARGS) $CONST { \\
+ ScriptInstance *script_instance = ((Object*)(this))->get_script_instance();\\
+ if (script_instance) {\\
+ Callable::CallError ce; \\
+ $CALLSIARGS\\
+ $CALLSIBEGINscript_instance->call(_gdvirtual_##m_name##_sn, $CALLSIARGPASS, ce);\\
+ if (ce.error == Callable::CallError::CALL_OK) {\\
+ $CALLSIRET\\
+ return true;\\
+ } \\
+ }\\
+ if (_gdvirtual_##m_name) {\\
+ $CALLPTRARGS\\
+ $CALLPTRRETDEF\\
+ _gdvirtual_##m_name(_get_extension_instance(),$CALLPTRARGPASS,$CALLPTRRETPASS);\\
+ $CALLPTRRET\\
+ return true;\\
+ }\\
+\\
+ return false;\\
+}\\
+\\
+_FORCE_INLINE_ static MethodInfo _gdvirtual_##m_name##_get_method_info() { \\
+ MethodInfo method_info;\\
+ method_info.name = #m_name;\\
+ method_info.flags = METHOD_FLAG_VIRTUAL;\\
+ $FILL_METHOD_INFO\\
+ return method_info;\\
+}
+
+
+"""
+
+
+def generate_version(argcount, const=False, returns=False):
+ s = proto
+ sproto = str(argcount)
+ method_info = ""
+ if returns:
+ sproto += "R"
+ s = s.replace("$RET", "m_ret, ")
+ s = s.replace("$CALLPTRRETDEF", "PtrToArg<m_ret>::EncodeT ret;")
+ method_info += "\tmethod_info.return_val = GetTypeInfo<m_ret>::get_class_info();\\\n"
+ else:
+ s = s.replace("$RET", "")
+ s = s.replace("$CALLPTRRETDEF", "")
+
+ if const:
+ sproto += "C"
+ s = s.replace("$CONST", "const")
+ method_info += "\tmethod_info.flags|=METHOD_FLAG_CONST;\\\n"
+ else:
+ s = s.replace("$CONST", "")
+
+ s = s.replace("$VER", sproto)
+ argtext = ""
+ callargtext = ""
+ callsiargs = ""
+ callsiargptrs = ""
+ callptrargsptr = ""
+ if argcount > 0:
+ argtext += ", "
+ callsiargs = "Variant vargs[" + str(argcount) + "]={"
+ callsiargptrs = "\t\tconst Variant *vargptrs[" + str(argcount) + "]={"
+ callptrargsptr = "\t\tconst GDNativeTypePtr argptrs[" + str(argcount) + "]={"
+ callptrargs = ""
+ for i in range(argcount):
+ if i > 0:
+ argtext += ", "
+ callargtext += ", "
+ callsiargs += ", "
+ callsiargptrs += ", "
+ callptrargs += "\t\t"
+ callptrargsptr += ", "
+ argtext += "m_type" + str(i + 1)
+ callargtext += "const m_type" + str(i + 1) + "& arg" + str(i + 1)
+ callsiargs += "Variant(arg" + str(i + 1) + ")"
+ callsiargptrs += "&vargs[" + str(i) + "]"
+ callptrargs += (
+ "PtrToArg<m_type" + str(i + 1) + ">::EncodeT argval" + str(i + 1) + " = arg" + str(i + 1) + ";\\\n"
+ )
+ callptrargsptr += "&argval" + str(i + 1)
+ method_info += "\tmethod_info.arguments.push_back(GetTypeInfo<m_type" + str(i + 1) + ">::get_class_info());\\\n"
+
+ if argcount:
+ callsiargs += "};\\\n"
+ callsiargptrs += "};\\\n"
+ s = s.replace("$CALLSIARGS", callsiargs + callsiargptrs)
+ s = s.replace("$CALLSIARGPASS", "(const Variant **)vargptrs," + str(argcount))
+ callptrargsptr += "};\\\n"
+ s = s.replace("$CALLPTRARGS", callptrargs + callptrargsptr)
+ s = s.replace("$CALLPTRARGPASS", "(const GDNativeTypePtr*)argptrs")
+ else:
+ s = s.replace("$CALLSIARGS", "")
+ s = s.replace("$CALLSIARGPASS", "nullptr, 0")
+ s = s.replace("$CALLPTRARGS", "")
+ s = s.replace("$CALLPTRARGPASS", "nullptr")
+
+ if returns:
+ if argcount > 0:
+ callargtext += ","
+ callargtext += " m_ret& r_ret"
+ s = s.replace("$CALLSIBEGIN", "Variant ret = ")
+ s = s.replace("$CALLSIRET", "r_ret = ret;")
+ s = s.replace("$CALLPTRRETPASS", "&ret")
+ s = s.replace("$CALLPTRRET", "r_ret = ret;")
+ else:
+ s = s.replace("$CALLSIBEGIN", "")
+ s = s.replace("$CALLSIRET", "")
+ s = s.replace("$CALLPTRRETPASS", "nullptr")
+ s = s.replace("$CALLPTRRET", "")
+
+ s = s.replace("$ARG", argtext)
+ s = s.replace("$CALLARGS", callargtext)
+ s = s.replace("$FILL_METHOD_INFO", method_info)
+
+ return s
+
+
+def run(target, source, env):
+
+ max_versions = 12
+
+ txt = """
+#ifndef GDVIRTUAL_GEN_H
+#define GDVIRTUAL_GEN_H
+
+
+"""
+
+ for i in range(max_versions + 1):
+
+ txt += "/* " + str(i) + " Arguments */\n\n"
+ txt += generate_version(i, False, False)
+ txt += generate_version(i, False, True)
+ txt += generate_version(i, True, False)
+ txt += generate_version(i, True, True)
+
+ txt += "#endif"
+
+ with open(target[0], "w") as f:
+ f.write(txt)
+
+
+if __name__ == "__main__":
+ from platform_methods import subprocess_main
+
+ subprocess_main(globals())
diff --git a/core/object/method_bind.cpp b/core/object/method_bind.cpp
index 9c5ed60708..c53104fe3f 100644
--- a/core/object/method_bind.cpp
+++ b/core/object/method_bind.cpp
@@ -34,6 +34,35 @@
#include "method_bind.h"
+uint32_t MethodBind::get_hash() const {
+ uint32_t hash = hash_djb2_one_32(has_return() ? 1 : 0);
+ hash = hash_djb2_one_32(get_argument_count(), hash);
+
+#ifndef _MSC_VER
+#warning This needs proper class name and argument type for hashing
+#endif
+#if 0
+
+ for (int i = (has_return() ? -1 : 0); i < get_argument_count(); i++) {
+ PropertyInfo pi = i == -1 ? get_return_info() : get_argument_info(i);
+ hash = hash_djb2_one_32(get_argument_type(i), hash);
+ if (pi.class_name != StringName()) {
+ hash = hash_djb2_one_32(pi.class_name.operator String().hash(), hash);
+ }
+ }
+#endif
+ hash = hash_djb2_one_32(get_default_argument_count(), hash);
+ for (int i = 0; i < get_default_argument_count(); i++) {
+ Variant v = get_default_argument(i);
+ hash = hash_djb2_one_32(v.hash(), hash);
+ }
+
+ hash = hash_djb2_one_32(is_const(), hash);
+ hash = hash_djb2_one_32(is_vararg(), hash);
+
+ return hash;
+}
+
#ifdef DEBUG_METHODS_ENABLED
PropertyInfo MethodBind::get_argument_info(int p_argument) const {
ERR_FAIL_INDEX_V(p_argument, get_argument_count(), PropertyInfo());
diff --git a/core/object/method_bind.h b/core/object/method_bind.h
index 7030ae201b..92b964772a 100644
--- a/core/object/method_bind.h
+++ b/core/object/method_bind.h
@@ -135,6 +135,8 @@ public:
void set_default_arguments(const Vector<Variant> &p_defargs);
+ uint32_t get_hash() const;
+
MethodBind();
virtual ~MethodBind();
};
diff --git a/core/object/object.cpp b/core/object/object.cpp
index 799e63a512..1c8db89e5e 100644
--- a/core/object/object.cpp
+++ b/core/object/object.cpp
@@ -386,12 +386,20 @@ void Object::set(const StringName &p_name, const Variant &p_value, bool *r_valid
}
if (_extension && _extension->set) {
- if (_extension->set(_extension_instance, &p_name, &p_value)) {
+// C style pointer casts should never trigger a compiler warning because the risk is assumed by the user, so GCC should keep quiet about it.
+#if defined(__GNUC__) && !defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wignored-qualifiers"
+#endif
+ if (_extension->set(_extension_instance, (const GDNativeStringNamePtr)&p_name, (const GDNativeVariantPtr)&p_value)) {
if (r_valid) {
*r_valid = true;
}
return;
}
+#if defined(__GNUC__) && !defined(__clang__)
+#pragma GCC diagnostic pop
+#endif
}
//try built-in setgetter
@@ -459,14 +467,22 @@ Variant Object::get(const StringName &p_name, bool *r_valid) const {
return ret;
}
}
-
if (_extension && _extension->get) {
- if (_extension->get(_extension_instance, &p_name, &ret)) {
+// C style pointer casts should never trigger a compiler warning because the risk is assumed by the user, so GCC should keep quiet about it.
+#if defined(__GNUC__) && !defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wignored-qualifiers"
+#endif
+
+ if (_extension->get(_extension_instance, (const GDNativeStringNamePtr)&p_name, (GDNativeVariantPtr)&ret)) {
if (r_valid) {
*r_valid = true;
}
return ret;
}
+#if defined(__GNUC__) && !defined(__clang__)
+#pragma GCC diagnostic pop
+#endif
}
//try built-in setgetter
@@ -616,7 +632,7 @@ void Object::get_property_list(List<PropertyInfo> *p_list, bool p_reversed) cons
if (_extension && _extension->get_property_list) {
uint32_t pcount;
- const ObjectNativeExtension::PInfo *pinfo = _extension->get_property_list(_extension_instance, &pcount);
+ const GDNativePropertyInfo *pinfo = _extension->get_property_list(_extension_instance, &pcount);
for (uint32_t i = 0; i < pcount; i++) {
p_list->push_back(PropertyInfo(Variant::Type(pinfo[i].type), pinfo[i].class_name, PropertyHint(pinfo[i].hint), pinfo[i].hint_string, pinfo[i].usage, pinfo[i].class_name));
}
@@ -871,7 +887,7 @@ void Object::set_script(const Variant &p_script) {
Ref<Script> s = script;
if (!s.is_null()) {
- if (s->can_instance()) {
+ if (s->can_instantiate()) {
OBJ_DEBUG_LOCK
script_instance = s->instance_create(this);
} else if (Engine::get_singleton()->is_editor_hint()) {
@@ -920,7 +936,7 @@ void Object::set_meta(const String &p_name, const Variant &p_value) {
}
Variant Object::get_meta(const String &p_name) const {
- ERR_FAIL_COND_V(!metadata.has(p_name), Variant());
+ ERR_FAIL_COND_V_MSG(!metadata.has(p_name), Variant(), "The object does not have any 'meta' values with the key '" + p_name + "'.");
return metadata[p_name];
}
@@ -1287,10 +1303,10 @@ void Object::get_signals_connected_to_this(List<Connection> *p_connections) cons
}
Error Object::connect(const StringName &p_signal, const Callable &p_callable, const Vector<Variant> &p_binds, uint32_t p_flags) {
- ERR_FAIL_COND_V(p_callable.is_null(), ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V_MSG(p_callable.is_null(), ERR_INVALID_PARAMETER, "Cannot connect to '" + p_signal + "': the provided callable is null.");
Object *target_object = p_callable.get_object();
- ERR_FAIL_COND_V(!target_object, ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V_MSG(!target_object, ERR_INVALID_PARAMETER, "Cannot connect to '" + p_signal + "' to callable '" + p_callable + "': the callable object is null.");
SignalData *s = signal_map.getptr(p_signal);
if (!s) {
@@ -1348,7 +1364,7 @@ Error Object::connect(const StringName &p_signal, const Callable &p_callable, co
}
bool Object::is_connected(const StringName &p_signal, const Callable &p_callable) const {
- ERR_FAIL_COND_V(p_callable.is_null(), false);
+ ERR_FAIL_COND_V_MSG(p_callable.is_null(), false, "Cannot determine if connected to '" + p_signal + "': the provided callable is null.");
const SignalData *s = signal_map.getptr(p_signal);
if (!s) {
bool signal_is_valid = ClassDB::has_signal(get_class_name(), p_signal);
@@ -1375,10 +1391,10 @@ void Object::disconnect(const StringName &p_signal, const Callable &p_callable)
}
void Object::_disconnect(const StringName &p_signal, const Callable &p_callable, bool p_force) {
- ERR_FAIL_COND(p_callable.is_null());
+ ERR_FAIL_COND_MSG(p_callable.is_null(), "Cannot disconnect from '" + p_signal + "': the provided callable is null.");
Object *target_object = p_callable.get_object();
- ERR_FAIL_COND(!target_object);
+ ERR_FAIL_COND_MSG(!target_object, "Cannot disconnect '" + p_signal + "' from callable '" + p_callable + "': the callable object is null.");
SignalData *s = signal_map.getptr(p_signal);
if (!s) {
@@ -1812,7 +1828,7 @@ Object::~Object() {
script_instance = nullptr;
if (_extension && _extension->free_instance) {
- _extension->free_instance(_extension->create_instance_userdata, _extension_instance);
+ _extension->free_instance(_extension->class_userdata, _extension_instance);
_extension = nullptr;
_extension_instance = nullptr;
}
diff --git a/core/object/object.h b/core/object/object.h
index 37b2e61dfe..461ed482fe 100644
--- a/core/object/object.h
+++ b/core/object/object.h
@@ -31,6 +31,7 @@
#ifndef OBJECT_H
#define OBJECT_H
+#include "core/extension/gdnative_interface.h"
#include "core/object/object_id.h"
#include "core/os/rw_lock.h"
#include "core/os/spin_lock.h"
@@ -101,6 +102,7 @@ enum PropertyHint {
};
enum PropertyUsageFlags {
+ PROPERTY_USAGE_NONE = 0,
PROPERTY_USAGE_STORAGE = 1,
PROPERTY_USAGE_EDITOR = 2,
PROPERTY_USAGE_NETWORK = 4,
@@ -243,29 +245,18 @@ class MethodBind;
struct ObjectNativeExtension {
ObjectNativeExtension *parent = nullptr;
+ List<ObjectNativeExtension *> children;
StringName parent_class_name;
StringName class_name;
bool editor_class = false;
- bool (*set)(void *instance, const void *name, const void *value) = nullptr;
- bool (*get)(void *instance, const void *name, void *ret_variant) = nullptr;
- struct PInfo {
- uint32_t type;
- const char *name;
- const char *class_name;
- uint32_t hint;
- const char *hint_string;
- uint32_t usage;
- };
- const PInfo *(*get_property_list)(void *instance, uint32_t *count) = nullptr;
- void (*free_property_list)(void *instance, const PInfo *) = nullptr;
-
- //call is not used, as all methods registered in ClassDB
-
- void (*notification)(void *instance, int32_t what) = nullptr;
- const char *(*to_string)(void *instance) = nullptr;
-
- void (*reference)(void *instance) = nullptr;
- void (*unreference)(void *instance) = nullptr;
+ GDNativeExtensionClassSet set;
+ GDNativeExtensionClassGet get;
+ GDNativeExtensionClassGetPropertyList get_property_list;
+ GDNativeExtensionClassFreePropertyList free_property_list;
+ GDNativeExtensionClassNotification notification;
+ GDNativeExtensionClassToString to_string;
+ GDNativeExtensionClassReference reference;
+ GDNativeExtensionClassReference unreference;
_FORCE_INLINE_ bool is_class(const String &p_class) const {
const ObjectNativeExtension *e = this;
@@ -277,11 +268,16 @@ struct ObjectNativeExtension {
}
return false;
}
- void *create_instance_userdata = nullptr;
- void *(*create_instance)(void *create_instance_userdata) = nullptr;
- void (*free_instance)(void *create_instance_userdata, void *instance) = nullptr;
+ void *class_userdata = nullptr;
+
+ GDNativeExtensionClassCreateInstance create_instance;
+ GDNativeExtensionClassFreeInstance free_instance;
+ GDNativeExtensionClassGetVirtual get_virtual;
};
+#define GDVIRTUAL_CALL(m_name, ...) _gdvirtual_##m_name##_call(__VA_ARGS__)
+#define GDVIRTUAL_BIND(m_name) ClassDB::add_virtual_method(get_class_static(), _gdvirtual_##m_name##_get_method_info());
+
/*
the following is an incomprehensible blob of hacks and workarounds to compensate for many of the fallencies in C++. As a plus, this macro pretty much alone defines the object model.
*/
@@ -496,7 +492,7 @@ private:
friend void postinitialize_handler(Object *);
ObjectNativeExtension *_extension = nullptr;
- void *_extension_instance = nullptr;
+ GDExtensionClassInstancePtr _extension_instance = nullptr;
struct SignalData {
struct Slot {
@@ -553,8 +549,9 @@ private:
Object(bool p_reference);
protected:
+ friend class NativeExtensionMethodBind;
_ALWAYS_INLINE_ const ObjectNativeExtension *_get_extension() const { return _extension; }
- _ALWAYS_INLINE_ void *_get_extension_instance() const { return _extension_instance; }
+ _ALWAYS_INLINE_ GDExtensionClassInstancePtr _get_extension_instance() const { return _extension_instance; }
virtual void _initialize_classv() { initialize_class(); }
virtual bool _setv(const StringName &p_name, const Variant &p_property) { return false; };
virtual bool _getv(const StringName &p_name, Variant &r_property) const { return false; };
diff --git a/core/object/ref_counted.h b/core/object/ref_counted.h
index 3dd7cc456b..e0af2c18bb 100644
--- a/core/object/ref_counted.h
+++ b/core/object/ref_counted.h
@@ -213,7 +213,7 @@ public:
inline bool is_null() const { return reference == nullptr; }
void unref() {
- //TODO this should be moved to mutexes, since this engine does not really
+ // TODO: this should be moved to mutexes, since this engine does not really
// do a lot of referencing on references and stuff
// mutexes will avoid more crashes?
@@ -223,7 +223,7 @@ public:
reference = nullptr;
}
- void instance() {
+ void instantiate() {
ref(memnew(T));
}
@@ -258,6 +258,8 @@ struct PtrToArg<Ref<T>> {
return Ref<T>(const_cast<T *>(reinterpret_cast<const T *>(p_ptr)));
}
+ typedef Ref<T> EncodeT;
+
_FORCE_INLINE_ static void encode(Ref<T> p_val, const void *p_ptr) {
*(Ref<RefCounted> *)p_ptr = p_val;
}
@@ -265,6 +267,8 @@ struct PtrToArg<Ref<T>> {
template <class T>
struct PtrToArg<const Ref<T> &> {
+ typedef Ref<T> EncodeT;
+
_FORCE_INLINE_ static Ref<T> convert(const void *p_ptr) {
return Ref<T>((T *)p_ptr);
}
diff --git a/core/object/script_language.cpp b/core/object/script_language.cpp
index 196f7a1876..626a7413e7 100644
--- a/core/object/script_language.cpp
+++ b/core/object/script_language.cpp
@@ -100,7 +100,7 @@ Dictionary Script::_get_script_constant_map() {
}
void Script::_bind_methods() {
- ClassDB::bind_method(D_METHOD("can_instance"), &Script::can_instance);
+ ClassDB::bind_method(D_METHOD("can_instantiate"), &Script::can_instantiate);
//ClassDB::bind_method(D_METHOD("instance_create","base_object"),&Script::instance_create);
ClassDB::bind_method(D_METHOD("instance_has", "base_object"), &Script::instance_has);
ClassDB::bind_method(D_METHOD("has_source_code"), &Script::has_source_code);
@@ -120,7 +120,7 @@ void Script::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_tool"), &Script::is_tool);
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "source_code", PROPERTY_HINT_NONE, "", 0), "set_source_code", "get_source_code");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "source_code", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_source_code", "get_source_code");
}
void ScriptServer::set_scripting_enabled(bool p_enabled) {
diff --git a/core/object/script_language.h b/core/object/script_language.h
index a22e91870e..2cbaa0f52e 100644
--- a/core/object/script_language.h
+++ b/core/object/script_language.h
@@ -115,7 +115,7 @@ protected:
Dictionary _get_script_constant_map();
public:
- virtual bool can_instance() const = 0;
+ virtual bool can_instantiate() const = 0;
virtual Ref<Script> get_base_script() const = 0; //for script inheritance
@@ -268,6 +268,12 @@ public:
String message;
};
+ struct ScriptError {
+ int line = -1;
+ int column = -1;
+ String message;
+ };
+
void get_core_type_words(List<String> *p_core_type_words) const;
virtual void get_reserved_words(List<String> *p_words) const = 0;
virtual bool is_control_flow_keyword(String p_string) const = 0;
@@ -276,7 +282,7 @@ public:
virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const = 0;
virtual void make_template(const String &p_class_name, const String &p_base_class_name, Ref<Script> &p_script) {}
virtual bool is_using_templates() { return false; }
- virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path = "", List<String> *r_functions = nullptr, List<Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const = 0;
+ virtual bool validate(const String &p_script, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptError> *r_errors = nullptr, List<Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const = 0;
virtual String validate_path(const String &p_path) const { return ""; }
virtual Script *create_script() const = 0;
virtual bool has_named_classes() const = 0;
diff --git a/core/os/midi_driver.cpp b/core/os/midi_driver.cpp
index a8be84c56c..ee87346dfc 100644
--- a/core/os/midi_driver.cpp
+++ b/core/os/midi_driver.cpp
@@ -45,23 +45,23 @@ void MIDIDriver::set_singleton() {
void MIDIDriver::receive_input_packet(uint64_t timestamp, uint8_t *data, uint32_t length) {
Ref<InputEventMIDI> event;
- event.instance();
+ event.instantiate();
uint32_t param_position = 1;
if (length >= 1) {
if (data[0] >= 0xF0) {
// channel does not apply to system common messages
event->set_channel(0);
- event->set_message(data[0]);
+ event->set_message(MIDIMessage(data[0]));
last_received_message = data[0];
} else if ((data[0] & 0x80) == 0x00) {
// running status
event->set_channel(last_received_message & 0xF);
- event->set_message(last_received_message >> 4);
+ event->set_message(MIDIMessage(last_received_message >> 4));
param_position = 0;
} else {
event->set_channel(data[0] & 0xF);
- event->set_message(data[0] >> 4);
+ event->set_message(MIDIMessage(data[0] >> 4));
param_position = 1;
last_received_message = data[0];
}
@@ -112,6 +112,8 @@ void MIDIDriver::receive_input_packet(uint64_t timestamp, uint8_t *data, uint32_
event->set_pressure(data[param_position]);
}
break;
+ default:
+ break;
}
Input *id = Input::get_singleton();
diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp
index f67d615418..1cbb0bb597 100644
--- a/core/register_core_types.cpp
+++ b/core/register_core_types.cpp
@@ -37,6 +37,8 @@
#include "core/crypto/aes_context.h"
#include "core/crypto/crypto.h"
#include "core/crypto/hashing_context.h"
+#include "core/extension/native_extension.h"
+#include "core/extension/native_extension_manager.h"
#include "core/input/input.h"
#include "core/input/input_map.h"
#include "core/io/config_file.h"
@@ -86,7 +88,6 @@ static _OS *_os = nullptr;
static _Engine *_engine = nullptr;
static _ClassDB *_classdb = nullptr;
static _Marshalls *_marshalls = nullptr;
-static _JSON *_json = nullptr;
static _EngineDebugger *_engine_debugger = nullptr;
static IP *ip = nullptr;
@@ -96,6 +97,8 @@ static _Geometry3D *_geometry_3d = nullptr;
extern Mutex _global_mutex;
+static NativeExtensionManager *native_extension_manager = nullptr;
+
extern void register_global_constants();
extern void unregister_global_constants();
@@ -114,18 +117,18 @@ void register_core_types() {
CoreStringNames::create();
- resource_format_po.instance();
+ resource_format_po.instantiate();
ResourceLoader::add_resource_format_loader(resource_format_po);
- resource_saver_binary.instance();
+ resource_saver_binary.instantiate();
ResourceSaver::add_resource_format_saver(resource_saver_binary);
- resource_loader_binary.instance();
+ resource_loader_binary.instantiate();
ResourceLoader::add_resource_format_loader(resource_loader_binary);
- resource_format_importer.instance();
+ resource_format_importer.instantiate();
ResourceLoader::add_resource_format_loader(resource_format_importer);
- resource_format_image.instance();
+ resource_format_image.instantiate();
ResourceLoader::add_resource_format_loader(resource_format_image);
ClassDB::register_class<Object>();
@@ -154,14 +157,20 @@ void register_core_types() {
ClassDB::register_class<InputEventPanGesture>();
ClassDB::register_class<InputEventMIDI>();
+ // Network
+ ClassDB::register_virtual_class<IP>();
+
ClassDB::register_virtual_class<StreamPeer>();
ClassDB::register_class<StreamPeerBuffer>();
ClassDB::register_class<StreamPeerTCP>();
ClassDB::register_class<TCPServer>();
+
+ ClassDB::register_virtual_class<PacketPeer>();
+ ClassDB::register_class<PacketPeerStream>();
ClassDB::register_class<PacketPeerUDP>();
ClassDB::register_class<UDPServer>();
- ClassDB::register_custom_instance_class<PacketPeerDTLS>();
- ClassDB::register_custom_instance_class<DTLSServer>();
+
+ ClassDB::register_custom_instance_class<HTTPClient>();
// Crypto
ClassDB::register_class<HashingContext>();
@@ -171,22 +180,20 @@ void register_core_types() {
ClassDB::register_custom_instance_class<HMACContext>();
ClassDB::register_custom_instance_class<Crypto>();
ClassDB::register_custom_instance_class<StreamPeerSSL>();
+ ClassDB::register_custom_instance_class<PacketPeerDTLS>();
+ ClassDB::register_custom_instance_class<DTLSServer>();
- resource_format_saver_crypto.instance();
+ resource_format_saver_crypto.instantiate();
ResourceSaver::add_resource_format_saver(resource_format_saver_crypto);
- resource_format_loader_crypto.instance();
+ resource_format_loader_crypto.instantiate();
ResourceLoader::add_resource_format_loader(resource_format_loader_crypto);
- ClassDB::register_virtual_class<IP>();
- ClassDB::register_virtual_class<PacketPeer>();
- ClassDB::register_class<PacketPeerStream>();
ClassDB::register_virtual_class<NetworkedMultiplayerPeer>();
ClassDB::register_class<MultiplayerAPI>();
ClassDB::register_class<MainLoop>();
ClassDB::register_class<Translation>();
ClassDB::register_class<OptimizedTranslation>();
ClassDB::register_class<UndoRedo>();
- ClassDB::register_class<HTTPClient>();
ClassDB::register_class<TriangleMesh>();
ClassDB::register_class<ResourceFormatLoader>();
@@ -199,7 +206,7 @@ void register_core_types() {
ClassDB::register_class<_Semaphore>();
ClassDB::register_class<XMLParser>();
- ClassDB::register_class<JSONParser>();
+ ClassDB::register_class<JSON>();
ClassDB::register_class<ConfigFile>();
@@ -212,10 +219,14 @@ void register_core_types() {
ClassDB::register_class<EncodedObjectAsID>();
ClassDB::register_class<RandomNumberGenerator>();
- ClassDB::register_class<JSONParseResult>();
-
ClassDB::register_virtual_class<ResourceImporter>();
+ ClassDB::register_class<NativeExtension>();
+
+ ClassDB::register_virtual_class<NativeExtensionManager>();
+
+ native_extension_manager = memnew(NativeExtensionManager);
+
ip = IP::create();
_geometry_2d = memnew(_Geometry2D);
@@ -227,7 +238,6 @@ void register_core_types() {
_engine = memnew(_Engine);
_classdb = memnew(_ClassDB);
_marshalls = memnew(_Marshalls);
- _json = memnew(_JSON);
_engine_debugger = memnew(_EngineDebugger);
}
@@ -256,13 +266,12 @@ void register_core_singletons() {
ClassDB::register_class<TranslationServer>();
ClassDB::register_virtual_class<Input>();
ClassDB::register_class<InputMap>();
- ClassDB::register_class<_JSON>();
ClassDB::register_class<Expression>();
ClassDB::register_class<_EngineDebugger>();
ClassDB::register_class<Time>();
Engine::get_singleton()->add_singleton(Engine::Singleton("ProjectSettings", ProjectSettings::get_singleton()));
- Engine::get_singleton()->add_singleton(Engine::Singleton("IP", IP::get_singleton()));
+ Engine::get_singleton()->add_singleton(Engine::Singleton("IP", IP::get_singleton(), "IP"));
Engine::get_singleton()->add_singleton(Engine::Singleton("Geometry2D", _Geometry2D::get_singleton()));
Engine::get_singleton()->add_singleton(Engine::Singleton("Geometry3D", _Geometry3D::get_singleton()));
Engine::get_singleton()->add_singleton(Engine::Singleton("ResourceLoader", _ResourceLoader::get_singleton()));
@@ -274,19 +283,33 @@ void register_core_singletons() {
Engine::get_singleton()->add_singleton(Engine::Singleton("TranslationServer", TranslationServer::get_singleton()));
Engine::get_singleton()->add_singleton(Engine::Singleton("Input", Input::get_singleton()));
Engine::get_singleton()->add_singleton(Engine::Singleton("InputMap", InputMap::get_singleton()));
- Engine::get_singleton()->add_singleton(Engine::Singleton("JSON", _JSON::get_singleton()));
Engine::get_singleton()->add_singleton(Engine::Singleton("EngineDebugger", _EngineDebugger::get_singleton()));
Engine::get_singleton()->add_singleton(Engine::Singleton("Time", Time::get_singleton()));
+ Engine::get_singleton()->add_singleton(Engine::Singleton("NativeExtensionManager", NativeExtensionManager::get_singleton()));
+}
+
+void register_core_extensions() {
+ //harcoded for now
+ if (ProjectSettings::get_singleton()->has_setting("native_extensions/paths")) {
+ Vector<String> paths = ProjectSettings::get_singleton()->get("native_extensions/paths");
+ for (int i = 0; i < paths.size(); i++) {
+ NativeExtensionManager::LoadStatus status = native_extension_manager->load_extension(paths[i]);
+ ERR_CONTINUE_MSG(status != NativeExtensionManager::LOAD_STATUS_OK, "Error loading extension: " + paths[i]);
+ }
+ }
+ native_extension_manager->initialize_extensions(NativeExtension::INITIALIZATION_LEVEL_CORE);
}
void unregister_core_types() {
+ native_extension_manager->deinitialize_extensions(NativeExtension::INITIALIZATION_LEVEL_CORE);
+
+ memdelete(native_extension_manager);
memdelete(_resource_loader);
memdelete(_resource_saver);
memdelete(_os);
memdelete(_engine);
memdelete(_classdb);
memdelete(_marshalls);
- memdelete(_json);
memdelete(_engine_debugger);
memdelete(_geometry_2d);
diff --git a/core/register_core_types.h b/core/register_core_types.h
index baf7ddbe65..830f05607d 100644
--- a/core/register_core_types.h
+++ b/core/register_core_types.h
@@ -33,6 +33,7 @@
void register_core_types();
void register_core_settings();
+void register_core_extensions();
void register_core_singletons();
void unregister_core_types();
diff --git a/core/string/translation_po.cpp b/core/string/translation_po.cpp
index d6b84cabc9..f9b4e661e4 100644
--- a/core/string/translation_po.cpp
+++ b/core/string/translation_po.cpp
@@ -188,7 +188,7 @@ void TranslationPO::set_plural_rule(const String &p_plural_rule) {
plural_rule = plural_rule.replacen("(", "");
plural_rule = plural_rule.replacen(")", "");
_cache_plural_tests(plural_rule);
- expr.instance();
+ expr.instantiate();
input_name.push_back("n");
}
diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp
index 019754bc22..16ecd2b985 100644
--- a/core/string/ustring.cpp
+++ b/core/string/ustring.cpp
@@ -294,7 +294,7 @@ Error String::parse_url(String &r_scheme, String &r_host, int &r_port, String &r
// Port
if (base.begins_with(":")) {
base = base.substr(1, base.length() - 1);
- if (!base.is_valid_integer()) {
+ if (!base.is_valid_int()) {
return ERR_INVALID_PARAMETER;
}
r_port = base.to_int();
@@ -4168,7 +4168,7 @@ String String::trim_suffix(const String &p_suffix) const {
return s;
}
-bool String::is_valid_integer() const {
+bool String::is_valid_int() const {
int len = length();
if (len == 0) {
@@ -4393,7 +4393,7 @@ bool String::is_valid_ip_address() const {
}
for (int i = 0; i < ip.size(); i++) {
String n = ip[i];
- if (!n.is_valid_integer()) {
+ if (!n.is_valid_int()) {
return false;
}
int val = n.to_int();
diff --git a/core/string/ustring.h b/core/string/ustring.h
index 82cd3e1667..ffb354d6e1 100644
--- a/core/string/ustring.h
+++ b/core/string/ustring.h
@@ -425,7 +425,7 @@ public:
String validate_node_name() const;
bool is_valid_identifier() const;
- bool is_valid_integer() const;
+ bool is_valid_int() const;
bool is_valid_float() const;
bool is_valid_hex_number(bool p_with_prefix) const;
bool is_valid_html_color() const;
diff --git a/core/templates/rid_owner.h b/core/templates/rid_owner.h
index c4aa93c394..31278b71bd 100644
--- a/core/templates/rid_owner.h
+++ b/core/templates/rid_owner.h
@@ -351,6 +351,9 @@ public:
for (size_t i = 0; i < max_alloc; i++) {
uint64_t validator = validator_chunks[i / elements_in_chunk][i % elements_in_chunk];
+ if (validator & 0x80000000) {
+ continue; //uninitialized
+ }
if (validator != 0xFFFFFFFF) {
chunks[i / elements_in_chunk][i % elements_in_chunk].~T();
}
diff --git a/core/variant/binder_common.h b/core/variant/binder_common.h
index 830e0a5cbd..ef5867c685 100644
--- a/core/variant/binder_common.h
+++ b/core/variant/binder_common.h
@@ -31,6 +31,7 @@
#ifndef BINDER_COMMON_H
#define BINDER_COMMON_H
+#include "core/input/input_enums.h"
#include "core/object/object.h"
#include "core/templates/list.h"
#include "core/templates/simple_type.h"
@@ -76,6 +77,7 @@ struct VariantCaster<const T &> {
_FORCE_INLINE_ static m_enum convert(const void *p_ptr) { \
return m_enum(*reinterpret_cast<const int *>(p_ptr)); \
} \
+ typedef int64_t EncodeT; \
_FORCE_INLINE_ static void encode(m_enum p_val, const void *p_ptr) { \
*(int *)p_ptr = p_val; \
} \
@@ -90,6 +92,12 @@ VARIANT_ENUM_CAST(Error);
VARIANT_ENUM_CAST(Side);
VARIANT_ENUM_CAST(ClockDirection);
VARIANT_ENUM_CAST(Corner);
+VARIANT_ENUM_CAST(HatDir);
+VARIANT_ENUM_CAST(HatMask);
+VARIANT_ENUM_CAST(JoyAxis);
+VARIANT_ENUM_CAST(JoyButton);
+VARIANT_ENUM_CAST(MIDIMessage);
+VARIANT_ENUM_CAST(MouseButton);
VARIANT_ENUM_CAST(Orientation);
VARIANT_ENUM_CAST(HAlign);
VARIANT_ENUM_CAST(VAlign);
@@ -110,6 +118,7 @@ struct PtrToArg<char32_t> {
_FORCE_INLINE_ static char32_t convert(const void *p_ptr) {
return char32_t(*reinterpret_cast<const int *>(p_ptr));
}
+ typedef int64_t EncodeT;
_FORCE_INLINE_ static void encode(char32_t p_val, const void *p_ptr) {
*(int *)p_ptr = p_val;
}
diff --git a/core/variant/method_ptrcall.h b/core/variant/method_ptrcall.h
index d4ec5e570c..7852187b77 100644
--- a/core/variant/method_ptrcall.h
+++ b/core/variant/method_ptrcall.h
@@ -45,6 +45,7 @@ struct PtrToArg {};
_FORCE_INLINE_ static m_type convert(const void *p_ptr) { \
return *reinterpret_cast<const m_type *>(p_ptr); \
} \
+ typedef m_type EncodeT; \
_FORCE_INLINE_ static void encode(m_type p_val, void *p_ptr) { \
*((m_type *)p_ptr) = p_val; \
} \
@@ -54,6 +55,7 @@ struct PtrToArg {};
_FORCE_INLINE_ static m_type convert(const void *p_ptr) { \
return *reinterpret_cast<const m_type *>(p_ptr); \
} \
+ typedef m_type EncodeT; \
_FORCE_INLINE_ static void encode(m_type p_val, void *p_ptr) { \
*((m_type *)p_ptr) = p_val; \
} \
@@ -65,6 +67,7 @@ struct PtrToArg {};
_FORCE_INLINE_ static m_type convert(const void *p_ptr) { \
return static_cast<m_type>(*reinterpret_cast<const m_conv *>(p_ptr)); \
} \
+ typedef m_conv EncodeT; \
_FORCE_INLINE_ static void encode(m_type p_val, void *p_ptr) { \
*((m_conv *)p_ptr) = static_cast<m_conv>(p_val); \
} \
@@ -74,6 +77,7 @@ struct PtrToArg {};
_FORCE_INLINE_ static m_type convert(const void *p_ptr) { \
return static_cast<m_type>(*reinterpret_cast<const m_conv *>(p_ptr)); \
} \
+ typedef m_conv EncodeT; \
_FORCE_INLINE_ static void encode(m_type p_val, void *p_ptr) { \
*((m_conv *)p_ptr) = static_cast<m_conv>(p_val); \
} \
@@ -85,6 +89,7 @@ struct PtrToArg {};
_FORCE_INLINE_ static m_type convert(const void *p_ptr) { \
return *reinterpret_cast<const m_type *>(p_ptr); \
} \
+ typedef m_type EncodeT; \
_FORCE_INLINE_ static void encode(const m_type &p_val, void *p_ptr) { \
*((m_type *)p_ptr) = p_val; \
} \
@@ -94,12 +99,13 @@ struct PtrToArg {};
_FORCE_INLINE_ static m_type convert(const void *p_ptr) { \
return *reinterpret_cast<const m_type *>(p_ptr); \
} \
+ typedef m_type EncodeT; \
_FORCE_INLINE_ static void encode(const m_type &p_val, void *p_ptr) { \
*((m_type *)p_ptr) = p_val; \
} \
}
-MAKE_PTRARG(bool);
+MAKE_PTRARGCONV(bool, uint32_t);
// Integer types.
MAKE_PTRARGCONV(uint8_t, int64_t);
MAKE_PTRARGCONV(int8_t, int64_t);
@@ -153,7 +159,7 @@ struct PtrToArg<T *> {
_FORCE_INLINE_ static T *convert(const void *p_ptr) {
return const_cast<T *>(reinterpret_cast<const T *>(p_ptr));
}
-
+ typedef Object *EncodeT;
_FORCE_INLINE_ static void encode(T *p_var, void *p_ptr) {
*((T **)p_ptr) = p_var;
}
@@ -164,7 +170,7 @@ struct PtrToArg<const T *> {
_FORCE_INLINE_ static const T *convert(const void *p_ptr) {
return reinterpret_cast<const T *>(p_ptr);
}
-
+ typedef const Object *EncodeT;
_FORCE_INLINE_ static void encode(T *p_var, void *p_ptr) {
*((T **)p_ptr) = p_var;
}
@@ -177,7 +183,7 @@ struct PtrToArg<ObjectID> {
_FORCE_INLINE_ static const ObjectID convert(const void *p_ptr) {
return ObjectID(*reinterpret_cast<const uint64_t *>(p_ptr));
}
-
+ typedef uint64_t EncodeT;
_FORCE_INLINE_ static void encode(const ObjectID &p_val, void *p_ptr) {
*((uint64_t *)p_ptr) = p_val;
}
diff --git a/core/variant/variant.cpp b/core/variant/variant.cpp
index 4e45862fd3..badb5ba103 100644
--- a/core/variant/variant.cpp
+++ b/core/variant/variant.cpp
@@ -32,6 +32,7 @@
#include "core/core_string_names.h"
#include "core/debugger/engine_debugger.h"
+#include "core/io/json.h"
#include "core/io/marshalls.h"
#include "core/io/resource.h"
#include "core/math/math_funcs.h"
@@ -1838,6 +1839,11 @@ String Variant::stringify(List<const void *> &stack) const {
return "";
}
+String Variant::to_json_string() const {
+ JSON json;
+ return json.stringify(*this);
+}
+
Variant::operator Vector2() const {
if (type == VECTOR2) {
return *reinterpret_cast<const Vector2 *>(_data._mem);
diff --git a/core/variant/variant.h b/core/variant/variant.h
index 75316da63f..373fe32921 100644
--- a/core/variant/variant.h
+++ b/core/variant/variant.h
@@ -499,6 +499,7 @@ public:
static bool is_builtin_method_vararg(Variant::Type p_type, const StringName &p_method);
static void get_builtin_method_list(Variant::Type p_type, List<StringName> *p_list);
static int get_builtin_method_count(Variant::Type p_type);
+ static uint32_t get_builtin_method_hash(Variant::Type p_type, const StringName &p_method);
void call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error);
Variant call(const StringName &p_method, const Variant &p_arg1 = Variant(), const Variant &p_arg2 = Variant(), const Variant &p_arg3 = Variant(), const Variant &p_arg4 = Variant(), const Variant &p_arg5 = Variant());
@@ -586,7 +587,7 @@ public:
typedef void (*PTRKeyedSetter)(void *base, const void *key, const void *value);
typedef void (*PTRKeyedGetter)(const void *base, const void *key, void *value);
- typedef bool (*PTRKeyedChecker)(const void *base, const void *key);
+ typedef uint32_t (*PTRKeyedChecker)(const void *base, const void *key);
static PTRKeyedSetter get_member_ptr_keyed_setter(Variant::Type p_type);
static PTRKeyedGetter get_member_ptr_keyed_getter(Variant::Type p_type);
@@ -631,6 +632,7 @@ public:
static bool has_utility_function_return_value(const StringName &p_name);
static Variant::Type get_utility_function_return_type(const StringName &p_name);
static bool is_utility_function_vararg(const StringName &p_name);
+ static uint32_t get_utility_function_hash(const StringName &p_name);
static void get_utility_function_list(List<StringName> *r_functions);
static int get_utility_function_count();
@@ -645,6 +647,7 @@ public:
bool hash_compare(const Variant &p_variant) const;
bool booleanize() const;
String stringify(List<const void *> &stack) const;
+ String to_json_string() const;
void static_assign(const Variant &p_variant);
static void get_constants_for_type(Variant::Type p_type, List<StringName> *p_constants);
diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp
index 05ed35c760..95c4e7121b 100644
--- a/core/variant/variant_call.cpp
+++ b/core/variant/variant_call.cpp
@@ -1126,6 +1126,25 @@ bool Variant::is_builtin_method_vararg(Variant::Type p_type, const StringName &p
return method->is_vararg;
}
+uint32_t Variant::get_builtin_method_hash(Variant::Type p_type, const StringName &p_method) {
+ ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, 0);
+ const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].lookup_ptr(p_method);
+ ERR_FAIL_COND_V(!method, 0);
+ uint32_t hash = hash_djb2_one_32(method->is_const);
+ hash = hash_djb2_one_32(method->is_static, hash);
+ hash = hash_djb2_one_32(method->is_vararg, hash);
+ hash = hash_djb2_one_32(method->has_return_type, hash);
+ if (method->has_return_type) {
+ hash = hash_djb2_one_32(method->return_type, hash);
+ }
+ hash = hash_djb2_one_32(method->argument_count, hash);
+ for (int i = 0; i < method->argument_count; i++) {
+ hash = method->get_argument_type(i);
+ }
+
+ return hash;
+}
+
void Variant::get_method_list(List<MethodInfo> *p_list) const {
if (type == OBJECT) {
Object *obj = get_validated_object();
@@ -1380,7 +1399,7 @@ static void _register_variant_builtin_methods() {
bind_method(String, validate_node_name, sarray(), varray());
bind_method(String, is_valid_identifier, sarray(), varray());
- bind_method(String, is_valid_integer, sarray(), varray());
+ bind_method(String, is_valid_int, sarray(), varray());
bind_method(String, is_valid_float, sarray(), varray());
bind_method(String, is_valid_hex_number, sarray("with_prefix"), varray(false));
bind_method(String, is_valid_html_color, sarray(), varray());
@@ -1552,6 +1571,7 @@ static void _register_variant_builtin_methods() {
bind_method(Quaternion, is_normalized, sarray(), varray());
bind_method(Quaternion, is_equal_approx, sarray("to"), varray());
bind_method(Quaternion, inverse, sarray(), varray());
+ bind_method(Quaternion, angle_to, sarray("to"), varray());
bind_method(Quaternion, dot, sarray("with"), varray());
bind_method(Quaternion, slerp, sarray("to", "weight"), varray());
bind_method(Quaternion, slerpni, sarray("to", "weight"), varray());
diff --git a/core/variant/variant_construct.cpp b/core/variant/variant_construct.cpp
index 9e3ab5897b..a1a2bec369 100644
--- a/core/variant/variant_construct.cpp
+++ b/core/variant/variant_construct.cpp
@@ -28,543 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "variant.h"
-
-#include "core/core_string_names.h"
-#include "core/crypto/crypto_core.h"
-#include "core/debugger/engine_debugger.h"
-#include "core/io/compression.h"
-#include "core/object/class_db.h"
-#include "core/os/os.h"
-#include "core/templates/local_vector.h"
-#include "core/templates/oa_hash_map.h"
-
-template <class T>
-struct PtrConstruct {};
-
-#define MAKE_PTRCONSTRUCT(m_type) \
- template <> \
- struct PtrConstruct<m_type> { \
- _FORCE_INLINE_ static void construct(const m_type &p_value, void *p_ptr) { \
- memnew_placement(p_ptr, m_type(p_value)); \
- } \
- };
-
-MAKE_PTRCONSTRUCT(bool);
-MAKE_PTRCONSTRUCT(int64_t);
-MAKE_PTRCONSTRUCT(double);
-MAKE_PTRCONSTRUCT(String);
-MAKE_PTRCONSTRUCT(Vector2);
-MAKE_PTRCONSTRUCT(Vector2i);
-MAKE_PTRCONSTRUCT(Rect2);
-MAKE_PTRCONSTRUCT(Rect2i);
-MAKE_PTRCONSTRUCT(Vector3);
-MAKE_PTRCONSTRUCT(Vector3i);
-MAKE_PTRCONSTRUCT(Transform2D);
-MAKE_PTRCONSTRUCT(Plane);
-MAKE_PTRCONSTRUCT(Quaternion);
-MAKE_PTRCONSTRUCT(AABB);
-MAKE_PTRCONSTRUCT(Basis);
-MAKE_PTRCONSTRUCT(Transform3D);
-MAKE_PTRCONSTRUCT(Color);
-MAKE_PTRCONSTRUCT(StringName);
-MAKE_PTRCONSTRUCT(NodePath);
-MAKE_PTRCONSTRUCT(RID);
-
-template <>
-struct PtrConstruct<Object *> {
- _FORCE_INLINE_ static void construct(Object *p_value, void *p_ptr) {
- *((Object **)p_ptr) = p_value;
- }
-};
-
-MAKE_PTRCONSTRUCT(Callable);
-MAKE_PTRCONSTRUCT(Signal);
-MAKE_PTRCONSTRUCT(Dictionary);
-MAKE_PTRCONSTRUCT(Array);
-MAKE_PTRCONSTRUCT(PackedByteArray);
-MAKE_PTRCONSTRUCT(PackedInt32Array);
-MAKE_PTRCONSTRUCT(PackedInt64Array);
-MAKE_PTRCONSTRUCT(PackedFloat32Array);
-MAKE_PTRCONSTRUCT(PackedFloat64Array);
-MAKE_PTRCONSTRUCT(PackedStringArray);
-MAKE_PTRCONSTRUCT(PackedVector2Array);
-MAKE_PTRCONSTRUCT(PackedVector3Array);
-MAKE_PTRCONSTRUCT(PackedColorArray);
-MAKE_PTRCONSTRUCT(Variant);
-
-template <class T, class... P>
-class VariantConstructor {
- template <size_t... Is>
- static _FORCE_INLINE_ void construct_helper(T &base, const Variant **p_args, Callable::CallError &r_error, IndexSequence<Is...>) {
- r_error.error = Callable::CallError::CALL_OK;
-
-#ifdef DEBUG_METHODS_ENABLED
- base = T(VariantCasterAndValidate<P>::cast(p_args, Is, r_error)...);
-#else
- base = T(VariantCaster<P>::cast(*p_args[Is])...);
-#endif
- }
-
- template <size_t... Is>
- static _FORCE_INLINE_ void validated_construct_helper(T &base, const Variant **p_args, IndexSequence<Is...>) {
- base = T((*VariantGetInternalPtr<P>::get_ptr(p_args[Is]))...);
- }
-
- template <size_t... Is>
- static _FORCE_INLINE_ void ptr_construct_helper(void *base, const void **p_args, IndexSequence<Is...>) {
- PtrConstruct<T>::construct(T(PtrToArg<P>::convert(p_args[Is])...), base);
- }
-
-public:
- static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) {
- r_error.error = Callable::CallError::CALL_OK;
- VariantTypeChanger<T>::change(&r_ret);
- construct_helper(*VariantGetInternalPtr<T>::get_ptr(&r_ret), p_args, r_error, BuildIndexSequence<sizeof...(P)>{});
- }
-
- static void validated_construct(Variant *r_ret, const Variant **p_args) {
- VariantTypeChanger<T>::change(r_ret);
- validated_construct_helper(*VariantGetInternalPtr<T>::get_ptr(r_ret), p_args, BuildIndexSequence<sizeof...(P)>{});
- }
- static void ptr_construct(void *base, const void **p_args) {
- ptr_construct_helper(base, p_args, BuildIndexSequence<sizeof...(P)>{});
- }
-
- static int get_argument_count() {
- return sizeof...(P);
- }
-
- static Variant::Type get_argument_type(int p_arg) {
- return call_get_argument_type<P...>(p_arg);
- }
-
- static Variant::Type get_base_type() {
- return GetTypeInfo<T>::VARIANT_TYPE;
- }
-};
-
-class VariantConstructorObject {
-public:
- static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) {
- VariantInternal::clear(&r_ret);
- if (p_args[0]->get_type() == Variant::NIL) {
- VariantInternal::object_assign_null(&r_ret);
- r_error.error = Callable::CallError::CALL_OK;
- } else if (p_args[0]->get_type() == Variant::OBJECT) {
- VariantInternal::object_assign(&r_ret, p_args[0]);
- r_error.error = Callable::CallError::CALL_OK;
- } else {
- r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
- r_error.argument = 0;
- r_error.expected = Variant::OBJECT;
- }
- }
-
- static void validated_construct(Variant *r_ret, const Variant **p_args) {
- VariantInternal::clear(r_ret);
- VariantInternal::object_assign(r_ret, p_args[0]);
- }
- static void ptr_construct(void *base, const void **p_args) {
- PtrConstruct<Object *>::construct(PtrToArg<Object *>::convert(p_args[0]), base);
- }
-
- static int get_argument_count() {
- return 1;
- }
-
- static Variant::Type get_argument_type(int p_arg) {
- return Variant::OBJECT;
- }
-
- static Variant::Type get_base_type() {
- return Variant::OBJECT;
- }
-};
-
-class VariantConstructorNilObject {
-public:
- static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) {
- if (p_args[0]->get_type() != Variant::NIL) {
- r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
- r_error.argument = 0;
- r_error.expected = Variant::NIL;
- }
-
- VariantInternal::clear(&r_ret);
- VariantInternal::object_assign_null(&r_ret);
- }
-
- static void validated_construct(Variant *r_ret, const Variant **p_args) {
- VariantInternal::clear(r_ret);
- VariantInternal::object_assign_null(r_ret);
- }
- static void ptr_construct(void *base, const void **p_args) {
- PtrConstruct<Object *>::construct(nullptr, base);
- }
-
- static int get_argument_count() {
- return 1;
- }
-
- static Variant::Type get_argument_type(int p_arg) {
- return Variant::NIL;
- }
-
- static Variant::Type get_base_type() {
- return Variant::OBJECT;
- }
-};
-
-class VariantConstructorCallableArgs {
-public:
- static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) {
- ObjectID object_id;
- StringName method;
-
- if (p_args[0]->get_type() == Variant::NIL) {
- // leave as is
- } else if (p_args[0]->get_type() == Variant::OBJECT) {
- object_id = VariantInternal::get_object_id(p_args[0]);
- } else {
- r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
- r_error.argument = 0;
- r_error.expected = Variant::OBJECT;
- return;
- }
-
- if (p_args[1]->get_type() == Variant::STRING_NAME) {
- method = *VariantGetInternalPtr<StringName>::get_ptr(p_args[1]);
- } else if (p_args[1]->get_type() == Variant::STRING) {
- method = *VariantGetInternalPtr<String>::get_ptr(p_args[1]);
- } else {
- r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
- r_error.argument = 1;
- r_error.expected = Variant::STRING_NAME;
- return;
- }
-
- VariantTypeChanger<Callable>::change(&r_ret);
- *VariantGetInternalPtr<Callable>::get_ptr(&r_ret) = Callable(object_id, method);
- }
-
- static void validated_construct(Variant *r_ret, const Variant **p_args) {
- VariantTypeChanger<Callable>::change(r_ret);
- *VariantGetInternalPtr<Callable>::get_ptr(r_ret) = Callable(VariantInternal::get_object_id(p_args[0]), *VariantGetInternalPtr<StringName>::get_ptr(p_args[1]));
- }
- static void ptr_construct(void *base, const void **p_args) {
- PtrConstruct<Callable>::construct(Callable(PtrToArg<Object *>::convert(p_args[0]), PtrToArg<StringName>::convert(p_args[1])), base);
- }
-
- static int get_argument_count() {
- return 2;
- }
-
- static Variant::Type get_argument_type(int p_arg) {
- if (p_arg == 0) {
- return Variant::OBJECT;
- } else {
- return Variant::STRING_NAME;
- }
- }
-
- static Variant::Type get_base_type() {
- return Variant::CALLABLE;
- }
-};
-
-class VariantConstructorSignalArgs {
-public:
- static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) {
- ObjectID object_id;
- StringName method;
-
- if (p_args[0]->get_type() == Variant::NIL) {
- // leave as is
- } else if (p_args[0]->get_type() == Variant::OBJECT) {
- object_id = VariantInternal::get_object_id(p_args[0]);
- } else {
- r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
- r_error.argument = 0;
- r_error.expected = Variant::OBJECT;
- return;
- }
-
- if (p_args[1]->get_type() == Variant::STRING_NAME) {
- method = *VariantGetInternalPtr<StringName>::get_ptr(p_args[1]);
- } else if (p_args[1]->get_type() == Variant::STRING) {
- method = *VariantGetInternalPtr<String>::get_ptr(p_args[1]);
- } else {
- r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
- r_error.argument = 1;
- r_error.expected = Variant::STRING_NAME;
- return;
- }
-
- VariantTypeChanger<Signal>::change(&r_ret);
- *VariantGetInternalPtr<Signal>::get_ptr(&r_ret) = Signal(object_id, method);
- }
-
- static void validated_construct(Variant *r_ret, const Variant **p_args) {
- VariantTypeChanger<Signal>::change(r_ret);
- *VariantGetInternalPtr<Signal>::get_ptr(r_ret) = Signal(VariantInternal::get_object_id(p_args[0]), *VariantGetInternalPtr<StringName>::get_ptr(p_args[1]));
- }
- static void ptr_construct(void *base, const void **p_args) {
- PtrConstruct<Signal>::construct(Signal(PtrToArg<Object *>::convert(p_args[0]), PtrToArg<StringName>::convert(p_args[1])), base);
- }
-
- static int get_argument_count() {
- return 2;
- }
-
- static Variant::Type get_argument_type(int p_arg) {
- if (p_arg == 0) {
- return Variant::OBJECT;
- } else {
- return Variant::STRING_NAME;
- }
- }
-
- static Variant::Type get_base_type() {
- return Variant::SIGNAL;
- }
-};
-
-template <class T>
-class VariantConstructorToArray {
-public:
- static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) {
- if (p_args[0]->get_type() != GetTypeInfo<T>::VARIANT_TYPE) {
- r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
- r_error.argument = 0;
- r_error.expected = GetTypeInfo<T>::VARIANT_TYPE;
- return;
- }
-
- VariantTypeChanger<Array>::change(&r_ret);
- Array &dst_arr = *VariantGetInternalPtr<Array>::get_ptr(&r_ret);
- const T &src_arr = *VariantGetInternalPtr<T>::get_ptr(p_args[0]);
-
- int size = src_arr.size();
- dst_arr.resize(size);
- for (int i = 0; i < size; i++) {
- dst_arr[i] = src_arr[i];
- }
- }
-
- static void validated_construct(Variant *r_ret, const Variant **p_args) {
- VariantTypeChanger<Array>::change(r_ret);
- Array &dst_arr = *VariantGetInternalPtr<Array>::get_ptr(r_ret);
- const T &src_arr = *VariantGetInternalPtr<T>::get_ptr(p_args[0]);
-
- int size = src_arr.size();
- dst_arr.resize(size);
- for (int i = 0; i < size; i++) {
- dst_arr[i] = src_arr[i];
- }
- }
- static void ptr_construct(void *base, const void **p_args) {
- Array dst_arr;
- T src_arr = PtrToArg<T>::convert(p_args[0]);
-
- int size = src_arr.size();
- dst_arr.resize(size);
- for (int i = 0; i < size; i++) {
- dst_arr[i] = src_arr[i];
- }
-
- PtrConstruct<Array>::construct(dst_arr, base);
- }
-
- static int get_argument_count() {
- return 1;
- }
-
- static Variant::Type get_argument_type(int p_arg) {
- return GetTypeInfo<T>::VARIANT_TYPE;
- }
-
- static Variant::Type get_base_type() {
- return Variant::ARRAY;
- }
-};
-
-template <class T>
-class VariantConstructorFromArray {
-public:
- static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) {
- if (p_args[0]->get_type() != Variant::ARRAY) {
- r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
- r_error.argument = 0;
- r_error.expected = Variant::ARRAY;
- return;
- }
-
- VariantTypeChanger<T>::change(&r_ret);
- const Array &src_arr = *VariantGetInternalPtr<Array>::get_ptr(p_args[0]);
- T &dst_arr = *VariantGetInternalPtr<T>::get_ptr(&r_ret);
-
- int size = src_arr.size();
- dst_arr.resize(size);
- for (int i = 0; i < size; i++) {
- dst_arr.write[i] = src_arr[i];
- }
- }
-
- static void validated_construct(Variant *r_ret, const Variant **p_args) {
- VariantTypeChanger<T>::change(r_ret);
- const Array &src_arr = *VariantGetInternalPtr<Array>::get_ptr(p_args[0]);
- T &dst_arr = *VariantGetInternalPtr<T>::get_ptr(r_ret);
-
- int size = src_arr.size();
- dst_arr.resize(size);
- for (int i = 0; i < size; i++) {
- dst_arr.write[i] = src_arr[i];
- }
- }
- static void ptr_construct(void *base, const void **p_args) {
- Array src_arr = PtrToArg<Array>::convert(p_args[0]);
- T dst_arr;
-
- int size = src_arr.size();
- dst_arr.resize(size);
- for (int i = 0; i < size; i++) {
- dst_arr.write[i] = src_arr[i];
- }
-
- PtrConstruct<T>::construct(dst_arr, base);
- }
-
- static int get_argument_count() {
- return 1;
- }
-
- static Variant::Type get_argument_type(int p_arg) {
- return Variant::ARRAY;
- }
-
- static Variant::Type get_base_type() {
- return GetTypeInfo<T>::VARIANT_TYPE;
- }
-};
-
-class VariantConstructorNil {
-public:
- static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) {
- if (p_args[0]->get_type() != Variant::NIL) {
- r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
- r_error.argument = 0;
- r_error.expected = Variant::NIL;
- return;
- }
-
- r_error.error = Callable::CallError::CALL_OK;
- VariantInternal::clear(&r_ret);
- }
-
- static void validated_construct(Variant *r_ret, const Variant **p_args) {
- VariantInternal::clear(r_ret);
- }
- static void ptr_construct(void *base, const void **p_args) {
- PtrConstruct<Variant>::construct(Variant(), base);
- }
-
- static int get_argument_count() {
- return 1;
- }
-
- static Variant::Type get_argument_type(int p_arg) {
- return Variant::NIL;
- }
-
- static Variant::Type get_base_type() {
- return Variant::NIL;
- }
-};
-
-template <class T>
-class VariantConstructNoArgs {
-public:
- static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) {
- VariantTypeChanger<T>::change_and_reset(&r_ret);
- r_error.error = Callable::CallError::CALL_OK;
- }
-
- static void validated_construct(Variant *r_ret, const Variant **p_args) {
- VariantTypeChanger<T>::change_and_reset(r_ret);
- }
- static void ptr_construct(void *base, const void **p_args) {
- PtrConstruct<T>::construct(T(), base);
- }
-
- static int get_argument_count() {
- return 0;
- }
-
- static Variant::Type get_argument_type(int p_arg) {
- return Variant::NIL;
- }
-
- static Variant::Type get_base_type() {
- return GetTypeInfo<T>::VARIANT_TYPE;
- }
-};
-
-class VariantConstructNoArgsNil {
-public:
- static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) {
- VariantInternal::clear(&r_ret);
- r_error.error = Callable::CallError::CALL_OK;
- }
-
- static void validated_construct(Variant *r_ret, const Variant **p_args) {
- VariantInternal::clear(r_ret);
- }
- static void ptr_construct(void *base, const void **p_args) {
- ERR_FAIL_MSG("can't ptrcall nil constructor");
- }
-
- static int get_argument_count() {
- return 0;
- }
-
- static Variant::Type get_argument_type(int p_arg) {
- return Variant::NIL;
- }
-
- static Variant::Type get_base_type() {
- return Variant::NIL;
- }
-};
-
-class VariantConstructNoArgsObject {
-public:
- static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) {
- VariantInternal::clear(&r_ret);
- VariantInternal::object_assign_null(&r_ret);
- r_error.error = Callable::CallError::CALL_OK;
- }
-
- static void validated_construct(Variant *r_ret, const Variant **p_args) {
- VariantInternal::clear(r_ret);
- VariantInternal::object_assign_null(r_ret);
- }
- static void ptr_construct(void *base, const void **p_args) {
- PtrConstruct<Object *>::construct(nullptr, base);
- }
-
- static int get_argument_count() {
- return 0;
- }
-
- static Variant::Type get_argument_type(int p_arg) {
- return Variant::NIL;
- }
-
- static Variant::Type get_base_type() {
- return Variant::OBJECT;
- }
-};
+#include "variant_construct.h"
struct VariantConstructData {
void (*construct)(Variant &r_base, const Variant **p_args, Callable::CallError &r_error);
diff --git a/core/variant/variant_construct.h b/core/variant/variant_construct.h
new file mode 100644
index 0000000000..b03f4a8d3b
--- /dev/null
+++ b/core/variant/variant_construct.h
@@ -0,0 +1,572 @@
+/*************************************************************************/
+/* variant_construct.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef VARIANT_CONSTRUCT_H
+#define VARIANT_CONSTRUCT_H
+
+#include "variant.h"
+
+#include "core/core_string_names.h"
+#include "core/crypto/crypto_core.h"
+#include "core/debugger/engine_debugger.h"
+#include "core/io/compression.h"
+#include "core/object/class_db.h"
+#include "core/os/os.h"
+#include "core/templates/local_vector.h"
+#include "core/templates/oa_hash_map.h"
+
+template <class T>
+struct PtrConstruct {};
+
+#define MAKE_PTRCONSTRUCT(m_type) \
+ template <> \
+ struct PtrConstruct<m_type> { \
+ _FORCE_INLINE_ static void construct(const m_type &p_value, void *p_ptr) { \
+ memnew_placement(p_ptr, m_type(p_value)); \
+ } \
+ };
+
+MAKE_PTRCONSTRUCT(bool);
+MAKE_PTRCONSTRUCT(int64_t);
+MAKE_PTRCONSTRUCT(double);
+MAKE_PTRCONSTRUCT(String);
+MAKE_PTRCONSTRUCT(Vector2);
+MAKE_PTRCONSTRUCT(Vector2i);
+MAKE_PTRCONSTRUCT(Rect2);
+MAKE_PTRCONSTRUCT(Rect2i);
+MAKE_PTRCONSTRUCT(Vector3);
+MAKE_PTRCONSTRUCT(Vector3i);
+MAKE_PTRCONSTRUCT(Transform2D);
+MAKE_PTRCONSTRUCT(Plane);
+MAKE_PTRCONSTRUCT(Quaternion);
+MAKE_PTRCONSTRUCT(AABB);
+MAKE_PTRCONSTRUCT(Basis);
+MAKE_PTRCONSTRUCT(Transform3D);
+MAKE_PTRCONSTRUCT(Color);
+MAKE_PTRCONSTRUCT(StringName);
+MAKE_PTRCONSTRUCT(NodePath);
+MAKE_PTRCONSTRUCT(RID);
+
+template <>
+struct PtrConstruct<Object *> {
+ _FORCE_INLINE_ static void construct(Object *p_value, void *p_ptr) {
+ *((Object **)p_ptr) = p_value;
+ }
+};
+
+MAKE_PTRCONSTRUCT(Callable);
+MAKE_PTRCONSTRUCT(Signal);
+MAKE_PTRCONSTRUCT(Dictionary);
+MAKE_PTRCONSTRUCT(Array);
+MAKE_PTRCONSTRUCT(PackedByteArray);
+MAKE_PTRCONSTRUCT(PackedInt32Array);
+MAKE_PTRCONSTRUCT(PackedInt64Array);
+MAKE_PTRCONSTRUCT(PackedFloat32Array);
+MAKE_PTRCONSTRUCT(PackedFloat64Array);
+MAKE_PTRCONSTRUCT(PackedStringArray);
+MAKE_PTRCONSTRUCT(PackedVector2Array);
+MAKE_PTRCONSTRUCT(PackedVector3Array);
+MAKE_PTRCONSTRUCT(PackedColorArray);
+MAKE_PTRCONSTRUCT(Variant);
+
+template <class T, class... P>
+class VariantConstructor {
+ template <size_t... Is>
+ static _FORCE_INLINE_ void construct_helper(T &base, const Variant **p_args, Callable::CallError &r_error, IndexSequence<Is...>) {
+ r_error.error = Callable::CallError::CALL_OK;
+
+#ifdef DEBUG_METHODS_ENABLED
+ base = T(VariantCasterAndValidate<P>::cast(p_args, Is, r_error)...);
+#else
+ base = T(VariantCaster<P>::cast(*p_args[Is])...);
+#endif
+ }
+
+ template <size_t... Is>
+ static _FORCE_INLINE_ void validated_construct_helper(T &base, const Variant **p_args, IndexSequence<Is...>) {
+ base = T((*VariantGetInternalPtr<P>::get_ptr(p_args[Is]))...);
+ }
+
+ template <size_t... Is>
+ static _FORCE_INLINE_ void ptr_construct_helper(void *base, const void **p_args, IndexSequence<Is...>) {
+ PtrConstruct<T>::construct(T(PtrToArg<P>::convert(p_args[Is])...), base);
+ }
+
+public:
+ static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) {
+ r_error.error = Callable::CallError::CALL_OK;
+ VariantTypeChanger<T>::change(&r_ret);
+ construct_helper(*VariantGetInternalPtr<T>::get_ptr(&r_ret), p_args, r_error, BuildIndexSequence<sizeof...(P)>{});
+ }
+
+ static inline void validated_construct(Variant *r_ret, const Variant **p_args) {
+ VariantTypeChanger<T>::change(r_ret);
+ validated_construct_helper(*VariantGetInternalPtr<T>::get_ptr(r_ret), p_args, BuildIndexSequence<sizeof...(P)>{});
+ }
+ static void ptr_construct(void *base, const void **p_args) {
+ ptr_construct_helper(base, p_args, BuildIndexSequence<sizeof...(P)>{});
+ }
+
+ static int get_argument_count() {
+ return sizeof...(P);
+ }
+
+ static Variant::Type get_argument_type(int p_arg) {
+ return call_get_argument_type<P...>(p_arg);
+ }
+
+ static Variant::Type get_base_type() {
+ return GetTypeInfo<T>::VARIANT_TYPE;
+ }
+};
+
+class VariantConstructorObject {
+public:
+ static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) {
+ VariantInternal::clear(&r_ret);
+ if (p_args[0]->get_type() == Variant::NIL) {
+ VariantInternal::object_assign_null(&r_ret);
+ r_error.error = Callable::CallError::CALL_OK;
+ } else if (p_args[0]->get_type() == Variant::OBJECT) {
+ VariantInternal::object_assign(&r_ret, p_args[0]);
+ r_error.error = Callable::CallError::CALL_OK;
+ } else {
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.argument = 0;
+ r_error.expected = Variant::OBJECT;
+ }
+ }
+
+ static inline void validated_construct(Variant *r_ret, const Variant **p_args) {
+ VariantInternal::clear(r_ret);
+ VariantInternal::object_assign(r_ret, p_args[0]);
+ }
+ static void ptr_construct(void *base, const void **p_args) {
+ PtrConstruct<Object *>::construct(PtrToArg<Object *>::convert(p_args[0]), base);
+ }
+
+ static int get_argument_count() {
+ return 1;
+ }
+
+ static Variant::Type get_argument_type(int p_arg) {
+ return Variant::OBJECT;
+ }
+
+ static Variant::Type get_base_type() {
+ return Variant::OBJECT;
+ }
+};
+
+class VariantConstructorNilObject {
+public:
+ static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) {
+ if (p_args[0]->get_type() != Variant::NIL) {
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.argument = 0;
+ r_error.expected = Variant::NIL;
+ }
+
+ VariantInternal::clear(&r_ret);
+ VariantInternal::object_assign_null(&r_ret);
+ }
+
+ static inline void validated_construct(Variant *r_ret, const Variant **p_args) {
+ VariantInternal::clear(r_ret);
+ VariantInternal::object_assign_null(r_ret);
+ }
+ static void ptr_construct(void *base, const void **p_args) {
+ PtrConstruct<Object *>::construct(nullptr, base);
+ }
+
+ static int get_argument_count() {
+ return 1;
+ }
+
+ static Variant::Type get_argument_type(int p_arg) {
+ return Variant::NIL;
+ }
+
+ static Variant::Type get_base_type() {
+ return Variant::OBJECT;
+ }
+};
+
+class VariantConstructorCallableArgs {
+public:
+ static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) {
+ ObjectID object_id;
+ StringName method;
+
+ if (p_args[0]->get_type() == Variant::NIL) {
+ // leave as is
+ } else if (p_args[0]->get_type() == Variant::OBJECT) {
+ object_id = VariantInternal::get_object_id(p_args[0]);
+ } else {
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.argument = 0;
+ r_error.expected = Variant::OBJECT;
+ return;
+ }
+
+ if (p_args[1]->get_type() == Variant::STRING_NAME) {
+ method = *VariantGetInternalPtr<StringName>::get_ptr(p_args[1]);
+ } else if (p_args[1]->get_type() == Variant::STRING) {
+ method = *VariantGetInternalPtr<String>::get_ptr(p_args[1]);
+ } else {
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.argument = 1;
+ r_error.expected = Variant::STRING_NAME;
+ return;
+ }
+
+ VariantTypeChanger<Callable>::change(&r_ret);
+ *VariantGetInternalPtr<Callable>::get_ptr(&r_ret) = Callable(object_id, method);
+ }
+
+ static inline void validated_construct(Variant *r_ret, const Variant **p_args) {
+ VariantTypeChanger<Callable>::change(r_ret);
+ *VariantGetInternalPtr<Callable>::get_ptr(r_ret) = Callable(VariantInternal::get_object_id(p_args[0]), *VariantGetInternalPtr<StringName>::get_ptr(p_args[1]));
+ }
+ static void ptr_construct(void *base, const void **p_args) {
+ PtrConstruct<Callable>::construct(Callable(PtrToArg<Object *>::convert(p_args[0]), PtrToArg<StringName>::convert(p_args[1])), base);
+ }
+
+ static int get_argument_count() {
+ return 2;
+ }
+
+ static Variant::Type get_argument_type(int p_arg) {
+ if (p_arg == 0) {
+ return Variant::OBJECT;
+ } else {
+ return Variant::STRING_NAME;
+ }
+ }
+
+ static Variant::Type get_base_type() {
+ return Variant::CALLABLE;
+ }
+};
+
+class VariantConstructorSignalArgs {
+public:
+ static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) {
+ ObjectID object_id;
+ StringName method;
+
+ if (p_args[0]->get_type() == Variant::NIL) {
+ // leave as is
+ } else if (p_args[0]->get_type() == Variant::OBJECT) {
+ object_id = VariantInternal::get_object_id(p_args[0]);
+ } else {
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.argument = 0;
+ r_error.expected = Variant::OBJECT;
+ return;
+ }
+
+ if (p_args[1]->get_type() == Variant::STRING_NAME) {
+ method = *VariantGetInternalPtr<StringName>::get_ptr(p_args[1]);
+ } else if (p_args[1]->get_type() == Variant::STRING) {
+ method = *VariantGetInternalPtr<String>::get_ptr(p_args[1]);
+ } else {
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.argument = 1;
+ r_error.expected = Variant::STRING_NAME;
+ return;
+ }
+
+ VariantTypeChanger<Signal>::change(&r_ret);
+ *VariantGetInternalPtr<Signal>::get_ptr(&r_ret) = Signal(object_id, method);
+ }
+
+ static inline void validated_construct(Variant *r_ret, const Variant **p_args) {
+ VariantTypeChanger<Signal>::change(r_ret);
+ *VariantGetInternalPtr<Signal>::get_ptr(r_ret) = Signal(VariantInternal::get_object_id(p_args[0]), *VariantGetInternalPtr<StringName>::get_ptr(p_args[1]));
+ }
+ static void ptr_construct(void *base, const void **p_args) {
+ PtrConstruct<Signal>::construct(Signal(PtrToArg<Object *>::convert(p_args[0]), PtrToArg<StringName>::convert(p_args[1])), base);
+ }
+
+ static int get_argument_count() {
+ return 2;
+ }
+
+ static Variant::Type get_argument_type(int p_arg) {
+ if (p_arg == 0) {
+ return Variant::OBJECT;
+ } else {
+ return Variant::STRING_NAME;
+ }
+ }
+
+ static Variant::Type get_base_type() {
+ return Variant::SIGNAL;
+ }
+};
+
+template <class T>
+class VariantConstructorToArray {
+public:
+ static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) {
+ if (p_args[0]->get_type() != GetTypeInfo<T>::VARIANT_TYPE) {
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.argument = 0;
+ r_error.expected = GetTypeInfo<T>::VARIANT_TYPE;
+ return;
+ }
+
+ VariantTypeChanger<Array>::change(&r_ret);
+ Array &dst_arr = *VariantGetInternalPtr<Array>::get_ptr(&r_ret);
+ const T &src_arr = *VariantGetInternalPtr<T>::get_ptr(p_args[0]);
+
+ int size = src_arr.size();
+ dst_arr.resize(size);
+ for (int i = 0; i < size; i++) {
+ dst_arr[i] = src_arr[i];
+ }
+ }
+
+ static inline void validated_construct(Variant *r_ret, const Variant **p_args) {
+ VariantTypeChanger<Array>::change(r_ret);
+ Array &dst_arr = *VariantGetInternalPtr<Array>::get_ptr(r_ret);
+ const T &src_arr = *VariantGetInternalPtr<T>::get_ptr(p_args[0]);
+
+ int size = src_arr.size();
+ dst_arr.resize(size);
+ for (int i = 0; i < size; i++) {
+ dst_arr[i] = src_arr[i];
+ }
+ }
+ static void ptr_construct(void *base, const void **p_args) {
+ Array dst_arr;
+ T src_arr = PtrToArg<T>::convert(p_args[0]);
+
+ int size = src_arr.size();
+ dst_arr.resize(size);
+ for (int i = 0; i < size; i++) {
+ dst_arr[i] = src_arr[i];
+ }
+
+ PtrConstruct<Array>::construct(dst_arr, base);
+ }
+
+ static int get_argument_count() {
+ return 1;
+ }
+
+ static Variant::Type get_argument_type(int p_arg) {
+ return GetTypeInfo<T>::VARIANT_TYPE;
+ }
+
+ static Variant::Type get_base_type() {
+ return Variant::ARRAY;
+ }
+};
+
+template <class T>
+class VariantConstructorFromArray {
+public:
+ static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) {
+ if (p_args[0]->get_type() != Variant::ARRAY) {
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.argument = 0;
+ r_error.expected = Variant::ARRAY;
+ return;
+ }
+
+ VariantTypeChanger<T>::change(&r_ret);
+ const Array &src_arr = *VariantGetInternalPtr<Array>::get_ptr(p_args[0]);
+ T &dst_arr = *VariantGetInternalPtr<T>::get_ptr(&r_ret);
+
+ int size = src_arr.size();
+ dst_arr.resize(size);
+ for (int i = 0; i < size; i++) {
+ dst_arr.write[i] = src_arr[i];
+ }
+ }
+
+ static inline void validated_construct(Variant *r_ret, const Variant **p_args) {
+ VariantTypeChanger<T>::change(r_ret);
+ const Array &src_arr = *VariantGetInternalPtr<Array>::get_ptr(p_args[0]);
+ T &dst_arr = *VariantGetInternalPtr<T>::get_ptr(r_ret);
+
+ int size = src_arr.size();
+ dst_arr.resize(size);
+ for (int i = 0; i < size; i++) {
+ dst_arr.write[i] = src_arr[i];
+ }
+ }
+ static void ptr_construct(void *base, const void **p_args) {
+ Array src_arr = PtrToArg<Array>::convert(p_args[0]);
+ T dst_arr;
+
+ int size = src_arr.size();
+ dst_arr.resize(size);
+ for (int i = 0; i < size; i++) {
+ dst_arr.write[i] = src_arr[i];
+ }
+
+ PtrConstruct<T>::construct(dst_arr, base);
+ }
+
+ static int get_argument_count() {
+ return 1;
+ }
+
+ static Variant::Type get_argument_type(int p_arg) {
+ return Variant::ARRAY;
+ }
+
+ static Variant::Type get_base_type() {
+ return GetTypeInfo<T>::VARIANT_TYPE;
+ }
+};
+
+class VariantConstructorNil {
+public:
+ static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) {
+ if (p_args[0]->get_type() != Variant::NIL) {
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.argument = 0;
+ r_error.expected = Variant::NIL;
+ return;
+ }
+
+ r_error.error = Callable::CallError::CALL_OK;
+ VariantInternal::clear(&r_ret);
+ }
+
+ static inline void validated_construct(Variant *r_ret, const Variant **p_args) {
+ VariantInternal::clear(r_ret);
+ }
+ static void ptr_construct(void *base, const void **p_args) {
+ PtrConstruct<Variant>::construct(Variant(), base);
+ }
+
+ static int get_argument_count() {
+ return 1;
+ }
+
+ static Variant::Type get_argument_type(int p_arg) {
+ return Variant::NIL;
+ }
+
+ static Variant::Type get_base_type() {
+ return Variant::NIL;
+ }
+};
+
+template <class T>
+class VariantConstructNoArgs {
+public:
+ static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) {
+ VariantTypeChanger<T>::change_and_reset(&r_ret);
+ r_error.error = Callable::CallError::CALL_OK;
+ }
+
+ static inline void validated_construct(Variant *r_ret, const Variant **p_args) {
+ VariantTypeChanger<T>::change_and_reset(r_ret);
+ }
+ static void ptr_construct(void *base, const void **p_args) {
+ PtrConstruct<T>::construct(T(), base);
+ }
+
+ static int get_argument_count() {
+ return 0;
+ }
+
+ static Variant::Type get_argument_type(int p_arg) {
+ return Variant::NIL;
+ }
+
+ static Variant::Type get_base_type() {
+ return GetTypeInfo<T>::VARIANT_TYPE;
+ }
+};
+
+class VariantConstructNoArgsNil {
+public:
+ static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) {
+ VariantInternal::clear(&r_ret);
+ r_error.error = Callable::CallError::CALL_OK;
+ }
+
+ static inline void validated_construct(Variant *r_ret, const Variant **p_args) {
+ VariantInternal::clear(r_ret);
+ }
+ static void ptr_construct(void *base, const void **p_args) {
+ ERR_FAIL_MSG("can't ptrcall nil constructor");
+ }
+
+ static int get_argument_count() {
+ return 0;
+ }
+
+ static Variant::Type get_argument_type(int p_arg) {
+ return Variant::NIL;
+ }
+
+ static Variant::Type get_base_type() {
+ return Variant::NIL;
+ }
+};
+
+class VariantConstructNoArgsObject {
+public:
+ static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) {
+ VariantInternal::clear(&r_ret);
+ VariantInternal::object_assign_null(&r_ret);
+ r_error.error = Callable::CallError::CALL_OK;
+ }
+
+ static inline void validated_construct(Variant *r_ret, const Variant **p_args) {
+ VariantInternal::clear(r_ret);
+ VariantInternal::object_assign_null(r_ret);
+ }
+ static void ptr_construct(void *base, const void **p_args) {
+ PtrConstruct<Object *>::construct(nullptr, base);
+ }
+
+ static int get_argument_count() {
+ return 0;
+ }
+
+ static Variant::Type get_argument_type(int p_arg) {
+ return Variant::NIL;
+ }
+
+ static Variant::Type get_base_type() {
+ return Variant::OBJECT;
+ }
+};
+
+#endif // VARIANT_CONSTRUCT_H
diff --git a/core/variant/variant_op.cpp b/core/variant/variant_op.cpp
index 10d0a83014..16c7428781 100644
--- a/core/variant/variant_op.cpp
+++ b/core/variant/variant_op.cpp
@@ -28,1342 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "variant.h"
-
-#include "core/core_string_names.h"
-#include "core/debugger/engine_debugger.h"
-#include "core/object/class_db.h"
-
-template <class R, class A, class B>
-class OperatorEvaluatorAdd {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
- const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
- *r_ret = a + b;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<R>::change(r_ret);
- *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) + *VariantGetInternalPtr<B>::get_ptr(right);
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<R>::encode(PtrToArg<A>::convert(left) + PtrToArg<B>::convert(right), r_ret);
- }
- static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
-};
-
-template <class R, class A, class B>
-class OperatorEvaluatorSub {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
- const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
- *r_ret = a - b;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<R>::change(r_ret);
- *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) - *VariantGetInternalPtr<B>::get_ptr(right);
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<R>::encode(PtrToArg<A>::convert(left) - PtrToArg<B>::convert(right), r_ret);
- }
- static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
-};
-
-template <class R, class A, class B>
-class OperatorEvaluatorMul {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
- const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
- *r_ret = a * b;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<R>::change(r_ret);
- *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) * *VariantGetInternalPtr<B>::get_ptr(right);
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<R>::encode(PtrToArg<A>::convert(left) * PtrToArg<B>::convert(right), r_ret);
- }
- static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
-};
-
-template <class R, class A, class B>
-class OperatorEvaluatorXForm {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
- const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
- *r_ret = a.xform(b);
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<R>::change(r_ret);
- *VariantGetInternalPtr<R>::get_ptr(r_ret) = VariantGetInternalPtr<A>::get_ptr(left)->xform(*VariantGetInternalPtr<B>::get_ptr(right));
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<R>::encode(PtrToArg<A>::convert(left).xform(PtrToArg<B>::convert(right)), r_ret);
- }
- static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
-};
-
-template <class R, class A, class B>
-class OperatorEvaluatorXFormInv {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
- const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
- *r_ret = b.xform_inv(a);
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<R>::change(r_ret);
- *VariantGetInternalPtr<R>::get_ptr(r_ret) = VariantGetInternalPtr<B>::get_ptr(right)->xform_inv(*VariantGetInternalPtr<A>::get_ptr(left));
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<R>::encode(PtrToArg<B>::convert(right).xform_inv(PtrToArg<A>::convert(left)), r_ret);
- }
- static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
-};
-
-template <class R, class A, class B>
-class OperatorEvaluatorDiv {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
- const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
- *r_ret = a / b;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<R>::change(r_ret);
- *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) / *VariantGetInternalPtr<B>::get_ptr(right);
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<R>::encode(PtrToArg<A>::convert(left) / PtrToArg<B>::convert(right), r_ret);
- }
- static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
-};
-
-template <class R, class A, class B>
-class OperatorEvaluatorDivNZ {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
- const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
- if (b == 0) {
- r_valid = false;
- *r_ret = "Division by zero error";
- return;
- }
- *r_ret = a / b;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<R>::change(r_ret);
- *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) / *VariantGetInternalPtr<B>::get_ptr(right);
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<R>::encode(PtrToArg<A>::convert(left) / PtrToArg<B>::convert(right), r_ret);
- }
- static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
-};
-
-template <class R, class A, class B>
-class OperatorEvaluatorMod {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
- const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
- *r_ret = a % b;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<R>::change(r_ret);
- *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) % *VariantGetInternalPtr<B>::get_ptr(right);
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<R>::encode(PtrToArg<A>::convert(left) % PtrToArg<B>::convert(right), r_ret);
- }
- static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
-};
-
-template <class R, class A, class B>
-class OperatorEvaluatorModNZ {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
- const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
- if (b == 0) {
- r_valid = false;
- *r_ret = "Module by zero error";
- return;
- }
- *r_ret = a % b;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<R>::change(r_ret);
- *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) % *VariantGetInternalPtr<B>::get_ptr(right);
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<R>::encode(PtrToArg<A>::convert(left) % PtrToArg<B>::convert(right), r_ret);
- }
- static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
-};
-
-template <class R, class A>
-class OperatorEvaluatorNeg {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
- *r_ret = -a;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<R>::change(r_ret);
- *VariantGetInternalPtr<R>::get_ptr(r_ret) = -*VariantGetInternalPtr<A>::get_ptr(left);
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<R>::encode(-PtrToArg<A>::convert(left), r_ret);
- }
- static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
-};
-
-template <class R, class A>
-class OperatorEvaluatorPos {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
- *r_ret = a;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<R>::change(r_ret);
- *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left);
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<R>::encode(PtrToArg<A>::convert(left), r_ret);
- }
- static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
-};
-
-template <class R, class A, class B>
-class OperatorEvaluatorShiftLeft {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
- const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
-
-#if defined(DEBUG_ENABLED)
- if (b < 0 || a < 0) {
- *r_ret = "Invalid operands for bit shifting. Only positive operands are supported.";
- r_valid = false;
- return;
- }
-#endif
- *r_ret = a << b;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<R>::change(r_ret);
- *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) << *VariantGetInternalPtr<B>::get_ptr(right);
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<R>::encode(PtrToArg<A>::convert(left) << PtrToArg<B>::convert(right), r_ret);
- }
- static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
-};
-
-template <class R, class A, class B>
-class OperatorEvaluatorShiftRight {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
- const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
-
-#if defined(DEBUG_ENABLED)
- if (b < 0 || a < 0) {
- *r_ret = "Invalid operands for bit shifting. Only positive operands are supported.";
- r_valid = false;
- return;
- }
-#endif
- *r_ret = a >> b;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<R>::change(r_ret);
- *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) >> *VariantGetInternalPtr<B>::get_ptr(right);
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<R>::encode(PtrToArg<A>::convert(left) >> PtrToArg<B>::convert(right), r_ret);
- }
- static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
-};
-
-template <class R, class A, class B>
-class OperatorEvaluatorBitOr {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
- const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
- *r_ret = a | b;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<R>::change(r_ret);
- *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) | *VariantGetInternalPtr<B>::get_ptr(right);
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<R>::encode(PtrToArg<A>::convert(left) | PtrToArg<B>::convert(right), r_ret);
- }
- static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
-};
-
-template <class R, class A, class B>
-class OperatorEvaluatorBitAnd {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
- const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
- *r_ret = a & b;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<R>::change(r_ret);
- *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) & *VariantGetInternalPtr<B>::get_ptr(right);
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<R>::encode(PtrToArg<A>::convert(left) & PtrToArg<B>::convert(right), r_ret);
- }
- static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
-};
-
-template <class R, class A, class B>
-class OperatorEvaluatorBitXor {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
- const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
- *r_ret = a ^ b;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<R>::change(r_ret);
- *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) ^ *VariantGetInternalPtr<B>::get_ptr(right);
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<R>::encode(PtrToArg<A>::convert(left) ^ PtrToArg<B>::convert(right), r_ret);
- }
- static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
-};
-
-template <class R, class A>
-class OperatorEvaluatorBitNeg {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
- *r_ret = ~a;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<R>::change(r_ret);
- *VariantGetInternalPtr<R>::get_ptr(r_ret) = ~*VariantGetInternalPtr<A>::get_ptr(left);
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<R>::encode(~PtrToArg<A>::convert(left), r_ret);
- }
- static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
-};
-
-template <class A, class B>
-class OperatorEvaluatorEqual {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
- const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
- *r_ret = a == b;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<bool>::change(r_ret);
- *VariantGetInternalPtr<bool>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) == *VariantGetInternalPtr<B>::get_ptr(right);
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<bool>::encode(PtrToArg<A>::convert(left) == PtrToArg<B>::convert(right), r_ret);
- }
- static Variant::Type get_return_type() { return Variant::BOOL; }
-};
-
-class OperatorEvaluatorEqualObject {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const Object *a = p_left.get_validated_object();
- const Object *b = p_right.get_validated_object();
- *r_ret = a == b;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- const Object *a = left->get_validated_object();
- const Object *b = right->get_validated_object();
- VariantTypeChanger<bool>::change(r_ret);
- *VariantGetInternalPtr<bool>::get_ptr(r_ret) = a == b;
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<bool>::encode(PtrToArg<Object *>::convert(left) == PtrToArg<Object *>::convert(right), r_ret);
- }
- static Variant::Type get_return_type() { return Variant::BOOL; }
-};
-
-class OperatorEvaluatorEqualObjectNil {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const Object *a = p_left.get_validated_object();
- *r_ret = a == nullptr;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- const Object *a = left->get_validated_object();
- VariantTypeChanger<bool>::change(r_ret);
- *VariantGetInternalPtr<bool>::get_ptr(r_ret) = a == nullptr;
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<bool>::encode(PtrToArg<Object *>::convert(left) == nullptr, r_ret);
- }
- static Variant::Type get_return_type() { return Variant::BOOL; }
-};
-
-class OperatorEvaluatorEqualNilObject {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const Object *b = p_right.get_validated_object();
- *r_ret = nullptr == b;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- const Object *b = right->get_validated_object();
- VariantTypeChanger<bool>::change(r_ret);
- *VariantGetInternalPtr<bool>::get_ptr(r_ret) = nullptr == b;
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<bool>::encode(nullptr == PtrToArg<Object *>::convert(right), r_ret);
- }
- static Variant::Type get_return_type() { return Variant::BOOL; }
-};
-
-template <class A, class B>
-class OperatorEvaluatorNotEqual {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
- const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
- *r_ret = a != b;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<bool>::change(r_ret);
- *VariantGetInternalPtr<bool>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) != *VariantGetInternalPtr<B>::get_ptr(right);
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<bool>::encode(PtrToArg<A>::convert(left) != PtrToArg<B>::convert(right), r_ret);
- }
- static Variant::Type get_return_type() { return Variant::BOOL; }
-};
-
-class OperatorEvaluatorNotEqualObject {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- Object *a = p_left.get_validated_object();
- Object *b = p_right.get_validated_object();
- *r_ret = a != b;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- Object *a = left->get_validated_object();
- Object *b = right->get_validated_object();
- VariantTypeChanger<bool>::change(r_ret);
- *VariantGetInternalPtr<bool>::get_ptr(r_ret) = a != b;
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<bool>::encode(PtrToArg<Object *>::convert(left) != PtrToArg<Object *>::convert(right), r_ret);
- }
- static Variant::Type get_return_type() { return Variant::BOOL; }
-};
-
-class OperatorEvaluatorNotEqualObjectNil {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- Object *a = p_left.get_validated_object();
- *r_ret = a != nullptr;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- Object *a = left->get_validated_object();
- VariantTypeChanger<bool>::change(r_ret);
- *VariantGetInternalPtr<bool>::get_ptr(r_ret) = a != nullptr;
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<bool>::encode(PtrToArg<Object *>::convert(left) != nullptr, r_ret);
- }
- static Variant::Type get_return_type() { return Variant::BOOL; }
-};
-
-class OperatorEvaluatorNotEqualNilObject {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- Object *b = p_right.get_validated_object();
- *r_ret = nullptr != b;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- Object *b = right->get_validated_object();
- VariantTypeChanger<bool>::change(r_ret);
- *VariantGetInternalPtr<bool>::get_ptr(r_ret) = nullptr != b;
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<bool>::encode(nullptr != PtrToArg<Object *>::convert(right), r_ret);
- }
- static Variant::Type get_return_type() { return Variant::BOOL; }
-};
-
-template <class A, class B>
-class OperatorEvaluatorLess {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
- const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
- *r_ret = a < b;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<bool>::change(r_ret);
- *VariantGetInternalPtr<bool>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) < *VariantGetInternalPtr<B>::get_ptr(right);
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<bool>::encode(PtrToArg<A>::convert(left) < PtrToArg<B>::convert(right), r_ret);
- }
- static Variant::Type get_return_type() { return Variant::BOOL; }
-};
-
-template <class A, class B>
-class OperatorEvaluatorLessEqual {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
- const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
- *r_ret = a <= b;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<bool>::change(r_ret);
- *VariantGetInternalPtr<bool>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) <= *VariantGetInternalPtr<B>::get_ptr(right);
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<bool>::encode(PtrToArg<A>::convert(left) <= PtrToArg<B>::convert(right), r_ret);
- }
- static Variant::Type get_return_type() { return Variant::BOOL; }
-};
-
-template <class A, class B>
-class OperatorEvaluatorGreater {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
- const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
- *r_ret = a > b;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<bool>::change(r_ret);
- *VariantGetInternalPtr<bool>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) > *VariantGetInternalPtr<B>::get_ptr(right);
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<bool>::encode(PtrToArg<A>::convert(left) > PtrToArg<B>::convert(right), r_ret);
- }
- static Variant::Type get_return_type() { return Variant::BOOL; }
-};
-
-template <class A, class B>
-class OperatorEvaluatorGreaterEqual {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
- const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
- *r_ret = a >= b;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<bool>::change(r_ret);
- *VariantGetInternalPtr<bool>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) >= *VariantGetInternalPtr<B>::get_ptr(right);
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<bool>::encode(PtrToArg<A>::convert(left) >= PtrToArg<B>::convert(right), r_ret);
- }
- static Variant::Type get_return_type() { return Variant::BOOL; }
-};
-
-template <class A, class B>
-class OperatorEvaluatorAnd {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
- const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
- *r_ret = a && b;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<bool>::change(r_ret);
- *VariantGetInternalPtr<bool>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) && *VariantGetInternalPtr<B>::get_ptr(right);
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<bool>::encode(PtrToArg<A>::convert(left) && PtrToArg<B>::convert(right), r_ret);
- }
- static Variant::Type get_return_type() { return Variant::BOOL; }
-};
-
-template <class A, class B>
-class OperatorEvaluatorOr {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
- const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
- *r_ret = a || b;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<bool>::change(r_ret);
- *VariantGetInternalPtr<bool>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) || *VariantGetInternalPtr<B>::get_ptr(right);
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<bool>::encode(PtrToArg<A>::convert(left) || PtrToArg<B>::convert(right), r_ret);
- }
- static Variant::Type get_return_type() { return Variant::BOOL; }
-};
-
-#define XOR_OP(m_a, m_b) (((m_a) || (m_b)) && !((m_a) && (m_b)))
-template <class A, class B>
-class OperatorEvaluatorXor {
-public:
- _FORCE_INLINE_ static bool xor_op(const A &a, const B &b) {
- return ((a) || (b)) && !((a) && (b));
- }
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
- const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
- *r_ret = xor_op(a, b);
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<bool>::change(r_ret);
- *VariantGetInternalPtr<bool>::get_ptr(r_ret) = xor_op(*VariantGetInternalPtr<A>::get_ptr(left), *VariantGetInternalPtr<B>::get_ptr(right));
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<bool>::encode(xor_op(PtrToArg<A>::convert(left), PtrToArg<B>::convert(right)), r_ret);
- }
- static Variant::Type get_return_type() { return Variant::BOOL; }
-};
-
-template <class A>
-class OperatorEvaluatorNot {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
- *r_ret = !a;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<bool>::change(r_ret);
- *VariantGetInternalPtr<bool>::get_ptr(r_ret) = !*VariantGetInternalPtr<A>::get_ptr(left);
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<bool>::encode(!PtrToArg<A>::convert(left));
- }
- static Variant::Type get_return_type() { return Variant::BOOL; }
-};
-
-//// CUSTOM ////
-
-class OperatorEvaluatorAddArray {
-public:
- _FORCE_INLINE_ static void _add_arrays(Array &sum, const Array &array_a, const Array &array_b) {
- int asize = array_a.size();
- int bsize = array_b.size();
- sum.resize(asize + bsize);
- for (int i = 0; i < asize; i++) {
- sum[i] = array_a[i];
- }
- for (int i = 0; i < bsize; i++) {
- sum[i + asize] = array_b[i];
- }
- }
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const Array &array_a = *VariantGetInternalPtr<Array>::get_ptr(&p_left);
- const Array &array_b = *VariantGetInternalPtr<Array>::get_ptr(&p_right);
- Array sum;
- _add_arrays(sum, array_a, array_b);
- *r_ret = sum;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<Array>::change(r_ret);
- _add_arrays(*VariantGetInternalPtr<Array>::get_ptr(r_ret), *VariantGetInternalPtr<Array>::get_ptr(left), *VariantGetInternalPtr<Array>::get_ptr(right));
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- Array ret;
- _add_arrays(ret, PtrToArg<Array>::convert(left), PtrToArg<Array>::convert(right));
- PtrToArg<Array>::encode(ret, r_ret);
- }
- static Variant::Type get_return_type() { return Variant::ARRAY; }
-};
-
-template <class T>
-class OperatorEvaluatorAppendArray {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const Vector<T> &array_a = *VariantGetInternalPtr<Vector<T>>::get_ptr(&p_left);
- const Vector<T> &array_b = *VariantGetInternalPtr<Vector<T>>::get_ptr(&p_right);
- Vector<T> sum = array_a;
- sum.append_array(array_b);
- *r_ret = sum;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<Vector<T>>::change(r_ret);
- *VariantGetInternalPtr<Vector<T>>::get_ptr(r_ret) = *VariantGetInternalPtr<Vector<T>>::get_ptr(left);
- VariantGetInternalPtr<Vector<T>>::get_ptr(r_ret)->append_array(*VariantGetInternalPtr<Vector<T>>::get_ptr(right));
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- Vector<T> sum = PtrToArg<Vector<T>>::convert(left);
- sum.append_array(PtrToArg<Vector<T>>::convert(right));
- PtrToArg<Vector<T>>::encode(sum, r_ret);
- }
- static Variant::Type get_return_type() { return GetTypeInfo<Vector<T>>::VARIANT_TYPE; }
-};
-
-class OperatorEvaluatorStringModNil {
-public:
- _FORCE_INLINE_ static String do_mod(const String &s, bool *r_valid) {
- Array values;
- values.push_back(Variant());
-
- String a = s.sprintf(values, r_valid);
- if (r_valid) {
- *r_valid = !*r_valid;
- }
- return a;
- }
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const String &a = *VariantGetInternalPtr<String>::get_ptr(&p_left);
- *r_ret = do_mod(a, &r_valid);
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<String>::change(r_ret);
- *VariantGetInternalPtr<String>::get_ptr(r_ret) = do_mod(*VariantGetInternalPtr<String>::get_ptr(left), nullptr);
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<String>::encode(do_mod(PtrToArg<String>::convert(left), nullptr), r_ret);
- }
- static Variant::Type get_return_type() { return Variant::STRING; }
-};
-
-class OperatorEvaluatorStringModArray {
-public:
- _FORCE_INLINE_ static String do_mod(const String &s, const Array &p_values, bool *r_valid) {
- String a = s.sprintf(p_values, r_valid);
- if (r_valid) {
- *r_valid = !*r_valid;
- }
- return a;
- }
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const String &a = *VariantGetInternalPtr<String>::get_ptr(&p_left);
- *r_ret = do_mod(a, *VariantGetInternalPtr<Array>::get_ptr(&p_right), &r_valid);
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<String>::change(r_ret);
- *VariantGetInternalPtr<String>::get_ptr(r_ret) = do_mod(*VariantGetInternalPtr<String>::get_ptr(left), *VariantGetInternalPtr<Array>::get_ptr(right), nullptr);
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<String>::encode(do_mod(PtrToArg<String>::convert(left), PtrToArg<Array>::convert(right), nullptr), r_ret);
- }
- static Variant::Type get_return_type() { return Variant::STRING; }
-};
-
-class OperatorEvaluatorStringModObject {
-public:
- _FORCE_INLINE_ static String do_mod(const String &s, const Object *p_object, bool *r_valid) {
- Array values;
- values.push_back(p_object);
- String a = s.sprintf(values, r_valid);
- if (r_valid) {
- *r_valid = !*r_valid;
- }
-
- return a;
- }
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const String &a = *VariantGetInternalPtr<String>::get_ptr(&p_left);
- *r_ret = do_mod(a, p_right.get_validated_object(), &r_valid);
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<String>::change(r_ret);
- *VariantGetInternalPtr<String>::get_ptr(r_ret) = do_mod(*VariantGetInternalPtr<String>::get_ptr(left), right->get_validated_object(), nullptr);
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<String>::encode(do_mod(PtrToArg<String>::convert(left), PtrToArg<Object *>::convert(right), nullptr), r_ret);
- }
- static Variant::Type get_return_type() { return Variant::STRING; }
-};
-
-template <class T>
-class OperatorEvaluatorStringModT {
-public:
- _FORCE_INLINE_ static String do_mod(const String &s, const T &p_value, bool *r_valid) {
- Array values;
- values.push_back(p_value);
- String a = s.sprintf(values, r_valid);
- if (r_valid) {
- *r_valid = !*r_valid;
- }
- return a;
- }
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const String &a = *VariantGetInternalPtr<String>::get_ptr(&p_left);
- *r_ret = do_mod(a, *VariantGetInternalPtr<T>::get_ptr(&p_right), &r_valid);
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<String>::change(r_ret);
- *VariantGetInternalPtr<String>::get_ptr(r_ret) = do_mod(*VariantGetInternalPtr<String>::get_ptr(left), *VariantGetInternalPtr<T>::get_ptr(right), nullptr);
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<String>::encode(do_mod(PtrToArg<String>::convert(left), PtrToArg<T>::convert(right), nullptr), r_ret);
- }
- static Variant::Type get_return_type() { return Variant::STRING; }
-};
-
-template <Variant::Operator op, Variant::Type type_left, Variant::Type type_right>
-class OperatorEvaluatorAlwaysTrue {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- *r_ret = true;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<bool>::change(r_ret);
- *VariantGetInternalPtr<bool>::get_ptr(r_ret) = true;
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<bool>::encode(true, r_ret);
- }
- static Variant::Type get_return_type() { return Variant::BOOL; }
-};
-
-template <Variant::Operator op, Variant::Type type_left, Variant::Type type_right>
-class OperatorEvaluatorAlwaysFalse {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- *r_ret = false;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<bool>::change(r_ret);
- *VariantGetInternalPtr<bool>::get_ptr(r_ret) = false;
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<bool>::encode(false, r_ret);
- }
- static Variant::Type get_return_type() { return Variant::BOOL; }
-};
-
-///// OR ///////
-
-_FORCE_INLINE_ static bool _operate_or(bool p_left, bool p_right) {
- return p_left || p_right;
-}
-
-_FORCE_INLINE_ static bool _operate_and(bool p_left, bool p_right) {
- return p_left && p_right;
-}
-
-_FORCE_INLINE_ static bool _operate_xor(bool p_left, bool p_right) {
- return (p_left || p_right) && !(p_left && p_right);
-}
-
-_FORCE_INLINE_ static bool _operate_get_nil(const Variant *p_ptr) {
- return p_ptr->get_validated_object() != nullptr;
-}
-
-_FORCE_INLINE_ static bool _operate_get_bool(const Variant *p_ptr) {
- return *VariantGetInternalPtr<bool>::get_ptr(p_ptr);
-}
-
-_FORCE_INLINE_ static bool _operate_get_int(const Variant *p_ptr) {
- return *VariantGetInternalPtr<int64_t>::get_ptr(p_ptr) != 0;
-}
-
-_FORCE_INLINE_ static bool _operate_get_float(const Variant *p_ptr) {
- return *VariantGetInternalPtr<double>::get_ptr(p_ptr) != 0.0;
-}
-
-_FORCE_INLINE_ static bool _operate_get_object(const Variant *p_ptr) {
- return p_ptr->get_validated_object() != nullptr;
-}
-
-_FORCE_INLINE_ static bool _operate_get_ptr_nil(const void *p_ptr) {
- return false;
-}
-
-_FORCE_INLINE_ static bool _operate_get_ptr_bool(const void *p_ptr) {
- return PtrToArg<bool>::convert(p_ptr);
-}
-
-_FORCE_INLINE_ static bool _operate_get_ptr_int(const void *p_ptr) {
- return PtrToArg<int64_t>::convert(p_ptr) != 0;
-}
-
-_FORCE_INLINE_ static bool _operate_get_ptr_float(const void *p_ptr) {
- return PtrToArg<double>::convert(p_ptr) != 0.0;
-}
-
-_FORCE_INLINE_ static bool _operate_get_ptr_object(const void *p_ptr) {
- return PtrToArg<Object *>::convert(p_ptr) != nullptr;
-}
-
-#define OP_EVALUATOR(m_class_name, m_left, m_right, m_op) \
- class m_class_name { \
- public: \
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { \
- *r_ret = m_op(_operate_get_##m_left(&p_left), _operate_get_##m_right(&p_right)); \
- r_valid = true; \
- } \
- \
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { \
- VariantTypeChanger<bool>::change(r_ret); \
- *VariantGetInternalPtr<bool>::get_ptr(r_ret) = m_op(_operate_get_##m_left(left), _operate_get_##m_right(right)); \
- } \
- \
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) { \
- PtrToArg<bool>::encode(m_op(_operate_get_ptr_##m_left(left), _operate_get_ptr_##m_right(right)), r_ret); \
- } \
- \
- static Variant::Type get_return_type() { \
- return Variant::BOOL; \
- } \
- };
-
-// OR
-
-// nil
-OP_EVALUATOR(OperatorEvaluatorNilXBoolOr, nil, bool, _operate_or)
-OP_EVALUATOR(OperatorEvaluatorBoolXNilOr, bool, nil, _operate_or)
-
-OP_EVALUATOR(OperatorEvaluatorNilXIntOr, nil, int, _operate_or)
-OP_EVALUATOR(OperatorEvaluatorIntXNilOr, int, nil, _operate_or)
-
-OP_EVALUATOR(OperatorEvaluatorNilXFloatOr, nil, float, _operate_or)
-OP_EVALUATOR(OperatorEvaluatorFloatXNilOr, float, nil, _operate_or)
-
-OP_EVALUATOR(OperatorEvaluatorObjectXNilOr, object, nil, _operate_or)
-OP_EVALUATOR(OperatorEvaluatorNilXObjectOr, nil, object, _operate_or)
-
-// bool
-OP_EVALUATOR(OperatorEvaluatorBoolXBoolOr, bool, bool, _operate_or)
-
-OP_EVALUATOR(OperatorEvaluatorBoolXIntOr, bool, int, _operate_or)
-OP_EVALUATOR(OperatorEvaluatorIntXBoolOr, int, bool, _operate_or)
-
-OP_EVALUATOR(OperatorEvaluatorBoolXFloatOr, bool, float, _operate_or)
-OP_EVALUATOR(OperatorEvaluatorFloatXBoolOr, float, bool, _operate_or)
-
-OP_EVALUATOR(OperatorEvaluatorBoolXObjectOr, bool, object, _operate_or)
-OP_EVALUATOR(OperatorEvaluatorObjectXBoolOr, object, bool, _operate_or)
-
-// int
-OP_EVALUATOR(OperatorEvaluatorIntXIntOr, int, int, _operate_or)
-
-OP_EVALUATOR(OperatorEvaluatorIntXFloatOr, int, float, _operate_or)
-OP_EVALUATOR(OperatorEvaluatorFloatXIntOr, float, int, _operate_or)
-
-OP_EVALUATOR(OperatorEvaluatorIntXObjectOr, int, object, _operate_or)
-OP_EVALUATOR(OperatorEvaluatorObjectXIntOr, object, int, _operate_or)
-
-// float
-OP_EVALUATOR(OperatorEvaluatorFloatXFloatOr, float, float, _operate_or)
-
-OP_EVALUATOR(OperatorEvaluatorFloatXObjectOr, float, object, _operate_or)
-OP_EVALUATOR(OperatorEvaluatorObjectXFloatOr, object, float, _operate_or)
-
-// object
-OP_EVALUATOR(OperatorEvaluatorObjectXObjectOr, object, object, _operate_or)
-
-// AND
-
-// nil
-OP_EVALUATOR(OperatorEvaluatorNilXBoolAnd, nil, bool, _operate_and)
-OP_EVALUATOR(OperatorEvaluatorBoolXNilAnd, bool, nil, _operate_and)
-
-OP_EVALUATOR(OperatorEvaluatorNilXIntAnd, nil, int, _operate_and)
-OP_EVALUATOR(OperatorEvaluatorIntXNilAnd, int, nil, _operate_and)
-
-OP_EVALUATOR(OperatorEvaluatorNilXFloatAnd, nil, float, _operate_and)
-OP_EVALUATOR(OperatorEvaluatorFloatXNilAnd, float, nil, _operate_and)
-
-OP_EVALUATOR(OperatorEvaluatorObjectXNilAnd, object, nil, _operate_and)
-OP_EVALUATOR(OperatorEvaluatorNilXObjectAnd, nil, object, _operate_and)
-
-// bool
-OP_EVALUATOR(OperatorEvaluatorBoolXBoolAnd, bool, bool, _operate_and)
-
-OP_EVALUATOR(OperatorEvaluatorBoolXIntAnd, bool, int, _operate_and)
-OP_EVALUATOR(OperatorEvaluatorIntXBoolAnd, int, bool, _operate_and)
-
-OP_EVALUATOR(OperatorEvaluatorBoolXFloatAnd, bool, float, _operate_and)
-OP_EVALUATOR(OperatorEvaluatorFloatXBoolAnd, float, bool, _operate_and)
-
-OP_EVALUATOR(OperatorEvaluatorBoolXObjectAnd, bool, object, _operate_and)
-OP_EVALUATOR(OperatorEvaluatorObjectXBoolAnd, object, bool, _operate_and)
-
-// int
-OP_EVALUATOR(OperatorEvaluatorIntXIntAnd, int, int, _operate_and)
-
-OP_EVALUATOR(OperatorEvaluatorIntXFloatAnd, int, float, _operate_and)
-OP_EVALUATOR(OperatorEvaluatorFloatXIntAnd, float, int, _operate_and)
-
-OP_EVALUATOR(OperatorEvaluatorIntXObjectAnd, int, object, _operate_and)
-OP_EVALUATOR(OperatorEvaluatorObjectXIntAnd, object, int, _operate_and)
-
-// float
-OP_EVALUATOR(OperatorEvaluatorFloatXFloatAnd, float, float, _operate_and)
-
-OP_EVALUATOR(OperatorEvaluatorFloatXObjectAnd, float, object, _operate_and)
-OP_EVALUATOR(OperatorEvaluatorObjectXFloatAnd, object, float, _operate_and)
-
-// object
-OP_EVALUATOR(OperatorEvaluatorObjectXObjectAnd, object, object, _operate_and)
-
-// XOR
-
-// nil
-OP_EVALUATOR(OperatorEvaluatorNilXBoolXor, nil, bool, _operate_xor)
-OP_EVALUATOR(OperatorEvaluatorBoolXNilXor, bool, nil, _operate_xor)
-
-OP_EVALUATOR(OperatorEvaluatorNilXIntXor, nil, int, _operate_xor)
-OP_EVALUATOR(OperatorEvaluatorIntXNilXor, int, nil, _operate_xor)
-
-OP_EVALUATOR(OperatorEvaluatorNilXFloatXor, nil, float, _operate_xor)
-OP_EVALUATOR(OperatorEvaluatorFloatXNilXor, float, nil, _operate_xor)
-
-OP_EVALUATOR(OperatorEvaluatorObjectXNilXor, object, nil, _operate_xor)
-OP_EVALUATOR(OperatorEvaluatorNilXObjectXor, nil, object, _operate_xor)
-
-// bool
-OP_EVALUATOR(OperatorEvaluatorBoolXBoolXor, bool, bool, _operate_xor)
-
-OP_EVALUATOR(OperatorEvaluatorBoolXIntXor, bool, int, _operate_xor)
-OP_EVALUATOR(OperatorEvaluatorIntXBoolXor, int, bool, _operate_xor)
-
-OP_EVALUATOR(OperatorEvaluatorBoolXFloatXor, bool, float, _operate_xor)
-OP_EVALUATOR(OperatorEvaluatorFloatXBoolXor, float, bool, _operate_xor)
-
-OP_EVALUATOR(OperatorEvaluatorBoolXObjectXor, bool, object, _operate_xor)
-OP_EVALUATOR(OperatorEvaluatorObjectXBoolXor, object, bool, _operate_xor)
-
-// int
-OP_EVALUATOR(OperatorEvaluatorIntXIntXor, int, int, _operate_xor)
-
-OP_EVALUATOR(OperatorEvaluatorIntXFloatXor, int, float, _operate_xor)
-OP_EVALUATOR(OperatorEvaluatorFloatXIntXor, float, int, _operate_xor)
-
-OP_EVALUATOR(OperatorEvaluatorIntXObjectXor, int, object, _operate_xor)
-OP_EVALUATOR(OperatorEvaluatorObjectXIntXor, object, int, _operate_xor)
-
-// float
-OP_EVALUATOR(OperatorEvaluatorFloatXFloatXor, float, float, _operate_xor)
-
-OP_EVALUATOR(OperatorEvaluatorFloatXObjectXor, float, object, _operate_xor)
-OP_EVALUATOR(OperatorEvaluatorObjectXFloatXor, object, float, _operate_xor)
-
-// object
-OP_EVALUATOR(OperatorEvaluatorObjectXObjectXor, object, object, _operate_xor)
-
-class OperatorEvaluatorNotBool {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- *r_ret = !*VariantGetInternalPtr<bool>::get_ptr(&p_left);
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<bool>::change(r_ret);
- *VariantGetInternalPtr<bool>::get_ptr(r_ret) = !*VariantGetInternalPtr<bool>::get_ptr(left);
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<bool>::encode(!PtrToArg<bool>::convert(left), r_ret);
- }
- static Variant::Type get_return_type() { return Variant::BOOL; }
-};
-
-class OperatorEvaluatorNotInt {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- *r_ret = !*VariantGetInternalPtr<int64_t>::get_ptr(&p_left);
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<bool>::change(r_ret);
- *VariantGetInternalPtr<bool>::get_ptr(r_ret) = !*VariantGetInternalPtr<int64_t>::get_ptr(left);
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<bool>::encode(!PtrToArg<int64_t>::convert(left), r_ret);
- }
- static Variant::Type get_return_type() { return Variant::BOOL; }
-};
-
-class OperatorEvaluatorNotFloat {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- *r_ret = !*VariantGetInternalPtr<double>::get_ptr(&p_left);
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<bool>::change(r_ret);
- *VariantGetInternalPtr<bool>::get_ptr(r_ret) = !*VariantGetInternalPtr<double>::get_ptr(left);
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<bool>::encode(!PtrToArg<double>::convert(left), r_ret);
- }
- static Variant::Type get_return_type() { return Variant::BOOL; }
-};
-
-class OperatorEvaluatorNotObject {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- *r_ret = p_left.get_validated_object() == nullptr;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- VariantTypeChanger<bool>::change(r_ret);
- *VariantGetInternalPtr<bool>::get_ptr(r_ret) = left->get_validated_object() == nullptr;
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<bool>::encode(PtrToArg<Object *>::convert(left) == nullptr, r_ret);
- }
- static Variant::Type get_return_type() { return Variant::BOOL; }
-};
-
-////
-
-class OperatorEvaluatorInStringFind {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const String &str_a = *VariantGetInternalPtr<String>::get_ptr(&p_left);
- const String &str_b = *VariantGetInternalPtr<String>::get_ptr(&p_right);
-
- *r_ret = str_b.find(str_a) != -1;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- const String &str_a = *VariantGetInternalPtr<String>::get_ptr(left);
- const String &str_b = *VariantGetInternalPtr<String>::get_ptr(right);
- VariantTypeChanger<bool>::change(r_ret);
- *VariantGetInternalPtr<bool>::get_ptr(r_ret) = str_b.find(str_a) != -1;
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<bool>::encode(PtrToArg<String>::convert(right).find(PtrToArg<String>::convert(left)) != -1, r_ret);
- }
- static Variant::Type get_return_type() { return Variant::BOOL; }
-};
-
-template <class A, class B>
-class OperatorEvaluatorInArrayFind {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
- const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
-
- *r_ret = b.find(a) != -1;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- const A &a = *VariantGetInternalPtr<A>::get_ptr(left);
- const B &b = *VariantGetInternalPtr<B>::get_ptr(right);
- VariantTypeChanger<bool>::change(r_ret);
- *VariantGetInternalPtr<bool>::get_ptr(r_ret) = b.find(a) != -1;
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<bool>::encode(PtrToArg<B>::convert(right).find(PtrToArg<A>::convert(left)) != -1, r_ret);
- }
- static Variant::Type get_return_type() { return Variant::BOOL; }
-};
-
-class OperatorEvaluatorInArrayFindNil {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const Array &b = *VariantGetInternalPtr<Array>::get_ptr(&p_right);
- *r_ret = b.find(Variant()) != -1;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- const Array &b = *VariantGetInternalPtr<Array>::get_ptr(right);
- VariantTypeChanger<bool>::change(r_ret);
- *VariantGetInternalPtr<bool>::get_ptr(r_ret) = b.find(Variant()) != -1;
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<bool>::encode(PtrToArg<Array>::convert(right).find(Variant()) != -1, r_ret);
- }
- static Variant::Type get_return_type() { return Variant::BOOL; }
-};
-
-class OperatorEvaluatorInArrayFindObject {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const Array &b = *VariantGetInternalPtr<Array>::get_ptr(&p_right);
- *r_ret = b.find(p_left) != -1;
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- const Array &b = *VariantGetInternalPtr<Array>::get_ptr(right);
- VariantTypeChanger<bool>::change(r_ret);
- *VariantGetInternalPtr<bool>::get_ptr(r_ret) = b.find(*left) != -1;
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<bool>::encode(PtrToArg<Array>::convert(right).find(PtrToArg<Object *>::convert(left)) != -1, r_ret);
- }
- static Variant::Type get_return_type() { return Variant::BOOL; }
-};
-
-template <class A>
-class OperatorEvaluatorInDictionaryHas {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const Dictionary &b = *VariantGetInternalPtr<Dictionary>::get_ptr(&p_right);
- const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
-
- *r_ret = b.has(a);
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- const Dictionary &b = *VariantGetInternalPtr<Dictionary>::get_ptr(right);
- const A &a = *VariantGetInternalPtr<A>::get_ptr(left);
- VariantTypeChanger<bool>::change(r_ret);
- *VariantGetInternalPtr<bool>::get_ptr(r_ret) = b.has(a);
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<bool>::encode(PtrToArg<Dictionary>::convert(right).has(PtrToArg<A>::convert(left)), r_ret);
- }
- static Variant::Type get_return_type() { return Variant::BOOL; }
-};
-
-class OperatorEvaluatorInDictionaryHasNil {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const Dictionary &b = *VariantGetInternalPtr<Dictionary>::get_ptr(&p_right);
-
- *r_ret = b.has(Variant());
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- const Dictionary &b = *VariantGetInternalPtr<Dictionary>::get_ptr(right);
- VariantTypeChanger<bool>::change(r_ret);
- *VariantGetInternalPtr<bool>::get_ptr(r_ret) = b.has(Variant());
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<bool>::encode(PtrToArg<Dictionary>::convert(right).has(Variant()), r_ret);
- }
- static Variant::Type get_return_type() { return Variant::BOOL; }
-};
-
-class OperatorEvaluatorInDictionaryHasObject {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- const Dictionary &b = *VariantGetInternalPtr<Dictionary>::get_ptr(&p_right);
-
- *r_ret = b.has(p_left);
- r_valid = true;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- const Dictionary &b = *VariantGetInternalPtr<Dictionary>::get_ptr(right);
- VariantTypeChanger<bool>::change(r_ret);
- *VariantGetInternalPtr<bool>::get_ptr(r_ret) = b.has(*left);
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- PtrToArg<bool>::encode(PtrToArg<Dictionary>::convert(right).has(PtrToArg<Object *>::convert(left)), r_ret);
- }
- static Variant::Type get_return_type() { return Variant::BOOL; }
-};
-
-class OperatorEvaluatorObjectHasPropertyString {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- Object *b = p_right.get_validated_object();
- if (!b) {
- *r_ret = "Invalid base object for 'in'";
- r_valid = false;
- return;
- }
-
- const String &a = *VariantGetInternalPtr<String>::get_ptr(&p_left);
-
- b->get(a, &r_valid);
- *r_ret = r_valid;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- Object *l = right->get_validated_object();
- ERR_FAIL_COND(l == nullptr);
- const String &a = *VariantGetInternalPtr<String>::get_ptr(left);
-
- bool valid;
- l->get(a, &valid);
- VariantTypeChanger<bool>::change(r_ret);
- *VariantGetInternalPtr<bool>::get_ptr(r_ret) = valid;
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- bool valid;
- PtrToArg<Object *>::convert(right)->get(PtrToArg<String>::convert(left), &valid);
- PtrToArg<bool>::encode(valid, r_ret);
- }
- static Variant::Type get_return_type() { return Variant::BOOL; }
-};
-
-class OperatorEvaluatorObjectHasPropertyStringName {
-public:
- static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
- Object *b = p_right.get_validated_object();
- if (!b) {
- *r_ret = "Invalid base object for 'in'";
- r_valid = false;
- return;
- }
-
- const StringName &a = *VariantGetInternalPtr<StringName>::get_ptr(&p_left);
-
- b->get(a, &r_valid);
- *r_ret = r_valid;
- }
- static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
- Object *l = right->get_validated_object();
- ERR_FAIL_COND(l == nullptr);
- const StringName &a = *VariantGetInternalPtr<StringName>::get_ptr(left);
-
- bool valid;
- l->get(a, &valid);
- VariantTypeChanger<bool>::change(r_ret);
- *VariantGetInternalPtr<bool>::get_ptr(r_ret) = valid;
- }
- static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
- bool valid;
- PtrToArg<Object *>::convert(right)->get(PtrToArg<StringName>::convert(left), &valid);
- PtrToArg<bool>::encode(valid, r_ret);
- }
- static Variant::Type get_return_type() { return Variant::BOOL; }
-};
+#include "variant_op.h"
typedef void (*VariantEvaluatorFunction)(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid);
@@ -1458,6 +123,8 @@ void Variant::_register_variant_operators() {
register_op<OperatorEvaluatorMul<Color, Color, double>>(Variant::OP_MULTIPLY, Variant::COLOR, Variant::FLOAT);
register_op<OperatorEvaluatorMul<Transform2D, Transform2D, Transform2D>>(Variant::OP_MULTIPLY, Variant::TRANSFORM2D, Variant::TRANSFORM2D);
+ register_op<OperatorEvaluatorMul<Transform2D, Transform2D, int64_t>>(Variant::OP_MULTIPLY, Variant::TRANSFORM2D, Variant::INT);
+ register_op<OperatorEvaluatorMul<Transform2D, Transform2D, double>>(Variant::OP_MULTIPLY, Variant::TRANSFORM2D, Variant::FLOAT);
register_op<OperatorEvaluatorXForm<Vector2, Transform2D, Vector2>>(Variant::OP_MULTIPLY, Variant::TRANSFORM2D, Variant::VECTOR2);
register_op<OperatorEvaluatorXFormInv<Vector2, Vector2, Transform2D>>(Variant::OP_MULTIPLY, Variant::VECTOR2, Variant::TRANSFORM2D);
register_op<OperatorEvaluatorXForm<Rect2, Transform2D, Rect2>>(Variant::OP_MULTIPLY, Variant::TRANSFORM2D, Variant::RECT2);
@@ -1466,6 +133,8 @@ void Variant::_register_variant_operators() {
register_op<OperatorEvaluatorXFormInv<Vector<Vector2>, Vector<Vector2>, Transform2D>>(Variant::OP_MULTIPLY, Variant::PACKED_VECTOR2_ARRAY, Variant::TRANSFORM2D);
register_op<OperatorEvaluatorMul<Transform3D, Transform3D, Transform3D>>(Variant::OP_MULTIPLY, Variant::TRANSFORM3D, Variant::TRANSFORM3D);
+ register_op<OperatorEvaluatorMul<Transform3D, Transform3D, int64_t>>(Variant::OP_MULTIPLY, Variant::TRANSFORM3D, Variant::INT);
+ register_op<OperatorEvaluatorMul<Transform3D, Transform3D, double>>(Variant::OP_MULTIPLY, Variant::TRANSFORM3D, Variant::FLOAT);
register_op<OperatorEvaluatorXForm<Vector3, Transform3D, Vector3>>(Variant::OP_MULTIPLY, Variant::TRANSFORM3D, Variant::VECTOR3);
register_op<OperatorEvaluatorXFormInv<Vector3, Vector3, Transform3D>>(Variant::OP_MULTIPLY, Variant::VECTOR3, Variant::TRANSFORM3D);
register_op<OperatorEvaluatorXForm<::AABB, Transform3D, ::AABB>>(Variant::OP_MULTIPLY, Variant::TRANSFORM3D, Variant::AABB);
@@ -1474,6 +143,8 @@ void Variant::_register_variant_operators() {
register_op<OperatorEvaluatorXFormInv<Vector<Vector3>, Vector<Vector3>, Transform3D>>(Variant::OP_MULTIPLY, Variant::PACKED_VECTOR3_ARRAY, Variant::TRANSFORM3D);
register_op<OperatorEvaluatorMul<Basis, Basis, Basis>>(Variant::OP_MULTIPLY, Variant::BASIS, Variant::BASIS);
+ register_op<OperatorEvaluatorMul<Basis, Basis, int64_t>>(Variant::OP_MULTIPLY, Variant::BASIS, Variant::INT);
+ register_op<OperatorEvaluatorMul<Basis, Basis, double>>(Variant::OP_MULTIPLY, Variant::BASIS, Variant::FLOAT);
register_op<OperatorEvaluatorXForm<Vector3, Basis, Vector3>>(Variant::OP_MULTIPLY, Variant::BASIS, Variant::VECTOR3);
register_op<OperatorEvaluatorXFormInv<Vector3, Vector3, Basis>>(Variant::OP_MULTIPLY, Variant::VECTOR3, Variant::BASIS);
@@ -1990,8 +661,8 @@ static const char *_op_names[Variant::OP_MAX] = {
"-",
"*",
"/",
- "-",
- "+",
+ "unary-",
+ "unary+",
"%",
"<<",
">>",
diff --git a/core/variant/variant_op.h b/core/variant/variant_op.h
new file mode 100644
index 0000000000..e744e76ea3
--- /dev/null
+++ b/core/variant/variant_op.h
@@ -0,0 +1,1316 @@
+/*************************************************************************/
+/* variant_op.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef VARIANT_OP_H
+#define VARIANT_OP_H
+
+#include "variant.h"
+
+#include "core/core_string_names.h"
+#include "core/debugger/engine_debugger.h"
+#include "core/object/class_db.h"
+
+template <class R, class A, class B>
+class OperatorEvaluatorAdd {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
+ const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
+ *r_ret = a + b;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) + *VariantGetInternalPtr<B>::get_ptr(right);
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<R>::encode(PtrToArg<A>::convert(left) + PtrToArg<B>::convert(right), r_ret);
+ }
+ static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
+};
+
+template <class R, class A, class B>
+class OperatorEvaluatorSub {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
+ const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
+ *r_ret = a - b;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) - *VariantGetInternalPtr<B>::get_ptr(right);
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<R>::encode(PtrToArg<A>::convert(left) - PtrToArg<B>::convert(right), r_ret);
+ }
+ static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
+};
+
+template <class R, class A, class B>
+class OperatorEvaluatorMul {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
+ const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
+ *r_ret = a * b;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) * *VariantGetInternalPtr<B>::get_ptr(right);
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<R>::encode(PtrToArg<A>::convert(left) * PtrToArg<B>::convert(right), r_ret);
+ }
+ static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
+};
+
+template <class R, class A, class B>
+class OperatorEvaluatorXForm {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
+ const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
+ *r_ret = a.xform(b);
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<R>::get_ptr(r_ret) = VariantGetInternalPtr<A>::get_ptr(left)->xform(*VariantGetInternalPtr<B>::get_ptr(right));
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<R>::encode(PtrToArg<A>::convert(left).xform(PtrToArg<B>::convert(right)), r_ret);
+ }
+ static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
+};
+
+template <class R, class A, class B>
+class OperatorEvaluatorXFormInv {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
+ const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
+ *r_ret = b.xform_inv(a);
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<R>::get_ptr(r_ret) = VariantGetInternalPtr<B>::get_ptr(right)->xform_inv(*VariantGetInternalPtr<A>::get_ptr(left));
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<R>::encode(PtrToArg<B>::convert(right).xform_inv(PtrToArg<A>::convert(left)), r_ret);
+ }
+ static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
+};
+
+template <class R, class A, class B>
+class OperatorEvaluatorDiv {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
+ const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
+ *r_ret = a / b;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) / *VariantGetInternalPtr<B>::get_ptr(right);
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<R>::encode(PtrToArg<A>::convert(left) / PtrToArg<B>::convert(right), r_ret);
+ }
+ static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
+};
+
+template <class R, class A, class B>
+class OperatorEvaluatorDivNZ {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
+ const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
+ if (b == 0) {
+ r_valid = false;
+ *r_ret = "Division by zero error";
+ return;
+ }
+ *r_ret = a / b;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) / *VariantGetInternalPtr<B>::get_ptr(right);
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<R>::encode(PtrToArg<A>::convert(left) / PtrToArg<B>::convert(right), r_ret);
+ }
+ static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
+};
+
+template <class R, class A, class B>
+class OperatorEvaluatorMod {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
+ const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
+ *r_ret = a % b;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) % *VariantGetInternalPtr<B>::get_ptr(right);
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<R>::encode(PtrToArg<A>::convert(left) % PtrToArg<B>::convert(right), r_ret);
+ }
+ static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
+};
+
+template <class R, class A, class B>
+class OperatorEvaluatorModNZ {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
+ const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
+ if (b == 0) {
+ r_valid = false;
+ *r_ret = "Module by zero error";
+ return;
+ }
+ *r_ret = a % b;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) % *VariantGetInternalPtr<B>::get_ptr(right);
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<R>::encode(PtrToArg<A>::convert(left) % PtrToArg<B>::convert(right), r_ret);
+ }
+ static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
+};
+
+template <class R, class A>
+class OperatorEvaluatorNeg {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
+ *r_ret = -a;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<R>::get_ptr(r_ret) = -*VariantGetInternalPtr<A>::get_ptr(left);
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<R>::encode(-PtrToArg<A>::convert(left), r_ret);
+ }
+ static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
+};
+
+template <class R, class A>
+class OperatorEvaluatorPos {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
+ *r_ret = a;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left);
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<R>::encode(PtrToArg<A>::convert(left), r_ret);
+ }
+ static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
+};
+
+template <class R, class A, class B>
+class OperatorEvaluatorShiftLeft {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
+ const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
+
+#if defined(DEBUG_ENABLED)
+ if (b < 0 || a < 0) {
+ *r_ret = "Invalid operands for bit shifting. Only positive operands are supported.";
+ r_valid = false;
+ return;
+ }
+#endif
+ *r_ret = a << b;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) << *VariantGetInternalPtr<B>::get_ptr(right);
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<R>::encode(PtrToArg<A>::convert(left) << PtrToArg<B>::convert(right), r_ret);
+ }
+ static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
+};
+
+template <class R, class A, class B>
+class OperatorEvaluatorShiftRight {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
+ const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
+
+#if defined(DEBUG_ENABLED)
+ if (b < 0 || a < 0) {
+ *r_ret = "Invalid operands for bit shifting. Only positive operands are supported.";
+ r_valid = false;
+ return;
+ }
+#endif
+ *r_ret = a >> b;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) >> *VariantGetInternalPtr<B>::get_ptr(right);
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<R>::encode(PtrToArg<A>::convert(left) >> PtrToArg<B>::convert(right), r_ret);
+ }
+ static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
+};
+
+template <class R, class A, class B>
+class OperatorEvaluatorBitOr {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
+ const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
+ *r_ret = a | b;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) | *VariantGetInternalPtr<B>::get_ptr(right);
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<R>::encode(PtrToArg<A>::convert(left) | PtrToArg<B>::convert(right), r_ret);
+ }
+ static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
+};
+
+template <class R, class A, class B>
+class OperatorEvaluatorBitAnd {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
+ const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
+ *r_ret = a & b;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) & *VariantGetInternalPtr<B>::get_ptr(right);
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<R>::encode(PtrToArg<A>::convert(left) & PtrToArg<B>::convert(right), r_ret);
+ }
+ static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
+};
+
+template <class R, class A, class B>
+class OperatorEvaluatorBitXor {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
+ const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
+ *r_ret = a ^ b;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) ^ *VariantGetInternalPtr<B>::get_ptr(right);
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<R>::encode(PtrToArg<A>::convert(left) ^ PtrToArg<B>::convert(right), r_ret);
+ }
+ static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
+};
+
+template <class R, class A>
+class OperatorEvaluatorBitNeg {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
+ *r_ret = ~a;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<R>::get_ptr(r_ret) = ~*VariantGetInternalPtr<A>::get_ptr(left);
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<R>::encode(~PtrToArg<A>::convert(left), r_ret);
+ }
+ static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; }
+};
+
+template <class A, class B>
+class OperatorEvaluatorEqual {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
+ const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
+ *r_ret = a == b;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<bool>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) == *VariantGetInternalPtr<B>::get_ptr(right);
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<bool>::encode(PtrToArg<A>::convert(left) == PtrToArg<B>::convert(right), r_ret);
+ }
+ static Variant::Type get_return_type() { return Variant::BOOL; }
+};
+
+class OperatorEvaluatorEqualObject {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const Object *a = p_left.get_validated_object();
+ const Object *b = p_right.get_validated_object();
+ *r_ret = a == b;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ const Object *a = left->get_validated_object();
+ const Object *b = right->get_validated_object();
+ *VariantGetInternalPtr<bool>::get_ptr(r_ret) = a == b;
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<bool>::encode(PtrToArg<Object *>::convert(left) == PtrToArg<Object *>::convert(right), r_ret);
+ }
+ static Variant::Type get_return_type() { return Variant::BOOL; }
+};
+
+class OperatorEvaluatorEqualObjectNil {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const Object *a = p_left.get_validated_object();
+ *r_ret = a == nullptr;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ const Object *a = left->get_validated_object();
+ *VariantGetInternalPtr<bool>::get_ptr(r_ret) = a == nullptr;
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<bool>::encode(PtrToArg<Object *>::convert(left) == nullptr, r_ret);
+ }
+ static Variant::Type get_return_type() { return Variant::BOOL; }
+};
+
+class OperatorEvaluatorEqualNilObject {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const Object *b = p_right.get_validated_object();
+ *r_ret = nullptr == b;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ const Object *b = right->get_validated_object();
+ *VariantGetInternalPtr<bool>::get_ptr(r_ret) = nullptr == b;
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<bool>::encode(nullptr == PtrToArg<Object *>::convert(right), r_ret);
+ }
+ static Variant::Type get_return_type() { return Variant::BOOL; }
+};
+
+template <class A, class B>
+class OperatorEvaluatorNotEqual {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
+ const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
+ *r_ret = a != b;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<bool>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) != *VariantGetInternalPtr<B>::get_ptr(right);
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<bool>::encode(PtrToArg<A>::convert(left) != PtrToArg<B>::convert(right), r_ret);
+ }
+ static Variant::Type get_return_type() { return Variant::BOOL; }
+};
+
+class OperatorEvaluatorNotEqualObject {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ Object *a = p_left.get_validated_object();
+ Object *b = p_right.get_validated_object();
+ *r_ret = a != b;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ Object *a = left->get_validated_object();
+ Object *b = right->get_validated_object();
+ *VariantGetInternalPtr<bool>::get_ptr(r_ret) = a != b;
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<bool>::encode(PtrToArg<Object *>::convert(left) != PtrToArg<Object *>::convert(right), r_ret);
+ }
+ static Variant::Type get_return_type() { return Variant::BOOL; }
+};
+
+class OperatorEvaluatorNotEqualObjectNil {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ Object *a = p_left.get_validated_object();
+ *r_ret = a != nullptr;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ Object *a = left->get_validated_object();
+ *VariantGetInternalPtr<bool>::get_ptr(r_ret) = a != nullptr;
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<bool>::encode(PtrToArg<Object *>::convert(left) != nullptr, r_ret);
+ }
+ static Variant::Type get_return_type() { return Variant::BOOL; }
+};
+
+class OperatorEvaluatorNotEqualNilObject {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ Object *b = p_right.get_validated_object();
+ *r_ret = nullptr != b;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ Object *b = right->get_validated_object();
+ *VariantGetInternalPtr<bool>::get_ptr(r_ret) = nullptr != b;
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<bool>::encode(nullptr != PtrToArg<Object *>::convert(right), r_ret);
+ }
+ static Variant::Type get_return_type() { return Variant::BOOL; }
+};
+
+template <class A, class B>
+class OperatorEvaluatorLess {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
+ const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
+ *r_ret = a < b;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<bool>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) < *VariantGetInternalPtr<B>::get_ptr(right);
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<bool>::encode(PtrToArg<A>::convert(left) < PtrToArg<B>::convert(right), r_ret);
+ }
+ static Variant::Type get_return_type() { return Variant::BOOL; }
+};
+
+template <class A, class B>
+class OperatorEvaluatorLessEqual {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
+ const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
+ *r_ret = a <= b;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<bool>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) <= *VariantGetInternalPtr<B>::get_ptr(right);
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<bool>::encode(PtrToArg<A>::convert(left) <= PtrToArg<B>::convert(right), r_ret);
+ }
+ static Variant::Type get_return_type() { return Variant::BOOL; }
+};
+
+template <class A, class B>
+class OperatorEvaluatorGreater {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
+ const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
+ *r_ret = a > b;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<bool>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) > *VariantGetInternalPtr<B>::get_ptr(right);
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<bool>::encode(PtrToArg<A>::convert(left) > PtrToArg<B>::convert(right), r_ret);
+ }
+ static Variant::Type get_return_type() { return Variant::BOOL; }
+};
+
+template <class A, class B>
+class OperatorEvaluatorGreaterEqual {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
+ const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
+ *r_ret = a >= b;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<bool>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) >= *VariantGetInternalPtr<B>::get_ptr(right);
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<bool>::encode(PtrToArg<A>::convert(left) >= PtrToArg<B>::convert(right), r_ret);
+ }
+ static Variant::Type get_return_type() { return Variant::BOOL; }
+};
+
+template <class A, class B>
+class OperatorEvaluatorAnd {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
+ const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
+ *r_ret = a && b;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<bool>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) && *VariantGetInternalPtr<B>::get_ptr(right);
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<bool>::encode(PtrToArg<A>::convert(left) && PtrToArg<B>::convert(right), r_ret);
+ }
+ static Variant::Type get_return_type() { return Variant::BOOL; }
+};
+
+template <class A, class B>
+class OperatorEvaluatorOr {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
+ const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
+ *r_ret = a || b;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<bool>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) || *VariantGetInternalPtr<B>::get_ptr(right);
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<bool>::encode(PtrToArg<A>::convert(left) || PtrToArg<B>::convert(right), r_ret);
+ }
+ static Variant::Type get_return_type() { return Variant::BOOL; }
+};
+
+#define XOR_OP(m_a, m_b) (((m_a) || (m_b)) && !((m_a) && (m_b)))
+template <class A, class B>
+class OperatorEvaluatorXor {
+public:
+ _FORCE_INLINE_ static bool xor_op(const A &a, const B &b) {
+ return ((a) || (b)) && !((a) && (b));
+ }
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
+ const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
+ *r_ret = xor_op(a, b);
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<bool>::get_ptr(r_ret) = xor_op(*VariantGetInternalPtr<A>::get_ptr(left), *VariantGetInternalPtr<B>::get_ptr(right));
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<bool>::encode(xor_op(PtrToArg<A>::convert(left), PtrToArg<B>::convert(right)), r_ret);
+ }
+ static Variant::Type get_return_type() { return Variant::BOOL; }
+};
+
+template <class A>
+class OperatorEvaluatorNot {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
+ *r_ret = !a;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<bool>::get_ptr(r_ret) = !*VariantGetInternalPtr<A>::get_ptr(left);
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<bool>::encode(!PtrToArg<A>::convert(left));
+ }
+ static Variant::Type get_return_type() { return Variant::BOOL; }
+};
+
+//// CUSTOM ////
+
+class OperatorEvaluatorAddArray {
+public:
+ _FORCE_INLINE_ static void _add_arrays(Array &sum, const Array &array_a, const Array &array_b) {
+ int asize = array_a.size();
+ int bsize = array_b.size();
+ sum.resize(asize + bsize);
+ for (int i = 0; i < asize; i++) {
+ sum[i] = array_a[i];
+ }
+ for (int i = 0; i < bsize; i++) {
+ sum[i + asize] = array_b[i];
+ }
+ }
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const Array &array_a = *VariantGetInternalPtr<Array>::get_ptr(&p_left);
+ const Array &array_b = *VariantGetInternalPtr<Array>::get_ptr(&p_right);
+ Array sum;
+ _add_arrays(sum, array_a, array_b);
+ *r_ret = sum;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ _add_arrays(*VariantGetInternalPtr<Array>::get_ptr(r_ret), *VariantGetInternalPtr<Array>::get_ptr(left), *VariantGetInternalPtr<Array>::get_ptr(right));
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ Array ret;
+ _add_arrays(ret, PtrToArg<Array>::convert(left), PtrToArg<Array>::convert(right));
+ PtrToArg<Array>::encode(ret, r_ret);
+ }
+ static Variant::Type get_return_type() { return Variant::ARRAY; }
+};
+
+template <class T>
+class OperatorEvaluatorAppendArray {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const Vector<T> &array_a = *VariantGetInternalPtr<Vector<T>>::get_ptr(&p_left);
+ const Vector<T> &array_b = *VariantGetInternalPtr<Vector<T>>::get_ptr(&p_right);
+ Vector<T> sum = array_a;
+ sum.append_array(array_b);
+ *r_ret = sum;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<Vector<T>>::get_ptr(r_ret) = *VariantGetInternalPtr<Vector<T>>::get_ptr(left);
+ VariantGetInternalPtr<Vector<T>>::get_ptr(r_ret)->append_array(*VariantGetInternalPtr<Vector<T>>::get_ptr(right));
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ Vector<T> sum = PtrToArg<Vector<T>>::convert(left);
+ sum.append_array(PtrToArg<Vector<T>>::convert(right));
+ PtrToArg<Vector<T>>::encode(sum, r_ret);
+ }
+ static Variant::Type get_return_type() { return GetTypeInfo<Vector<T>>::VARIANT_TYPE; }
+};
+
+class OperatorEvaluatorStringModNil {
+public:
+ _FORCE_INLINE_ static String do_mod(const String &s, bool *r_valid) {
+ Array values;
+ values.push_back(Variant());
+
+ String a = s.sprintf(values, r_valid);
+ if (r_valid) {
+ *r_valid = !*r_valid;
+ }
+ return a;
+ }
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const String &a = *VariantGetInternalPtr<String>::get_ptr(&p_left);
+ *r_ret = do_mod(a, &r_valid);
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<String>::get_ptr(r_ret) = do_mod(*VariantGetInternalPtr<String>::get_ptr(left), nullptr);
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<String>::encode(do_mod(PtrToArg<String>::convert(left), nullptr), r_ret);
+ }
+ static Variant::Type get_return_type() { return Variant::STRING; }
+};
+
+class OperatorEvaluatorStringModArray {
+public:
+ _FORCE_INLINE_ static String do_mod(const String &s, const Array &p_values, bool *r_valid) {
+ String a = s.sprintf(p_values, r_valid);
+ if (r_valid) {
+ *r_valid = !*r_valid;
+ }
+ return a;
+ }
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const String &a = *VariantGetInternalPtr<String>::get_ptr(&p_left);
+ *r_ret = do_mod(a, *VariantGetInternalPtr<Array>::get_ptr(&p_right), &r_valid);
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<String>::get_ptr(r_ret) = do_mod(*VariantGetInternalPtr<String>::get_ptr(left), *VariantGetInternalPtr<Array>::get_ptr(right), nullptr);
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<String>::encode(do_mod(PtrToArg<String>::convert(left), PtrToArg<Array>::convert(right), nullptr), r_ret);
+ }
+ static Variant::Type get_return_type() { return Variant::STRING; }
+};
+
+class OperatorEvaluatorStringModObject {
+public:
+ _FORCE_INLINE_ static String do_mod(const String &s, const Object *p_object, bool *r_valid) {
+ Array values;
+ values.push_back(p_object);
+ String a = s.sprintf(values, r_valid);
+ if (r_valid) {
+ *r_valid = !*r_valid;
+ }
+
+ return a;
+ }
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const String &a = *VariantGetInternalPtr<String>::get_ptr(&p_left);
+ *r_ret = do_mod(a, p_right.get_validated_object(), &r_valid);
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<String>::get_ptr(r_ret) = do_mod(*VariantGetInternalPtr<String>::get_ptr(left), right->get_validated_object(), nullptr);
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<String>::encode(do_mod(PtrToArg<String>::convert(left), PtrToArg<Object *>::convert(right), nullptr), r_ret);
+ }
+ static Variant::Type get_return_type() { return Variant::STRING; }
+};
+
+template <class T>
+class OperatorEvaluatorStringModT {
+public:
+ _FORCE_INLINE_ static String do_mod(const String &s, const T &p_value, bool *r_valid) {
+ Array values;
+ values.push_back(p_value);
+ String a = s.sprintf(values, r_valid);
+ if (r_valid) {
+ *r_valid = !*r_valid;
+ }
+ return a;
+ }
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const String &a = *VariantGetInternalPtr<String>::get_ptr(&p_left);
+ *r_ret = do_mod(a, *VariantGetInternalPtr<T>::get_ptr(&p_right), &r_valid);
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<String>::get_ptr(r_ret) = do_mod(*VariantGetInternalPtr<String>::get_ptr(left), *VariantGetInternalPtr<T>::get_ptr(right), nullptr);
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<String>::encode(do_mod(PtrToArg<String>::convert(left), PtrToArg<T>::convert(right), nullptr), r_ret);
+ }
+ static Variant::Type get_return_type() { return Variant::STRING; }
+};
+
+template <Variant::Operator op, Variant::Type type_left, Variant::Type type_right>
+class OperatorEvaluatorAlwaysTrue {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ *r_ret = true;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<bool>::get_ptr(r_ret) = true;
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<bool>::encode(true, r_ret);
+ }
+ static Variant::Type get_return_type() { return Variant::BOOL; }
+};
+
+template <Variant::Operator op, Variant::Type type_left, Variant::Type type_right>
+class OperatorEvaluatorAlwaysFalse {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ *r_ret = false;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<bool>::get_ptr(r_ret) = false;
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<bool>::encode(false, r_ret);
+ }
+ static Variant::Type get_return_type() { return Variant::BOOL; }
+};
+
+///// OR ///////
+
+_FORCE_INLINE_ static bool _operate_or(bool p_left, bool p_right) {
+ return p_left || p_right;
+}
+
+_FORCE_INLINE_ static bool _operate_and(bool p_left, bool p_right) {
+ return p_left && p_right;
+}
+
+_FORCE_INLINE_ static bool _operate_xor(bool p_left, bool p_right) {
+ return (p_left || p_right) && !(p_left && p_right);
+}
+
+_FORCE_INLINE_ static bool _operate_get_nil(const Variant *p_ptr) {
+ return p_ptr->get_validated_object() != nullptr;
+}
+
+_FORCE_INLINE_ static bool _operate_get_bool(const Variant *p_ptr) {
+ return *VariantGetInternalPtr<bool>::get_ptr(p_ptr);
+}
+
+_FORCE_INLINE_ static bool _operate_get_int(const Variant *p_ptr) {
+ return *VariantGetInternalPtr<int64_t>::get_ptr(p_ptr) != 0;
+}
+
+_FORCE_INLINE_ static bool _operate_get_float(const Variant *p_ptr) {
+ return *VariantGetInternalPtr<double>::get_ptr(p_ptr) != 0.0;
+}
+
+_FORCE_INLINE_ static bool _operate_get_object(const Variant *p_ptr) {
+ return p_ptr->get_validated_object() != nullptr;
+}
+
+_FORCE_INLINE_ static bool _operate_get_ptr_nil(const void *p_ptr) {
+ return false;
+}
+
+_FORCE_INLINE_ static bool _operate_get_ptr_bool(const void *p_ptr) {
+ return PtrToArg<bool>::convert(p_ptr);
+}
+
+_FORCE_INLINE_ static bool _operate_get_ptr_int(const void *p_ptr) {
+ return PtrToArg<int64_t>::convert(p_ptr) != 0;
+}
+
+_FORCE_INLINE_ static bool _operate_get_ptr_float(const void *p_ptr) {
+ return PtrToArg<double>::convert(p_ptr) != 0.0;
+}
+
+_FORCE_INLINE_ static bool _operate_get_ptr_object(const void *p_ptr) {
+ return PtrToArg<Object *>::convert(p_ptr) != nullptr;
+}
+
+#define OP_EVALUATOR(m_class_name, m_left, m_right, m_op) \
+ class m_class_name { \
+ public: \
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { \
+ *r_ret = m_op(_operate_get_##m_left(&p_left), _operate_get_##m_right(&p_right)); \
+ r_valid = true; \
+ } \
+ \
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { \
+ *VariantGetInternalPtr<bool>::get_ptr(r_ret) = m_op(_operate_get_##m_left(left), _operate_get_##m_right(right)); \
+ } \
+ \
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) { \
+ PtrToArg<bool>::encode(m_op(_operate_get_ptr_##m_left(left), _operate_get_ptr_##m_right(right)), r_ret); \
+ } \
+ \
+ static Variant::Type get_return_type() { \
+ return Variant::BOOL; \
+ } \
+ };
+
+// OR
+
+// nil
+OP_EVALUATOR(OperatorEvaluatorNilXBoolOr, nil, bool, _operate_or)
+OP_EVALUATOR(OperatorEvaluatorBoolXNilOr, bool, nil, _operate_or)
+
+OP_EVALUATOR(OperatorEvaluatorNilXIntOr, nil, int, _operate_or)
+OP_EVALUATOR(OperatorEvaluatorIntXNilOr, int, nil, _operate_or)
+
+OP_EVALUATOR(OperatorEvaluatorNilXFloatOr, nil, float, _operate_or)
+OP_EVALUATOR(OperatorEvaluatorFloatXNilOr, float, nil, _operate_or)
+
+OP_EVALUATOR(OperatorEvaluatorObjectXNilOr, object, nil, _operate_or)
+OP_EVALUATOR(OperatorEvaluatorNilXObjectOr, nil, object, _operate_or)
+
+// bool
+OP_EVALUATOR(OperatorEvaluatorBoolXBoolOr, bool, bool, _operate_or)
+
+OP_EVALUATOR(OperatorEvaluatorBoolXIntOr, bool, int, _operate_or)
+OP_EVALUATOR(OperatorEvaluatorIntXBoolOr, int, bool, _operate_or)
+
+OP_EVALUATOR(OperatorEvaluatorBoolXFloatOr, bool, float, _operate_or)
+OP_EVALUATOR(OperatorEvaluatorFloatXBoolOr, float, bool, _operate_or)
+
+OP_EVALUATOR(OperatorEvaluatorBoolXObjectOr, bool, object, _operate_or)
+OP_EVALUATOR(OperatorEvaluatorObjectXBoolOr, object, bool, _operate_or)
+
+// int
+OP_EVALUATOR(OperatorEvaluatorIntXIntOr, int, int, _operate_or)
+
+OP_EVALUATOR(OperatorEvaluatorIntXFloatOr, int, float, _operate_or)
+OP_EVALUATOR(OperatorEvaluatorFloatXIntOr, float, int, _operate_or)
+
+OP_EVALUATOR(OperatorEvaluatorIntXObjectOr, int, object, _operate_or)
+OP_EVALUATOR(OperatorEvaluatorObjectXIntOr, object, int, _operate_or)
+
+// float
+OP_EVALUATOR(OperatorEvaluatorFloatXFloatOr, float, float, _operate_or)
+
+OP_EVALUATOR(OperatorEvaluatorFloatXObjectOr, float, object, _operate_or)
+OP_EVALUATOR(OperatorEvaluatorObjectXFloatOr, object, float, _operate_or)
+
+// object
+OP_EVALUATOR(OperatorEvaluatorObjectXObjectOr, object, object, _operate_or)
+
+// AND
+
+// nil
+OP_EVALUATOR(OperatorEvaluatorNilXBoolAnd, nil, bool, _operate_and)
+OP_EVALUATOR(OperatorEvaluatorBoolXNilAnd, bool, nil, _operate_and)
+
+OP_EVALUATOR(OperatorEvaluatorNilXIntAnd, nil, int, _operate_and)
+OP_EVALUATOR(OperatorEvaluatorIntXNilAnd, int, nil, _operate_and)
+
+OP_EVALUATOR(OperatorEvaluatorNilXFloatAnd, nil, float, _operate_and)
+OP_EVALUATOR(OperatorEvaluatorFloatXNilAnd, float, nil, _operate_and)
+
+OP_EVALUATOR(OperatorEvaluatorObjectXNilAnd, object, nil, _operate_and)
+OP_EVALUATOR(OperatorEvaluatorNilXObjectAnd, nil, object, _operate_and)
+
+// bool
+OP_EVALUATOR(OperatorEvaluatorBoolXBoolAnd, bool, bool, _operate_and)
+
+OP_EVALUATOR(OperatorEvaluatorBoolXIntAnd, bool, int, _operate_and)
+OP_EVALUATOR(OperatorEvaluatorIntXBoolAnd, int, bool, _operate_and)
+
+OP_EVALUATOR(OperatorEvaluatorBoolXFloatAnd, bool, float, _operate_and)
+OP_EVALUATOR(OperatorEvaluatorFloatXBoolAnd, float, bool, _operate_and)
+
+OP_EVALUATOR(OperatorEvaluatorBoolXObjectAnd, bool, object, _operate_and)
+OP_EVALUATOR(OperatorEvaluatorObjectXBoolAnd, object, bool, _operate_and)
+
+// int
+OP_EVALUATOR(OperatorEvaluatorIntXIntAnd, int, int, _operate_and)
+
+OP_EVALUATOR(OperatorEvaluatorIntXFloatAnd, int, float, _operate_and)
+OP_EVALUATOR(OperatorEvaluatorFloatXIntAnd, float, int, _operate_and)
+
+OP_EVALUATOR(OperatorEvaluatorIntXObjectAnd, int, object, _operate_and)
+OP_EVALUATOR(OperatorEvaluatorObjectXIntAnd, object, int, _operate_and)
+
+// float
+OP_EVALUATOR(OperatorEvaluatorFloatXFloatAnd, float, float, _operate_and)
+
+OP_EVALUATOR(OperatorEvaluatorFloatXObjectAnd, float, object, _operate_and)
+OP_EVALUATOR(OperatorEvaluatorObjectXFloatAnd, object, float, _operate_and)
+
+// object
+OP_EVALUATOR(OperatorEvaluatorObjectXObjectAnd, object, object, _operate_and)
+
+// XOR
+
+// nil
+OP_EVALUATOR(OperatorEvaluatorNilXBoolXor, nil, bool, _operate_xor)
+OP_EVALUATOR(OperatorEvaluatorBoolXNilXor, bool, nil, _operate_xor)
+
+OP_EVALUATOR(OperatorEvaluatorNilXIntXor, nil, int, _operate_xor)
+OP_EVALUATOR(OperatorEvaluatorIntXNilXor, int, nil, _operate_xor)
+
+OP_EVALUATOR(OperatorEvaluatorNilXFloatXor, nil, float, _operate_xor)
+OP_EVALUATOR(OperatorEvaluatorFloatXNilXor, float, nil, _operate_xor)
+
+OP_EVALUATOR(OperatorEvaluatorObjectXNilXor, object, nil, _operate_xor)
+OP_EVALUATOR(OperatorEvaluatorNilXObjectXor, nil, object, _operate_xor)
+
+// bool
+OP_EVALUATOR(OperatorEvaluatorBoolXBoolXor, bool, bool, _operate_xor)
+
+OP_EVALUATOR(OperatorEvaluatorBoolXIntXor, bool, int, _operate_xor)
+OP_EVALUATOR(OperatorEvaluatorIntXBoolXor, int, bool, _operate_xor)
+
+OP_EVALUATOR(OperatorEvaluatorBoolXFloatXor, bool, float, _operate_xor)
+OP_EVALUATOR(OperatorEvaluatorFloatXBoolXor, float, bool, _operate_xor)
+
+OP_EVALUATOR(OperatorEvaluatorBoolXObjectXor, bool, object, _operate_xor)
+OP_EVALUATOR(OperatorEvaluatorObjectXBoolXor, object, bool, _operate_xor)
+
+// int
+OP_EVALUATOR(OperatorEvaluatorIntXIntXor, int, int, _operate_xor)
+
+OP_EVALUATOR(OperatorEvaluatorIntXFloatXor, int, float, _operate_xor)
+OP_EVALUATOR(OperatorEvaluatorFloatXIntXor, float, int, _operate_xor)
+
+OP_EVALUATOR(OperatorEvaluatorIntXObjectXor, int, object, _operate_xor)
+OP_EVALUATOR(OperatorEvaluatorObjectXIntXor, object, int, _operate_xor)
+
+// float
+OP_EVALUATOR(OperatorEvaluatorFloatXFloatXor, float, float, _operate_xor)
+
+OP_EVALUATOR(OperatorEvaluatorFloatXObjectXor, float, object, _operate_xor)
+OP_EVALUATOR(OperatorEvaluatorObjectXFloatXor, object, float, _operate_xor)
+
+// object
+OP_EVALUATOR(OperatorEvaluatorObjectXObjectXor, object, object, _operate_xor)
+
+class OperatorEvaluatorNotBool {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ *r_ret = !*VariantGetInternalPtr<bool>::get_ptr(&p_left);
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<bool>::get_ptr(r_ret) = !*VariantGetInternalPtr<bool>::get_ptr(left);
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<bool>::encode(!PtrToArg<bool>::convert(left), r_ret);
+ }
+ static Variant::Type get_return_type() { return Variant::BOOL; }
+};
+
+class OperatorEvaluatorNotInt {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ *r_ret = !*VariantGetInternalPtr<int64_t>::get_ptr(&p_left);
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<bool>::get_ptr(r_ret) = !*VariantGetInternalPtr<int64_t>::get_ptr(left);
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<bool>::encode(!PtrToArg<int64_t>::convert(left), r_ret);
+ }
+ static Variant::Type get_return_type() { return Variant::BOOL; }
+};
+
+class OperatorEvaluatorNotFloat {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ *r_ret = !*VariantGetInternalPtr<double>::get_ptr(&p_left);
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<bool>::get_ptr(r_ret) = !*VariantGetInternalPtr<double>::get_ptr(left);
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<bool>::encode(!PtrToArg<double>::convert(left), r_ret);
+ }
+ static Variant::Type get_return_type() { return Variant::BOOL; }
+};
+
+class OperatorEvaluatorNotObject {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ *r_ret = p_left.get_validated_object() == nullptr;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ *VariantGetInternalPtr<bool>::get_ptr(r_ret) = left->get_validated_object() == nullptr;
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<bool>::encode(PtrToArg<Object *>::convert(left) == nullptr, r_ret);
+ }
+ static Variant::Type get_return_type() { return Variant::BOOL; }
+};
+
+////
+
+class OperatorEvaluatorInStringFind {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const String &str_a = *VariantGetInternalPtr<String>::get_ptr(&p_left);
+ const String &str_b = *VariantGetInternalPtr<String>::get_ptr(&p_right);
+
+ *r_ret = str_b.find(str_a) != -1;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ const String &str_a = *VariantGetInternalPtr<String>::get_ptr(left);
+ const String &str_b = *VariantGetInternalPtr<String>::get_ptr(right);
+ *VariantGetInternalPtr<bool>::get_ptr(r_ret) = str_b.find(str_a) != -1;
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<bool>::encode(PtrToArg<String>::convert(right).find(PtrToArg<String>::convert(left)) != -1, r_ret);
+ }
+ static Variant::Type get_return_type() { return Variant::BOOL; }
+};
+
+template <class A, class B>
+class OperatorEvaluatorInArrayFind {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
+ const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
+
+ *r_ret = b.find(a) != -1;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ const A &a = *VariantGetInternalPtr<A>::get_ptr(left);
+ const B &b = *VariantGetInternalPtr<B>::get_ptr(right);
+ *VariantGetInternalPtr<bool>::get_ptr(r_ret) = b.find(a) != -1;
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<bool>::encode(PtrToArg<B>::convert(right).find(PtrToArg<A>::convert(left)) != -1, r_ret);
+ }
+ static Variant::Type get_return_type() { return Variant::BOOL; }
+};
+
+class OperatorEvaluatorInArrayFindNil {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const Array &b = *VariantGetInternalPtr<Array>::get_ptr(&p_right);
+ *r_ret = b.find(Variant()) != -1;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ const Array &b = *VariantGetInternalPtr<Array>::get_ptr(right);
+ *VariantGetInternalPtr<bool>::get_ptr(r_ret) = b.find(Variant()) != -1;
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<bool>::encode(PtrToArg<Array>::convert(right).find(Variant()) != -1, r_ret);
+ }
+ static Variant::Type get_return_type() { return Variant::BOOL; }
+};
+
+class OperatorEvaluatorInArrayFindObject {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const Array &b = *VariantGetInternalPtr<Array>::get_ptr(&p_right);
+ *r_ret = b.find(p_left) != -1;
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ const Array &b = *VariantGetInternalPtr<Array>::get_ptr(right);
+ *VariantGetInternalPtr<bool>::get_ptr(r_ret) = b.find(*left) != -1;
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<bool>::encode(PtrToArg<Array>::convert(right).find(PtrToArg<Object *>::convert(left)) != -1, r_ret);
+ }
+ static Variant::Type get_return_type() { return Variant::BOOL; }
+};
+
+template <class A>
+class OperatorEvaluatorInDictionaryHas {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const Dictionary &b = *VariantGetInternalPtr<Dictionary>::get_ptr(&p_right);
+ const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
+
+ *r_ret = b.has(a);
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ const Dictionary &b = *VariantGetInternalPtr<Dictionary>::get_ptr(right);
+ const A &a = *VariantGetInternalPtr<A>::get_ptr(left);
+ *VariantGetInternalPtr<bool>::get_ptr(r_ret) = b.has(a);
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<bool>::encode(PtrToArg<Dictionary>::convert(right).has(PtrToArg<A>::convert(left)), r_ret);
+ }
+ static Variant::Type get_return_type() { return Variant::BOOL; }
+};
+
+class OperatorEvaluatorInDictionaryHasNil {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const Dictionary &b = *VariantGetInternalPtr<Dictionary>::get_ptr(&p_right);
+
+ *r_ret = b.has(Variant());
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ const Dictionary &b = *VariantGetInternalPtr<Dictionary>::get_ptr(right);
+ *VariantGetInternalPtr<bool>::get_ptr(r_ret) = b.has(Variant());
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<bool>::encode(PtrToArg<Dictionary>::convert(right).has(Variant()), r_ret);
+ }
+ static Variant::Type get_return_type() { return Variant::BOOL; }
+};
+
+class OperatorEvaluatorInDictionaryHasObject {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ const Dictionary &b = *VariantGetInternalPtr<Dictionary>::get_ptr(&p_right);
+
+ *r_ret = b.has(p_left);
+ r_valid = true;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ const Dictionary &b = *VariantGetInternalPtr<Dictionary>::get_ptr(right);
+ *VariantGetInternalPtr<bool>::get_ptr(r_ret) = b.has(*left);
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ PtrToArg<bool>::encode(PtrToArg<Dictionary>::convert(right).has(PtrToArg<Object *>::convert(left)), r_ret);
+ }
+ static Variant::Type get_return_type() { return Variant::BOOL; }
+};
+
+class OperatorEvaluatorObjectHasPropertyString {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ Object *b = p_right.get_validated_object();
+ if (!b) {
+ *r_ret = "Invalid base object for 'in'";
+ r_valid = false;
+ return;
+ }
+
+ const String &a = *VariantGetInternalPtr<String>::get_ptr(&p_left);
+
+ b->get(a, &r_valid);
+ *r_ret = r_valid;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ Object *l = right->get_validated_object();
+ ERR_FAIL_COND(l == nullptr);
+ const String &a = *VariantGetInternalPtr<String>::get_ptr(left);
+
+ bool valid;
+ l->get(a, &valid);
+ *VariantGetInternalPtr<bool>::get_ptr(r_ret) = valid;
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ bool valid;
+ PtrToArg<Object *>::convert(right)->get(PtrToArg<String>::convert(left), &valid);
+ PtrToArg<bool>::encode(valid, r_ret);
+ }
+ static Variant::Type get_return_type() { return Variant::BOOL; }
+};
+
+class OperatorEvaluatorObjectHasPropertyStringName {
+public:
+ static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
+ Object *b = p_right.get_validated_object();
+ if (!b) {
+ *r_ret = "Invalid base object for 'in'";
+ r_valid = false;
+ return;
+ }
+
+ const StringName &a = *VariantGetInternalPtr<StringName>::get_ptr(&p_left);
+
+ b->get(a, &r_valid);
+ *r_ret = r_valid;
+ }
+ static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) {
+ Object *l = right->get_validated_object();
+ ERR_FAIL_COND(l == nullptr);
+ const StringName &a = *VariantGetInternalPtr<StringName>::get_ptr(left);
+
+ bool valid;
+ l->get(a, &valid);
+ *VariantGetInternalPtr<bool>::get_ptr(r_ret) = valid;
+ }
+ static void ptr_evaluate(const void *left, const void *right, void *r_ret) {
+ bool valid;
+ PtrToArg<Object *>::convert(right)->get(PtrToArg<StringName>::convert(left), &valid);
+ PtrToArg<bool>::encode(valid, r_ret);
+ }
+ static Variant::Type get_return_type() { return Variant::BOOL; }
+};
+
+#endif // VARIANT_OP_H
diff --git a/core/variant/variant_parser.cpp b/core/variant/variant_parser.cpp
index 751cb64c62..e61ce1eeaa 100644
--- a/core/variant/variant_parser.cpp
+++ b/core/variant/variant_parser.cpp
@@ -738,10 +738,10 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
String type = token.value;
- Object *obj = ClassDB::instance(type);
+ Object *obj = ClassDB::instantiate(type);
if (!obj) {
- r_err_str = "Can't instance Object() of type: " + type;
+ r_err_str = "Can't instantiate Object() of type: " + type;
return ERR_PARSE_ERROR;
}
@@ -1423,47 +1423,47 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
} break;
case Variant::VECTOR2: {
Vector2 v = p_variant;
- p_store_string_func(p_store_string_ud, "Vector2( " + rtosfix(v.x) + ", " + rtosfix(v.y) + " )");
+ p_store_string_func(p_store_string_ud, "Vector2(" + rtosfix(v.x) + ", " + rtosfix(v.y) + ")");
} break;
case Variant::VECTOR2I: {
Vector2i v = p_variant;
- p_store_string_func(p_store_string_ud, "Vector2i( " + itos(v.x) + ", " + itos(v.y) + " )");
+ p_store_string_func(p_store_string_ud, "Vector2i(" + itos(v.x) + ", " + itos(v.y) + ")");
} break;
case Variant::RECT2: {
Rect2 aabb = p_variant;
- p_store_string_func(p_store_string_ud, "Rect2( " + rtosfix(aabb.position.x) + ", " + rtosfix(aabb.position.y) + ", " + rtosfix(aabb.size.x) + ", " + rtosfix(aabb.size.y) + " )");
+ p_store_string_func(p_store_string_ud, "Rect2(" + rtosfix(aabb.position.x) + ", " + rtosfix(aabb.position.y) + ", " + rtosfix(aabb.size.x) + ", " + rtosfix(aabb.size.y) + ")");
} break;
case Variant::RECT2I: {
Rect2i aabb = p_variant;
- p_store_string_func(p_store_string_ud, "Rect2i( " + itos(aabb.position.x) + ", " + itos(aabb.position.y) + ", " + itos(aabb.size.x) + ", " + itos(aabb.size.y) + " )");
+ p_store_string_func(p_store_string_ud, "Rect2i(" + itos(aabb.position.x) + ", " + itos(aabb.position.y) + ", " + itos(aabb.size.x) + ", " + itos(aabb.size.y) + ")");
} break;
case Variant::VECTOR3: {
Vector3 v = p_variant;
- p_store_string_func(p_store_string_ud, "Vector3( " + rtosfix(v.x) + ", " + rtosfix(v.y) + ", " + rtosfix(v.z) + " )");
+ p_store_string_func(p_store_string_ud, "Vector3(" + rtosfix(v.x) + ", " + rtosfix(v.y) + ", " + rtosfix(v.z) + ")");
} break;
case Variant::VECTOR3I: {
Vector3i v = p_variant;
- p_store_string_func(p_store_string_ud, "Vector3i( " + itos(v.x) + ", " + itos(v.y) + ", " + itos(v.z) + " )");
+ p_store_string_func(p_store_string_ud, "Vector3i(" + itos(v.x) + ", " + itos(v.y) + ", " + itos(v.z) + ")");
} break;
case Variant::PLANE: {
Plane p = p_variant;
- p_store_string_func(p_store_string_ud, "Plane( " + rtosfix(p.normal.x) + ", " + rtosfix(p.normal.y) + ", " + rtosfix(p.normal.z) + ", " + rtosfix(p.d) + " )");
+ p_store_string_func(p_store_string_ud, "Plane(" + rtosfix(p.normal.x) + ", " + rtosfix(p.normal.y) + ", " + rtosfix(p.normal.z) + ", " + rtosfix(p.d) + ")");
} break;
case Variant::AABB: {
AABB aabb = p_variant;
- p_store_string_func(p_store_string_ud, "AABB( " + rtosfix(aabb.position.x) + ", " + rtosfix(aabb.position.y) + ", " + rtosfix(aabb.position.z) + ", " + rtosfix(aabb.size.x) + ", " + rtosfix(aabb.size.y) + ", " + rtosfix(aabb.size.z) + " )");
+ p_store_string_func(p_store_string_ud, "AABB(" + rtosfix(aabb.position.x) + ", " + rtosfix(aabb.position.y) + ", " + rtosfix(aabb.position.z) + ", " + rtosfix(aabb.size.x) + ", " + rtosfix(aabb.size.y) + ", " + rtosfix(aabb.size.z) + ")");
} break;
case Variant::QUATERNION: {
Quaternion quaternion = p_variant;
- p_store_string_func(p_store_string_ud, "Quaternion( " + rtosfix(quaternion.x) + ", " + rtosfix(quaternion.y) + ", " + rtosfix(quaternion.z) + ", " + rtosfix(quaternion.w) + " )");
+ p_store_string_func(p_store_string_ud, "Quaternion(" + rtosfix(quaternion.x) + ", " + rtosfix(quaternion.y) + ", " + rtosfix(quaternion.z) + ", " + rtosfix(quaternion.w) + ")");
} break;
case Variant::TRANSFORM2D: {
- String s = "Transform2D( ";
+ String s = "Transform2D(";
Transform2D m3 = p_variant;
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 2; j++) {
@@ -1474,11 +1474,11 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
}
}
- p_store_string_func(p_store_string_ud, s + " )");
+ p_store_string_func(p_store_string_ud, s + ")");
} break;
case Variant::BASIS: {
- String s = "Basis( ";
+ String s = "Basis(";
Basis m3 = p_variant;
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
@@ -1489,11 +1489,11 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
}
}
- p_store_string_func(p_store_string_ud, s + " )");
+ p_store_string_func(p_store_string_ud, s + ")");
} break;
case Variant::TRANSFORM3D: {
- String s = "Transform3D( ";
+ String s = "Transform3D(";
Transform3D t = p_variant;
Basis &m3 = t.basis;
for (int i = 0; i < 3; i++) {
@@ -1507,13 +1507,13 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
s = s + ", " + rtosfix(t.origin.x) + ", " + rtosfix(t.origin.y) + ", " + rtosfix(t.origin.z);
- p_store_string_func(p_store_string_ud, s + " )");
+ p_store_string_func(p_store_string_ud, s + ")");
} break;
// misc types
case Variant::COLOR: {
Color c = p_variant;
- p_store_string_func(p_store_string_ud, "Color( " + rtosfix(c.r) + ", " + rtosfix(c.g) + ", " + rtosfix(c.b) + ", " + rtosfix(c.a) + " )");
+ p_store_string_func(p_store_string_ud, "Color(" + rtosfix(c.r) + ", " + rtosfix(c.g) + ", " + rtosfix(c.b) + ", " + rtosfix(c.a) + ")");
} break;
case Variant::STRING_NAME: {
@@ -1553,7 +1553,7 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
if (res_text == String() && res->get_path().is_resource_file()) {
//external resource
String path = res->get_path();
- res_text = "Resource( \"" + path + "\")";
+ res_text = "Resource(\"" + path + "\")";
}
//could come up with some sort of text
@@ -1616,7 +1616,7 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
} break;
case Variant::ARRAY: {
- p_store_string_func(p_store_string_ud, "[ ");
+ p_store_string_func(p_store_string_ud, "[");
Array array = p_variant;
int len = array.size();
for (int i = 0; i < len; i++) {
@@ -1625,12 +1625,12 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
}
write(array[i], p_store_string_func, p_store_string_ud, p_encode_res_func, p_encode_res_ud);
}
- p_store_string_func(p_store_string_ud, " ]");
+ p_store_string_func(p_store_string_ud, "]");
} break;
case Variant::PACKED_BYTE_ARRAY: {
- p_store_string_func(p_store_string_ud, "PackedByteArray( ");
+ p_store_string_func(p_store_string_ud, "PackedByteArray(");
String s;
Vector<uint8_t> data = p_variant;
int len = data.size();
@@ -1644,11 +1644,11 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
p_store_string_func(p_store_string_ud, itos(ptr[i]));
}
- p_store_string_func(p_store_string_ud, " )");
+ p_store_string_func(p_store_string_ud, ")");
} break;
case Variant::PACKED_INT32_ARRAY: {
- p_store_string_func(p_store_string_ud, "PackedInt32Array( ");
+ p_store_string_func(p_store_string_ud, "PackedInt32Array(");
Vector<int32_t> data = p_variant;
int32_t len = data.size();
const int32_t *ptr = data.ptr();
@@ -1661,11 +1661,11 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
p_store_string_func(p_store_string_ud, itos(ptr[i]));
}
- p_store_string_func(p_store_string_ud, " )");
+ p_store_string_func(p_store_string_ud, ")");
} break;
case Variant::PACKED_INT64_ARRAY: {
- p_store_string_func(p_store_string_ud, "PackedInt64Array( ");
+ p_store_string_func(p_store_string_ud, "PackedInt64Array(");
Vector<int64_t> data = p_variant;
int64_t len = data.size();
const int64_t *ptr = data.ptr();
@@ -1678,11 +1678,11 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
p_store_string_func(p_store_string_ud, itos(ptr[i]));
}
- p_store_string_func(p_store_string_ud, " )");
+ p_store_string_func(p_store_string_ud, ")");
} break;
case Variant::PACKED_FLOAT32_ARRAY: {
- p_store_string_func(p_store_string_ud, "PackedFloat32Array( ");
+ p_store_string_func(p_store_string_ud, "PackedFloat32Array(");
Vector<float> data = p_variant;
int len = data.size();
const float *ptr = data.ptr();
@@ -1694,11 +1694,11 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
p_store_string_func(p_store_string_ud, rtosfix(ptr[i]));
}
- p_store_string_func(p_store_string_ud, " )");
+ p_store_string_func(p_store_string_ud, ")");
} break;
case Variant::PACKED_FLOAT64_ARRAY: {
- p_store_string_func(p_store_string_ud, "PackedFloat64Array( ");
+ p_store_string_func(p_store_string_ud, "PackedFloat64Array(");
Vector<double> data = p_variant;
int len = data.size();
const double *ptr = data.ptr();
@@ -1710,11 +1710,11 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
p_store_string_func(p_store_string_ud, rtosfix(ptr[i]));
}
- p_store_string_func(p_store_string_ud, " )");
+ p_store_string_func(p_store_string_ud, ")");
} break;
case Variant::PACKED_STRING_ARRAY: {
- p_store_string_func(p_store_string_ud, "PackedStringArray( ");
+ p_store_string_func(p_store_string_ud, "PackedStringArray(");
Vector<String> data = p_variant;
int len = data.size();
const String *ptr = data.ptr();
@@ -1730,11 +1730,11 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
p_store_string_func(p_store_string_ud, "\"" + str.c_escape() + "\"");
}
- p_store_string_func(p_store_string_ud, " )");
+ p_store_string_func(p_store_string_ud, ")");
} break;
case Variant::PACKED_VECTOR2_ARRAY: {
- p_store_string_func(p_store_string_ud, "PackedVector2Array( ");
+ p_store_string_func(p_store_string_ud, "PackedVector2Array(");
Vector<Vector2> data = p_variant;
int len = data.size();
const Vector2 *ptr = data.ptr();
@@ -1746,11 +1746,11 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
p_store_string_func(p_store_string_ud, rtosfix(ptr[i].x) + ", " + rtosfix(ptr[i].y));
}
- p_store_string_func(p_store_string_ud, " )");
+ p_store_string_func(p_store_string_ud, ")");
} break;
case Variant::PACKED_VECTOR3_ARRAY: {
- p_store_string_func(p_store_string_ud, "PackedVector3Array( ");
+ p_store_string_func(p_store_string_ud, "PackedVector3Array(");
Vector<Vector3> data = p_variant;
int len = data.size();
const Vector3 *ptr = data.ptr();
@@ -1762,12 +1762,11 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
p_store_string_func(p_store_string_ud, rtosfix(ptr[i].x) + ", " + rtosfix(ptr[i].y) + ", " + rtosfix(ptr[i].z));
}
- p_store_string_func(p_store_string_ud, " )");
+ p_store_string_func(p_store_string_ud, ")");
} break;
case Variant::PACKED_COLOR_ARRAY: {
- p_store_string_func(p_store_string_ud, "PackedColorArray( ");
-
+ p_store_string_func(p_store_string_ud, "PackedColorArray(");
Vector<Color> data = p_variant;
int len = data.size();
const Color *ptr = data.ptr();
@@ -1779,7 +1778,7 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
p_store_string_func(p_store_string_ud, rtosfix(ptr[i].r) + ", " + rtosfix(ptr[i].g) + ", " + rtosfix(ptr[i].b) + ", " + rtosfix(ptr[i].a));
}
- p_store_string_func(p_store_string_ud, " )");
+ p_store_string_func(p_store_string_ud, ")");
} break;
default: {
diff --git a/core/variant/variant_setget.cpp b/core/variant/variant_setget.cpp
index ae2795f2fd..de1deace63 100644
--- a/core/variant/variant_setget.cpp
+++ b/core/variant/variant_setget.cpp
@@ -28,282 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "variant.h"
-
-#include "core/core_string_names.h"
-#include "core/debugger/engine_debugger.h"
-#include "core/object/class_db.h"
-#include "core/templates/local_vector.h"
-#include "core/variant/variant_internal.h"
-
-/**** NAMED SETTERS AND GETTERS ****/
-
-#define SETGET_STRUCT(m_base_type, m_member_type, m_member) \
- struct VariantSetGet_##m_base_type##_##m_member { \
- static void get(const Variant *base, Variant *member) { \
- VariantTypeAdjust<m_member_type>::adjust(member); \
- *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_member; \
- } \
- static void ptr_get(const void *base, void *member) { \
- PtrToArg<m_member_type>::encode(PtrToArg<m_base_type>::convert(base).m_member, member); \
- } \
- static void set(Variant *base, const Variant *value, bool &valid) { \
- if (value->get_type() == GetTypeInfo<m_member_type>::VARIANT_TYPE) { \
- VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_member = *VariantGetInternalPtr<m_member_type>::get_ptr(value); \
- valid = true; \
- } else { \
- valid = false; \
- } \
- } \
- static void validated_set(Variant *base, const Variant *value) { \
- VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_member = *VariantGetInternalPtr<m_member_type>::get_ptr(value); \
- } \
- static void ptr_set(void *base, const void *member) { \
- m_base_type b = PtrToArg<m_base_type>::convert(base); \
- b.m_member = PtrToArg<m_member_type>::convert(member); \
- PtrToArg<m_base_type>::encode(b, base); \
- } \
- static Variant::Type get_type() { return GetTypeInfo<m_member_type>::VARIANT_TYPE; } \
- };
-
-#define SETGET_NUMBER_STRUCT(m_base_type, m_member_type, m_member) \
- struct VariantSetGet_##m_base_type##_##m_member { \
- static void get(const Variant *base, Variant *member) { \
- VariantTypeAdjust<m_member_type>::adjust(member); \
- *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_member; \
- } \
- static void ptr_get(const void *base, void *member) { \
- PtrToArg<m_member_type>::encode(PtrToArg<m_base_type>::convert(base).m_member, member); \
- } \
- static void set(Variant *base, const Variant *value, bool &valid) { \
- if (value->get_type() == Variant::FLOAT) { \
- VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_member = *VariantGetInternalPtr<double>::get_ptr(value); \
- valid = true; \
- } else if (value->get_type() == Variant::INT) { \
- VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_member = *VariantGetInternalPtr<int64_t>::get_ptr(value); \
- valid = true; \
- } else { \
- valid = false; \
- } \
- } \
- static void validated_set(Variant *base, const Variant *value) { \
- VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_member = *VariantGetInternalPtr<m_member_type>::get_ptr(value); \
- } \
- static void ptr_set(void *base, const void *member) { \
- m_base_type b = PtrToArg<m_base_type>::convert(base); \
- b.m_member = PtrToArg<m_member_type>::convert(member); \
- PtrToArg<m_base_type>::encode(b, base); \
- } \
- static Variant::Type get_type() { return GetTypeInfo<m_member_type>::VARIANT_TYPE; } \
- };
-
-#define SETGET_STRUCT_CUSTOM(m_base_type, m_member_type, m_member, m_custom) \
- struct VariantSetGet_##m_base_type##_##m_member { \
- static void get(const Variant *base, Variant *member) { \
- VariantTypeAdjust<m_member_type>::adjust(member); \
- *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_custom; \
- } \
- static void ptr_get(const void *base, void *member) { \
- PtrToArg<m_member_type>::encode(PtrToArg<m_base_type>::convert(base).m_custom, member); \
- } \
- static void set(Variant *base, const Variant *value, bool &valid) { \
- if (value->get_type() == GetTypeInfo<m_member_type>::VARIANT_TYPE) { \
- VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_custom = *VariantGetInternalPtr<m_member_type>::get_ptr(value); \
- valid = true; \
- } else { \
- valid = false; \
- } \
- } \
- static void validated_set(Variant *base, const Variant *value) { \
- VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_custom = *VariantGetInternalPtr<m_member_type>::get_ptr(value); \
- } \
- static void ptr_set(void *base, const void *member) { \
- m_base_type b = PtrToArg<m_base_type>::convert(base); \
- b.m_custom = PtrToArg<m_member_type>::convert(member); \
- PtrToArg<m_base_type>::encode(b, base); \
- } \
- static Variant::Type get_type() { return GetTypeInfo<m_member_type>::VARIANT_TYPE; } \
- };
-
-#define SETGET_NUMBER_STRUCT_CUSTOM(m_base_type, m_member_type, m_member, m_custom) \
- struct VariantSetGet_##m_base_type##_##m_member { \
- static void get(const Variant *base, Variant *member) { \
- VariantTypeAdjust<m_member_type>::adjust(member); \
- *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_custom; \
- } \
- static void ptr_get(const void *base, void *member) { \
- PtrToArg<m_member_type>::encode(PtrToArg<m_base_type>::convert(base).m_custom, member); \
- } \
- static void set(Variant *base, const Variant *value, bool &valid) { \
- if (value->get_type() == Variant::FLOAT) { \
- VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_custom = *VariantGetInternalPtr<double>::get_ptr(value); \
- valid = true; \
- } else if (value->get_type() == Variant::INT) { \
- VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_custom = *VariantGetInternalPtr<int64_t>::get_ptr(value); \
- valid = true; \
- } else { \
- valid = false; \
- } \
- } \
- static void validated_set(Variant *base, const Variant *value) { \
- VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_custom = *VariantGetInternalPtr<m_member_type>::get_ptr(value); \
- } \
- static void ptr_set(void *base, const void *member) { \
- m_base_type b = PtrToArg<m_base_type>::convert(base); \
- b.m_custom = PtrToArg<m_member_type>::convert(member); \
- PtrToArg<m_base_type>::encode(b, base); \
- } \
- static Variant::Type get_type() { return GetTypeInfo<m_member_type>::VARIANT_TYPE; } \
- };
-
-#define SETGET_STRUCT_FUNC(m_base_type, m_member_type, m_member, m_setter, m_getter) \
- struct VariantSetGet_##m_base_type##_##m_member { \
- static void get(const Variant *base, Variant *member) { \
- VariantTypeAdjust<m_member_type>::adjust(member); \
- *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_getter(); \
- } \
- static void ptr_get(const void *base, void *member) { \
- PtrToArg<m_member_type>::encode(PtrToArg<m_base_type>::convert(base).m_getter(), member); \
- } \
- static void set(Variant *base, const Variant *value, bool &valid) { \
- if (value->get_type() == GetTypeInfo<m_member_type>::VARIANT_TYPE) { \
- VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_setter(*VariantGetInternalPtr<m_member_type>::get_ptr(value)); \
- valid = true; \
- } else { \
- valid = false; \
- } \
- } \
- static void validated_set(Variant *base, const Variant *value) { \
- VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_setter(*VariantGetInternalPtr<m_member_type>::get_ptr(value)); \
- } \
- static void ptr_set(void *base, const void *member) { \
- m_base_type b = PtrToArg<m_base_type>::convert(base); \
- b.m_setter(PtrToArg<m_member_type>::convert(member)); \
- PtrToArg<m_base_type>::encode(b, base); \
- } \
- static Variant::Type get_type() { return GetTypeInfo<m_member_type>::VARIANT_TYPE; } \
- };
-
-#define SETGET_NUMBER_STRUCT_FUNC(m_base_type, m_member_type, m_member, m_setter, m_getter) \
- struct VariantSetGet_##m_base_type##_##m_member { \
- static void get(const Variant *base, Variant *member) { \
- VariantTypeAdjust<m_member_type>::adjust(member); \
- *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_getter(); \
- } \
- static void ptr_get(const void *base, void *member) { \
- PtrToArg<m_member_type>::encode(PtrToArg<m_base_type>::convert(base).m_getter(), member); \
- } \
- static void set(Variant *base, const Variant *value, bool &valid) { \
- if (value->get_type() == Variant::FLOAT) { \
- VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_setter(*VariantGetInternalPtr<double>::get_ptr(value)); \
- valid = true; \
- } else if (value->get_type() == Variant::INT) { \
- VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_setter(*VariantGetInternalPtr<int64_t>::get_ptr(value)); \
- valid = true; \
- } else { \
- valid = false; \
- } \
- } \
- static void validated_set(Variant *base, const Variant *value) { \
- VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_setter(*VariantGetInternalPtr<m_member_type>::get_ptr(value)); \
- } \
- static void ptr_set(void *base, const void *member) { \
- m_base_type b = PtrToArg<m_base_type>::convert(base); \
- b.m_setter(PtrToArg<m_member_type>::convert(member)); \
- PtrToArg<m_base_type>::encode(b, base); \
- } \
- static Variant::Type get_type() { return GetTypeInfo<m_member_type>::VARIANT_TYPE; } \
- };
-
-#define SETGET_STRUCT_FUNC_INDEX(m_base_type, m_member_type, m_member, m_setter, m_getter, m_index) \
- struct VariantSetGet_##m_base_type##_##m_member { \
- static void get(const Variant *base, Variant *member) { \
- VariantTypeAdjust<m_member_type>::adjust(member); \
- *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_getter(m_index); \
- } \
- static void ptr_get(const void *base, void *member) { \
- PtrToArg<m_member_type>::encode(PtrToArg<m_base_type>::convert(base).m_getter(m_index), member); \
- } \
- static void set(Variant *base, const Variant *value, bool &valid) { \
- if (value->get_type() == GetTypeInfo<m_member_type>::VARIANT_TYPE) { \
- VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_setter(m_index, *VariantGetInternalPtr<m_member_type>::get_ptr(value)); \
- valid = true; \
- } else { \
- valid = false; \
- } \
- } \
- static void validated_set(Variant *base, const Variant *value) { \
- VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_setter(m_index, *VariantGetInternalPtr<m_member_type>::get_ptr(value)); \
- } \
- static void ptr_set(void *base, const void *member) { \
- m_base_type b = PtrToArg<m_base_type>::convert(base); \
- b.m_setter(m_index, PtrToArg<m_member_type>::convert(member)); \
- PtrToArg<m_base_type>::encode(b, base); \
- } \
- static Variant::Type get_type() { return GetTypeInfo<m_member_type>::VARIANT_TYPE; } \
- };
-
-SETGET_NUMBER_STRUCT(Vector2, double, x)
-SETGET_NUMBER_STRUCT(Vector2, double, y)
-
-SETGET_NUMBER_STRUCT(Vector2i, int64_t, x)
-SETGET_NUMBER_STRUCT(Vector2i, int64_t, y)
-
-SETGET_NUMBER_STRUCT(Vector3, double, x)
-SETGET_NUMBER_STRUCT(Vector3, double, y)
-SETGET_NUMBER_STRUCT(Vector3, double, z)
-
-SETGET_NUMBER_STRUCT(Vector3i, int64_t, x)
-SETGET_NUMBER_STRUCT(Vector3i, int64_t, y)
-SETGET_NUMBER_STRUCT(Vector3i, int64_t, z)
-
-SETGET_STRUCT(Rect2, Vector2, position)
-SETGET_STRUCT(Rect2, Vector2, size)
-SETGET_STRUCT_FUNC(Rect2, Vector2, end, set_end, get_end)
-
-SETGET_STRUCT(Rect2i, Vector2i, position)
-SETGET_STRUCT(Rect2i, Vector2i, size)
-SETGET_STRUCT_FUNC(Rect2i, Vector2i, end, set_end, get_end)
-
-SETGET_STRUCT(AABB, Vector3, position)
-SETGET_STRUCT(AABB, Vector3, size)
-SETGET_STRUCT_FUNC(AABB, Vector3, end, set_end, get_end)
-
-SETGET_STRUCT_CUSTOM(Transform2D, Vector2, x, elements[0])
-SETGET_STRUCT_CUSTOM(Transform2D, Vector2, y, elements[1])
-SETGET_STRUCT_CUSTOM(Transform2D, Vector2, origin, elements[2])
-
-SETGET_NUMBER_STRUCT_CUSTOM(Plane, double, x, normal.x)
-SETGET_NUMBER_STRUCT_CUSTOM(Plane, double, y, normal.y)
-SETGET_NUMBER_STRUCT_CUSTOM(Plane, double, z, normal.z)
-SETGET_STRUCT(Plane, Vector3, normal)
-SETGET_NUMBER_STRUCT(Plane, double, d)
-
-SETGET_NUMBER_STRUCT(Quaternion, double, x)
-SETGET_NUMBER_STRUCT(Quaternion, double, y)
-SETGET_NUMBER_STRUCT(Quaternion, double, z)
-SETGET_NUMBER_STRUCT(Quaternion, double, w)
-
-SETGET_STRUCT_FUNC_INDEX(Basis, Vector3, x, set_axis, get_axis, 0)
-SETGET_STRUCT_FUNC_INDEX(Basis, Vector3, y, set_axis, get_axis, 1)
-SETGET_STRUCT_FUNC_INDEX(Basis, Vector3, z, set_axis, get_axis, 2)
-
-SETGET_STRUCT(Transform3D, Basis, basis)
-SETGET_STRUCT(Transform3D, Vector3, origin)
-
-SETGET_NUMBER_STRUCT(Color, double, r)
-SETGET_NUMBER_STRUCT(Color, double, g)
-SETGET_NUMBER_STRUCT(Color, double, b)
-SETGET_NUMBER_STRUCT(Color, double, a)
-
-SETGET_NUMBER_STRUCT_FUNC(Color, int64_t, r8, set_r8, get_r8)
-SETGET_NUMBER_STRUCT_FUNC(Color, int64_t, g8, set_g8, get_g8)
-SETGET_NUMBER_STRUCT_FUNC(Color, int64_t, b8, set_b8, get_b8)
-SETGET_NUMBER_STRUCT_FUNC(Color, int64_t, a8, set_a8, get_a8)
-
-SETGET_NUMBER_STRUCT_FUNC(Color, double, h, set_h, get_h)
-SETGET_NUMBER_STRUCT_FUNC(Color, double, s, set_s, get_s)
-SETGET_NUMBER_STRUCT_FUNC(Color, double, v, set_v, get_v)
+#include "variant_setget.h"
struct VariantSetterGetterInfo {
void (*setter)(Variant *base, const Variant *value, bool &valid);
@@ -326,7 +51,7 @@ static void register_member(Variant::Type p_type, const StringName &p_member) {
sgi.ptr_setter = T::ptr_set;
sgi.getter = T::get;
- sgi.validated_getter = T::get;
+ sgi.validated_getter = T::validated_get;
sgi.ptr_getter = T::ptr_get;
sgi.member_type = T::get_type();
@@ -1146,7 +871,7 @@ struct VariantKeyedSetGetDictionary {
*r_valid = true;
return VariantGetInternalPtr<Dictionary>::get_ptr(base)->has(*key);
}
- static bool ptr_has(const void *base, const void *key) {
+ static uint32_t ptr_has(const void *base, const void *key) {
/* avoid ptrconvert for performance*/
const Dictionary &v = *reinterpret_cast<const Dictionary *>(base);
return v.has(PtrToArg<Variant>::convert(key));
@@ -1196,7 +921,7 @@ struct VariantKeyedSetGetObject {
obj->getvar(*key, &exists);
return exists;
}
- static bool ptr_has(const void *base, const void *key) {
+ static uint32_t ptr_has(const void *base, const void *key) {
const Object *obj = PtrToArg<Object *>::convert(base);
ERR_FAIL_COND_V(!obj, false);
bool valid;
diff --git a/core/variant/variant_setget.h b/core/variant/variant_setget.h
new file mode 100644
index 0000000000..dbf24ab3e3
--- /dev/null
+++ b/core/variant/variant_setget.h
@@ -0,0 +1,332 @@
+/*************************************************************************/
+/* variant_setget.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef VARIANT_SETGET_H
+#define VARIANT_SETGET_H
+
+#include "variant.h"
+
+#include "core/core_string_names.h"
+#include "core/debugger/engine_debugger.h"
+#include "core/object/class_db.h"
+#include "core/templates/local_vector.h"
+#include "core/variant/variant_internal.h"
+
+/**** NAMED SETTERS AND GETTERS ****/
+
+#define SETGET_STRUCT(m_base_type, m_member_type, m_member) \
+ struct VariantSetGet_##m_base_type##_##m_member { \
+ static void get(const Variant *base, Variant *member) { \
+ VariantTypeAdjust<m_member_type>::adjust(member); \
+ *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_member; \
+ } \
+ static inline void validated_get(const Variant *base, Variant *member) { \
+ *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_member; \
+ } \
+ static void ptr_get(const void *base, void *member) { \
+ PtrToArg<m_member_type>::encode(PtrToArg<m_base_type>::convert(base).m_member, member); \
+ } \
+ static void set(Variant *base, const Variant *value, bool &valid) { \
+ if (value->get_type() == GetTypeInfo<m_member_type>::VARIANT_TYPE) { \
+ VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_member = *VariantGetInternalPtr<m_member_type>::get_ptr(value); \
+ valid = true; \
+ } else { \
+ valid = false; \
+ } \
+ } \
+ static inline void validated_set(Variant *base, const Variant *value) { \
+ VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_member = *VariantGetInternalPtr<m_member_type>::get_ptr(value); \
+ } \
+ static void ptr_set(void *base, const void *member) { \
+ m_base_type b = PtrToArg<m_base_type>::convert(base); \
+ b.m_member = PtrToArg<m_member_type>::convert(member); \
+ PtrToArg<m_base_type>::encode(b, base); \
+ } \
+ static Variant::Type get_type() { return GetTypeInfo<m_member_type>::VARIANT_TYPE; } \
+ };
+
+#define SETGET_NUMBER_STRUCT(m_base_type, m_member_type, m_member) \
+ struct VariantSetGet_##m_base_type##_##m_member { \
+ static void get(const Variant *base, Variant *member) { \
+ VariantTypeAdjust<m_member_type>::adjust(member); \
+ *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_member; \
+ } \
+ static inline void validated_get(const Variant *base, Variant *member) { \
+ *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_member; \
+ } \
+ static void ptr_get(const void *base, void *member) { \
+ PtrToArg<m_member_type>::encode(PtrToArg<m_base_type>::convert(base).m_member, member); \
+ } \
+ static void set(Variant *base, const Variant *value, bool &valid) { \
+ if (value->get_type() == Variant::FLOAT) { \
+ VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_member = *VariantGetInternalPtr<double>::get_ptr(value); \
+ valid = true; \
+ } else if (value->get_type() == Variant::INT) { \
+ VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_member = *VariantGetInternalPtr<int64_t>::get_ptr(value); \
+ valid = true; \
+ } else { \
+ valid = false; \
+ } \
+ } \
+ static inline void validated_set(Variant *base, const Variant *value) { \
+ VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_member = *VariantGetInternalPtr<m_member_type>::get_ptr(value); \
+ } \
+ static void ptr_set(void *base, const void *member) { \
+ m_base_type b = PtrToArg<m_base_type>::convert(base); \
+ b.m_member = PtrToArg<m_member_type>::convert(member); \
+ PtrToArg<m_base_type>::encode(b, base); \
+ } \
+ static Variant::Type get_type() { return GetTypeInfo<m_member_type>::VARIANT_TYPE; } \
+ };
+
+#define SETGET_STRUCT_CUSTOM(m_base_type, m_member_type, m_member, m_custom) \
+ struct VariantSetGet_##m_base_type##_##m_member { \
+ static void get(const Variant *base, Variant *member) { \
+ VariantTypeAdjust<m_member_type>::adjust(member); \
+ *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_custom; \
+ } \
+ static inline void validated_get(const Variant *base, Variant *member) { \
+ *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_custom; \
+ } \
+ static void ptr_get(const void *base, void *member) { \
+ PtrToArg<m_member_type>::encode(PtrToArg<m_base_type>::convert(base).m_custom, member); \
+ } \
+ static void set(Variant *base, const Variant *value, bool &valid) { \
+ if (value->get_type() == GetTypeInfo<m_member_type>::VARIANT_TYPE) { \
+ VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_custom = *VariantGetInternalPtr<m_member_type>::get_ptr(value); \
+ valid = true; \
+ } else { \
+ valid = false; \
+ } \
+ } \
+ static inline void validated_set(Variant *base, const Variant *value) { \
+ VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_custom = *VariantGetInternalPtr<m_member_type>::get_ptr(value); \
+ } \
+ static void ptr_set(void *base, const void *member) { \
+ m_base_type b = PtrToArg<m_base_type>::convert(base); \
+ b.m_custom = PtrToArg<m_member_type>::convert(member); \
+ PtrToArg<m_base_type>::encode(b, base); \
+ } \
+ static Variant::Type get_type() { return GetTypeInfo<m_member_type>::VARIANT_TYPE; } \
+ };
+
+#define SETGET_NUMBER_STRUCT_CUSTOM(m_base_type, m_member_type, m_member, m_custom) \
+ struct VariantSetGet_##m_base_type##_##m_member { \
+ static void get(const Variant *base, Variant *member) { \
+ VariantTypeAdjust<m_member_type>::adjust(member); \
+ *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_custom; \
+ } \
+ static inline void validated_get(const Variant *base, Variant *member) { \
+ *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_custom; \
+ } \
+ static void ptr_get(const void *base, void *member) { \
+ PtrToArg<m_member_type>::encode(PtrToArg<m_base_type>::convert(base).m_custom, member); \
+ } \
+ static void set(Variant *base, const Variant *value, bool &valid) { \
+ if (value->get_type() == Variant::FLOAT) { \
+ VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_custom = *VariantGetInternalPtr<double>::get_ptr(value); \
+ valid = true; \
+ } else if (value->get_type() == Variant::INT) { \
+ VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_custom = *VariantGetInternalPtr<int64_t>::get_ptr(value); \
+ valid = true; \
+ } else { \
+ valid = false; \
+ } \
+ } \
+ static inline void validated_set(Variant *base, const Variant *value) { \
+ VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_custom = *VariantGetInternalPtr<m_member_type>::get_ptr(value); \
+ } \
+ static void ptr_set(void *base, const void *member) { \
+ m_base_type b = PtrToArg<m_base_type>::convert(base); \
+ b.m_custom = PtrToArg<m_member_type>::convert(member); \
+ PtrToArg<m_base_type>::encode(b, base); \
+ } \
+ static Variant::Type get_type() { return GetTypeInfo<m_member_type>::VARIANT_TYPE; } \
+ };
+
+#define SETGET_STRUCT_FUNC(m_base_type, m_member_type, m_member, m_setter, m_getter) \
+ struct VariantSetGet_##m_base_type##_##m_member { \
+ static void get(const Variant *base, Variant *member) { \
+ VariantTypeAdjust<m_member_type>::adjust(member); \
+ *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_getter(); \
+ } \
+ static inline void validated_get(const Variant *base, Variant *member) { \
+ *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_getter(); \
+ } \
+ static void ptr_get(const void *base, void *member) { \
+ PtrToArg<m_member_type>::encode(PtrToArg<m_base_type>::convert(base).m_getter(), member); \
+ } \
+ static void set(Variant *base, const Variant *value, bool &valid) { \
+ if (value->get_type() == GetTypeInfo<m_member_type>::VARIANT_TYPE) { \
+ VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_setter(*VariantGetInternalPtr<m_member_type>::get_ptr(value)); \
+ valid = true; \
+ } else { \
+ valid = false; \
+ } \
+ } \
+ static inline void validated_set(Variant *base, const Variant *value) { \
+ VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_setter(*VariantGetInternalPtr<m_member_type>::get_ptr(value)); \
+ } \
+ static void ptr_set(void *base, const void *member) { \
+ m_base_type b = PtrToArg<m_base_type>::convert(base); \
+ b.m_setter(PtrToArg<m_member_type>::convert(member)); \
+ PtrToArg<m_base_type>::encode(b, base); \
+ } \
+ static Variant::Type get_type() { return GetTypeInfo<m_member_type>::VARIANT_TYPE; } \
+ };
+
+#define SETGET_NUMBER_STRUCT_FUNC(m_base_type, m_member_type, m_member, m_setter, m_getter) \
+ struct VariantSetGet_##m_base_type##_##m_member { \
+ static void get(const Variant *base, Variant *member) { \
+ VariantTypeAdjust<m_member_type>::adjust(member); \
+ *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_getter(); \
+ } \
+ static inline void validated_get(const Variant *base, Variant *member) { \
+ *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_getter(); \
+ } \
+ static void ptr_get(const void *base, void *member) { \
+ PtrToArg<m_member_type>::encode(PtrToArg<m_base_type>::convert(base).m_getter(), member); \
+ } \
+ static void set(Variant *base, const Variant *value, bool &valid) { \
+ if (value->get_type() == Variant::FLOAT) { \
+ VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_setter(*VariantGetInternalPtr<double>::get_ptr(value)); \
+ valid = true; \
+ } else if (value->get_type() == Variant::INT) { \
+ VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_setter(*VariantGetInternalPtr<int64_t>::get_ptr(value)); \
+ valid = true; \
+ } else { \
+ valid = false; \
+ } \
+ } \
+ static inline void validated_set(Variant *base, const Variant *value) { \
+ VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_setter(*VariantGetInternalPtr<m_member_type>::get_ptr(value)); \
+ } \
+ static void ptr_set(void *base, const void *member) { \
+ m_base_type b = PtrToArg<m_base_type>::convert(base); \
+ b.m_setter(PtrToArg<m_member_type>::convert(member)); \
+ PtrToArg<m_base_type>::encode(b, base); \
+ } \
+ static Variant::Type get_type() { return GetTypeInfo<m_member_type>::VARIANT_TYPE; } \
+ };
+
+#define SETGET_STRUCT_FUNC_INDEX(m_base_type, m_member_type, m_member, m_setter, m_getter, m_index) \
+ struct VariantSetGet_##m_base_type##_##m_member { \
+ static void get(const Variant *base, Variant *member) { \
+ VariantTypeAdjust<m_member_type>::adjust(member); \
+ *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_getter(m_index); \
+ } \
+ static inline void validated_get(const Variant *base, Variant *member) { \
+ *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_getter(m_index); \
+ } \
+ static void ptr_get(const void *base, void *member) { \
+ PtrToArg<m_member_type>::encode(PtrToArg<m_base_type>::convert(base).m_getter(m_index), member); \
+ } \
+ static void set(Variant *base, const Variant *value, bool &valid) { \
+ if (value->get_type() == GetTypeInfo<m_member_type>::VARIANT_TYPE) { \
+ VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_setter(m_index, *VariantGetInternalPtr<m_member_type>::get_ptr(value)); \
+ valid = true; \
+ } else { \
+ valid = false; \
+ } \
+ } \
+ static inline void validated_set(Variant *base, const Variant *value) { \
+ VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_setter(m_index, *VariantGetInternalPtr<m_member_type>::get_ptr(value)); \
+ } \
+ static void ptr_set(void *base, const void *member) { \
+ m_base_type b = PtrToArg<m_base_type>::convert(base); \
+ b.m_setter(m_index, PtrToArg<m_member_type>::convert(member)); \
+ PtrToArg<m_base_type>::encode(b, base); \
+ } \
+ static Variant::Type get_type() { return GetTypeInfo<m_member_type>::VARIANT_TYPE; } \
+ };
+
+SETGET_NUMBER_STRUCT(Vector2, double, x)
+SETGET_NUMBER_STRUCT(Vector2, double, y)
+
+SETGET_NUMBER_STRUCT(Vector2i, int64_t, x)
+SETGET_NUMBER_STRUCT(Vector2i, int64_t, y)
+
+SETGET_NUMBER_STRUCT(Vector3, double, x)
+SETGET_NUMBER_STRUCT(Vector3, double, y)
+SETGET_NUMBER_STRUCT(Vector3, double, z)
+
+SETGET_NUMBER_STRUCT(Vector3i, int64_t, x)
+SETGET_NUMBER_STRUCT(Vector3i, int64_t, y)
+SETGET_NUMBER_STRUCT(Vector3i, int64_t, z)
+
+SETGET_STRUCT(Rect2, Vector2, position)
+SETGET_STRUCT(Rect2, Vector2, size)
+SETGET_STRUCT_FUNC(Rect2, Vector2, end, set_end, get_end)
+
+SETGET_STRUCT(Rect2i, Vector2i, position)
+SETGET_STRUCT(Rect2i, Vector2i, size)
+SETGET_STRUCT_FUNC(Rect2i, Vector2i, end, set_end, get_end)
+
+SETGET_STRUCT(AABB, Vector3, position)
+SETGET_STRUCT(AABB, Vector3, size)
+SETGET_STRUCT_FUNC(AABB, Vector3, end, set_end, get_end)
+
+SETGET_STRUCT_CUSTOM(Transform2D, Vector2, x, elements[0])
+SETGET_STRUCT_CUSTOM(Transform2D, Vector2, y, elements[1])
+SETGET_STRUCT_CUSTOM(Transform2D, Vector2, origin, elements[2])
+
+SETGET_NUMBER_STRUCT_CUSTOM(Plane, double, x, normal.x)
+SETGET_NUMBER_STRUCT_CUSTOM(Plane, double, y, normal.y)
+SETGET_NUMBER_STRUCT_CUSTOM(Plane, double, z, normal.z)
+SETGET_STRUCT(Plane, Vector3, normal)
+SETGET_NUMBER_STRUCT(Plane, double, d)
+
+SETGET_NUMBER_STRUCT(Quaternion, double, x)
+SETGET_NUMBER_STRUCT(Quaternion, double, y)
+SETGET_NUMBER_STRUCT(Quaternion, double, z)
+SETGET_NUMBER_STRUCT(Quaternion, double, w)
+
+SETGET_STRUCT_FUNC_INDEX(Basis, Vector3, x, set_axis, get_axis, 0)
+SETGET_STRUCT_FUNC_INDEX(Basis, Vector3, y, set_axis, get_axis, 1)
+SETGET_STRUCT_FUNC_INDEX(Basis, Vector3, z, set_axis, get_axis, 2)
+
+SETGET_STRUCT(Transform3D, Basis, basis)
+SETGET_STRUCT(Transform3D, Vector3, origin)
+
+SETGET_NUMBER_STRUCT(Color, double, r)
+SETGET_NUMBER_STRUCT(Color, double, g)
+SETGET_NUMBER_STRUCT(Color, double, b)
+SETGET_NUMBER_STRUCT(Color, double, a)
+
+SETGET_NUMBER_STRUCT_FUNC(Color, int64_t, r8, set_r8, get_r8)
+SETGET_NUMBER_STRUCT_FUNC(Color, int64_t, g8, set_g8, get_g8)
+SETGET_NUMBER_STRUCT_FUNC(Color, int64_t, b8, set_b8, get_b8)
+SETGET_NUMBER_STRUCT_FUNC(Color, int64_t, a8, set_a8, get_a8)
+
+SETGET_NUMBER_STRUCT_FUNC(Color, double, h, set_h, get_h)
+SETGET_NUMBER_STRUCT_FUNC(Color, double, s, set_s, get_s)
+SETGET_NUMBER_STRUCT_FUNC(Color, double, v, set_v, get_v)
+
+#endif // VARIANT_SETGET_H
diff --git a/core/variant/variant_utility.cpp b/core/variant/variant_utility.cpp
index 5d1efb4166..1f69e81d99 100644
--- a/core/variant/variant_utility.cpp
+++ b/core/variant/variant_utility.cpp
@@ -1348,8 +1348,8 @@ String Variant::get_utility_function_argument_name(const StringName &p_name, int
if (!bfi) {
return String();
}
- ERR_FAIL_COND_V(bfi->is_vararg, String());
ERR_FAIL_INDEX_V(p_arg, bfi->argnames.size(), String());
+ ERR_FAIL_COND_V(bfi->is_vararg, String());
return bfi->argnames[p_arg];
}
@@ -1379,6 +1379,23 @@ bool Variant::is_utility_function_vararg(const StringName &p_name) {
return bfi->is_vararg;
}
+uint32_t Variant::get_utility_function_hash(const StringName &p_name) {
+ const VariantUtilityFunctionInfo *bfi = utility_function_table.lookup_ptr(p_name);
+ ERR_FAIL_COND_V(!bfi, 0);
+
+ uint32_t hash = hash_djb2_one_32(bfi->is_vararg);
+ hash = hash_djb2_one_32(bfi->returns_value, hash);
+ if (bfi->returns_value) {
+ hash = hash_djb2_one_32(bfi->return_type, hash);
+ }
+ hash = hash_djb2_one_32(bfi->argcount, hash);
+ for (int i = 0; i < bfi->argcount; i++) {
+ hash = hash_djb2_one_32(bfi->get_arg_type(i), hash);
+ }
+
+ return hash;
+}
+
void Variant::get_utility_function_list(List<StringName> *r_functions) {
for (List<StringName>::Element *E = utility_function_name_table.front(); E; E = E->next()) {
r_functions->push_back(E->get());
diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml
index 552fc41318..d0e594a78b 100644
--- a/doc/classes/@GlobalScope.xml
+++ b/doc/classes/@GlobalScope.xml
@@ -1066,11 +1066,13 @@
<description>
Returns the internal type of the given Variant object, using the [enum Variant.Type] values.
[codeblock]
- p = parse_json('["a", "b", "c"]')
- if typeof(p) == TYPE_ARRAY:
- print(p[0]) # Prints a
+ var json = JSON.new()
+ json.parse('["a", "b", "c"]')
+ var result = json.get_data()
+ if typeof(result) == TYPE_ARRAY:
+ print(result[0]) # Prints a
else:
- print("unexpected results")
+ print("Unexpected result")
[/codeblock]
</description>
</method>
@@ -1211,9 +1213,6 @@
<member name="InputMap" type="InputMap" setter="" getter="">
The [InputMap] singleton.
</member>
- <member name="JSON" type="JSON" setter="" getter="">
- The [JSON] singleton.
- </member>
<member name="JavaClassWrapper" type="JavaClassWrapper" setter="" getter="">
The [JavaClassWrapper] singleton.
[b]Note:[/b] Only implemented on Android.
@@ -1225,6 +1224,8 @@
<member name="Marshalls" type="Marshalls" setter="" getter="">
The [Marshalls] singleton.
</member>
+ <member name="NativeExtensionManager" type="NativeExtensionManager" setter="" getter="">
+ </member>
<member name="NavigationMeshGenerator" type="NavigationMeshGenerator" setter="" getter="">
The [NavigationMeshGenerator] singleton.
</member>
diff --git a/doc/classes/AABB.xml b/doc/classes/AABB.xml
index af34a948f5..03607661df 100644
--- a/doc/classes/AABB.xml
+++ b/doc/classes/AABB.xml
@@ -257,13 +257,13 @@
</method>
</methods>
<members>
- <member name="end" type="Vector3" setter="" getter="" default="Vector3( 0, 0, 0 )">
+ <member name="end" type="Vector3" setter="" getter="" default="Vector3(0, 0, 0)">
Ending corner. This is calculated as [code]position + size[/code]. Setting this value will change the size.
</member>
- <member name="position" type="Vector3" setter="" getter="" default="Vector3( 0, 0, 0 )">
+ <member name="position" type="Vector3" setter="" getter="" default="Vector3(0, 0, 0)">
Beginning corner. Typically has values lower than [member end].
</member>
- <member name="size" type="Vector3" setter="" getter="" default="Vector3( 0, 0, 0 )">
+ <member name="size" type="Vector3" setter="" getter="" default="Vector3(0, 0, 0)">
Size from [member position] to [member end]. Typically, all components are positive.
If the size is negative, you can use [method abs] to fix it.
</member>
diff --git a/doc/classes/AESContext.xml b/doc/classes/AESContext.xml
index 9dde25028e..e179c97677 100644
--- a/doc/classes/AESContext.xml
+++ b/doc/classes/AESContext.xml
@@ -101,7 +101,7 @@
</argument>
<argument index="1" name="key" type="PackedByteArray">
</argument>
- <argument index="2" name="iv" type="PackedByteArray" default="PackedByteArray( )">
+ <argument index="2" name="iv" type="PackedByteArray" default="PackedByteArray()">
</argument>
<description>
Start the AES context in the given [code]mode[/code]. A [code]key[/code] of either 16 or 32 bytes must always be provided, while an [code]iv[/code] (initialization vector) of exactly 16 bytes, is only needed when [code]mode[/code] is either [constant MODE_CBC_ENCRYPT] or [constant MODE_CBC_DECRYPT].
diff --git a/doc/classes/AnimatedSprite2D.xml b/doc/classes/AnimatedSprite2D.xml
index d18419f163..7662e8368b 100644
--- a/doc/classes/AnimatedSprite2D.xml
+++ b/doc/classes/AnimatedSprite2D.xml
@@ -57,7 +57,7 @@
<member name="frames" type="SpriteFrames" setter="set_sprite_frames" getter="get_sprite_frames">
The [SpriteFrames] resource containing the animation(s).
</member>
- <member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2( 0, 0 )">
+ <member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2(0, 0)">
The texture's drawing offset.
</member>
<member name="playing" type="bool" setter="_set_playing" getter="_is_playing" default="false">
diff --git a/doc/classes/Animation.xml b/doc/classes/Animation.xml
index 02203a3725..894e784397 100644
--- a/doc/classes/Animation.xml
+++ b/doc/classes/Animation.xml
@@ -213,9 +213,9 @@
</argument>
<argument index="2" name="value" type="float">
</argument>
- <argument index="3" name="in_handle" type="Vector2" default="Vector2( 0, 0 )">
+ <argument index="3" name="in_handle" type="Vector2" default="Vector2(0, 0)">
</argument>
- <argument index="4" name="out_handle" type="Vector2" default="Vector2( 0, 0 )">
+ <argument index="4" name="out_handle" type="Vector2" default="Vector2(0, 0)">
</argument>
<description>
Inserts a Bezier Track key at the given [code]time[/code] in seconds. The [code]track_idx[/code] must be the index of a Bezier Track.
diff --git a/doc/classes/AnimationNodeBlendSpace2D.xml b/doc/classes/AnimationNodeBlendSpace2D.xml
index abbc8cb2e6..1a6d2bd755 100644
--- a/doc/classes/AnimationNodeBlendSpace2D.xml
+++ b/doc/classes/AnimationNodeBlendSpace2D.xml
@@ -132,13 +132,13 @@
<member name="blend_mode" type="int" setter="set_blend_mode" getter="get_blend_mode" enum="AnimationNodeBlendSpace2D.BlendMode" default="0">
Controls the interpolation between animations. See [enum BlendMode] constants.
</member>
- <member name="max_space" type="Vector2" setter="set_max_space" getter="get_max_space" default="Vector2( 1, 1 )">
+ <member name="max_space" type="Vector2" setter="set_max_space" getter="get_max_space" default="Vector2(1, 1)">
The blend space's X and Y axes' upper limit for the points' position. See [method add_blend_point].
</member>
- <member name="min_space" type="Vector2" setter="set_min_space" getter="get_min_space" default="Vector2( -1, -1 )">
+ <member name="min_space" type="Vector2" setter="set_min_space" getter="get_min_space" default="Vector2(-1, -1)">
The blend space's X and Y axes' lower limit for the points' position. See [method add_blend_point].
</member>
- <member name="snap" type="Vector2" setter="set_snap" getter="get_snap" default="Vector2( 0.1, 0.1 )">
+ <member name="snap" type="Vector2" setter="set_snap" getter="get_snap" default="Vector2(0.1, 0.1)">
Position increment to snap to when moving a point.
</member>
<member name="x_label" type="String" setter="set_x_label" getter="get_x_label" default="&quot;x&quot;">
diff --git a/doc/classes/AnimationNodeBlendTree.xml b/doc/classes/AnimationNodeBlendTree.xml
index 8f87ce453f..a90e8647bb 100644
--- a/doc/classes/AnimationNodeBlendTree.xml
+++ b/doc/classes/AnimationNodeBlendTree.xml
@@ -17,7 +17,7 @@
</argument>
<argument index="1" name="node" type="AnimationNode">
</argument>
- <argument index="2" name="position" type="Vector2" default="Vector2( 0, 0 )">
+ <argument index="2" name="position" type="Vector2" default="Vector2(0, 0)">
</argument>
<description>
Adds an [AnimationNode] at the given [code]position[/code]. The [code]name[/code] is used to identify the created sub-node later.
@@ -107,7 +107,7 @@
</method>
</methods>
<members>
- <member name="graph_offset" type="Vector2" setter="set_graph_offset" getter="get_graph_offset" default="Vector2( 0, 0 )">
+ <member name="graph_offset" type="Vector2" setter="set_graph_offset" getter="get_graph_offset" default="Vector2(0, 0)">
The global offset of all sub-nodes.
</member>
</members>
diff --git a/doc/classes/AnimationNodeStateMachine.xml b/doc/classes/AnimationNodeStateMachine.xml
index e08e288c59..8e070142c4 100644
--- a/doc/classes/AnimationNodeStateMachine.xml
+++ b/doc/classes/AnimationNodeStateMachine.xml
@@ -28,7 +28,7 @@
</argument>
<argument index="1" name="node" type="AnimationNode">
</argument>
- <argument index="2" name="position" type="Vector2" default="Vector2( 0, 0 )">
+ <argument index="2" name="position" type="Vector2" default="Vector2(0, 0)">
</argument>
<description>
Adds a new node to the graph. The [code]position[/code] is used for display in the editor.
diff --git a/doc/classes/Area2D.xml b/doc/classes/Area2D.xml
index 96333988f8..f52c810ad2 100644
--- a/doc/classes/Area2D.xml
+++ b/doc/classes/Area2D.xml
@@ -69,7 +69,7 @@
<member name="gravity_point" type="bool" setter="set_gravity_is_point" getter="is_gravity_a_point" default="false">
If [code]true[/code], gravity is calculated from a point (set via [member gravity_vec]). See also [member space_override].
</member>
- <member name="gravity_vec" type="Vector2" setter="set_gravity_vector" getter="get_gravity_vector" default="Vector2( 0, 1 )">
+ <member name="gravity_vec" type="Vector2" setter="set_gravity_vector" getter="get_gravity_vector" default="Vector2(0, 1)">
The area's gravity vector (not normalized). If gravity is a point (see [member gravity_point]), this will be the point of attraction.
</member>
<member name="linear_damp" type="float" setter="set_linear_damp" getter="get_linear_damp" default="0.1">
diff --git a/doc/classes/Area3D.xml b/doc/classes/Area3D.xml
index a2724f3f23..cc31b6c203 100644
--- a/doc/classes/Area3D.xml
+++ b/doc/classes/Area3D.xml
@@ -67,7 +67,7 @@
<member name="gravity_point" type="bool" setter="set_gravity_is_point" getter="is_gravity_a_point" default="false">
If [code]true[/code], gravity is calculated from a point (set via [member gravity_vec]). See also [member space_override].
</member>
- <member name="gravity_vec" type="Vector3" setter="set_gravity_vector" getter="get_gravity_vector" default="Vector3( 0, -1, 0 )">
+ <member name="gravity_vec" type="Vector3" setter="set_gravity_vector" getter="get_gravity_vector" default="Vector3(0, -1, 0)">
The area's gravity vector (not normalized). If gravity is a point (see [member gravity_point]), this will be the point of attraction.
</member>
<member name="linear_damp" type="float" setter="set_linear_damp" getter="get_linear_damp" default="0.1">
diff --git a/doc/classes/ArrayMesh.xml b/doc/classes/ArrayMesh.xml
index f8cbc942e6..1bbf9bcd93 100644
--- a/doc/classes/ArrayMesh.xml
+++ b/doc/classes/ArrayMesh.xml
@@ -66,7 +66,7 @@
</argument>
<argument index="1" name="arrays" type="Array">
</argument>
- <argument index="2" name="blend_shapes" type="Array" default="[ ]">
+ <argument index="2" name="blend_shapes" type="Array" default="[]">
</argument>
<argument index="3" name="lods" type="Dictionary" default="{
}">
@@ -221,7 +221,7 @@
<member name="blend_shape_mode" type="int" setter="set_blend_shape_mode" getter="get_blend_shape_mode" enum="Mesh.BlendShapeMode" default="1">
Sets the blend shape mode to one of [enum Mesh.BlendShapeMode].
</member>
- <member name="custom_aabb" type="AABB" setter="set_custom_aabb" getter="get_custom_aabb" default="AABB( 0, 0, 0, 0, 0, 0 )">
+ <member name="custom_aabb" type="AABB" setter="set_custom_aabb" getter="get_custom_aabb" default="AABB(0, 0, 0, 0, 0, 0)">
Overrides the [AABB] with one defined by user for use with frustum culling. Especially useful to avoid unexpected culling when using a shader to offset vertices.
</member>
<member name="shadow_mesh" type="ArrayMesh" setter="set_shadow_mesh" getter="get_shadow_mesh">
diff --git a/doc/classes/AtlasTexture.xml b/doc/classes/AtlasTexture.xml
index 9865319419..b49c0e4278 100644
--- a/doc/classes/AtlasTexture.xml
+++ b/doc/classes/AtlasTexture.xml
@@ -18,10 +18,10 @@
<member name="filter_clip" type="bool" setter="set_filter_clip" getter="has_filter_clip" default="false">
If [code]true[/code], clips the area outside of the region to avoid bleeding of the surrounding texture pixels.
</member>
- <member name="margin" type="Rect2" setter="set_margin" getter="get_margin" default="Rect2( 0, 0, 0, 0 )">
+ <member name="margin" type="Rect2" setter="set_margin" getter="get_margin" default="Rect2(0, 0, 0, 0)">
The margin around the region. The [Rect2]'s [member Rect2.size] parameter ("w" and "h" in the editor) resizes the texture so it fits within the margin.
</member>
- <member name="region" type="Rect2" setter="set_region" getter="get_region" default="Rect2( 0, 0, 0, 0 )">
+ <member name="region" type="Rect2" setter="set_region" getter="get_region" default="Rect2(0, 0, 0, 0)">
The AtlasTexture's used region.
</member>
</members>
diff --git a/doc/classes/AudioStreamSample.xml b/doc/classes/AudioStreamSample.xml
index d07b1ac66d..5a0e71a0f8 100644
--- a/doc/classes/AudioStreamSample.xml
+++ b/doc/classes/AudioStreamSample.xml
@@ -22,7 +22,7 @@
</method>
</methods>
<members>
- <member name="data" type="PackedByteArray" setter="set_data" getter="get_data" default="PackedByteArray( )">
+ <member name="data" type="PackedByteArray" setter="set_data" getter="get_data" default="PackedByteArray()">
Contains the audio data in bytes.
[b]Note:[/b] This property expects signed PCM8 data. To convert unsigned PCM8 to signed PCM8, subtract 128 from each byte.
</member>
diff --git a/doc/classes/BackBufferCopy.xml b/doc/classes/BackBufferCopy.xml
index 9a70b8f20c..55ee573811 100644
--- a/doc/classes/BackBufferCopy.xml
+++ b/doc/classes/BackBufferCopy.xml
@@ -15,7 +15,7 @@
<member name="copy_mode" type="int" setter="set_copy_mode" getter="get_copy_mode" enum="BackBufferCopy.CopyMode" default="1">
Buffer mode. See [enum CopyMode] constants.
</member>
- <member name="rect" type="Rect2" setter="set_rect" getter="get_rect" default="Rect2( -100, -100, 200, 200 )">
+ <member name="rect" type="Rect2" setter="set_rect" getter="get_rect" default="Rect2(-100, -100, 200, 200)">
The area covered by the BackBufferCopy. Only used if [member copy_mode] is [constant COPY_MODE_RECT].
</member>
</members>
diff --git a/doc/classes/BaseMaterial3D.xml b/doc/classes/BaseMaterial3D.xml
index 49edb4c691..abe06bc7e1 100644
--- a/doc/classes/BaseMaterial3D.xml
+++ b/doc/classes/BaseMaterial3D.xml
@@ -72,7 +72,7 @@
</method>
</methods>
<members>
- <member name="albedo_color" type="Color" setter="set_albedo" getter="get_albedo" default="Color( 1, 1, 1, 1 )">
+ <member name="albedo_color" type="Color" setter="set_albedo" getter="get_albedo" default="Color(1, 1, 1, 1)">
The material's base color.
</member>
<member name="albedo_tex_force_srgb" type="bool" setter="set_flag" getter="get_flag" default="false">
@@ -117,7 +117,7 @@
<member name="ao_texture_channel" type="int" setter="set_ao_texture_channel" getter="get_ao_texture_channel" enum="BaseMaterial3D.TextureChannel" default="0">
Specifies the channel of the [member ao_texture] in which the ambient occlusion information is stored. This is useful when you store the information for multiple effects in a single texture. For example if you stored metallic in the red channel, roughness in the blue, and ambient occlusion in the green you could reduce the number of textures you use.
</member>
- <member name="backlight" type="Color" setter="set_backlight" getter="get_backlight" default="Color( 0, 0, 0, 1 )">
+ <member name="backlight" type="Color" setter="set_backlight" getter="get_backlight" default="Color(0, 0, 0, 1)">
The color used by the backlight effect. Represents the light passing through an object.
</member>
<member name="backlight_enabled" type="bool" setter="set_feature" getter="get_feature" default="false">
@@ -195,7 +195,7 @@
<member name="distance_fade_mode" type="int" setter="set_distance_fade" getter="get_distance_fade" enum="BaseMaterial3D.DistanceFadeMode" default="0">
Specifies which type of fade to use. Can be any of the [enum DistanceFadeMode]s.
</member>
- <member name="emission" type="Color" setter="set_emission" getter="get_emission" default="Color( 0, 0, 0, 1 )">
+ <member name="emission" type="Color" setter="set_emission" getter="get_emission" default="Color(0, 0, 0, 1)">
The emitted light's color. See [member emission_enabled].
</member>
<member name="emission_enabled" type="bool" setter="set_feature" getter="get_feature" default="false">
@@ -345,7 +345,7 @@
</member>
<member name="subsurf_scatter_transmittance_boost" type="float" setter="set_transmittance_boost" getter="get_transmittance_boost" default="0.0">
</member>
- <member name="subsurf_scatter_transmittance_color" type="Color" setter="set_transmittance_color" getter="get_transmittance_color" default="Color( 1, 1, 1, 1 )">
+ <member name="subsurf_scatter_transmittance_color" type="Color" setter="set_transmittance_color" getter="get_transmittance_color" default="Color(1, 1, 1, 1)">
</member>
<member name="subsurf_scatter_transmittance_curve" type="float" setter="set_transmittance_curve" getter="get_transmittance_curve" default="1.0">
</member>
@@ -370,10 +370,10 @@
If [code]true[/code], render point size can be changed.
[b]Note:[/b] this is only effective for objects whose geometry is point-based rather than triangle-based. See also [member point_size].
</member>
- <member name="uv1_offset" type="Vector3" setter="set_uv1_offset" getter="get_uv1_offset" default="Vector3( 0, 0, 0 )">
+ <member name="uv1_offset" type="Vector3" setter="set_uv1_offset" getter="get_uv1_offset" default="Vector3(0, 0, 0)">
How much to offset the [code]UV[/code] coordinates. This amount will be added to [code]UV[/code] in the vertex function. This can be used to offset a texture.
</member>
- <member name="uv1_scale" type="Vector3" setter="set_uv1_scale" getter="get_uv1_scale" default="Vector3( 1, 1, 1 )">
+ <member name="uv1_scale" type="Vector3" setter="set_uv1_scale" getter="get_uv1_scale" default="Vector3(1, 1, 1)">
How much to scale the [code]UV[/code] coordinates. This is multiplied by [code]UV[/code] in the vertex function.
</member>
<member name="uv1_triplanar" type="bool" setter="set_flag" getter="get_flag" default="false">
@@ -385,10 +385,10 @@
<member name="uv1_world_triplanar" type="bool" setter="set_flag" getter="get_flag" default="false">
If [code]true[/code], triplanar mapping for [code]UV[/code] is calculated in world space rather than object local space. See also [member uv1_triplanar].
</member>
- <member name="uv2_offset" type="Vector3" setter="set_uv2_offset" getter="get_uv2_offset" default="Vector3( 0, 0, 0 )">
+ <member name="uv2_offset" type="Vector3" setter="set_uv2_offset" getter="get_uv2_offset" default="Vector3(0, 0, 0)">
How much to offset the [code]UV2[/code] coordinates. This amount will be added to [code]UV2[/code] in the vertex function. This can be used to offset a texture.
</member>
- <member name="uv2_scale" type="Vector3" setter="set_uv2_scale" getter="get_uv2_scale" default="Vector3( 1, 1, 1 )">
+ <member name="uv2_scale" type="Vector3" setter="set_uv2_scale" getter="get_uv2_scale" default="Vector3(1, 1, 1)">
How much to scale the [code]UV2[/code] coordinates. This is multiplied by [code]UV2[/code] in the vertex function.
</member>
<member name="uv2_triplanar" type="bool" setter="set_flag" getter="get_flag" default="false">
diff --git a/doc/classes/Basis.xml b/doc/classes/Basis.xml
index 14fca04672..bd1abe914d 100644
--- a/doc/classes/Basis.xml
+++ b/doc/classes/Basis.xml
@@ -155,6 +155,24 @@
<description>
</description>
</method>
+ <method name="operator *" qualifiers="operator">
+ <return type="Basis">
+ </return>
+ <argument index="0" name="right" type="float">
+ </argument>
+ <description>
+ This operator multiplies all components of the [Basis], which scales it uniformly.
+ </description>
+ </method>
+ <method name="operator *" qualifiers="operator">
+ <return type="Basis">
+ </return>
+ <argument index="0" name="right" type="int">
+ </argument>
+ <description>
+ This operator multiplies all components of the [Basis], which scales it uniformly.
+ </description>
+ </method>
<method name="operator ==" qualifiers="operator">
<return type="bool">
</return>
@@ -245,28 +263,28 @@
</method>
</methods>
<members>
- <member name="x" type="Vector3" setter="" getter="" default="Vector3( 1, 0, 0 )">
+ <member name="x" type="Vector3" setter="" getter="" default="Vector3(1, 0, 0)">
The basis matrix's X vector (column 0). Equivalent to array index [code]0[/code].
</member>
- <member name="y" type="Vector3" setter="" getter="" default="Vector3( 0, 1, 0 )">
+ <member name="y" type="Vector3" setter="" getter="" default="Vector3(0, 1, 0)">
The basis matrix's Y vector (column 1). Equivalent to array index [code]1[/code].
</member>
- <member name="z" type="Vector3" setter="" getter="" default="Vector3( 0, 0, 1 )">
+ <member name="z" type="Vector3" setter="" getter="" default="Vector3(0, 0, 1)">
The basis matrix's Z vector (column 2). Equivalent to array index [code]2[/code].
</member>
</members>
<constants>
- <constant name="IDENTITY" value="Basis( 1, 0, 0, 0, 1, 0, 0, 0, 1 )">
+ <constant name="IDENTITY" value="Basis(1, 0, 0, 0, 1, 0, 0, 0, 1)">
The identity basis, with no rotation or scaling applied.
This is identical to calling [code]Basis()[/code] without any parameters. This constant can be used to make your code clearer, and for consistency with C#.
</constant>
- <constant name="FLIP_X" value="Basis( -1, 0, 0, 0, 1, 0, 0, 0, 1 )">
+ <constant name="FLIP_X" value="Basis(-1, 0, 0, 0, 1, 0, 0, 0, 1)">
The basis that will flip something along the X axis when used in a transformation.
</constant>
- <constant name="FLIP_Y" value="Basis( 1, 0, 0, 0, -1, 0, 0, 0, 1 )">
+ <constant name="FLIP_Y" value="Basis(1, 0, 0, 0, -1, 0, 0, 0, 1)">
The basis that will flip something along the Y axis when used in a transformation.
</constant>
- <constant name="FLIP_Z" value="Basis( 1, 0, 0, 0, 1, 0, 0, 0, -1 )">
+ <constant name="FLIP_Z" value="Basis(1, 0, 0, 0, 1, 0, 0, 0, -1)">
The basis that will flip something along the Z axis when used in a transformation.
</constant>
</constants>
diff --git a/doc/classes/Bone2D.xml b/doc/classes/Bone2D.xml
index 93744ddad7..b8d5544d59 100644
--- a/doc/classes/Bone2D.xml
+++ b/doc/classes/Bone2D.xml
@@ -101,7 +101,7 @@
</method>
</methods>
<members>
- <member name="rest" type="Transform2D" setter="set_rest" getter="get_rest" default="Transform2D( 0, 0, 0, 0, 0, 0 )">
+ <member name="rest" type="Transform2D" setter="set_rest" getter="get_rest" default="Transform2D(0, 0, 0, 0, 0, 0)">
Rest transform of the bone. You can reset the node's transforms to this value using [method apply_rest].
</member>
</members>
diff --git a/doc/classes/BoxMesh.xml b/doc/classes/BoxMesh.xml
index 1404477b46..dda5e2f1e5 100644
--- a/doc/classes/BoxMesh.xml
+++ b/doc/classes/BoxMesh.xml
@@ -13,7 +13,7 @@
<methods>
</methods>
<members>
- <member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3( 2, 2, 2 )">
+ <member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3(2, 2, 2)">
The box's width, height and depth.
</member>
<member name="subdivide_depth" type="int" setter="set_subdivide_depth" getter="get_subdivide_depth" default="0">
diff --git a/doc/classes/BoxShape3D.xml b/doc/classes/BoxShape3D.xml
index f5051413ce..5704de905b 100644
--- a/doc/classes/BoxShape3D.xml
+++ b/doc/classes/BoxShape3D.xml
@@ -14,7 +14,7 @@
<methods>
</methods>
<members>
- <member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3( 2, 2, 2 )">
+ <member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3(2, 2, 2)">
The box's width, height and depth.
</member>
</members>
diff --git a/doc/classes/Button.xml b/doc/classes/Button.xml
index 51c35b15ce..c9078a4de5 100644
--- a/doc/classes/Button.xml
+++ b/doc/classes/Button.xml
@@ -116,22 +116,22 @@
<theme_item name="font" type="Font">
[Font] of the [Button]'s text.
</theme_item>
- <theme_item name="font_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )">
+ <theme_item name="font_color" type="Color" default="Color(0.88, 0.88, 0.88, 1)">
Default text [Color] of the [Button].
</theme_item>
- <theme_item name="font_disabled_color" type="Color" default="Color( 0.9, 0.9, 0.9, 0.2 )">
+ <theme_item name="font_disabled_color" type="Color" default="Color(0.9, 0.9, 0.9, 0.2)">
Text [Color] used when the [Button] is disabled.
</theme_item>
- <theme_item name="font_hover_color" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )">
+ <theme_item name="font_hover_color" type="Color" default="Color(0.94, 0.94, 0.94, 1)">
Text [Color] used when the [Button] is being hovered.
</theme_item>
- <theme_item name="font_hover_pressed_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="font_hover_pressed_color" type="Color" default="Color(1, 1, 1, 1)">
Text [Color] used when the [Button] is being hovered and pressed.
</theme_item>
- <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)">
The tint of text outline of the [Button].
</theme_item>
- <theme_item name="font_pressed_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="font_pressed_color" type="Color" default="Color(1, 1, 1, 1)">
Text [Color] used when the [Button] is being pressed.
</theme_item>
<theme_item name="font_size" type="int">
@@ -143,19 +143,19 @@
<theme_item name="hseparation" type="int" default="2">
The horizontal space between [Button]'s icon and text.
</theme_item>
- <theme_item name="icon_disabled_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="icon_disabled_color" type="Color" default="Color(1, 1, 1, 1)">
Icon modulate [Color] used when the [Button] is disabled.
</theme_item>
- <theme_item name="icon_hover_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="icon_hover_color" type="Color" default="Color(1, 1, 1, 1)">
Icon modulate [Color] used when the [Button] is being hovered.
</theme_item>
- <theme_item name="icon_hover_pressed_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="icon_hover_pressed_color" type="Color" default="Color(1, 1, 1, 1)">
Icon modulate [Color] used when the [Button] is being hovered and pressed.
</theme_item>
- <theme_item name="icon_normal_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="icon_normal_color" type="Color" default="Color(1, 1, 1, 1)">
Default icon modulate [Color] of the [Button].
</theme_item>
- <theme_item name="icon_pressed_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="icon_pressed_color" type="Color" default="Color(1, 1, 1, 1)">
Icon modulate [Color] used when the [Button] is being pressed.
</theme_item>
<theme_item name="normal" type="StyleBox">
diff --git a/doc/classes/CPUParticles2D.xml b/doc/classes/CPUParticles2D.xml
index 9e70978db8..9620e9abd1 100644
--- a/doc/classes/CPUParticles2D.xml
+++ b/doc/classes/CPUParticles2D.xml
@@ -148,7 +148,7 @@
<member name="anim_speed_random" type="float" setter="set_param_randomness" getter="get_param_randomness" default="0.0">
Animation speed randomness ratio.
</member>
- <member name="color" type="Color" setter="set_color" getter="get_color" default="Color( 1, 1, 1, 1 )">
+ <member name="color" type="Color" setter="set_color" getter="get_color" default="Color(1, 1, 1, 1)">
Each particle's initial color. If [member texture] is defined, it will be multiplied by this color.
</member>
<member name="color_ramp" type="Gradient" setter="set_color_ramp" getter="get_color_ramp">
@@ -163,7 +163,7 @@
<member name="damping_random" type="float" setter="set_param_randomness" getter="get_param_randomness" default="0.0">
Damping randomness ratio.
</member>
- <member name="direction" type="Vector2" setter="set_direction" getter="get_direction" default="Vector2( 1, 0 )">
+ <member name="direction" type="Vector2" setter="set_direction" getter="get_direction" default="Vector2(1, 0)">
Unit vector specifying the particles' emission direction.
</member>
<member name="draw_order" type="int" setter="set_draw_order" getter="get_draw_order" enum="CPUParticles2D.DrawOrder" default="0">
@@ -199,7 +199,7 @@
<member name="fract_delta" type="bool" setter="set_fractional_delta" getter="get_fractional_delta" default="true">
If [code]true[/code], results in fractional delta calculation which has a smoother particles display effect.
</member>
- <member name="gravity" type="Vector2" setter="set_gravity" getter="get_gravity" default="Vector2( 0, 980 )">
+ <member name="gravity" type="Vector2" setter="set_gravity" getter="get_gravity" default="Vector2(0, 980)">
Gravity applied to every particle.
</member>
<member name="hue_variation" type="float" setter="set_param" getter="get_param" default="0.0">
diff --git a/doc/classes/CPUParticles3D.xml b/doc/classes/CPUParticles3D.xml
index 0512efa8c2..7509775d20 100644
--- a/doc/classes/CPUParticles3D.xml
+++ b/doc/classes/CPUParticles3D.xml
@@ -147,7 +147,7 @@
<member name="anim_speed_random" type="float" setter="set_param_randomness" getter="get_param_randomness" default="0.0">
Animation speed randomness ratio.
</member>
- <member name="color" type="Color" setter="set_color" getter="get_color" default="Color( 1, 1, 1, 1 )">
+ <member name="color" type="Color" setter="set_color" getter="get_color" default="Color(1, 1, 1, 1)">
Unused for 3D particles.
</member>
<member name="color_ramp" type="Gradient" setter="set_color_ramp" getter="get_color_ramp">
@@ -162,7 +162,7 @@
<member name="damping_random" type="float" setter="set_param_randomness" getter="get_param_randomness" default="0.0">
Damping randomness ratio.
</member>
- <member name="direction" type="Vector3" setter="set_direction" getter="get_direction" default="Vector3( 1, 0, 0 )">
+ <member name="direction" type="Vector3" setter="set_direction" getter="get_direction" default="Vector3(1, 0, 0)">
Unit vector specifying the particles' emission direction.
</member>
<member name="draw_order" type="int" setter="set_draw_order" getter="get_draw_order" enum="CPUParticles3D.DrawOrder" default="0">
@@ -171,13 +171,13 @@
<member name="emission_box_extents" type="Vector3" setter="set_emission_box_extents" getter="get_emission_box_extents">
The rectangle's extents if [member emission_shape] is set to [constant EMISSION_SHAPE_BOX].
</member>
- <member name="emission_colors" type="PackedColorArray" setter="set_emission_colors" getter="get_emission_colors" default="PackedColorArray( )">
+ <member name="emission_colors" type="PackedColorArray" setter="set_emission_colors" getter="get_emission_colors" default="PackedColorArray()">
Sets the [Color]s to modulate particles by when using [constant EMISSION_SHAPE_POINTS] or [constant EMISSION_SHAPE_DIRECTED_POINTS].
</member>
<member name="emission_normals" type="PackedVector3Array" setter="set_emission_normals" getter="get_emission_normals">
Sets the direction the particles will be emitted in when using [constant EMISSION_SHAPE_DIRECTED_POINTS].
</member>
- <member name="emission_points" type="PackedVector3Array" setter="set_emission_points" getter="get_emission_points" default="PackedVector3Array( )">
+ <member name="emission_points" type="PackedVector3Array" setter="set_emission_points" getter="get_emission_points" default="PackedVector3Array()">
Sets the initial positions to spawn particles when using [constant EMISSION_SHAPE_POINTS] or [constant EMISSION_SHAPE_DIRECTED_POINTS].
</member>
<member name="emission_shape" type="int" setter="set_emission_shape" getter="get_emission_shape" enum="CPUParticles3D.EmissionShape" default="0">
@@ -201,7 +201,7 @@
<member name="fract_delta" type="bool" setter="set_fractional_delta" getter="get_fractional_delta" default="true">
If [code]true[/code], results in fractional delta calculation which has a smoother particles display effect.
</member>
- <member name="gravity" type="Vector3" setter="set_gravity" getter="get_gravity" default="Vector3( 0, -9.8, 0 )">
+ <member name="gravity" type="Vector3" setter="set_gravity" getter="get_gravity" default="Vector3(0, -9.8, 0)">
Gravity applied to every particle.
</member>
<member name="hue_variation" type="float" setter="set_param" getter="get_param" default="0.0">
diff --git a/doc/classes/CallbackTweener.xml b/doc/classes/CallbackTweener.xml
new file mode 100644
index 0000000000..8ac285c3df
--- /dev/null
+++ b/doc/classes/CallbackTweener.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="CallbackTweener" inherits="Tweener" version="4.0">
+ <brief_description>
+ Calls the specified method after optional delay.
+ </brief_description>
+ <description>
+ [CallbackTweener] is used to call a method in a tweening sequence. See [method Tween.tween_callback] for more usage information.
+ [b]Note:[/b] [method Tween.tween_callback] is the only correct way to create [CallbackTweener]. Any [CallbackTweener] created manually will not function correctly.
+ </description>
+ <tutorials>
+ </tutorials>
+ <methods>
+ <method name="set_delay">
+ <return type="CallbackTweener">
+ </return>
+ <argument index="0" name="delay" type="float">
+ </argument>
+ <description>
+ Makes the callback call delayed by given time in seconds. Example:
+ [codeblock]
+ var tween = get_tree().create_tween()
+ tween.tween_callback(queue_free).set_delay(2) #this will call queue_free() after 2 seconds
+ [/codeblock]
+ </description>
+ </method>
+ </methods>
+ <constants>
+ </constants>
+</class>
diff --git a/doc/classes/Camera2D.xml b/doc/classes/Camera2D.xml
index d40567bdcb..bf1a9cc929 100644
--- a/doc/classes/Camera2D.xml
+++ b/doc/classes/Camera2D.xml
@@ -165,7 +165,7 @@
<member name="limit_top" type="int" setter="set_limit" getter="get_limit" default="-10000000">
Top scroll limit in pixels. The camera stops moving when reaching this value.
</member>
- <member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2( 0, 0 )">
+ <member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2(0, 0)">
The camera's offset, useful for looking around or camera shake animations.
</member>
<member name="process_callback" type="int" setter="set_process_callback" getter="get_process_callback" enum="Camera2D.Camera2DProcessCallback" default="1">
@@ -180,7 +180,7 @@
<member name="smoothing_speed" type="float" setter="set_follow_smoothing" getter="get_follow_smoothing" default="5.0">
Speed in pixels per second of the camera's smoothing effect when [member smoothing_enabled] is [code]true[/code].
</member>
- <member name="zoom" type="Vector2" setter="set_zoom" getter="get_zoom" default="Vector2( 1, 1 )">
+ <member name="zoom" type="Vector2" setter="set_zoom" getter="get_zoom" default="Vector2(1, 1)">
The camera's zoom relative to the viewport. Values larger than [code]Vector2(1, 1)[/code] zoom out and smaller values zoom in. For an example, use [code]Vector2(0.5, 0.5)[/code] for a 2× zoom-in, and [code]Vector2(4, 4)[/code] for a 4× zoom-out.
</member>
</members>
diff --git a/doc/classes/Camera3D.xml b/doc/classes/Camera3D.xml
index 016eb05308..afba478a20 100644
--- a/doc/classes/Camera3D.xml
+++ b/doc/classes/Camera3D.xml
@@ -209,7 +209,7 @@
- ~107.51 degrees in a 16:9 viewport
- ~121.63 degrees in a 21:9 viewport
</member>
- <member name="frustum_offset" type="Vector2" setter="set_frustum_offset" getter="get_frustum_offset" default="Vector2( 0, 0 )">
+ <member name="frustum_offset" type="Vector2" setter="set_frustum_offset" getter="get_frustum_offset" default="Vector2(0, 0)">
The camera's frustum offset. This can be changed from the default to create "tilted frustum" effects such as [url=https://zdoom.org/wiki/Y-shearing]Y-shearing[/url].
</member>
<member name="h_offset" type="float" setter="set_h_offset" getter="get_h_offset" default="0.0">
diff --git a/doc/classes/CanvasItem.xml b/doc/classes/CanvasItem.xml
index f15bc14be3..d0950ae741 100644
--- a/doc/classes/CanvasItem.xml
+++ b/doc/classes/CanvasItem.xml
@@ -75,11 +75,11 @@
</argument>
<argument index="4" name="size" type="int" default="-1">
</argument>
- <argument index="5" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="5" name="modulate" type="Color" default="Color(1, 1, 1, 1)">
</argument>
<argument index="6" name="outline_size" type="int" default="0">
</argument>
- <argument index="7" name="outline_modulate" type="Color" default="Color( 1, 1, 1, 0 )">
+ <argument index="7" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)">
</argument>
<description>
Draws a string character using a custom font. Returns the advance, depending on the character width and kerning with an optional next character.
@@ -105,7 +105,7 @@
</argument>
<argument index="1" name="color" type="Color">
</argument>
- <argument index="2" name="uvs" type="PackedVector2Array" default="PackedVector2Array( )">
+ <argument index="2" name="uvs" type="PackedVector2Array" default="PackedVector2Array()">
</argument>
<argument index="3" name="texture" type="Texture2D" default="null">
</argument>
@@ -142,9 +142,9 @@
</argument>
<argument index="1" name="texture" type="Texture2D">
</argument>
- <argument index="2" name="transform" type="Transform2D" default="Transform2D( 1, 0, 0, 1, 0, 0 )">
+ <argument index="2" name="transform" type="Transform2D" default="Transform2D(1, 0, 0, 1, 0, 0)">
</argument>
- <argument index="3" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="3" name="modulate" type="Color" default="Color(1, 1, 1, 1)">
</argument>
<description>
Draws a [Mesh] in 2D, using the provided texture. See [MeshInstance2D] for related documentation.
@@ -193,11 +193,11 @@
</argument>
<argument index="6" name="size" type="int" default="-1">
</argument>
- <argument index="7" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="7" name="modulate" type="Color" default="Color(1, 1, 1, 1)">
</argument>
<argument index="8" name="outline_size" type="int" default="0">
</argument>
- <argument index="9" name="outline_modulate" type="Color" default="Color( 1, 1, 1, 0 )">
+ <argument index="9" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)">
</argument>
<argument index="10" name="flags" type="int" default="51">
</argument>
@@ -223,7 +223,7 @@
</argument>
<argument index="1" name="colors" type="PackedColorArray">
</argument>
- <argument index="2" name="uvs" type="PackedVector2Array" default="PackedVector2Array( )">
+ <argument index="2" name="uvs" type="PackedVector2Array" default="PackedVector2Array()">
</argument>
<argument index="3" name="texture" type="Texture2D" default="null">
</argument>
@@ -301,7 +301,7 @@
</argument>
<argument index="1" name="rotation" type="float" default="0.0">
</argument>
- <argument index="2" name="scale" type="Vector2" default="Vector2( 1, 1 )">
+ <argument index="2" name="scale" type="Vector2" default="Vector2(1, 1)">
</argument>
<description>
Sets a custom transform for drawing via components. Anything drawn afterwards will be transformed by this.
@@ -331,11 +331,11 @@
</argument>
<argument index="5" name="size" type="int" default="-1">
</argument>
- <argument index="6" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="6" name="modulate" type="Color" default="Color(1, 1, 1, 1)">
</argument>
<argument index="7" name="outline_size" type="int" default="0">
</argument>
- <argument index="8" name="outline_modulate" type="Color" default="Color( 1, 1, 1, 0 )">
+ <argument index="8" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)">
</argument>
<argument index="9" name="flags" type="int" default="3">
</argument>
@@ -381,7 +381,7 @@
</argument>
<argument index="1" name="position" type="Vector2">
</argument>
- <argument index="2" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="2" name="modulate" type="Color" default="Color(1, 1, 1, 1)">
</argument>
<description>
Draws a texture at a given position.
@@ -396,7 +396,7 @@
</argument>
<argument index="2" name="tile" type="bool">
</argument>
- <argument index="3" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="3" name="modulate" type="Color" default="Color(1, 1, 1, 1)">
</argument>
<argument index="4" name="transpose" type="bool" default="false">
</argument>
@@ -413,7 +413,7 @@
</argument>
<argument index="2" name="src_rect" type="Rect2">
</argument>
- <argument index="3" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="3" name="modulate" type="Color" default="Color(1, 1, 1, 1)">
</argument>
<argument index="4" name="transpose" type="bool" default="false">
</argument>
@@ -595,10 +595,10 @@
<member name="material" type="Material" setter="set_material" getter="get_material">
The material applied to textures on this [CanvasItem].
</member>
- <member name="modulate" type="Color" setter="set_modulate" getter="get_modulate" default="Color( 1, 1, 1, 1 )">
+ <member name="modulate" type="Color" setter="set_modulate" getter="get_modulate" default="Color(1, 1, 1, 1)">
The color applied to textures on this [CanvasItem].
</member>
- <member name="self_modulate" type="Color" setter="set_self_modulate" getter="get_self_modulate" default="Color( 1, 1, 1, 1 )">
+ <member name="self_modulate" type="Color" setter="set_self_modulate" getter="get_self_modulate" default="Color(1, 1, 1, 1)">
The color applied to textures on this [CanvasItem]. This is not inherited by children [CanvasItem]s.
</member>
<member name="show_behind_parent" type="bool" setter="set_draw_behind_parent" getter="is_draw_behind_parent_enabled" default="false">
diff --git a/doc/classes/CanvasLayer.xml b/doc/classes/CanvasLayer.xml
index 9d952cdba3..f4c04d7bca 100644
--- a/doc/classes/CanvasLayer.xml
+++ b/doc/classes/CanvasLayer.xml
@@ -33,7 +33,7 @@
<member name="layer" type="int" setter="set_layer" getter="get_layer" default="1">
Layer index for draw order. Lower values are drawn first.
</member>
- <member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2( 0, 0 )">
+ <member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2(0, 0)">
The layer's base offset.
</member>
<member name="rotation" type="float" setter="set_rotation" getter="get_rotation" default="0.0">
@@ -42,10 +42,10 @@
<member name="rotation_degrees" type="float" setter="set_rotation_degrees" getter="get_rotation_degrees" default="0.0">
The layer's rotation in degrees.
</member>
- <member name="scale" type="Vector2" setter="set_scale" getter="get_scale" default="Vector2( 1, 1 )">
+ <member name="scale" type="Vector2" setter="set_scale" getter="get_scale" default="Vector2(1, 1)">
The layer's scale.
</member>
- <member name="transform" type="Transform2D" setter="set_transform" getter="get_transform" default="Transform2D( 1, 0, 0, 1, 0, 0 )">
+ <member name="transform" type="Transform2D" setter="set_transform" getter="get_transform" default="Transform2D(1, 0, 0, 1, 0, 0)">
The layer's transform.
</member>
</members>
diff --git a/doc/classes/CanvasModulate.xml b/doc/classes/CanvasModulate.xml
index 19f8912cd8..3540fa423f 100644
--- a/doc/classes/CanvasModulate.xml
+++ b/doc/classes/CanvasModulate.xml
@@ -11,7 +11,7 @@
<methods>
</methods>
<members>
- <member name="color" type="Color" setter="set_color" getter="get_color" default="Color( 1, 1, 1, 1 )">
+ <member name="color" type="Color" setter="set_color" getter="get_color" default="Color(1, 1, 1, 1)">
The tint color to apply.
</member>
</members>
diff --git a/doc/classes/CanvasTexture.xml b/doc/classes/CanvasTexture.xml
index 0ca132746b..f7147d9f0b 100644
--- a/doc/classes/CanvasTexture.xml
+++ b/doc/classes/CanvasTexture.xml
@@ -13,7 +13,7 @@
</member>
<member name="normal_texture" type="Texture2D" setter="set_normal_texture" getter="get_normal_texture">
</member>
- <member name="specular_color" type="Color" setter="set_specular_color" getter="get_specular_color" default="Color( 1, 1, 1, 1 )">
+ <member name="specular_color" type="Color" setter="set_specular_color" getter="get_specular_color" default="Color(1, 1, 1, 1)">
</member>
<member name="specular_shininess" type="float" setter="set_specular_shininess" getter="get_specular_shininess" default="1.0">
</member>
diff --git a/doc/classes/CharFXTransform.xml b/doc/classes/CharFXTransform.xml
index 7a6a18f532..1f63b530b1 100644
--- a/doc/classes/CharFXTransform.xml
+++ b/doc/classes/CharFXTransform.xml
@@ -13,7 +13,7 @@
<methods>
</methods>
<members>
- <member name="color" type="Color" setter="set_color" getter="get_color" default="Color( 0, 0, 0, 1 )">
+ <member name="color" type="Color" setter="set_color" getter="get_color" default="Color(0, 0, 0, 1)">
The color the character will be drawn with.
</member>
<member name="elapsed_time" type="float" setter="set_elapsed_time" getter="get_elapsed_time" default="0.0">
@@ -33,13 +33,13 @@
<member name="glyph_index" type="int" setter="set_glyph_index" getter="get_glyph_index" default="0">
Font specific glyph index.
</member>
- <member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2( 0, 0 )">
+ <member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2(0, 0)">
The position offset the character will be drawn with (in pixels).
</member>
<member name="outline" type="bool" setter="set_outline" getter="is_outline" default="false">
If [code]true[/code], FX transform is called for outline drawing. Setting this property won't affect drawing.
</member>
- <member name="range" type="Vector2i" setter="set_range" getter="get_range" default="Vector2i( 0, 0 )">
+ <member name="range" type="Vector2i" setter="set_range" getter="get_range" default="Vector2i(0, 0)">
Absolute character range in the string, corresponding to the glyph. Setting this property won't affect drawing.
</member>
<member name="visible" type="bool" setter="set_visibility" getter="is_visible" default="true">
diff --git a/doc/classes/CharacterBody2D.xml b/doc/classes/CharacterBody2D.xml
index 0e6ca073a7..fbe5c34d7d 100644
--- a/doc/classes/CharacterBody2D.xml
+++ b/doc/classes/CharacterBody2D.xml
@@ -107,7 +107,7 @@
<member name="infinite_inertia" type="bool" setter="set_infinite_inertia_enabled" getter="is_infinite_inertia_enabled" default="true">
If [code]true[/code], the body will be able to push [RigidBody2D] nodes when calling [method move_and_slide], but it also won't detect any collisions with them. If [code]false[/code], it will interact with [RigidBody2D] nodes like with [StaticBody2D].
</member>
- <member name="linear_velocity" type="Vector2" setter="set_linear_velocity" getter="get_linear_velocity" default="Vector2( 0, 0 )">
+ <member name="linear_velocity" type="Vector2" setter="set_linear_velocity" getter="get_linear_velocity" default="Vector2(0, 0)">
Current velocity vector in pixels per second, used and modified during calls to [method move_and_slide].
</member>
<member name="max_slides" type="int" setter="set_max_slides" getter="get_max_slides" default="4">
@@ -116,14 +116,14 @@
<member name="motion/sync_to_physics" type="bool" setter="set_sync_to_physics" getter="is_sync_to_physics_enabled" default="false">
If [code]true[/code], the body's movement will be synchronized to the physics frame. This is useful when animating movement via [AnimationPlayer], for example on moving platforms. Do [b]not[/b] use together with [method move_and_slide] or [method PhysicsBody2D.move_and_collide] functions.
</member>
- <member name="snap" type="Vector2" setter="set_snap" getter="get_snap" default="Vector2( 0, 0 )">
+ <member name="snap" type="Vector2" setter="set_snap" getter="get_snap" default="Vector2(0, 0)">
When set to a value different from [code]Vector2(0, 0)[/code], the body is kept attached to slopes when calling [method move_and_slide].
As long as the [code]snap[/code] vector is in contact with the ground, the body will remain attached to the surface. This means you must disable snap in order to jump, for example. You can do this by setting [code]snap[/code] to [code]Vector2(0, 0)[/code].
</member>
<member name="stop_on_slope" type="bool" setter="set_stop_on_slope_enabled" getter="is_stop_on_slope_enabled" default="false">
If [code]true[/code], the body will not slide on slopes when you include gravity in [code]linear_velocity[/code] when calling [method move_and_slide] and the body is standing still.
</member>
- <member name="up_direction" type="Vector2" setter="set_up_direction" getter="get_up_direction" default="Vector2( 0, -1 )">
+ <member name="up_direction" type="Vector2" setter="set_up_direction" getter="get_up_direction" default="Vector2(0, -1)">
Direction vector used to determine what is a wall and what is a floor (or a ceiling), rather than a wall, when calling [method move_and_slide]. Defaults to [code]Vector2.UP[/code]. If set to [code]Vector2(0, 0)[/code], everything is considered a wall. This is useful for topdown games.
</member>
</members>
diff --git a/doc/classes/CharacterBody3D.xml b/doc/classes/CharacterBody3D.xml
index 790edfcad1..f6c3d68b3c 100644
--- a/doc/classes/CharacterBody3D.xml
+++ b/doc/classes/CharacterBody3D.xml
@@ -93,20 +93,20 @@
<member name="infinite_inertia" type="bool" setter="set_infinite_inertia_enabled" getter="is_infinite_inertia_enabled" default="true">
If [code]true[/code], the body will be able to push [RigidBody3D] nodes when calling [method move_and_slide], but it also won't detect any collisions with them. If [code]false[/code], it will interact with [RigidBody3D] nodes like with [StaticBody3D].
</member>
- <member name="linear_velocity" type="Vector3" setter="set_linear_velocity" getter="get_linear_velocity" default="Vector3( 0, 0, 0 )">
+ <member name="linear_velocity" type="Vector3" setter="set_linear_velocity" getter="get_linear_velocity" default="Vector3(0, 0, 0)">
Current velocity vector (typically meters per second), used and modified during calls to [method move_and_slide].
</member>
<member name="max_slides" type="int" setter="set_max_slides" getter="get_max_slides" default="4">
Maximum number of times the body can change direction before it stops when calling [method move_and_slide].
</member>
- <member name="snap" type="Vector3" setter="set_snap" getter="get_snap" default="Vector3( 0, 0, 0 )">
+ <member name="snap" type="Vector3" setter="set_snap" getter="get_snap" default="Vector3(0, 0, 0)">
When set to a value different from [code]Vector3(0, 0, 0)[/code], the body is kept attached to slopes when calling [method move_and_slide].
As long as the [code]snap[/code] vector is in contact with the ground, the body will remain attached to the surface. This means you must disable snap in order to jump, for example. You can do this by setting [code]snap[/code] to [code]Vector3(0, 0, 0)[/code].
</member>
<member name="stop_on_slope" type="bool" setter="set_stop_on_slope_enabled" getter="is_stop_on_slope_enabled" default="false">
If [code]true[/code], the body will not slide on slopes when you include gravity in [code]linear_velocity[/code] when calling [method move_and_slide] and the body is standing still.
</member>
- <member name="up_direction" type="Vector3" setter="set_up_direction" getter="get_up_direction" default="Vector3( 0, 1, 0 )">
+ <member name="up_direction" type="Vector3" setter="set_up_direction" getter="get_up_direction" default="Vector3(0, 1, 0)">
Direction vector used to determine what is a wall and what is a floor (or a ceiling), rather than a wall, when calling [method move_and_slide]. Defaults to [code]Vector3.UP[/code]. If set to [code]Vector3(0, 0, 0)[/code], everything is considered a wall. This is useful for topdown games.
</member>
</members>
diff --git a/doc/classes/CheckBox.xml b/doc/classes/CheckBox.xml
index 05e412e9da..90f3725172 100644
--- a/doc/classes/CheckBox.xml
+++ b/doc/classes/CheckBox.xml
@@ -35,22 +35,22 @@
<theme_item name="font" type="Font">
The [Font] to use for the [CheckBox] text.
</theme_item>
- <theme_item name="font_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )">
+ <theme_item name="font_color" type="Color" default="Color(0.88, 0.88, 0.88, 1)">
The [CheckBox] text's font color.
</theme_item>
- <theme_item name="font_disabled_color" type="Color" default="Color( 0.9, 0.9, 0.9, 0.2 )">
+ <theme_item name="font_disabled_color" type="Color" default="Color(0.9, 0.9, 0.9, 0.2)">
The [CheckBox] text's font color when it's disabled.
</theme_item>
- <theme_item name="font_hover_color" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )">
+ <theme_item name="font_hover_color" type="Color" default="Color(0.94, 0.94, 0.94, 1)">
The [CheckBox] text's font color when it's hovered.
</theme_item>
- <theme_item name="font_hover_pressed_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="font_hover_pressed_color" type="Color" default="Color(1, 1, 1, 1)">
The [CheckBox] text's font color when it's hovered and pressed.
</theme_item>
- <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)">
The tint of text outline of the [CheckBox].
</theme_item>
- <theme_item name="font_pressed_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="font_pressed_color" type="Color" default="Color(1, 1, 1, 1)">
The [CheckBox] text's font color when it's pressed.
</theme_item>
<theme_item name="font_size" type="int">
diff --git a/doc/classes/CheckButton.xml b/doc/classes/CheckButton.xml
index 46e590a115..7fa7093b32 100644
--- a/doc/classes/CheckButton.xml
+++ b/doc/classes/CheckButton.xml
@@ -30,22 +30,22 @@
<theme_item name="font" type="Font">
The [Font] to use for the [CheckButton] text.
</theme_item>
- <theme_item name="font_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )">
+ <theme_item name="font_color" type="Color" default="Color(0.88, 0.88, 0.88, 1)">
The [CheckButton] text's font color.
</theme_item>
- <theme_item name="font_disabled_color" type="Color" default="Color( 0.9, 0.9, 0.9, 0.2 )">
+ <theme_item name="font_disabled_color" type="Color" default="Color(0.9, 0.9, 0.9, 0.2)">
The [CheckButton] text's font color when it's disabled.
</theme_item>
- <theme_item name="font_hover_color" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )">
+ <theme_item name="font_hover_color" type="Color" default="Color(0.94, 0.94, 0.94, 1)">
The [CheckButton] text's font color when it's hovered.
</theme_item>
- <theme_item name="font_hover_pressed_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="font_hover_pressed_color" type="Color" default="Color(1, 1, 1, 1)">
The [CheckButton] text's font color when it's hovered and pressed.
</theme_item>
- <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)">
The tint of text outline of the [CheckButton].
</theme_item>
- <theme_item name="font_pressed_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="font_pressed_color" type="Color" default="Color(1, 1, 1, 1)">
The [CheckButton] text's font color when it's pressed.
</theme_item>
<theme_item name="font_size" type="int">
diff --git a/doc/classes/ClassDB.xml b/doc/classes/ClassDB.xml
index 860bdc7c8f..028781d313 100644
--- a/doc/classes/ClassDB.xml
+++ b/doc/classes/ClassDB.xml
@@ -9,7 +9,7 @@
<tutorials>
</tutorials>
<methods>
- <method name="can_instance" qualifiers="const">
+ <method name="can_instantiate" qualifiers="const">
<return type="bool">
</return>
<argument index="0" name="class" type="StringName">
@@ -187,7 +187,7 @@
Returns the parent class of [code]class[/code].
</description>
</method>
- <method name="instance" qualifiers="const">
+ <method name="instantiate" qualifiers="const">
<return type="Variant">
</return>
<argument index="0" name="class" type="StringName">
diff --git a/doc/classes/CodeEdit.xml b/doc/classes/CodeEdit.xml
index 1250350971..30fd47cdb6 100644
--- a/doc/classes/CodeEdit.xml
+++ b/doc/classes/CodeEdit.xml
@@ -45,7 +45,7 @@
</argument>
<argument index="2" name="insert_text" type="String">
</argument>
- <argument index="3" name="text_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="3" name="text_color" type="Color" default="Color(1, 1, 1, 1)">
</argument>
<argument index="4" name="icon" type="Resource" default="null">
</argument>
@@ -143,6 +143,20 @@
Inserts the selected entry into the text. If [code]replace[/code] is true, any existing text is replaced rather then merged.
</description>
</method>
+ <method name="do_indent">
+ <return type="void">
+ </return>
+ <description>
+ Perform an indent as if the user activated the "ui_text_indent" action.
+ </description>
+ </method>
+ <method name="do_unindent">
+ <return type="void">
+ </return>
+ <description>
+ Perform an unindent as if the user activated the "ui_text_unindent" action.
+ </description>
+ </method>
<method name="fold_all_lines">
<return type="void">
</return>
@@ -278,6 +292,13 @@
Returns [code]true[/code] if string [code]start_key[/code] exists.
</description>
</method>
+ <method name="indent_lines">
+ <return type="void">
+ </return>
+ <description>
+ Indents selected lines, or in the case of no selection the caret line by one.
+ </description>
+ </method>
<method name="is_in_comment" qualifiers="const">
<return type="int">
</return>
@@ -441,6 +462,13 @@
Unfolds all lines that were previously folded.
</description>
</method>
+ <method name="unindent_lines">
+ <return type="void">
+ </return>
+ <description>
+ Unindents selected lines, or in the case of no selection the caret line by one.
+ </description>
+ </method>
<method name="update_code_completion_options">
<return type="void">
</return>
@@ -456,13 +484,13 @@
<member name="code_completion_enabled" type="bool" setter="set_code_completion_enabled" getter="is_code_completion_enabled" default="false">
Sets whether code completion is allowed.
</member>
- <member name="code_completion_prefixes" type="String[]" setter="set_code_completion_prefixes" getter="get_code_comletion_prefixes" default="[ ]">
+ <member name="code_completion_prefixes" type="String[]" setter="set_code_completion_prefixes" getter="get_code_comletion_prefixes" default="[]">
Sets prefixes that will trigger code completion.
</member>
- <member name="delimiter_comments" type="String[]" setter="set_comment_delimiters" getter="get_comment_delimiters" default="[ ]">
+ <member name="delimiter_comments" type="String[]" setter="set_comment_delimiters" getter="get_comment_delimiters" default="[]">
Sets the comment delimiters. All existing comment delimiters will be removed.
</member>
- <member name="delimiter_strings" type="String[]" setter="set_string_delimiters" getter="get_string_delimiters" default="[ ]">
+ <member name="delimiter_strings" type="String[]" setter="set_string_delimiters" getter="get_string_delimiters" default="[]">
Sets the string delimiters. All existing string delimiters will be removed.
</member>
<member name="draw_bookmarks" type="bool" setter="set_draw_bookmarks_gutter" getter="is_drawing_bookmarks_gutter" default="false">
@@ -475,11 +503,23 @@
</member>
<member name="draw_line_numbers" type="bool" setter="set_draw_line_numbers" getter="is_draw_line_numbers_enabled" default="false">
</member>
+ <member name="indent_automatic" type="bool" setter="set_auto_indent_enabled" getter="is_auto_indent_enabled" default="false">
+ Sets whether automatic indent are enabled, this will add an extra indent if a prefix or brace is found.
+ </member>
+ <member name="indent_automatic_prefixes" type="String[]" setter="set_auto_indent_prefixes" getter="get_auto_indent_prefixes" default="[&quot;(&quot;, &quot;:&quot;, &quot;[&quot;, &quot;{&quot;]">
+ Prefixes to trigger an automatic indent.
+ </member>
+ <member name="indent_size" type="int" setter="set_indent_size" getter="get_indent_size" default="4">
+ Size of tabs, if [code]indent_use_spaces[/code] is enabled the amount of spaces to use.
+ </member>
+ <member name="indent_use_spaces" type="bool" setter="set_indent_using_spaces" getter="is_indent_using_spaces" default="false">
+ Use spaces instead of tabs for indentation.
+ </member>
<member name="layout_direction" type="int" setter="set_layout_direction" getter="get_layout_direction" override="true" enum="Control.LayoutDirection" default="2" />
<member name="line_folding" type="bool" setter="set_line_folding_enabled" getter="is_line_folding_enabled" default="true">
Sets whether line folding is allowed.
</member>
- <member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" override="true" default="[ ]" />
+ <member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" override="true" default="[]" />
<member name="text_direction" type="int" setter="set_text_direction" getter="get_text_direction" override="true" enum="Control.TextDirection" default="1" />
<member name="zero_pad_line_numbers" type="bool" setter="set_line_numbers_zero_padded" getter="is_line_numbers_zero_padded" default="false">
</member>
@@ -520,49 +560,49 @@
</constant>
</constants>
<theme_items>
- <theme_item name="background_color" type="Color" default="Color( 0, 0, 0, 0 )">
+ <theme_item name="background_color" type="Color" default="Color(0, 0, 0, 0)">
</theme_item>
<theme_item name="bookmark" type="Texture2D">
</theme_item>
- <theme_item name="bookmark_color" type="Color" default="Color( 0.5, 0.64, 1, 0.8 )">
+ <theme_item name="bookmark_color" type="Color" default="Color(0.5, 0.64, 1, 0.8)">
</theme_item>
- <theme_item name="brace_mismatch_color" type="Color" default="Color( 1, 0.2, 0.2, 1 )">
+ <theme_item name="brace_mismatch_color" type="Color" default="Color(1, 0.2, 0.2, 1)">
</theme_item>
<theme_item name="breakpoint" type="Texture2D">
</theme_item>
- <theme_item name="breakpoint_color" type="Color" default="Color( 0.9, 0.29, 0.3, 1 )">
+ <theme_item name="breakpoint_color" type="Color" default="Color(0.9, 0.29, 0.3, 1)">
</theme_item>
<theme_item name="can_fold" type="Texture2D">
</theme_item>
- <theme_item name="caret_background_color" type="Color" default="Color( 0, 0, 0, 1 )">
+ <theme_item name="caret_background_color" type="Color" default="Color(0, 0, 0, 1)">
</theme_item>
- <theme_item name="caret_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )">
+ <theme_item name="caret_color" type="Color" default="Color(0.88, 0.88, 0.88, 1)">
</theme_item>
- <theme_item name="code_folding_color" type="Color" default="Color( 0.8, 0.8, 0.8, 0.8 )">
+ <theme_item name="code_folding_color" type="Color" default="Color(0.8, 0.8, 0.8, 0.8)">
</theme_item>
<theme_item name="completion" type="StyleBox">
</theme_item>
- <theme_item name="completion_background_color" type="Color" default="Color( 0.17, 0.16, 0.2, 1 )">
+ <theme_item name="completion_background_color" type="Color" default="Color(0.17, 0.16, 0.2, 1)">
</theme_item>
- <theme_item name="completion_existing_color" type="Color" default="Color( 0.87, 0.87, 0.87, 0.13 )">
+ <theme_item name="completion_existing_color" type="Color" default="Color(0.87, 0.87, 0.87, 0.13)">
</theme_item>
- <theme_item name="completion_font_color" type="Color" default="Color( 0.67, 0.67, 0.67, 1 )">
+ <theme_item name="completion_font_color" type="Color" default="Color(0.67, 0.67, 0.67, 1)">
</theme_item>
<theme_item name="completion_lines" type="int" default="7">
</theme_item>
<theme_item name="completion_max_width" type="int" default="50">
</theme_item>
- <theme_item name="completion_scroll_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="completion_scroll_color" type="Color" default="Color(1, 1, 1, 1)">
</theme_item>
<theme_item name="completion_scroll_width" type="int" default="3">
</theme_item>
- <theme_item name="completion_selected_color" type="Color" default="Color( 0.26, 0.26, 0.27, 1 )">
+ <theme_item name="completion_selected_color" type="Color" default="Color(0.26, 0.26, 0.27, 1)">
</theme_item>
- <theme_item name="current_line_color" type="Color" default="Color( 0.25, 0.25, 0.26, 0.8 )">
+ <theme_item name="current_line_color" type="Color" default="Color(0.25, 0.25, 0.26, 0.8)">
</theme_item>
<theme_item name="executing_line" type="Texture2D">
</theme_item>
- <theme_item name="executing_line_color" type="Color" default="Color( 0.98, 0.89, 0.27, 1 )">
+ <theme_item name="executing_line_color" type="Color" default="Color(0.98, 0.89, 0.27, 1)">
</theme_item>
<theme_item name="focus" type="StyleBox">
</theme_item>
@@ -572,19 +612,19 @@
</theme_item>
<theme_item name="font" type="Font">
</theme_item>
- <theme_item name="font_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )">
+ <theme_item name="font_color" type="Color" default="Color(0.88, 0.88, 0.88, 1)">
</theme_item>
- <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)">
The tint of text outline of the [CodeEdit].
</theme_item>
- <theme_item name="font_readonly_color" type="Color" default="Color( 0.88, 0.88, 0.88, 0.5 )">
+ <theme_item name="font_readonly_color" type="Color" default="Color(0.88, 0.88, 0.88, 0.5)">
</theme_item>
- <theme_item name="font_selected_color" type="Color" default="Color( 0, 0, 0, 1 )">
+ <theme_item name="font_selected_color" type="Color" default="Color(0, 0, 0, 1)">
</theme_item>
<theme_item name="font_size" type="int">
Font size of the [CodeEdit]'s text.
</theme_item>
- <theme_item name="line_number_color" type="Color" default="Color( 0.67, 0.67, 0.67, 0.4 )">
+ <theme_item name="line_number_color" type="Color" default="Color(0.67, 0.67, 0.67, 0.4)">
</theme_item>
<theme_item name="line_spacing" type="int" default="4">
</theme_item>
@@ -595,15 +635,15 @@
</theme_item>
<theme_item name="read_only" type="StyleBox">
</theme_item>
- <theme_item name="safe_line_number_color" type="Color" default="Color( 0.67, 0.78, 0.67, 0.6 )">
+ <theme_item name="safe_line_number_color" type="Color" default="Color(0.67, 0.78, 0.67, 0.6)">
</theme_item>
- <theme_item name="selection_color" type="Color" default="Color( 0.49, 0.49, 0.49, 1 )">
+ <theme_item name="selection_color" type="Color" default="Color(0.49, 0.49, 0.49, 1)">
</theme_item>
<theme_item name="space" type="Texture2D">
</theme_item>
<theme_item name="tab" type="Texture2D">
</theme_item>
- <theme_item name="word_highlighted_color" type="Color" default="Color( 0.8, 0.9, 0.9, 0.15 )">
+ <theme_item name="word_highlighted_color" type="Color" default="Color(0.8, 0.9, 0.9, 0.15)">
</theme_item>
</theme_items>
</class>
diff --git a/doc/classes/CodeHighlighter.xml b/doc/classes/CodeHighlighter.xml
index f078e4e5b0..0406c25ffd 100644
--- a/doc/classes/CodeHighlighter.xml
+++ b/doc/classes/CodeHighlighter.xml
@@ -149,7 +149,7 @@
<member name="color_regions" type="Dictionary" setter="set_color_regions" getter="get_color_regions" default="{}">
Sets the color regions. All existing regions will be removed. The [Dictionary] key is the region start and end key, separated by a space. The value is the region color.
</member>
- <member name="function_color" type="Color" setter="set_function_color" getter="get_function_color" default="Color( 0, 0, 0, 1 )">
+ <member name="function_color" type="Color" setter="set_function_color" getter="get_function_color" default="Color(0, 0, 0, 1)">
Sets color for functions. A function is a non-keyword string followed by a '('.
</member>
<member name="keyword_colors" type="Dictionary" setter="set_keyword_colors" getter="get_keyword_colors" default="{}">
@@ -158,13 +158,13 @@
<member name="member_keyword_colors" type="Dictionary" setter="set_member_keyword_colors" getter="get_member_keyword_colors" default="{}">
Sets the member keyword colors. All existing member keyword will be removed. The [Dictionary] key is the member keyword. The value is the member keyword color.
</member>
- <member name="member_variable_color" type="Color" setter="set_member_variable_color" getter="get_member_variable_color" default="Color( 0, 0, 0, 1 )">
+ <member name="member_variable_color" type="Color" setter="set_member_variable_color" getter="get_member_variable_color" default="Color(0, 0, 0, 1)">
Sets color for member variables. A member variable is non-keyword, non-function string proceeded with a '.'.
</member>
- <member name="number_color" type="Color" setter="set_number_color" getter="get_number_color" default="Color( 0, 0, 0, 1 )">
+ <member name="number_color" type="Color" setter="set_number_color" getter="get_number_color" default="Color(0, 0, 0, 1)">
Sets the color for numbers.
</member>
- <member name="symbol_color" type="Color" setter="set_symbol_color" getter="get_symbol_color" default="Color( 0, 0, 0, 1 )">
+ <member name="symbol_color" type="Color" setter="set_symbol_color" getter="get_symbol_color" default="Color(0, 0, 0, 1)">
Sets the color for symbols.
</member>
</members>
diff --git a/doc/classes/CollisionPolygon2D.xml b/doc/classes/CollisionPolygon2D.xml
index 242cdb8c80..4607ab3fbd 100644
--- a/doc/classes/CollisionPolygon2D.xml
+++ b/doc/classes/CollisionPolygon2D.xml
@@ -23,7 +23,7 @@
<member name="one_way_collision_margin" type="float" setter="set_one_way_collision_margin" getter="get_one_way_collision_margin" default="1.0">
The margin used for one-way collision (in pixels). Higher values will make the shape thicker, and work better for colliders that enter the polygon at a high velocity.
</member>
- <member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array( )">
+ <member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array()">
The polygon's list of vertices. The final point will be connected to the first. The returned value is a clone of the [PackedVector2Array], not a reference.
</member>
</members>
diff --git a/doc/classes/CollisionPolygon3D.xml b/doc/classes/CollisionPolygon3D.xml
index 38f4c5fe5c..cf0e55e712 100644
--- a/doc/classes/CollisionPolygon3D.xml
+++ b/doc/classes/CollisionPolygon3D.xml
@@ -20,7 +20,7 @@
<member name="margin" type="float" setter="set_margin" getter="get_margin" default="0.04">
The collision margin for the generated [Shape3D]. See [member Shape3D.margin] for more details.
</member>
- <member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array( )">
+ <member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array()">
Array of vertices which define the polygon.
[b]Note:[/b] The returned value is a copy of the original. Methods which mutate the size or properties of the return value will not impact the original polygon. To change properties of the polygon, assign it to a temporary variable and make changes before reassigning the [code]polygon[/code] member.
</member>
diff --git a/doc/classes/Color.xml b/doc/classes/Color.xml
index ddff92e6fc..7b1415e40d 100644
--- a/doc/classes/Color.xml
+++ b/doc/classes/Color.xml
@@ -80,14 +80,16 @@
</argument>
<argument index="2" name="b" type="float">
</argument>
+ <argument index="3" name="a" type="float">
+ </argument>
<description>
- Constructs a [Color] from RGB values, typically between 0 and 1. Alpha will be 1.
+ Constructs a [Color] from RGBA values, typically between 0 and 1.
[codeblocks]
[gdscript]
- var color = Color(0.2, 1.0, 0.7) # Similar to `Color8(51, 255, 178, 255)`
+ var color = Color(0.2, 1.0, 0.7, 0.8) # Similar to `Color8(51, 255, 178, 204)`
[/gdscript]
[csharp]
- var color = new Color(0.2f, 1.0f, 0.7f); // Similar to `Color.Color8(51, 255, 178, 255)`
+ var color = new Color(0.2f, 1.0f, 0.7f, 0.8f); // Similar to `Color.Color8(51, 255, 178, 255, 204)`
[/csharp]
[/codeblocks]
</description>
@@ -101,16 +103,14 @@
</argument>
<argument index="2" name="b" type="float">
</argument>
- <argument index="3" name="a" type="float">
- </argument>
<description>
- Constructs a [Color] from RGBA values, typically between 0 and 1.
+ Constructs a [Color] from RGB values, typically between 0 and 1. Alpha will be 1.
[codeblocks]
[gdscript]
- var color = Color(0.2, 1.0, 0.7, 0.8) # Similar to `Color8(51, 255, 178, 204)`
+ var color = Color(0.2, 1.0, 0.7) # Similar to `Color8(51, 255, 178, 255)`
[/gdscript]
[csharp]
- var color = new Color(0.2f, 1.0f, 0.7f, 0.8f); // Similar to `Color.Color8(51, 255, 178, 255, 204)`
+ var color = new Color(0.2f, 1.0f, 0.7f); // Similar to `Color.Color8(51, 255, 178, 255)`
[/csharp]
[/codeblocks]
</description>
@@ -139,9 +139,9 @@
<method name="clamp" qualifiers="const">
<return type="Color">
</return>
- <argument index="0" name="min" type="Color" default="Color( 0, 0, 0, 0 )">
+ <argument index="0" name="min" type="Color" default="Color(0, 0, 0, 0)">
</argument>
- <argument index="1" name="max" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="1" name="max" type="Color" default="Color(1, 1, 1, 1)">
</argument>
<description>
Returns a new color with all components clamped between the components of [code]min[/code] and [code]max[/code], by running [method @GlobalScope.clamp] on each component.
@@ -349,12 +349,6 @@
<method name="operator +" qualifiers="operator">
<return type="Color">
</return>
- <description>
- </description>
- </method>
- <method name="operator +" qualifiers="operator">
- <return type="Color">
- </return>
<argument index="0" name="right" type="Color">
</argument>
<description>
@@ -363,12 +357,6 @@
<method name="operator -" qualifiers="operator">
<return type="Color">
</return>
- <description>
- </description>
- </method>
- <method name="operator -" qualifiers="operator">
- <return type="Color">
- </return>
<argument index="0" name="right" type="Color">
</argument>
<description>
@@ -414,6 +402,18 @@
<description>
</description>
</method>
+ <method name="operator unary+" qualifiers="operator">
+ <return type="Color">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="operator unary-" qualifiers="operator">
+ <return type="Color">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="to_abgr32" qualifiers="const">
<return type="int">
</return>
@@ -575,442 +575,442 @@
</member>
</members>
<constants>
- <constant name="ALICE_BLUE" value="Color( 0.94, 0.97, 1, 1 )">
+ <constant name="ALICE_BLUE" value="Color(0.94, 0.97, 1, 1)">
Alice blue color.
</constant>
- <constant name="ANTIQUE_WHITE" value="Color( 0.98, 0.92, 0.84, 1 )">
+ <constant name="ANTIQUE_WHITE" value="Color(0.98, 0.92, 0.84, 1)">
Antique white color.
</constant>
- <constant name="AQUA" value="Color( 0, 1, 1, 1 )">
+ <constant name="AQUA" value="Color(0, 1, 1, 1)">
Aqua color.
</constant>
- <constant name="AQUAMARINE" value="Color( 0.5, 1, 0.83, 1 )">
+ <constant name="AQUAMARINE" value="Color(0.5, 1, 0.83, 1)">
Aquamarine color.
</constant>
- <constant name="AZURE" value="Color( 0.94, 1, 1, 1 )">
+ <constant name="AZURE" value="Color(0.94, 1, 1, 1)">
Azure color.
</constant>
- <constant name="BEIGE" value="Color( 0.96, 0.96, 0.86, 1 )">
+ <constant name="BEIGE" value="Color(0.96, 0.96, 0.86, 1)">
Beige color.
</constant>
- <constant name="BISQUE" value="Color( 1, 0.89, 0.77, 1 )">
+ <constant name="BISQUE" value="Color(1, 0.89, 0.77, 1)">
Bisque color.
</constant>
- <constant name="BLACK" value="Color( 0, 0, 0, 1 )">
+ <constant name="BLACK" value="Color(0, 0, 0, 1)">
Black color.
</constant>
- <constant name="BLANCHED_ALMOND" value="Color( 1, 0.92, 0.8, 1 )">
+ <constant name="BLANCHED_ALMOND" value="Color(1, 0.92, 0.8, 1)">
Blanched almond color.
</constant>
- <constant name="BLUE" value="Color( 0, 0, 1, 1 )">
+ <constant name="BLUE" value="Color(0, 0, 1, 1)">
Blue color.
</constant>
- <constant name="BLUE_VIOLET" value="Color( 0.54, 0.17, 0.89, 1 )">
+ <constant name="BLUE_VIOLET" value="Color(0.54, 0.17, 0.89, 1)">
Blue violet color.
</constant>
- <constant name="BROWN" value="Color( 0.65, 0.16, 0.16, 1 )">
+ <constant name="BROWN" value="Color(0.65, 0.16, 0.16, 1)">
Brown color.
</constant>
- <constant name="BURLYWOOD" value="Color( 0.87, 0.72, 0.53, 1 )">
+ <constant name="BURLYWOOD" value="Color(0.87, 0.72, 0.53, 1)">
Burlywood color.
</constant>
- <constant name="CADET_BLUE" value="Color( 0.37, 0.62, 0.63, 1 )">
+ <constant name="CADET_BLUE" value="Color(0.37, 0.62, 0.63, 1)">
Cadet blue color.
</constant>
- <constant name="CHARTREUSE" value="Color( 0.5, 1, 0, 1 )">
+ <constant name="CHARTREUSE" value="Color(0.5, 1, 0, 1)">
Chartreuse color.
</constant>
- <constant name="CHOCOLATE" value="Color( 0.82, 0.41, 0.12, 1 )">
+ <constant name="CHOCOLATE" value="Color(0.82, 0.41, 0.12, 1)">
Chocolate color.
</constant>
- <constant name="CORAL" value="Color( 1, 0.5, 0.31, 1 )">
+ <constant name="CORAL" value="Color(1, 0.5, 0.31, 1)">
Coral color.
</constant>
- <constant name="CORNFLOWER_BLUE" value="Color( 0.39, 0.58, 0.93, 1 )">
+ <constant name="CORNFLOWER_BLUE" value="Color(0.39, 0.58, 0.93, 1)">
Cornflower blue color.
</constant>
- <constant name="CORNSILK" value="Color( 1, 0.97, 0.86, 1 )">
+ <constant name="CORNSILK" value="Color(1, 0.97, 0.86, 1)">
Cornsilk color.
</constant>
- <constant name="CRIMSON" value="Color( 0.86, 0.08, 0.24, 1 )">
+ <constant name="CRIMSON" value="Color(0.86, 0.08, 0.24, 1)">
Crimson color.
</constant>
- <constant name="CYAN" value="Color( 0, 1, 1, 1 )">
+ <constant name="CYAN" value="Color(0, 1, 1, 1)">
Cyan color.
</constant>
- <constant name="DARK_BLUE" value="Color( 0, 0, 0.55, 1 )">
+ <constant name="DARK_BLUE" value="Color(0, 0, 0.55, 1)">
Dark blue color.
</constant>
- <constant name="DARK_CYAN" value="Color( 0, 0.55, 0.55, 1 )">
+ <constant name="DARK_CYAN" value="Color(0, 0.55, 0.55, 1)">
Dark cyan color.
</constant>
- <constant name="DARK_GOLDENROD" value="Color( 0.72, 0.53, 0.04, 1 )">
+ <constant name="DARK_GOLDENROD" value="Color(0.72, 0.53, 0.04, 1)">
Dark goldenrod color.
</constant>
- <constant name="DARK_GRAY" value="Color( 0.66, 0.66, 0.66, 1 )">
+ <constant name="DARK_GRAY" value="Color(0.66, 0.66, 0.66, 1)">
Dark gray color.
</constant>
- <constant name="DARK_GREEN" value="Color( 0, 0.39, 0, 1 )">
+ <constant name="DARK_GREEN" value="Color(0, 0.39, 0, 1)">
Dark green color.
</constant>
- <constant name="DARK_KHAKI" value="Color( 0.74, 0.72, 0.42, 1 )">
+ <constant name="DARK_KHAKI" value="Color(0.74, 0.72, 0.42, 1)">
Dark khaki color.
</constant>
- <constant name="DARK_MAGENTA" value="Color( 0.55, 0, 0.55, 1 )">
+ <constant name="DARK_MAGENTA" value="Color(0.55, 0, 0.55, 1)">
Dark magenta color.
</constant>
- <constant name="DARK_OLIVE_GREEN" value="Color( 0.33, 0.42, 0.18, 1 )">
+ <constant name="DARK_OLIVE_GREEN" value="Color(0.33, 0.42, 0.18, 1)">
Dark olive green color.
</constant>
- <constant name="DARK_ORANGE" value="Color( 1, 0.55, 0, 1 )">
+ <constant name="DARK_ORANGE" value="Color(1, 0.55, 0, 1)">
Dark orange color.
</constant>
- <constant name="DARK_ORCHID" value="Color( 0.6, 0.2, 0.8, 1 )">
+ <constant name="DARK_ORCHID" value="Color(0.6, 0.2, 0.8, 1)">
Dark orchid color.
</constant>
- <constant name="DARK_RED" value="Color( 0.55, 0, 0, 1 )">
+ <constant name="DARK_RED" value="Color(0.55, 0, 0, 1)">
Dark red color.
</constant>
- <constant name="DARK_SALMON" value="Color( 0.91, 0.59, 0.48, 1 )">
+ <constant name="DARK_SALMON" value="Color(0.91, 0.59, 0.48, 1)">
Dark salmon color.
</constant>
- <constant name="DARK_SEA_GREEN" value="Color( 0.56, 0.74, 0.56, 1 )">
+ <constant name="DARK_SEA_GREEN" value="Color(0.56, 0.74, 0.56, 1)">
Dark sea green color.
</constant>
- <constant name="DARK_SLATE_BLUE" value="Color( 0.28, 0.24, 0.55, 1 )">
+ <constant name="DARK_SLATE_BLUE" value="Color(0.28, 0.24, 0.55, 1)">
Dark slate blue color.
</constant>
- <constant name="DARK_SLATE_GRAY" value="Color( 0.18, 0.31, 0.31, 1 )">
+ <constant name="DARK_SLATE_GRAY" value="Color(0.18, 0.31, 0.31, 1)">
Dark slate gray color.
</constant>
- <constant name="DARK_TURQUOISE" value="Color( 0, 0.81, 0.82, 1 )">
+ <constant name="DARK_TURQUOISE" value="Color(0, 0.81, 0.82, 1)">
Dark turquoise color.
</constant>
- <constant name="DARK_VIOLET" value="Color( 0.58, 0, 0.83, 1 )">
+ <constant name="DARK_VIOLET" value="Color(0.58, 0, 0.83, 1)">
Dark violet color.
</constant>
- <constant name="DEEP_PINK" value="Color( 1, 0.08, 0.58, 1 )">
+ <constant name="DEEP_PINK" value="Color(1, 0.08, 0.58, 1)">
Deep pink color.
</constant>
- <constant name="DEEP_SKY_BLUE" value="Color( 0, 0.75, 1, 1 )">
+ <constant name="DEEP_SKY_BLUE" value="Color(0, 0.75, 1, 1)">
Deep sky blue color.
</constant>
- <constant name="DIM_GRAY" value="Color( 0.41, 0.41, 0.41, 1 )">
+ <constant name="DIM_GRAY" value="Color(0.41, 0.41, 0.41, 1)">
Dim gray color.
</constant>
- <constant name="DODGER_BLUE" value="Color( 0.12, 0.56, 1, 1 )">
+ <constant name="DODGER_BLUE" value="Color(0.12, 0.56, 1, 1)">
Dodger blue color.
</constant>
- <constant name="FIREBRICK" value="Color( 0.7, 0.13, 0.13, 1 )">
+ <constant name="FIREBRICK" value="Color(0.7, 0.13, 0.13, 1)">
Firebrick color.
</constant>
- <constant name="FLORAL_WHITE" value="Color( 1, 0.98, 0.94, 1 )">
+ <constant name="FLORAL_WHITE" value="Color(1, 0.98, 0.94, 1)">
Floral white color.
</constant>
- <constant name="FOREST_GREEN" value="Color( 0.13, 0.55, 0.13, 1 )">
+ <constant name="FOREST_GREEN" value="Color(0.13, 0.55, 0.13, 1)">
Forest green color.
</constant>
- <constant name="FUCHSIA" value="Color( 1, 0, 1, 1 )">
+ <constant name="FUCHSIA" value="Color(1, 0, 1, 1)">
Fuchsia color.
</constant>
- <constant name="GAINSBORO" value="Color( 0.86, 0.86, 0.86, 1 )">
+ <constant name="GAINSBORO" value="Color(0.86, 0.86, 0.86, 1)">
Gainsboro color.
</constant>
- <constant name="GHOST_WHITE" value="Color( 0.97, 0.97, 1, 1 )">
+ <constant name="GHOST_WHITE" value="Color(0.97, 0.97, 1, 1)">
Ghost white color.
</constant>
- <constant name="GOLD" value="Color( 1, 0.84, 0, 1 )">
+ <constant name="GOLD" value="Color(1, 0.84, 0, 1)">
Gold color.
</constant>
- <constant name="GOLDENROD" value="Color( 0.85, 0.65, 0.13, 1 )">
+ <constant name="GOLDENROD" value="Color(0.85, 0.65, 0.13, 1)">
Goldenrod color.
</constant>
- <constant name="GRAY" value="Color( 0.75, 0.75, 0.75, 1 )">
+ <constant name="GRAY" value="Color(0.75, 0.75, 0.75, 1)">
Gray color.
</constant>
- <constant name="GREEN" value="Color( 0, 1, 0, 1 )">
+ <constant name="GREEN" value="Color(0, 1, 0, 1)">
Green color.
</constant>
- <constant name="GREEN_YELLOW" value="Color( 0.68, 1, 0.18, 1 )">
+ <constant name="GREEN_YELLOW" value="Color(0.68, 1, 0.18, 1)">
Green yellow color.
</constant>
- <constant name="HONEYDEW" value="Color( 0.94, 1, 0.94, 1 )">
+ <constant name="HONEYDEW" value="Color(0.94, 1, 0.94, 1)">
Honeydew color.
</constant>
- <constant name="HOT_PINK" value="Color( 1, 0.41, 0.71, 1 )">
+ <constant name="HOT_PINK" value="Color(1, 0.41, 0.71, 1)">
Hot pink color.
</constant>
- <constant name="INDIAN_RED" value="Color( 0.8, 0.36, 0.36, 1 )">
+ <constant name="INDIAN_RED" value="Color(0.8, 0.36, 0.36, 1)">
Indian red color.
</constant>
- <constant name="INDIGO" value="Color( 0.29, 0, 0.51, 1 )">
+ <constant name="INDIGO" value="Color(0.29, 0, 0.51, 1)">
Indigo color.
</constant>
- <constant name="IVORY" value="Color( 1, 1, 0.94, 1 )">
+ <constant name="IVORY" value="Color(1, 1, 0.94, 1)">
Ivory color.
</constant>
- <constant name="KHAKI" value="Color( 0.94, 0.9, 0.55, 1 )">
+ <constant name="KHAKI" value="Color(0.94, 0.9, 0.55, 1)">
Khaki color.
</constant>
- <constant name="LAVENDER" value="Color( 0.9, 0.9, 0.98, 1 )">
+ <constant name="LAVENDER" value="Color(0.9, 0.9, 0.98, 1)">
Lavender color.
</constant>
- <constant name="LAVENDER_BLUSH" value="Color( 1, 0.94, 0.96, 1 )">
+ <constant name="LAVENDER_BLUSH" value="Color(1, 0.94, 0.96, 1)">
Lavender blush color.
</constant>
- <constant name="LAWN_GREEN" value="Color( 0.49, 0.99, 0, 1 )">
+ <constant name="LAWN_GREEN" value="Color(0.49, 0.99, 0, 1)">
Lawn green color.
</constant>
- <constant name="LEMON_CHIFFON" value="Color( 1, 0.98, 0.8, 1 )">
+ <constant name="LEMON_CHIFFON" value="Color(1, 0.98, 0.8, 1)">
Lemon chiffon color.
</constant>
- <constant name="LIGHT_BLUE" value="Color( 0.68, 0.85, 0.9, 1 )">
+ <constant name="LIGHT_BLUE" value="Color(0.68, 0.85, 0.9, 1)">
Light blue color.
</constant>
- <constant name="LIGHT_CORAL" value="Color( 0.94, 0.5, 0.5, 1 )">
+ <constant name="LIGHT_CORAL" value="Color(0.94, 0.5, 0.5, 1)">
Light coral color.
</constant>
- <constant name="LIGHT_CYAN" value="Color( 0.88, 1, 1, 1 )">
+ <constant name="LIGHT_CYAN" value="Color(0.88, 1, 1, 1)">
Light cyan color.
</constant>
- <constant name="LIGHT_GOLDENROD" value="Color( 0.98, 0.98, 0.82, 1 )">
+ <constant name="LIGHT_GOLDENROD" value="Color(0.98, 0.98, 0.82, 1)">
Light goldenrod color.
</constant>
- <constant name="LIGHT_GRAY" value="Color( 0.83, 0.83, 0.83, 1 )">
+ <constant name="LIGHT_GRAY" value="Color(0.83, 0.83, 0.83, 1)">
Light gray color.
</constant>
- <constant name="LIGHT_GREEN" value="Color( 0.56, 0.93, 0.56, 1 )">
+ <constant name="LIGHT_GREEN" value="Color(0.56, 0.93, 0.56, 1)">
Light green color.
</constant>
- <constant name="LIGHT_PINK" value="Color( 1, 0.71, 0.76, 1 )">
+ <constant name="LIGHT_PINK" value="Color(1, 0.71, 0.76, 1)">
Light pink color.
</constant>
- <constant name="LIGHT_SALMON" value="Color( 1, 0.63, 0.48, 1 )">
+ <constant name="LIGHT_SALMON" value="Color(1, 0.63, 0.48, 1)">
Light salmon color.
</constant>
- <constant name="LIGHT_SEA_GREEN" value="Color( 0.13, 0.7, 0.67, 1 )">
+ <constant name="LIGHT_SEA_GREEN" value="Color(0.13, 0.7, 0.67, 1)">
Light sea green color.
</constant>
- <constant name="LIGHT_SKY_BLUE" value="Color( 0.53, 0.81, 0.98, 1 )">
+ <constant name="LIGHT_SKY_BLUE" value="Color(0.53, 0.81, 0.98, 1)">
Light sky blue color.
</constant>
- <constant name="LIGHT_SLATE_GRAY" value="Color( 0.47, 0.53, 0.6, 1 )">
+ <constant name="LIGHT_SLATE_GRAY" value="Color(0.47, 0.53, 0.6, 1)">
Light slate gray color.
</constant>
- <constant name="LIGHT_STEEL_BLUE" value="Color( 0.69, 0.77, 0.87, 1 )">
+ <constant name="LIGHT_STEEL_BLUE" value="Color(0.69, 0.77, 0.87, 1)">
Light steel blue color.
</constant>
- <constant name="LIGHT_YELLOW" value="Color( 1, 1, 0.88, 1 )">
+ <constant name="LIGHT_YELLOW" value="Color(1, 1, 0.88, 1)">
Light yellow color.
</constant>
- <constant name="LIME" value="Color( 0, 1, 0, 1 )">
+ <constant name="LIME" value="Color(0, 1, 0, 1)">
Lime color.
</constant>
- <constant name="LIME_GREEN" value="Color( 0.2, 0.8, 0.2, 1 )">
+ <constant name="LIME_GREEN" value="Color(0.2, 0.8, 0.2, 1)">
Lime green color.
</constant>
- <constant name="LINEN" value="Color( 0.98, 0.94, 0.9, 1 )">
+ <constant name="LINEN" value="Color(0.98, 0.94, 0.9, 1)">
Linen color.
</constant>
- <constant name="MAGENTA" value="Color( 1, 0, 1, 1 )">
+ <constant name="MAGENTA" value="Color(1, 0, 1, 1)">
Magenta color.
</constant>
- <constant name="MAROON" value="Color( 0.69, 0.19, 0.38, 1 )">
+ <constant name="MAROON" value="Color(0.69, 0.19, 0.38, 1)">
Maroon color.
</constant>
- <constant name="MEDIUM_AQUAMARINE" value="Color( 0.4, 0.8, 0.67, 1 )">
+ <constant name="MEDIUM_AQUAMARINE" value="Color(0.4, 0.8, 0.67, 1)">
Medium aquamarine color.
</constant>
- <constant name="MEDIUM_BLUE" value="Color( 0, 0, 0.8, 1 )">
+ <constant name="MEDIUM_BLUE" value="Color(0, 0, 0.8, 1)">
Medium blue color.
</constant>
- <constant name="MEDIUM_ORCHID" value="Color( 0.73, 0.33, 0.83, 1 )">
+ <constant name="MEDIUM_ORCHID" value="Color(0.73, 0.33, 0.83, 1)">
Medium orchid color.
</constant>
- <constant name="MEDIUM_PURPLE" value="Color( 0.58, 0.44, 0.86, 1 )">
+ <constant name="MEDIUM_PURPLE" value="Color(0.58, 0.44, 0.86, 1)">
Medium purple color.
</constant>
- <constant name="MEDIUM_SEA_GREEN" value="Color( 0.24, 0.7, 0.44, 1 )">
+ <constant name="MEDIUM_SEA_GREEN" value="Color(0.24, 0.7, 0.44, 1)">
Medium sea green color.
</constant>
- <constant name="MEDIUM_SLATE_BLUE" value="Color( 0.48, 0.41, 0.93, 1 )">
+ <constant name="MEDIUM_SLATE_BLUE" value="Color(0.48, 0.41, 0.93, 1)">
Medium slate blue color.
</constant>
- <constant name="MEDIUM_SPRING_GREEN" value="Color( 0, 0.98, 0.6, 1 )">
+ <constant name="MEDIUM_SPRING_GREEN" value="Color(0, 0.98, 0.6, 1)">
Medium spring green color.
</constant>
- <constant name="MEDIUM_TURQUOISE" value="Color( 0.28, 0.82, 0.8, 1 )">
+ <constant name="MEDIUM_TURQUOISE" value="Color(0.28, 0.82, 0.8, 1)">
Medium turquoise color.
</constant>
- <constant name="MEDIUM_VIOLET_RED" value="Color( 0.78, 0.08, 0.52, 1 )">
+ <constant name="MEDIUM_VIOLET_RED" value="Color(0.78, 0.08, 0.52, 1)">
Medium violet red color.
</constant>
- <constant name="MIDNIGHT_BLUE" value="Color( 0.1, 0.1, 0.44, 1 )">
+ <constant name="MIDNIGHT_BLUE" value="Color(0.1, 0.1, 0.44, 1)">
Midnight blue color.
</constant>
- <constant name="MINT_CREAM" value="Color( 0.96, 1, 0.98, 1 )">
+ <constant name="MINT_CREAM" value="Color(0.96, 1, 0.98, 1)">
Mint cream color.
</constant>
- <constant name="MISTY_ROSE" value="Color( 1, 0.89, 0.88, 1 )">
+ <constant name="MISTY_ROSE" value="Color(1, 0.89, 0.88, 1)">
Misty rose color.
</constant>
- <constant name="MOCCASIN" value="Color( 1, 0.89, 0.71, 1 )">
+ <constant name="MOCCASIN" value="Color(1, 0.89, 0.71, 1)">
Moccasin color.
</constant>
- <constant name="NAVAJO_WHITE" value="Color( 1, 0.87, 0.68, 1 )">
+ <constant name="NAVAJO_WHITE" value="Color(1, 0.87, 0.68, 1)">
Navajo white color.
</constant>
- <constant name="NAVY_BLUE" value="Color( 0, 0, 0.5, 1 )">
+ <constant name="NAVY_BLUE" value="Color(0, 0, 0.5, 1)">
Navy blue color.
</constant>
- <constant name="OLD_LACE" value="Color( 0.99, 0.96, 0.9, 1 )">
+ <constant name="OLD_LACE" value="Color(0.99, 0.96, 0.9, 1)">
Old lace color.
</constant>
- <constant name="OLIVE" value="Color( 0.5, 0.5, 0, 1 )">
+ <constant name="OLIVE" value="Color(0.5, 0.5, 0, 1)">
Olive color.
</constant>
- <constant name="OLIVE_DRAB" value="Color( 0.42, 0.56, 0.14, 1 )">
+ <constant name="OLIVE_DRAB" value="Color(0.42, 0.56, 0.14, 1)">
Olive drab color.
</constant>
- <constant name="ORANGE" value="Color( 1, 0.65, 0, 1 )">
+ <constant name="ORANGE" value="Color(1, 0.65, 0, 1)">
Orange color.
</constant>
- <constant name="ORANGE_RED" value="Color( 1, 0.27, 0, 1 )">
+ <constant name="ORANGE_RED" value="Color(1, 0.27, 0, 1)">
Orange red color.
</constant>
- <constant name="ORCHID" value="Color( 0.85, 0.44, 0.84, 1 )">
+ <constant name="ORCHID" value="Color(0.85, 0.44, 0.84, 1)">
Orchid color.
</constant>
- <constant name="PALE_GOLDENROD" value="Color( 0.93, 0.91, 0.67, 1 )">
+ <constant name="PALE_GOLDENROD" value="Color(0.93, 0.91, 0.67, 1)">
Pale goldenrod color.
</constant>
- <constant name="PALE_GREEN" value="Color( 0.6, 0.98, 0.6, 1 )">
+ <constant name="PALE_GREEN" value="Color(0.6, 0.98, 0.6, 1)">
Pale green color.
</constant>
- <constant name="PALE_TURQUOISE" value="Color( 0.69, 0.93, 0.93, 1 )">
+ <constant name="PALE_TURQUOISE" value="Color(0.69, 0.93, 0.93, 1)">
Pale turquoise color.
</constant>
- <constant name="PALE_VIOLET_RED" value="Color( 0.86, 0.44, 0.58, 1 )">
+ <constant name="PALE_VIOLET_RED" value="Color(0.86, 0.44, 0.58, 1)">
Pale violet red color.
</constant>
- <constant name="PAPAYA_WHIP" value="Color( 1, 0.94, 0.84, 1 )">
+ <constant name="PAPAYA_WHIP" value="Color(1, 0.94, 0.84, 1)">
Papaya whip color.
</constant>
- <constant name="PEACH_PUFF" value="Color( 1, 0.85, 0.73, 1 )">
+ <constant name="PEACH_PUFF" value="Color(1, 0.85, 0.73, 1)">
Peach puff color.
</constant>
- <constant name="PERU" value="Color( 0.8, 0.52, 0.25, 1 )">
+ <constant name="PERU" value="Color(0.8, 0.52, 0.25, 1)">
Peru color.
</constant>
- <constant name="PINK" value="Color( 1, 0.75, 0.8, 1 )">
+ <constant name="PINK" value="Color(1, 0.75, 0.8, 1)">
Pink color.
</constant>
- <constant name="PLUM" value="Color( 0.87, 0.63, 0.87, 1 )">
+ <constant name="PLUM" value="Color(0.87, 0.63, 0.87, 1)">
Plum color.
</constant>
- <constant name="POWDER_BLUE" value="Color( 0.69, 0.88, 0.9, 1 )">
+ <constant name="POWDER_BLUE" value="Color(0.69, 0.88, 0.9, 1)">
Powder blue color.
</constant>
- <constant name="PURPLE" value="Color( 0.63, 0.13, 0.94, 1 )">
+ <constant name="PURPLE" value="Color(0.63, 0.13, 0.94, 1)">
Purple color.
</constant>
- <constant name="REBECCA_PURPLE" value="Color( 0.4, 0.2, 0.6, 1 )">
+ <constant name="REBECCA_PURPLE" value="Color(0.4, 0.2, 0.6, 1)">
Rebecca purple color.
</constant>
- <constant name="RED" value="Color( 1, 0, 0, 1 )">
+ <constant name="RED" value="Color(1, 0, 0, 1)">
Red color.
</constant>
- <constant name="ROSY_BROWN" value="Color( 0.74, 0.56, 0.56, 1 )">
+ <constant name="ROSY_BROWN" value="Color(0.74, 0.56, 0.56, 1)">
Rosy brown color.
</constant>
- <constant name="ROYAL_BLUE" value="Color( 0.25, 0.41, 0.88, 1 )">
+ <constant name="ROYAL_BLUE" value="Color(0.25, 0.41, 0.88, 1)">
Royal blue color.
</constant>
- <constant name="SADDLE_BROWN" value="Color( 0.55, 0.27, 0.07, 1 )">
+ <constant name="SADDLE_BROWN" value="Color(0.55, 0.27, 0.07, 1)">
Saddle brown color.
</constant>
- <constant name="SALMON" value="Color( 0.98, 0.5, 0.45, 1 )">
+ <constant name="SALMON" value="Color(0.98, 0.5, 0.45, 1)">
Salmon color.
</constant>
- <constant name="SANDY_BROWN" value="Color( 0.96, 0.64, 0.38, 1 )">
+ <constant name="SANDY_BROWN" value="Color(0.96, 0.64, 0.38, 1)">
Sandy brown color.
</constant>
- <constant name="SEA_GREEN" value="Color( 0.18, 0.55, 0.34, 1 )">
+ <constant name="SEA_GREEN" value="Color(0.18, 0.55, 0.34, 1)">
Sea green color.
</constant>
- <constant name="SEASHELL" value="Color( 1, 0.96, 0.93, 1 )">
+ <constant name="SEASHELL" value="Color(1, 0.96, 0.93, 1)">
Seashell color.
</constant>
- <constant name="SIENNA" value="Color( 0.63, 0.32, 0.18, 1 )">
+ <constant name="SIENNA" value="Color(0.63, 0.32, 0.18, 1)">
Sienna color.
</constant>
- <constant name="SILVER" value="Color( 0.75, 0.75, 0.75, 1 )">
+ <constant name="SILVER" value="Color(0.75, 0.75, 0.75, 1)">
Silver color.
</constant>
- <constant name="SKY_BLUE" value="Color( 0.53, 0.81, 0.92, 1 )">
+ <constant name="SKY_BLUE" value="Color(0.53, 0.81, 0.92, 1)">
Sky blue color.
</constant>
- <constant name="SLATE_BLUE" value="Color( 0.42, 0.35, 0.8, 1 )">
+ <constant name="SLATE_BLUE" value="Color(0.42, 0.35, 0.8, 1)">
Slate blue color.
</constant>
- <constant name="SLATE_GRAY" value="Color( 0.44, 0.5, 0.56, 1 )">
+ <constant name="SLATE_GRAY" value="Color(0.44, 0.5, 0.56, 1)">
Slate gray color.
</constant>
- <constant name="SNOW" value="Color( 1, 0.98, 0.98, 1 )">
+ <constant name="SNOW" value="Color(1, 0.98, 0.98, 1)">
Snow color.
</constant>
- <constant name="SPRING_GREEN" value="Color( 0, 1, 0.5, 1 )">
+ <constant name="SPRING_GREEN" value="Color(0, 1, 0.5, 1)">
Spring green color.
</constant>
- <constant name="STEEL_BLUE" value="Color( 0.27, 0.51, 0.71, 1 )">
+ <constant name="STEEL_BLUE" value="Color(0.27, 0.51, 0.71, 1)">
Steel blue color.
</constant>
- <constant name="TAN" value="Color( 0.82, 0.71, 0.55, 1 )">
+ <constant name="TAN" value="Color(0.82, 0.71, 0.55, 1)">
Tan color.
</constant>
- <constant name="TEAL" value="Color( 0, 0.5, 0.5, 1 )">
+ <constant name="TEAL" value="Color(0, 0.5, 0.5, 1)">
Teal color.
</constant>
- <constant name="THISTLE" value="Color( 0.85, 0.75, 0.85, 1 )">
+ <constant name="THISTLE" value="Color(0.85, 0.75, 0.85, 1)">
Thistle color.
</constant>
- <constant name="TOMATO" value="Color( 1, 0.39, 0.28, 1 )">
+ <constant name="TOMATO" value="Color(1, 0.39, 0.28, 1)">
Tomato color.
</constant>
- <constant name="TRANSPARENT" value="Color( 1, 1, 1, 0 )">
+ <constant name="TRANSPARENT" value="Color(1, 1, 1, 0)">
Transparent color (white with zero alpha).
</constant>
- <constant name="TURQUOISE" value="Color( 0.25, 0.88, 0.82, 1 )">
+ <constant name="TURQUOISE" value="Color(0.25, 0.88, 0.82, 1)">
Turquoise color.
</constant>
- <constant name="VIOLET" value="Color( 0.93, 0.51, 0.93, 1 )">
+ <constant name="VIOLET" value="Color(0.93, 0.51, 0.93, 1)">
Violet color.
</constant>
- <constant name="WEB_GRAY" value="Color( 0.5, 0.5, 0.5, 1 )">
+ <constant name="WEB_GRAY" value="Color(0.5, 0.5, 0.5, 1)">
Web gray color.
</constant>
- <constant name="WEB_GREEN" value="Color( 0, 0.5, 0, 1 )">
+ <constant name="WEB_GREEN" value="Color(0, 0.5, 0, 1)">
Web green color.
</constant>
- <constant name="WEB_MAROON" value="Color( 0.5, 0, 0, 1 )">
+ <constant name="WEB_MAROON" value="Color(0.5, 0, 0, 1)">
Web maroon color.
</constant>
- <constant name="WEB_PURPLE" value="Color( 0.5, 0, 0.5, 1 )">
+ <constant name="WEB_PURPLE" value="Color(0.5, 0, 0.5, 1)">
Web purple color.
</constant>
- <constant name="WHEAT" value="Color( 0.96, 0.87, 0.7, 1 )">
+ <constant name="WHEAT" value="Color(0.96, 0.87, 0.7, 1)">
Wheat color.
</constant>
- <constant name="WHITE" value="Color( 1, 1, 1, 1 )">
+ <constant name="WHITE" value="Color(1, 1, 1, 1)">
White color.
</constant>
- <constant name="WHITE_SMOKE" value="Color( 0.96, 0.96, 0.96, 1 )">
+ <constant name="WHITE_SMOKE" value="Color(0.96, 0.96, 0.96, 1)">
White smoke color.
</constant>
- <constant name="YELLOW" value="Color( 1, 1, 0, 1 )">
+ <constant name="YELLOW" value="Color(1, 1, 0, 1)">
Yellow color.
</constant>
- <constant name="YELLOW_GREEN" value="Color( 0.6, 0.8, 0.2, 1 )">
+ <constant name="YELLOW_GREEN" value="Color(0.6, 0.8, 0.2, 1)">
Yellow green color.
</constant>
</constants>
diff --git a/doc/classes/ColorPicker.xml b/doc/classes/ColorPicker.xml
index fddfd27573..2111358ef4 100644
--- a/doc/classes/ColorPicker.xml
+++ b/doc/classes/ColorPicker.xml
@@ -38,7 +38,7 @@
</method>
</methods>
<members>
- <member name="color" type="Color" setter="set_pick_color" getter="get_pick_color" default="Color( 1, 1, 1, 1 )">
+ <member name="color" type="Color" setter="set_pick_color" getter="get_pick_color" default="Color(1, 1, 1, 1)">
The currently selected color.
</member>
<member name="deferred_mode" type="bool" setter="set_deferred_mode" getter="is_deferred_mode" default="false">
diff --git a/doc/classes/ColorPickerButton.xml b/doc/classes/ColorPickerButton.xml
index e49027e61d..09b828366f 100644
--- a/doc/classes/ColorPickerButton.xml
+++ b/doc/classes/ColorPickerButton.xml
@@ -28,7 +28,7 @@
</method>
</methods>
<members>
- <member name="color" type="Color" setter="set_pick_color" getter="get_pick_color" default="Color( 0, 0, 0, 1 )">
+ <member name="color" type="Color" setter="set_pick_color" getter="get_pick_color" default="Color(0, 0, 0, 1)">
The currently selected color.
</member>
<member name="edit_alpha" type="bool" setter="set_edit_alpha" getter="is_editing_alpha" default="true">
@@ -70,19 +70,19 @@
<theme_item name="font" type="Font">
[Font] of the [ColorPickerButton]'s text.
</theme_item>
- <theme_item name="font_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="font_color" type="Color" default="Color(1, 1, 1, 1)">
Default text [Color] of the [ColorPickerButton].
</theme_item>
- <theme_item name="font_disabled_color" type="Color" default="Color( 0.9, 0.9, 0.9, 0.3 )">
+ <theme_item name="font_disabled_color" type="Color" default="Color(0.9, 0.9, 0.9, 0.3)">
Text [Color] used when the [ColorPickerButton] is disabled.
</theme_item>
- <theme_item name="font_hover_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="font_hover_color" type="Color" default="Color(1, 1, 1, 1)">
Text [Color] used when the [ColorPickerButton] is being hovered.
</theme_item>
- <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)">
The tint of text outline of the [ColorPickerButton].
</theme_item>
- <theme_item name="font_pressed_color" type="Color" default="Color( 0.8, 0.8, 0.8, 1 )">
+ <theme_item name="font_pressed_color" type="Color" default="Color(0.8, 0.8, 0.8, 1)">
Text [Color] used when the [ColorPickerButton] is being pressed.
</theme_item>
<theme_item name="font_size" type="int">
diff --git a/doc/classes/ColorRect.xml b/doc/classes/ColorRect.xml
index 09ba4c8b26..84955fed8a 100644
--- a/doc/classes/ColorRect.xml
+++ b/doc/classes/ColorRect.xml
@@ -12,7 +12,7 @@
<methods>
</methods>
<members>
- <member name="color" type="Color" setter="set_color" getter="get_color" default="Color( 1, 1, 1, 1 )">
+ <member name="color" type="Color" setter="set_color" getter="get_color" default="Color(1, 1, 1, 1)">
The fill color.
[codeblocks]
[gdscript]
diff --git a/doc/classes/ConcavePolygonShape2D.xml b/doc/classes/ConcavePolygonShape2D.xml
index 9999d086da..e6b2e1845d 100644
--- a/doc/classes/ConcavePolygonShape2D.xml
+++ b/doc/classes/ConcavePolygonShape2D.xml
@@ -12,7 +12,7 @@
<methods>
</methods>
<members>
- <member name="segments" type="PackedVector2Array" setter="set_segments" getter="get_segments" default="PackedVector2Array( )">
+ <member name="segments" type="PackedVector2Array" setter="set_segments" getter="get_segments" default="PackedVector2Array()">
The array of points that make up the [ConcavePolygonShape2D]'s line segments.
</member>
</members>
diff --git a/doc/classes/ConfigFile.xml b/doc/classes/ConfigFile.xml
index 8b903d8dbc..76855fc19f 100644
--- a/doc/classes/ConfigFile.xml
+++ b/doc/classes/ConfigFile.xml
@@ -9,7 +9,7 @@
[section]
some_key=42
string_example="Hello World3D!"
- a_vector=Vector3( 1, 0, 2 )
+ a_vector=Vector3(1, 0, 2)
[/codeblock]
The stored data can be saved to or parsed from a file, though ConfigFile objects can also be used directly without accessing the filesystem.
The following example shows how to parse an INI-style file from the system, read its contents and store new values in it:
diff --git a/doc/classes/ConfirmationDialog.xml b/doc/classes/ConfirmationDialog.xml
index 9d8977cef1..0253ef21df 100644
--- a/doc/classes/ConfirmationDialog.xml
+++ b/doc/classes/ConfirmationDialog.xml
@@ -27,8 +27,8 @@
</method>
</methods>
<members>
- <member name="min_size" type="Vector2i" setter="set_min_size" getter="get_min_size" override="true" default="Vector2i( 200, 70 )" />
- <member name="size" type="Vector2i" setter="set_size" getter="get_size" override="true" default="Vector2i( 200, 100 )" />
+ <member name="min_size" type="Vector2i" setter="set_min_size" getter="get_min_size" override="true" default="Vector2i(200, 70)" />
+ <member name="size" type="Vector2i" setter="set_size" getter="get_size" override="true" default="Vector2i(200, 100)" />
<member name="title" type="String" setter="set_title" getter="get_title" override="true" default="&quot;Please Confirm...&quot;" />
</members>
<constants>
diff --git a/doc/classes/Control.xml b/doc/classes/Control.xml
index 33969cf4c3..2692108d94 100644
--- a/doc/classes/Control.xml
+++ b/doc/classes/Control.xml
@@ -50,14 +50,6 @@
[/codeblocks]
</description>
</method>
- <method name="_clips_input" qualifiers="virtual">
- <return type="bool">
- </return>
- <description>
- Virtual method to be implemented by the user. Returns whether [method _gui_input] should not be called for children controls outside this control's rectangle. Input will be clipped to the Rect of this [Control]. Similar to [member rect_clip_content], but doesn't affect visibility.
- If not overridden, defaults to [code]false[/code].
- </description>
- </method>
<method name="_drop_data" qualifiers="virtual">
<return type="void">
</return>
@@ -155,13 +147,13 @@
* control has [member mouse_filter] set to [constant MOUSE_FILTER_IGNORE];
* control is obstructed by another [Control] on top of it, which doesn't have [member mouse_filter] set to [constant MOUSE_FILTER_IGNORE];
* control's parent has [member mouse_filter] set to [constant MOUSE_FILTER_STOP] or has accepted the event;
- * it happens outside parent's rectangle and the parent has either [member rect_clip_content] or [method _clips_input] enabled.
+ * it happens outside parent's rectangle and the parent has either [member rect_clip_content] enabled.
</description>
</method>
- <method name="_has_point" qualifiers="virtual">
+ <method name="_has_point" qualifiers="virtual const">
<return type="bool">
</return>
- <argument index="0" name="point" type="Vector2">
+ <argument index="0" name="" type="Vector2">
</argument>
<description>
Virtual method to be implemented by the user. Returns whether the given [code]point[/code] is inside this control.
@@ -201,14 +193,14 @@
[codeblocks]
[gdscript]
func _make_custom_tooltip(for_text):
- var tooltip = preload("res://SomeTooltipScene.tscn").instance()
+ var tooltip = preload("res://SomeTooltipScene.tscn").instantiate()
tooltip.get_node("Label").text = for_text
return tooltip
[/gdscript]
[csharp]
public override Godot.Control _MakeCustomTooltip(String forText)
{
- Node tooltip = ResourceLoader.Load&lt;PackedScene&gt;("res://SomeTooltipScene.tscn").Instance();
+ Node tooltip = ResourceLoader.Load&lt;PackedScene&gt;("res://SomeTooltipScene.tscn").Instantiate();
tooltip.GetNode&lt;Label&gt;("Label").Text = forText;
return tooltip;
}
@@ -395,7 +387,7 @@
<method name="get_cursor_shape" qualifiers="const">
<return type="int" enum="Control.CursorShape">
</return>
- <argument index="0" name="position" type="Vector2" default="Vector2( 0, 0 )">
+ <argument index="0" name="position" type="Vector2" default="Vector2(0, 0)">
</argument>
<description>
Returns the mouse cursor shape the control displays on mouse hover. See [enum CursorShape].
@@ -549,7 +541,7 @@
<method name="get_tooltip" qualifiers="const">
<return type="String">
</return>
- <argument index="0" name="at_position" type="Vector2" default="Vector2( 0, 0 )">
+ <argument index="0" name="at_position" type="Vector2" default="Vector2(0, 0)">
</argument>
<description>
Returns the tooltip, which will appear when the cursor is resting over this control. See [member hint_tooltip].
@@ -1135,18 +1127,18 @@
Offsets are often controlled by one or multiple parent [Container] nodes, so you should not modify them manually if your node is a direct child of a [Container]. Offsets update automatically when you move or resize the node.
</member>
<member name="rect_clip_content" type="bool" setter="set_clip_contents" getter="is_clipping_contents" default="false">
- Enables whether rendering of [CanvasItem] based children should be clipped to this control's rectangle. If [code]true[/code], parts of a child which would be visibly outside of this control's rectangle will not be rendered.
+ Enables whether rendering of [CanvasItem] based children should be clipped to this control's rectangle. If [code]true[/code], parts of a child which would be visibly outside of this control's rectangle will not be rendered and won't receive input.
</member>
<member name="rect_global_position" type="Vector2" setter="_set_global_position" getter="get_global_position">
The node's global position, relative to the world (usually to the top-left corner of the window).
</member>
- <member name="rect_min_size" type="Vector2" setter="set_custom_minimum_size" getter="get_custom_minimum_size" default="Vector2( 0, 0 )">
+ <member name="rect_min_size" type="Vector2" setter="set_custom_minimum_size" getter="get_custom_minimum_size" default="Vector2(0, 0)">
The minimum size of the node's bounding rectangle. If you set it to a value greater than (0, 0), the node's bounding rectangle will always have at least this size, even if its content is smaller. If it's set to (0, 0), the node sizes automatically to fit its content, be it a texture or child nodes.
</member>
- <member name="rect_pivot_offset" type="Vector2" setter="set_pivot_offset" getter="get_pivot_offset" default="Vector2( 0, 0 )">
+ <member name="rect_pivot_offset" type="Vector2" setter="set_pivot_offset" getter="get_pivot_offset" default="Vector2(0, 0)">
By default, the node's pivot is its top-left corner. When you change its [member rect_scale], it will scale around this pivot. Set this property to [member rect_size] / 2 to center the pivot in the node's rectangle.
</member>
- <member name="rect_position" type="Vector2" setter="_set_position" getter="get_position" default="Vector2( 0, 0 )">
+ <member name="rect_position" type="Vector2" setter="_set_position" getter="get_position" default="Vector2(0, 0)">
The node's position, relative to its parent. It corresponds to the rectangle's top-left corner. The property is not affected by [member rect_pivot_offset].
</member>
<member name="rect_rotation" type="float" setter="set_rotation" getter="get_rotation" default="0.0">
@@ -1155,12 +1147,12 @@
<member name="rect_rotation_degrees" type="float" setter="set_rotation_degrees" getter="get_rotation_degrees" default="0.0">
The node's rotation around its pivot, in degrees. See [member rect_pivot_offset] to change the pivot's position.
</member>
- <member name="rect_scale" type="Vector2" setter="set_scale" getter="get_scale" default="Vector2( 1, 1 )">
+ <member name="rect_scale" type="Vector2" setter="set_scale" getter="get_scale" default="Vector2(1, 1)">
The node's scale, relative to its [member rect_size]. Change this property to scale the node around its [member rect_pivot_offset]. The Control's [member hint_tooltip] will also scale according to this value.
[b]Note:[/b] This property is mainly intended to be used for animation purposes. Text inside the Control will look pixelated or blurry when the Control is scaled. To support multiple resolutions in your project, use an appropriate viewport stretch mode as described in the [url=https://docs.godotengine.org/en/latest/tutorials/viewports/multiple_resolutions.html]documentation[/url] instead of scaling Controls individually.
- [b]Note:[/b] If the Control node is a child of a [Container] node, the scale will be reset to [code]Vector2(1, 1)[/code] when the scene is instanced. To set the Control's scale when it's instanced, wait for one frame using [code]yield(get_tree(), "idle_frame")[/code] then set its [member rect_scale] property.
+ [b]Note:[/b] If the Control node is a child of a [Container] node, the scale will be reset to [code]Vector2(1, 1)[/code] when the scene is instantiated. To set the Control's scale when it's instantiated, wait for one frame using [code]yield(get_tree(), "idle_frame")[/code] then set its [member rect_scale] property.
</member>
- <member name="rect_size" type="Vector2" setter="_set_size" getter="get_size" default="Vector2( 0, 0 )">
+ <member name="rect_size" type="Vector2" setter="_set_size" getter="get_size" default="Vector2(0, 0)">
The size of the node's bounding rectangle, in pixels. [Container] nodes update this property automatically.
</member>
<member name="size_flags_horizontal" type="int" setter="set_h_size_flags" getter="get_h_size_flags" default="1">
diff --git a/doc/classes/ConvexPolygonShape2D.xml b/doc/classes/ConvexPolygonShape2D.xml
index 42951e2158..d53900e6c5 100644
--- a/doc/classes/ConvexPolygonShape2D.xml
+++ b/doc/classes/ConvexPolygonShape2D.xml
@@ -21,7 +21,7 @@
</method>
</methods>
<members>
- <member name="points" type="PackedVector2Array" setter="set_points" getter="get_points" default="PackedVector2Array( )">
+ <member name="points" type="PackedVector2Array" setter="set_points" getter="get_points" default="PackedVector2Array()">
The polygon's list of vertices. Can be in either clockwise or counterclockwise order.
</member>
</members>
diff --git a/doc/classes/ConvexPolygonShape3D.xml b/doc/classes/ConvexPolygonShape3D.xml
index e18d716255..a5c86526b0 100644
--- a/doc/classes/ConvexPolygonShape3D.xml
+++ b/doc/classes/ConvexPolygonShape3D.xml
@@ -12,7 +12,7 @@
<methods>
</methods>
<members>
- <member name="points" type="PackedVector3Array" setter="set_points" getter="get_points" default="PackedVector3Array( )">
+ <member name="points" type="PackedVector3Array" setter="set_points" getter="get_points" default="PackedVector3Array()">
The list of 3D points forming the convex polygon shape.
</member>
</members>
diff --git a/doc/classes/Curve2D.xml b/doc/classes/Curve2D.xml
index b33f3b4ffc..c9fcbd2892 100644
--- a/doc/classes/Curve2D.xml
+++ b/doc/classes/Curve2D.xml
@@ -15,9 +15,9 @@
</return>
<argument index="0" name="position" type="Vector2">
</argument>
- <argument index="1" name="in" type="Vector2" default="Vector2( 0, 0 )">
+ <argument index="1" name="in" type="Vector2" default="Vector2(0, 0)">
</argument>
- <argument index="2" name="out" type="Vector2" default="Vector2( 0, 0 )">
+ <argument index="2" name="out" type="Vector2" default="Vector2(0, 0)">
</argument>
<argument index="3" name="at_position" type="int" default="-1">
</argument>
diff --git a/doc/classes/Curve3D.xml b/doc/classes/Curve3D.xml
index fcd150ad57..fdf96b4262 100644
--- a/doc/classes/Curve3D.xml
+++ b/doc/classes/Curve3D.xml
@@ -15,9 +15,9 @@
</return>
<argument index="0" name="position" type="Vector3">
</argument>
- <argument index="1" name="in" type="Vector3" default="Vector3( 0, 0, 0 )">
+ <argument index="1" name="in" type="Vector3" default="Vector3(0, 0, 0)">
</argument>
- <argument index="2" name="out" type="Vector3" default="Vector3( 0, 0, 0 )">
+ <argument index="2" name="out" type="Vector3" default="Vector3(0, 0, 0)">
</argument>
<argument index="3" name="at_position" type="int" default="-1">
</argument>
diff --git a/doc/classes/CylinderMesh.xml b/doc/classes/CylinderMesh.xml
index 3a81e98c3a..827fb5c10c 100644
--- a/doc/classes/CylinderMesh.xml
+++ b/doc/classes/CylinderMesh.xml
@@ -4,7 +4,7 @@
Class representing a cylindrical [PrimitiveMesh].
</brief_description>
<description>
- Class representing a cylindrical [PrimitiveMesh]. This class can be used to create cones by setting either the [member top_radius] or [member bottom_radius] properties to 0.0.
+ Class representing a cylindrical [PrimitiveMesh]. This class can be used to create cones by setting either the [member top_radius] or [member bottom_radius] properties to [code]0.0[/code].
</description>
<tutorials>
</tutorials>
@@ -12,19 +12,19 @@
</methods>
<members>
<member name="bottom_radius" type="float" setter="set_bottom_radius" getter="get_bottom_radius" default="1.0">
- Bottom radius of the cylinder.
+ Bottom radius of the cylinder. If set to [code]0.0[/code], the bottom faces will not be generated, resulting in a conic shape.
</member>
<member name="height" type="float" setter="set_height" getter="get_height" default="2.0">
Full height of the cylinder.
</member>
<member name="radial_segments" type="int" setter="set_radial_segments" getter="get_radial_segments" default="64">
- Number of radial segments on the cylinder.
+ Number of radial segments on the cylinder. Higher values result in a more detailed cylinder/cone at the cost of performance.
</member>
<member name="rings" type="int" setter="set_rings" getter="get_rings" default="4">
- Number of edge rings along the height of the cylinder.
+ Number of edge rings along the height of the cylinder. Changing [member rings] does not have any visual impact unless a shader or procedural mesh tool is used to alter the vertex data. Higher values result in more subdivisions, which can be used to create smoother-looking effects with shaders or procedural mesh tools (at the cost of performance). When not altering the vertex data using a shader or procedural mesh tool, [member rings] should be kept to its default value.
</member>
<member name="top_radius" type="float" setter="set_top_radius" getter="get_top_radius" default="1.0">
- Top radius of the cylinder.
+ Top radius of the cylinder. If set to [code]0.0[/code], the top faces will not be generated, resulting in a conic shape.
</member>
</members>
<constants>
diff --git a/doc/classes/Decal.xml b/doc/classes/Decal.xml
index 14c35ae6d3..e84cea7c30 100644
--- a/doc/classes/Decal.xml
+++ b/doc/classes/Decal.xml
@@ -79,13 +79,13 @@
<member name="emission_energy" type="float" setter="set_emission_energy" getter="get_emission_energy" default="1.0">
Energy multiplier for the emission texture. This will make the decal emit light at a higher intensity.
</member>
- <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3( 1, 1, 1 )">
+ <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3(1, 1, 1)">
Sets the size of the [AABB] used by the decal. The AABB goes from [code]-extents[/code] to [code]extents[/code].
</member>
<member name="lower_fade" type="float" setter="set_lower_fade" getter="get_lower_fade" default="0.3">
Sets the curve over which the decal will fade as the surface gets further from the center of the [AABB].
</member>
- <member name="modulate" type="Color" setter="set_modulate" getter="get_modulate" default="Color( 1, 1, 1, 1 )">
+ <member name="modulate" type="Color" setter="set_modulate" getter="get_modulate" default="Color(1, 1, 1, 1)">
Changes the [Color] of the Decal by multiplying it with this value.
</member>
<member name="normal_fade" type="float" setter="set_normal_fade" getter="get_normal_fade" default="0.0">
diff --git a/doc/classes/DisplayServer.xml b/doc/classes/DisplayServer.xml
index 6c1cd37beb..ef20174ee6 100644
--- a/doc/classes/DisplayServer.xml
+++ b/doc/classes/DisplayServer.xml
@@ -46,7 +46,7 @@
</argument>
<argument index="1" name="flags" type="int">
</argument>
- <argument index="2" name="rect" type="Rect2i" default="Rect2i( 0, 0, 0, 0 )">
+ <argument index="2" name="rect" type="Rect2i" default="Rect2i(0, 0, 0, 0)">
</argument>
<description>
</description>
@@ -64,7 +64,7 @@
</argument>
<argument index="1" name="shape" type="int" enum="DisplayServer.CursorShape" default="0">
</argument>
- <argument index="2" name="hotspot" type="Vector2" default="Vector2( 0, 0 )">
+ <argument index="2" name="hotspot" type="Vector2" default="Vector2(0, 0)">
</argument>
<description>
</description>
@@ -436,7 +436,7 @@
</description>
</method>
<method name="mouse_get_button_state" qualifiers="const">
- <return type="int">
+ <return type="int" enum="MouseButton">
</return>
<description>
</description>
@@ -650,7 +650,7 @@
</return>
<argument index="0" name="existing_text" type="String">
</argument>
- <argument index="1" name="position" type="Rect2" default="Rect2i( 0, 0, 0, 0 )">
+ <argument index="1" name="position" type="Rect2" default="Rect2i(0, 0, 0, 0)">
</argument>
<argument index="2" name="multiline" type="bool" default="false">
</argument>
diff --git a/doc/classes/EditorNode3DGizmo.xml b/doc/classes/EditorNode3DGizmo.xml
index dcc6d6ef12..221b5e44d6 100644
--- a/doc/classes/EditorNode3DGizmo.xml
+++ b/doc/classes/EditorNode3DGizmo.xml
@@ -115,7 +115,7 @@
</argument>
<argument index="2" name="billboard" type="bool" default="false">
</argument>
- <argument index="3" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="3" name="modulate" type="Color" default="Color(1, 1, 1, 1)">
</argument>
<description>
Adds lines to the gizmo (as sets of 2 points), with a given material. The lines are used for visualizing the gizmo. Call this function during [method _redraw].
@@ -143,7 +143,7 @@
</argument>
<argument index="1" name="default_scale" type="float" default="1">
</argument>
- <argument index="2" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="2" name="modulate" type="Color" default="Color(1, 1, 1, 1)">
</argument>
<description>
Adds an unscaled billboard for visualization. Call this function during [method _redraw].
diff --git a/doc/classes/EditorNode3DGizmoPlugin.xml b/doc/classes/EditorNode3DGizmoPlugin.xml
index 5551326533..41c94cbbc6 100644
--- a/doc/classes/EditorNode3DGizmoPlugin.xml
+++ b/doc/classes/EditorNode3DGizmoPlugin.xml
@@ -163,7 +163,7 @@
</argument>
<argument index="2" name="on_top" type="bool" default="false">
</argument>
- <argument index="3" name="color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="3" name="color" type="Color" default="Color(1, 1, 1, 1)">
</argument>
<description>
Creates an icon material with its variants (selected and/or editable) and adds them to the internal material list. They can then be accessed with [method get_material] and used in [method EditorNode3DGizmo.add_unscaled_billboard]. Should not be overridden.
diff --git a/doc/classes/EditorPlugin.xml b/doc/classes/EditorPlugin.xml
index 0c0439e9d3..a02d318f70 100644
--- a/doc/classes/EditorPlugin.xml
+++ b/doc/classes/EditorPlugin.xml
@@ -404,7 +404,7 @@
</argument>
<description>
Adds a custom type, which will appear in the list of nodes or resources. An icon can be optionally passed.
- When given node or resource is selected, the base type will be instanced (e.g. "Node3D", "Control", "Resource"), then the script will be loaded and set to this object.
+ When given node or resource is selected, the base type will be instantiated (e.g. "Node3D", "Control", "Resource"), then the script will be loaded and set to this object.
You can use the virtual method [method _handles] to check if your custom object is being edited by checking the script or using the [code]is[/code] keyword.
During run-time, this will be a simple object with a script so this function does not need to be called then.
</description>
diff --git a/doc/classes/EditorSceneImporterMesh.xml b/doc/classes/EditorSceneImporterMesh.xml
index 9daa3f16bc..90eca9072b 100644
--- a/doc/classes/EditorSceneImporterMesh.xml
+++ b/doc/classes/EditorSceneImporterMesh.xml
@@ -22,7 +22,7 @@
</argument>
<argument index="1" name="arrays" type="Array">
</argument>
- <argument index="2" name="blend_shapes" type="Array" default="[ ]">
+ <argument index="2" name="blend_shapes" type="Array" default="[]">
</argument>
<argument index="3" name="lods" type="Dictionary" default="{
}">
@@ -168,7 +168,7 @@
</method>
</methods>
<members>
- <member name="_data" type="Dictionary" setter="_set_data" getter="_get_data" default="{&quot;surfaces&quot;: [ ]}">
+ <member name="_data" type="Dictionary" setter="_set_data" getter="_get_data" default="{&quot;surfaces&quot;: []}">
</member>
</members>
<constants>
diff --git a/doc/classes/Engine.xml b/doc/classes/Engine.xml
index ab480c50ab..c0a8407ece 100644
--- a/doc/classes/Engine.xml
+++ b/doc/classes/Engine.xml
@@ -173,6 +173,11 @@
Controls how much physics ticks are synchronized with real time. For 0 or less, the ticks are synchronized. Such values are recommended for network games, where clock synchronization matters. Higher values cause higher deviation of in-game clock and real clock, but allows smoothing out framerate jitters. The default value of 0.5 should be fine for most; values above 2 could cause the game to react to dropped frames with a noticeable delay and are not recommended.
[b]Note:[/b] For best results, when using a custom physics interpolation solution, the physics jitter fix should be disabled by setting [member physics_jitter_fix] to [code]0[/code].
</member>
+ <member name="print_error_messages" type="bool" setter="set_print_error_messages" getter="is_printing_error_messages" default="true">
+ If [code]false[/code], stops printing error and warning messages to the console and editor Output log. This can be used to hide error and warning messages during unit test suite runs. This property is equivalent to the [member ProjectSettings.application/run/disable_stderr] project setting.
+ [b]Warning:[/b] If you set this to [code]false[/code] anywhere in the project, important error messages may be hidden even if they are emitted from other scripts. If this is set to [code]false[/code] in a [code]@tool[/code] script, this will also impact the editor itself. Do [i]not[/i] report bugs before ensuring error messages are enabled (as they are by default).
+ [b]Note:[/b] This property does not impact the editor's Errors tab when running a project from the editor.
+ </member>
<member name="target_fps" type="int" setter="set_target_fps" getter="get_target_fps" default="0">
The desired frames per second. If the hardware cannot keep up, this setting may not be respected. A value of 0 means no limit.
</member>
diff --git a/doc/classes/EngineDebugger.xml b/doc/classes/EngineDebugger.xml
index 7db36b89d0..50ccb6b075 100644
--- a/doc/classes/EngineDebugger.xml
+++ b/doc/classes/EngineDebugger.xml
@@ -61,7 +61,7 @@
</argument>
<argument index="1" name="enable" type="bool">
</argument>
- <argument index="2" name="arguments" type="Array" default="[ ]">
+ <argument index="2" name="arguments" type="Array" default="[]">
</argument>
<description>
Calls the [code]toggle[/code] callable of the profiler with given [code]name[/code] and [code]arguments[/code]. Enables/Disables the same profiler depending on [code]enable[/code] argument.
diff --git a/doc/classes/Environment.xml b/doc/classes/Environment.xml
index 878535a08d..ae87a62c84 100644
--- a/doc/classes/Environment.xml
+++ b/doc/classes/Environment.xml
@@ -55,13 +55,13 @@
<member name="adjustment_saturation" type="float" setter="set_adjustment_saturation" getter="get_adjustment_saturation" default="1.0">
The global color saturation value of the rendered scene (default value is 1). Effective only if [code]adjustment_enabled[/code] is [code]true[/code].
</member>
- <member name="ambient_light_color" type="Color" setter="set_ambient_light_color" getter="get_ambient_light_color" default="Color( 0, 0, 0, 1 )">
+ <member name="ambient_light_color" type="Color" setter="set_ambient_light_color" getter="get_ambient_light_color" default="Color(0, 0, 0, 1)">
The ambient light's [Color].
</member>
<member name="ambient_light_energy" type="float" setter="set_ambient_light_energy" getter="get_ambient_light_energy" default="1.0">
The ambient light's energy. The higher the value, the stronger the light.
</member>
- <member name="ambient_light_occlusion_color" type="Color" setter="set_ao_color" getter="get_ao_color" default="Color( 0, 0, 0, 1 )">
+ <member name="ambient_light_occlusion_color" type="Color" setter="set_ao_color" getter="get_ao_color" default="Color(0, 0, 0, 1)">
</member>
<member name="ambient_light_sky_contribution" type="float" setter="set_ambient_light_sky_contribution" getter="get_ambient_light_sky_contribution" default="1.0">
Defines the amount of light that the sky brings on the scene. A value of 0 means that the sky's light emission has no effect on the scene illumination, thus all ambient illumination is provided by the ambient light. On the contrary, a value of 1 means that all the light that affects the scene is provided by the sky, thus the ambient light parameter has no effect on the scene.
@@ -89,7 +89,7 @@
<member name="background_canvas_max_layer" type="int" setter="set_canvas_max_layer" getter="get_canvas_max_layer" default="0">
The maximum layer ID to display. Only effective when using the [constant BG_CANVAS] background mode.
</member>
- <member name="background_color" type="Color" setter="set_bg_color" getter="get_bg_color" default="Color( 0, 0, 0, 1 )">
+ <member name="background_color" type="Color" setter="set_bg_color" getter="get_bg_color" default="Color(0, 0, 0, 1)">
The [Color] displayed for clear areas of the scene. Only effective when using the [constant BG_COLOR] background mode.
</member>
<member name="background_energy" type="float" setter="set_bg_energy" getter="get_bg_energy" default="1.0">
@@ -111,7 +111,7 @@
</member>
<member name="fog_height_density" type="float" setter="set_fog_height_density" getter="get_fog_height_density" default="0.0">
</member>
- <member name="fog_light_color" type="Color" setter="set_fog_light_color" getter="get_fog_light_color" default="Color( 0.5, 0.6, 0.7, 1 )">
+ <member name="fog_light_color" type="Color" setter="set_fog_light_color" getter="get_fog_light_color" default="Color(0.5, 0.6, 0.7, 1)">
</member>
<member name="fog_light_energy" type="float" setter="set_fog_light_energy" getter="get_fog_light_energy" default="1.0">
</member>
@@ -200,7 +200,7 @@
</member>
<member name="sky_custom_fov" type="float" setter="set_sky_custom_fov" getter="get_sky_custom_fov" default="0.0">
</member>
- <member name="sky_rotation" type="Vector3" setter="set_sky_rotation" getter="get_sky_rotation" default="Vector3( 0, 0, 0 )">
+ <member name="sky_rotation" type="Vector3" setter="set_sky_rotation" getter="get_sky_rotation" default="Vector3(0, 0, 0)">
</member>
<member name="ss_reflections_depth_tolerance" type="float" setter="set_ssr_depth_tolerance" getter="get_ssr_depth_tolerance" default="0.2">
The depth tolerance for screen-space reflections.
@@ -263,7 +263,7 @@
</member>
<member name="volumetric_fog_length" type="float" setter="set_volumetric_fog_length" getter="get_volumetric_fog_length" default="64.0">
</member>
- <member name="volumetric_fog_light" type="Color" setter="set_volumetric_fog_light" getter="get_volumetric_fog_light" default="Color( 0, 0, 0, 1 )">
+ <member name="volumetric_fog_light" type="Color" setter="set_volumetric_fog_light" getter="get_volumetric_fog_light" default="Color(0, 0, 0, 1)">
</member>
<member name="volumetric_fog_light_energy" type="float" setter="set_volumetric_fog_light_energy" getter="get_volumetric_fog_light_energy" default="1.0">
</member>
diff --git a/doc/classes/Expression.xml b/doc/classes/Expression.xml
index 0781d2ffa2..640b45dca4 100644
--- a/doc/classes/Expression.xml
+++ b/doc/classes/Expression.xml
@@ -54,7 +54,7 @@
<method name="execute">
<return type="Variant">
</return>
- <argument index="0" name="inputs" type="Array" default="[ ]">
+ <argument index="0" name="inputs" type="Array" default="[]">
</argument>
<argument index="1" name="base_instance" type="Object" default="null">
</argument>
@@ -84,7 +84,7 @@
</return>
<argument index="0" name="expression" type="String">
</argument>
- <argument index="1" name="input_names" type="PackedStringArray" default="PackedStringArray( )">
+ <argument index="1" name="input_names" type="PackedStringArray" default="PackedStringArray()">
</argument>
<description>
Parses the expression and returns an [enum Error] code.
diff --git a/doc/classes/FileDialog.xml b/doc/classes/FileDialog.xml
index 966be0a981..8ccee1c82e 100644
--- a/doc/classes/FileDialog.xml
+++ b/doc/classes/FileDialog.xml
@@ -72,7 +72,7 @@
<member name="file_mode" type="int" setter="set_file_mode" getter="get_file_mode" enum="FileDialog.FileMode" default="4">
The dialog's open or save mode, which affects the selection behavior. See [enum FileMode].
</member>
- <member name="filters" type="PackedStringArray" setter="set_filters" getter="get_filters" default="PackedStringArray( )">
+ <member name="filters" type="PackedStringArray" setter="set_filters" getter="get_filters" default="PackedStringArray()">
The available file type filters. For example, this shows only [code].png[/code] and [code].gd[/code] files: [code]set_filters(PackedStringArray(["*.png ; PNG Images","*.gd ; GDScript Files"]))[/code].
</member>
<member name="mode_overrides_title" type="bool" setter="set_mode_overrides_title" getter="is_mode_overriding_title" default="true">
@@ -139,16 +139,16 @@
<theme_item name="file" type="Texture2D">
Custom icon for files.
</theme_item>
- <theme_item name="file_icon_modulate" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="file_icon_modulate" type="Color" default="Color(1, 1, 1, 1)">
The color modulation applied to the file icon.
</theme_item>
- <theme_item name="files_disabled" type="Color" default="Color( 0, 0, 0, 0.7 )">
+ <theme_item name="files_disabled" type="Color" default="Color(0, 0, 0, 0.7)">
The color tint for disabled files (when the [FileDialog] is used in open folder mode).
</theme_item>
<theme_item name="folder" type="Texture2D">
Custom icon for folders.
</theme_item>
- <theme_item name="folder_icon_modulate" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="folder_icon_modulate" type="Color" default="Color(1, 1, 1, 1)">
The color modulation applied to the folder icon.
</theme_item>
<theme_item name="forward_folder" type="Texture2D">
diff --git a/doc/classes/Font.xml b/doc/classes/Font.xml
index 20d5b6ce9b..186bfbb931 100644
--- a/doc/classes/Font.xml
+++ b/doc/classes/Font.xml
@@ -85,11 +85,11 @@
</argument>
<argument index="4" name="size" type="int" default="-1">
</argument>
- <argument index="5" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="5" name="modulate" type="Color" default="Color(1, 1, 1, 1)">
</argument>
<argument index="6" name="outline_size" type="int" default="0">
</argument>
- <argument index="7" name="outline_modulate" type="Color" default="Color( 1, 1, 1, 0 )">
+ <argument index="7" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)">
</argument>
<description>
Draw a single Unicode character [code]char[/code] into a canvas item using the font, at a given position, with [code]modulate[/code] color, and optionally kerning if [code]next[/code] is passed. [code]position[/code] specifies the baseline, not the top. To draw from the top, [i]ascent[/i] must be added to the Y axis.
@@ -113,11 +113,11 @@
</argument>
<argument index="6" name="size" type="int" default="-1">
</argument>
- <argument index="7" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="7" name="modulate" type="Color" default="Color(1, 1, 1, 1)">
</argument>
<argument index="8" name="outline_size" type="int" default="0">
</argument>
- <argument index="9" name="outline_modulate" type="Color" default="Color( 1, 1, 1, 0 )">
+ <argument index="9" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)">
</argument>
<argument index="10" name="flags" type="int" default="51">
</argument>
@@ -141,11 +141,11 @@
</argument>
<argument index="5" name="size" type="int" default="-1">
</argument>
- <argument index="6" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="6" name="modulate" type="Color" default="Color(1, 1, 1, 1)">
</argument>
<argument index="7" name="outline_size" type="int" default="0">
</argument>
- <argument index="8" name="outline_modulate" type="Color" default="Color( 1, 1, 1, 0 )">
+ <argument index="8" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)">
</argument>
<argument index="9" name="flags" type="int" default="3">
</argument>
diff --git a/doc/classes/FontData.xml b/doc/classes/FontData.xml
index e426c8fb36..0a2fb03750 100644
--- a/doc/classes/FontData.xml
+++ b/doc/classes/FontData.xml
@@ -61,7 +61,7 @@
</argument>
<argument index="3" name="index" type="int">
</argument>
- <argument index="4" name="color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="4" name="color" type="Color" default="Color(1, 1, 1, 1)">
</argument>
<description>
Draws single glyph into a canvas item at the position, using [code]font[/code] at the size [code]size[/code].
@@ -82,7 +82,7 @@
</argument>
<argument index="4" name="index" type="int">
</argument>
- <argument index="5" name="color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="5" name="color" type="Color" default="Color(1, 1, 1, 1)">
</argument>
<description>
Draws single glyph outline of size [code]outline_size[/code] into a canvas item at the position, using [code]font[/code] at the size [code]size[/code]. If outline drawing is not supported, nothing is drawn.
diff --git a/doc/classes/GPUParticles2D.xml b/doc/classes/GPUParticles2D.xml
index ebd6d2b92c..8684a7f41a 100644
--- a/doc/classes/GPUParticles2D.xml
+++ b/doc/classes/GPUParticles2D.xml
@@ -80,7 +80,7 @@
</member>
<member name="trail_sections" type="int" setter="set_trail_sections" getter="get_trail_sections" default="8">
</member>
- <member name="visibility_rect" type="Rect2" setter="set_visibility_rect" getter="get_visibility_rect" default="Rect2( -100, -100, 200, 200 )">
+ <member name="visibility_rect" type="Rect2" setter="set_visibility_rect" getter="get_visibility_rect" default="Rect2(-100, -100, 200, 200)">
The [Rect2] that determines the node's region which needs to be visible on screen for the particle system to be active.
Grow the rect if particles suddenly appear/disappear when the node enters/exits the screen. The [Rect2] can be grown via code or with the [b]Particles → Generate Visibility Rect[/b] editor tool.
</member>
diff --git a/doc/classes/GPUParticles3D.xml b/doc/classes/GPUParticles3D.xml
index 47bdd9d745..55e9b33aa8 100644
--- a/doc/classes/GPUParticles3D.xml
+++ b/doc/classes/GPUParticles3D.xml
@@ -132,7 +132,7 @@
</member>
<member name="transform_align" type="int" setter="set_transform_align" getter="get_transform_align" enum="GPUParticles3D.TransformAlign" default="0">
</member>
- <member name="visibility_aabb" type="AABB" setter="set_visibility_aabb" getter="get_visibility_aabb" default="AABB( -4, -4, -4, 8, 8, 8 )">
+ <member name="visibility_aabb" type="AABB" setter="set_visibility_aabb" getter="get_visibility_aabb" default="AABB(-4, -4, -4, 8, 8, 8)">
The [AABB] that determines the node's region which needs to be visible on screen for the particle system to be active.
Grow the box if particles suddenly appear/disappear when the node enters/exits the screen. The [AABB] can be grown via code or with the [b]Particles → Generate AABB[/b] editor tool.
</member>
diff --git a/doc/classes/GPUParticlesAttractorBox.xml b/doc/classes/GPUParticlesAttractorBox.xml
index 68616f9bbd..49e6111c29 100644
--- a/doc/classes/GPUParticlesAttractorBox.xml
+++ b/doc/classes/GPUParticlesAttractorBox.xml
@@ -9,7 +9,7 @@
<methods>
</methods>
<members>
- <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3( 1, 1, 1 )">
+ <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3(1, 1, 1)">
</member>
</members>
<constants>
diff --git a/doc/classes/GPUParticlesAttractorVectorField.xml b/doc/classes/GPUParticlesAttractorVectorField.xml
index cf5e375ea3..7364a4b09f 100644
--- a/doc/classes/GPUParticlesAttractorVectorField.xml
+++ b/doc/classes/GPUParticlesAttractorVectorField.xml
@@ -9,7 +9,7 @@
<methods>
</methods>
<members>
- <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3( 1, 1, 1 )">
+ <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3(1, 1, 1)">
</member>
<member name="texture" type="Texture3D" setter="set_texture" getter="get_texture">
</member>
diff --git a/doc/classes/GPUParticlesCollisionBox.xml b/doc/classes/GPUParticlesCollisionBox.xml
index 17fc124c41..58de18556e 100644
--- a/doc/classes/GPUParticlesCollisionBox.xml
+++ b/doc/classes/GPUParticlesCollisionBox.xml
@@ -9,7 +9,7 @@
<methods>
</methods>
<members>
- <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3( 1, 1, 1 )">
+ <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3(1, 1, 1)">
</member>
</members>
<constants>
diff --git a/doc/classes/GPUParticlesCollisionHeightField.xml b/doc/classes/GPUParticlesCollisionHeightField.xml
index c6987515a9..0ddddda8e4 100644
--- a/doc/classes/GPUParticlesCollisionHeightField.xml
+++ b/doc/classes/GPUParticlesCollisionHeightField.xml
@@ -9,7 +9,7 @@
<methods>
</methods>
<members>
- <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3( 1, 1, 1 )">
+ <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3(1, 1, 1)">
</member>
<member name="follow_camera_enabled" type="bool" setter="set_follow_camera_mode" getter="is_follow_camera_mode_enabled" default="false">
</member>
diff --git a/doc/classes/GPUParticlesCollisionSDF.xml b/doc/classes/GPUParticlesCollisionSDF.xml
index c3cbe4b1c6..7ef6f5f3cd 100644
--- a/doc/classes/GPUParticlesCollisionSDF.xml
+++ b/doc/classes/GPUParticlesCollisionSDF.xml
@@ -9,7 +9,7 @@
<methods>
</methods>
<members>
- <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3( 1, 1, 1 )">
+ <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3(1, 1, 1)">
</member>
<member name="resolution" type="int" setter="set_resolution" getter="get_resolution" enum="GPUParticlesCollisionSDF.Resolution" default="2">
</member>
diff --git a/doc/classes/Gradient.xml b/doc/classes/Gradient.xml
index 28c647a1c3..1f1f266c59 100644
--- a/doc/classes/Gradient.xml
+++ b/doc/classes/Gradient.xml
@@ -87,10 +87,10 @@
</method>
</methods>
<members>
- <member name="colors" type="PackedColorArray" setter="set_colors" getter="get_colors" default="PackedColorArray( 0, 0, 0, 1, 1, 1, 1, 1 )">
+ <member name="colors" type="PackedColorArray" setter="set_colors" getter="get_colors" default="PackedColorArray(0, 0, 0, 1, 1, 1, 1, 1)">
Gradient's colors returned as a [PackedColorArray].
</member>
- <member name="offsets" type="PackedFloat32Array" setter="set_offsets" getter="get_offsets" default="PackedFloat32Array( 0, 1 )">
+ <member name="offsets" type="PackedFloat32Array" setter="set_offsets" getter="get_offsets" default="PackedFloat32Array(0, 1)">
Gradient's offsets returned as a [PackedFloat32Array].
</member>
</members>
diff --git a/doc/classes/GraphEdit.xml b/doc/classes/GraphEdit.xml
index 16fc1ca17a..65701b3a6a 100644
--- a/doc/classes/GraphEdit.xml
+++ b/doc/classes/GraphEdit.xml
@@ -187,14 +187,14 @@
<member name="minimap_opacity" type="float" setter="set_minimap_opacity" getter="get_minimap_opacity" default="0.65">
The opacity of the minimap rectangle.
</member>
- <member name="minimap_size" type="Vector2" setter="set_minimap_size" getter="get_minimap_size" default="Vector2( 240, 160 )">
+ <member name="minimap_size" type="Vector2" setter="set_minimap_size" getter="get_minimap_size" default="Vector2(240, 160)">
The size of the minimap rectangle. The map itself is based on the size of the grid area and is scaled to fit this rectangle.
</member>
<member name="rect_clip_content" type="bool" setter="set_clip_contents" getter="is_clipping_contents" override="true" default="true" />
<member name="right_disconnects" type="bool" setter="set_right_disconnects" getter="is_right_disconnects_enabled" default="false">
If [code]true[/code], enables disconnection of existing connections in the GraphEdit by dragging the right end.
</member>
- <member name="scroll_offset" type="Vector2" setter="set_scroll_ofs" getter="get_scroll_ofs" default="Vector2( 0, 0 )">
+ <member name="scroll_offset" type="Vector2" setter="set_scroll_ofs" getter="get_scroll_ofs" default="Vector2(0, 0)">
The scroll offset.
</member>
<member name="show_zoom_label" type="bool" setter="set_show_zoom_label" getter="is_showing_zoom_label" default="false">
@@ -329,7 +329,7 @@
<constants>
</constants>
<theme_items>
- <theme_item name="activity" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="activity" type="Color" default="Color(1, 1, 1, 1)">
</theme_item>
<theme_item name="bezier_len_neg" type="int" default="160">
</theme_item>
@@ -338,10 +338,10 @@
<theme_item name="bg" type="StyleBox">
The background drawn under the grid.
</theme_item>
- <theme_item name="grid_major" type="Color" default="Color( 1, 1, 1, 0.2 )">
+ <theme_item name="grid_major" type="Color" default="Color(1, 1, 1, 0.2)">
Color of major grid lines.
</theme_item>
- <theme_item name="grid_minor" type="Color" default="Color( 1, 1, 1, 0.05 )">
+ <theme_item name="grid_minor" type="Color" default="Color(1, 1, 1, 0.05)">
Color of minor grid lines.
</theme_item>
<theme_item name="minimap" type="Texture2D">
@@ -361,10 +361,10 @@
<theme_item name="reset" type="Texture2D">
The icon for the zoom reset button.
</theme_item>
- <theme_item name="selection_fill" type="Color" default="Color( 1, 1, 1, 0.3 )">
+ <theme_item name="selection_fill" type="Color" default="Color(1, 1, 1, 0.3)">
The fill color of the selection rectangle.
</theme_item>
- <theme_item name="selection_stroke" type="Color" default="Color( 1, 1, 1, 0.8 )">
+ <theme_item name="selection_stroke" type="Color" default="Color(1, 1, 1, 0.8)">
The outline color of the selection rectangle.
</theme_item>
<theme_item name="snap" type="Texture2D">
diff --git a/doc/classes/GraphNode.xml b/doc/classes/GraphNode.xml
index 82ba45f11a..84eda7fcea 100644
--- a/doc/classes/GraphNode.xml
+++ b/doc/classes/GraphNode.xml
@@ -285,7 +285,7 @@
<member name="overlay" type="int" setter="set_overlay" getter="get_overlay" enum="GraphNode.Overlay" default="0">
Sets the overlay shown above the GraphNode. See [enum Overlay].
</member>
- <member name="position_offset" type="Vector2" setter="set_position_offset" getter="get_position_offset" default="Vector2( 0, 0 )">
+ <member name="position_offset" type="Vector2" setter="set_position_offset" getter="get_position_offset" default="Vector2(0, 0)">
The offset of the GraphNode, relative to the scroll offset of the [GraphEdit].
[b]Note:[/b] You cannot use position offset directly, as [GraphEdit] is a [Container].
</member>
@@ -365,7 +365,7 @@
<theme_item name="close" type="Texture2D">
The icon for the close button, visible when [member show_close] is enabled.
</theme_item>
- <theme_item name="close_color" type="Color" default="Color( 0, 0, 0, 1 )">
+ <theme_item name="close_color" type="Color" default="Color(0, 0, 0, 1)">
The color modulation applied to the close button icon.
</theme_item>
<theme_item name="close_offset" type="int" default="18">
@@ -396,7 +396,7 @@
<theme_item name="resizer" type="Texture2D">
The icon used for resizer, visible when [member resizable] is enabled.
</theme_item>
- <theme_item name="resizer_color" type="Color" default="Color( 0, 0, 0, 1 )">
+ <theme_item name="resizer_color" type="Color" default="Color(0, 0, 0, 1)">
The color modulation applied to the resizer icon.
</theme_item>
<theme_item name="selectedframe" type="StyleBox">
@@ -405,7 +405,7 @@
<theme_item name="separation" type="int" default="1">
The vertical distance between ports.
</theme_item>
- <theme_item name="title_color" type="Color" default="Color( 0, 0, 0, 1 )">
+ <theme_item name="title_color" type="Color" default="Color(0, 0, 0, 1)">
Color of the title text.
</theme_item>
<theme_item name="title_font" type="Font">
diff --git a/doc/classes/HTTPRequest.xml b/doc/classes/HTTPRequest.xml
index 25667d8f79..908e355db3 100644
--- a/doc/classes/HTTPRequest.xml
+++ b/doc/classes/HTTPRequest.xml
@@ -192,7 +192,7 @@
</return>
<argument index="0" name="url" type="String">
</argument>
- <argument index="1" name="custom_headers" type="PackedStringArray" default="PackedStringArray( )">
+ <argument index="1" name="custom_headers" type="PackedStringArray" default="PackedStringArray()">
</argument>
<argument index="2" name="ssl_validate_domain" type="bool" default="true">
</argument>
@@ -211,13 +211,13 @@
</return>
<argument index="0" name="url" type="String">
</argument>
- <argument index="1" name="custom_headers" type="PackedStringArray" default="PackedStringArray( )">
+ <argument index="1" name="custom_headers" type="PackedStringArray" default="PackedStringArray()">
</argument>
<argument index="2" name="ssl_validate_domain" type="bool" default="true">
</argument>
<argument index="3" name="method" type="int" enum="HTTPClient.Method" default="0">
</argument>
- <argument index="4" name="request_data_raw" type="PackedByteArray" default="PackedByteArray( )">
+ <argument index="4" name="request_data_raw" type="PackedByteArray" default="PackedByteArray()">
</argument>
<description>
Creates request on the underlying [HTTPClient] using a raw array of bytes for the request body. If there is no configuration errors, it tries to connect using [method HTTPClient.connect_to_host] and passes parameters onto [method HTTPClient.request].
diff --git a/doc/classes/HeightMapShape3D.xml b/doc/classes/HeightMapShape3D.xml
index f6f2a27891..9a9d3bf8f4 100644
--- a/doc/classes/HeightMapShape3D.xml
+++ b/doc/classes/HeightMapShape3D.xml
@@ -11,7 +11,7 @@
<methods>
</methods>
<members>
- <member name="map_data" type="PackedFloat32Array" setter="set_map_data" getter="get_map_data" default="PackedFloat32Array( 0, 0, 0, 0 )">
+ <member name="map_data" type="PackedFloat32Array" setter="set_map_data" getter="get_map_data" default="PackedFloat32Array(0, 0, 0, 0)">
Height map data, pool array must be of [member map_width] * [member map_depth] size.
</member>
<member name="map_depth" type="int" setter="set_map_depth" getter="get_map_depth" default="2">
diff --git a/doc/classes/Image.xml b/doc/classes/Image.xml
index 91a07f66e0..167b90ea73 100644
--- a/doc/classes/Image.xml
+++ b/doc/classes/Image.xml
@@ -560,7 +560,7 @@
</method>
</methods>
<members>
- <member name="data" type="Dictionary" setter="_set_data" getter="_get_data" default="{&quot;data&quot;: PackedByteArray( ),&quot;format&quot;: &quot;Lum8&quot;,&quot;height&quot;: 0,&quot;mipmaps&quot;: false,&quot;width&quot;: 0}">
+ <member name="data" type="Dictionary" setter="_set_data" getter="_get_data" default="{&quot;data&quot;: PackedByteArray(),&quot;format&quot;: &quot;Lum8&quot;,&quot;height&quot;: 0,&quot;mipmaps&quot;: false,&quot;width&quot;: 0}">
Holds all the image's color data in a given format. See [enum Format] constants.
</member>
</members>
diff --git a/doc/classes/Input.xml b/doc/classes/Input.xml
index ebfd32c5fb..b970070659 100644
--- a/doc/classes/Input.xml
+++ b/doc/classes/Input.xml
@@ -123,7 +123,7 @@
</return>
<argument index="0" name="device" type="int">
</argument>
- <argument index="1" name="axis" type="int">
+ <argument index="1" name="axis" type="int" enum="JoyAxis">
</argument>
<description>
Returns the current value of the joypad axis at given index (see [enum JoyAxis]).
@@ -252,7 +252,7 @@
</return>
<argument index="0" name="device" type="int">
</argument>
- <argument index="1" name="button" type="int">
+ <argument index="1" name="button" type="int" enum="JoyButton">
</argument>
<description>
Returns [code]true[/code] if you are pressing the joypad button (see [enum JoyButton]).
@@ -279,7 +279,7 @@
<method name="is_mouse_button_pressed" qualifiers="const">
<return type="bool">
</return>
- <argument index="0" name="button" type="int">
+ <argument index="0" name="button" type="int" enum="MouseButton">
</argument>
<description>
Returns [code]true[/code] if you are pressing the mouse button specified with [enum MouseButton].
@@ -341,7 +341,7 @@
</argument>
<argument index="1" name="shape" type="int" enum="Input.CursorShape" default="0">
</argument>
- <argument index="2" name="hotspot" type="Vector2" default="Vector2( 0, 0 )">
+ <argument index="2" name="hotspot" type="Vector2" default="Vector2(0, 0)">
</argument>
<description>
Sets a custom mouse cursor image, which is only visible inside the game window. The hotspot can also be specified. Passing [code]null[/code] to the image parameter resets to the system cursor. See [enum CursorShape] for the list of shapes.
diff --git a/doc/classes/InputEvent.xml b/doc/classes/InputEvent.xml
index 28c4773f51..c28c4c4282 100644
--- a/doc/classes/InputEvent.xml
+++ b/doc/classes/InputEvent.xml
@@ -90,20 +90,23 @@
Returns [code]true[/code] if this input event is an echo event (only for events of type [InputEventKey]).
</description>
</method>
- <method name="is_pressed" qualifiers="const">
+ <method name="is_match" qualifiers="const">
<return type="bool">
</return>
+ <argument index="0" name="event" type="InputEvent">
+ </argument>
+ <argument index="1" name="exact_match" type="bool" default="true">
+ </argument>
<description>
- Returns [code]true[/code] if this input event is pressed. Not relevant for events of type [InputEventMouseMotion] or [InputEventScreenDrag].
+ Returns [code]true[/code] if the specified [code]event[/code] matches this event. Only valid for action events i.e key ([InputEventKey]), button ([InputEventMouseButton] or [InputEventJoypadButton]), axis [InputEventJoypadMotion] or action ([InputEventAction]) events.
+ If [code]exact_match[/code] is [code]false[/code], it ignores the input modifiers for [InputEventKey] and [InputEventMouseButton] events, and the direction for [InputEventJoypadMotion] events.
</description>
</method>
- <method name="shortcut_match" qualifiers="const">
+ <method name="is_pressed" qualifiers="const">
<return type="bool">
</return>
- <argument index="0" name="event" type="InputEvent">
- </argument>
<description>
- Returns [code]true[/code] if the given input event is checking for the same key ([InputEventKey]), button ([InputEventJoypadButton]) or action ([InputEventAction]).
+ Returns [code]true[/code] if this input event is pressed. Not relevant for events of type [InputEventMouseMotion] or [InputEventScreenDrag].
</description>
</method>
<method name="xformed_by" qualifiers="const">
@@ -111,7 +114,7 @@
</return>
<argument index="0" name="xform" type="Transform2D">
</argument>
- <argument index="1" name="local_ofs" type="Vector2" default="Vector2( 0, 0 )">
+ <argument index="1" name="local_ofs" type="Vector2" default="Vector2(0, 0)">
</argument>
<description>
Returns a copy of the given input event which has been offset by [code]local_ofs[/code] and transformed by [code]xform[/code]. Relevant for events of type [InputEventMouseButton], [InputEventMouseMotion], [InputEventScreenTouch], [InputEventScreenDrag], [InputEventMagnifyGesture] and [InputEventPanGesture].
diff --git a/doc/classes/InputEventGesture.xml b/doc/classes/InputEventGesture.xml
index 861ec026cd..fbde318ada 100644
--- a/doc/classes/InputEventGesture.xml
+++ b/doc/classes/InputEventGesture.xml
@@ -10,7 +10,7 @@
<methods>
</methods>
<members>
- <member name="position" type="Vector2" setter="set_position" getter="get_position" default="Vector2( 0, 0 )">
+ <member name="position" type="Vector2" setter="set_position" getter="get_position" default="Vector2(0, 0)">
The local gesture position relative to the [Viewport]. If used in [method Control._gui_input], the position is relative to the current [Control] that received this gesture.
</member>
</members>
diff --git a/doc/classes/InputEventJoypadButton.xml b/doc/classes/InputEventJoypadButton.xml
index b1f4836f6e..f9afe42a7a 100644
--- a/doc/classes/InputEventJoypadButton.xml
+++ b/doc/classes/InputEventJoypadButton.xml
@@ -12,7 +12,7 @@
<methods>
</methods>
<members>
- <member name="button_index" type="int" setter="set_button_index" getter="get_button_index" default="0">
+ <member name="button_index" type="int" setter="set_button_index" getter="get_button_index" enum="JoyButton" default="0">
Button identifier. One of the [enum JoyButton] button constants.
</member>
<member name="pressed" type="bool" setter="set_pressed" getter="is_pressed" default="false">
diff --git a/doc/classes/InputEventJoypadMotion.xml b/doc/classes/InputEventJoypadMotion.xml
index 39fdb14016..398b9eb6f6 100644
--- a/doc/classes/InputEventJoypadMotion.xml
+++ b/doc/classes/InputEventJoypadMotion.xml
@@ -12,7 +12,7 @@
<methods>
</methods>
<members>
- <member name="axis" type="int" setter="set_axis" getter="get_axis" default="0">
+ <member name="axis" type="int" setter="set_axis" getter="get_axis" enum="JoyAxis" default="0">
Axis identifier. Use one of the [enum JoyAxis] axis constants.
</member>
<member name="axis_value" type="float" setter="set_axis_value" getter="get_axis_value" default="0.0">
diff --git a/doc/classes/InputEventMIDI.xml b/doc/classes/InputEventMIDI.xml
index 13bb9d8b85..afc9d476da 100644
--- a/doc/classes/InputEventMIDI.xml
+++ b/doc/classes/InputEventMIDI.xml
@@ -17,7 +17,7 @@
</member>
<member name="instrument" type="int" setter="set_instrument" getter="get_instrument" default="0">
</member>
- <member name="message" type="int" setter="set_message" getter="get_message" default="0">
+ <member name="message" type="int" setter="set_message" getter="get_message" enum="MIDIMessage" default="0">
</member>
<member name="pitch" type="int" setter="set_pitch" getter="get_pitch" default="0">
</member>
diff --git a/doc/classes/InputEventMouse.xml b/doc/classes/InputEventMouse.xml
index e54c3224da..b8043118b7 100644
--- a/doc/classes/InputEventMouse.xml
+++ b/doc/classes/InputEventMouse.xml
@@ -15,10 +15,10 @@
<member name="button_mask" type="int" setter="set_button_mask" getter="get_button_mask" default="0">
The mouse button mask identifier, one of or a bitwise combination of the [enum MouseButton] button masks.
</member>
- <member name="global_position" type="Vector2" setter="set_global_position" getter="get_global_position" default="Vector2( 0, 0 )">
+ <member name="global_position" type="Vector2" setter="set_global_position" getter="get_global_position" default="Vector2(0, 0)">
The global mouse position relative to the current [Viewport] when used in [method Control._gui_input], otherwise is at 0,0.
</member>
- <member name="position" type="Vector2" setter="set_position" getter="get_position" default="Vector2( 0, 0 )">
+ <member name="position" type="Vector2" setter="set_position" getter="get_position" default="Vector2(0, 0)">
The local mouse position relative to the [Viewport]. If used in [method Control._gui_input], the position is relative to the current [Control] which is under the mouse.
</member>
</members>
diff --git a/doc/classes/InputEventMouseButton.xml b/doc/classes/InputEventMouseButton.xml
index be71b42567..7a6c7410ef 100644
--- a/doc/classes/InputEventMouseButton.xml
+++ b/doc/classes/InputEventMouseButton.xml
@@ -12,7 +12,7 @@
<methods>
</methods>
<members>
- <member name="button_index" type="int" setter="set_button_index" getter="get_button_index" default="0">
+ <member name="button_index" type="int" setter="set_button_index" getter="get_button_index" enum="MouseButton" default="0">
The mouse button identifier, one of the [enum MouseButton] button or button wheel constants.
</member>
<member name="double_click" type="bool" setter="set_double_click" getter="is_double_click" default="false">
diff --git a/doc/classes/InputEventMouseMotion.xml b/doc/classes/InputEventMouseMotion.xml
index 0f9e71adb4..881d74ac7b 100644
--- a/doc/classes/InputEventMouseMotion.xml
+++ b/doc/classes/InputEventMouseMotion.xml
@@ -17,14 +17,14 @@
<member name="pressure" type="float" setter="set_pressure" getter="get_pressure" default="0.0">
Represents the pressure the user puts on the pen. Ranges from [code]0.0[/code] to [code]1.0[/code].
</member>
- <member name="relative" type="Vector2" setter="set_relative" getter="get_relative" default="Vector2( 0, 0 )">
+ <member name="relative" type="Vector2" setter="set_relative" getter="get_relative" default="Vector2(0, 0)">
The mouse position relative to the previous position (position at the last frame).
[b]Note:[/b] Since [InputEventMouseMotion] is only emitted when the mouse moves, the last event won't have a relative position of [code]Vector2(0, 0)[/code] when the user stops moving the mouse.
</member>
- <member name="speed" type="Vector2" setter="set_speed" getter="get_speed" default="Vector2( 0, 0 )">
+ <member name="speed" type="Vector2" setter="set_speed" getter="get_speed" default="Vector2(0, 0)">
The mouse speed in pixels per second.
</member>
- <member name="tilt" type="Vector2" setter="set_tilt" getter="get_tilt" default="Vector2( 0, 0 )">
+ <member name="tilt" type="Vector2" setter="set_tilt" getter="get_tilt" default="Vector2(0, 0)">
Represents the angles of tilt of the pen. Positive X-coordinate value indicates a tilt to the right. Positive Y-coordinate value indicates a tilt toward the user. Ranges from [code]-1.0[/code] to [code]1.0[/code] for both axes.
</member>
</members>
diff --git a/doc/classes/InputEventPanGesture.xml b/doc/classes/InputEventPanGesture.xml
index 83161cd163..ffb1901dad 100644
--- a/doc/classes/InputEventPanGesture.xml
+++ b/doc/classes/InputEventPanGesture.xml
@@ -9,7 +9,7 @@
<methods>
</methods>
<members>
- <member name="delta" type="Vector2" setter="set_delta" getter="get_delta" default="Vector2( 0, 0 )">
+ <member name="delta" type="Vector2" setter="set_delta" getter="get_delta" default="Vector2(0, 0)">
</member>
</members>
<constants>
diff --git a/doc/classes/InputEventScreenDrag.xml b/doc/classes/InputEventScreenDrag.xml
index d69f175be8..079ac03f45 100644
--- a/doc/classes/InputEventScreenDrag.xml
+++ b/doc/classes/InputEventScreenDrag.xml
@@ -15,13 +15,13 @@
<member name="index" type="int" setter="set_index" getter="get_index" default="0">
The drag event index in the case of a multi-drag event.
</member>
- <member name="position" type="Vector2" setter="set_position" getter="get_position" default="Vector2( 0, 0 )">
+ <member name="position" type="Vector2" setter="set_position" getter="get_position" default="Vector2(0, 0)">
The drag position.
</member>
- <member name="relative" type="Vector2" setter="set_relative" getter="get_relative" default="Vector2( 0, 0 )">
+ <member name="relative" type="Vector2" setter="set_relative" getter="get_relative" default="Vector2(0, 0)">
The drag position relative to its start position.
</member>
- <member name="speed" type="Vector2" setter="set_speed" getter="get_speed" default="Vector2( 0, 0 )">
+ <member name="speed" type="Vector2" setter="set_speed" getter="get_speed" default="Vector2(0, 0)">
The drag speed.
</member>
</members>
diff --git a/doc/classes/InputEventScreenTouch.xml b/doc/classes/InputEventScreenTouch.xml
index f497f2fecc..7aa5f62b05 100644
--- a/doc/classes/InputEventScreenTouch.xml
+++ b/doc/classes/InputEventScreenTouch.xml
@@ -16,7 +16,7 @@
<member name="index" type="int" setter="set_index" getter="get_index" default="0">
The touch index in the case of a multi-touch event. One index = one finger.
</member>
- <member name="position" type="Vector2" setter="set_position" getter="get_position" default="Vector2( 0, 0 )">
+ <member name="position" type="Vector2" setter="set_position" getter="get_position" default="Vector2(0, 0)">
The touch position.
</member>
<member name="pressed" type="bool" setter="set_pressed" getter="is_pressed" default="false">
diff --git a/doc/classes/InstancePlaceholder.xml b/doc/classes/InstancePlaceholder.xml
index defd23afb1..934764b461 100644
--- a/doc/classes/InstancePlaceholder.xml
+++ b/doc/classes/InstancePlaceholder.xml
@@ -4,7 +4,7 @@
Placeholder for the root [Node] of a [PackedScene].
</brief_description>
<description>
- Turning on the option [b]Load As Placeholder[/b] for an instanced scene in the editor causes it to be replaced by an [InstancePlaceholder] when running the game. This makes it possible to delay actually loading the scene until calling [method create_instance]. This is useful to avoid loading large scenes all at once by loading parts of it selectively.
+ Turning on the option [b]Load As Placeholder[/b] for an instantiated scene in the editor causes it to be replaced by an [InstancePlaceholder] when running the game. This makes it possible to delay actually loading the scene until calling [method create_instance]. This is useful to avoid loading large scenes all at once by loading parts of it selectively.
The [InstancePlaceholder] does not have a transform. This causes any child nodes to be positioned relatively to the [Viewport] from point (0,0), rather than their parent as displayed in the editor. Replacing the placeholder with a scene with a transform will transform children relatively to their parent again.
</description>
<tutorials>
diff --git a/doc/classes/IntervalTweener.xml b/doc/classes/IntervalTweener.xml
new file mode 100644
index 0000000000..1c59003c70
--- /dev/null
+++ b/doc/classes/IntervalTweener.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="IntervalTweener" inherits="Tweener" version="4.0">
+ <brief_description>
+ Creates an idle interval in a [Tween] animation.
+ </brief_description>
+ <description>
+ [IntervalTweener] is used to make delays in a tweening sequence. See [method Tween.tween_interval] for more usage information.
+ [b]Note:[/b] [method Tween.tween_interval] is the only correct way to create [IntervalTweener]. Any [IntervalTweener] created manually will not function correctly.
+ </description>
+ <tutorials>
+ </tutorials>
+ <methods>
+ </methods>
+ <constants>
+ </constants>
+</class>
diff --git a/doc/classes/ItemList.xml b/doc/classes/ItemList.xml
index 0020cbf242..c639e0b88e 100644
--- a/doc/classes/ItemList.xml
+++ b/doc/classes/ItemList.xml
@@ -484,7 +484,7 @@
The width all columns will be adjusted to.
A value of zero disables the adjustment, each item will have a width equal to the width of its content and the columns will have an uneven width.
</member>
- <member name="fixed_icon_size" type="Vector2" setter="set_fixed_icon_size" getter="get_fixed_icon_size" default="Vector2( 0, 0 )">
+ <member name="fixed_icon_size" type="Vector2" setter="set_fixed_icon_size" getter="get_fixed_icon_size" default="Vector2(0, 0)">
The size all icons will be adjusted to.
If either X or Y component is not greater than zero, icon size won't be affected.
</member>
@@ -593,19 +593,19 @@
<theme_item name="font" type="Font">
[Font] of the item's text.
</theme_item>
- <theme_item name="font_color" type="Color" default="Color( 0.63, 0.63, 0.63, 1 )">
+ <theme_item name="font_color" type="Color" default="Color(0.63, 0.63, 0.63, 1)">
Default text [Color] of the item.
</theme_item>
- <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)">
The tint of text outline of the item.
</theme_item>
- <theme_item name="font_selected_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="font_selected_color" type="Color" default="Color(1, 1, 1, 1)">
Text [Color] used when the item is selected.
</theme_item>
<theme_item name="font_size" type="int">
Font size of the item's text.
</theme_item>
- <theme_item name="guide_color" type="Color" default="Color( 0, 0, 0, 0.1 )">
+ <theme_item name="guide_color" type="Color" default="Color(0, 0, 0, 0.1)">
[Color] of the guideline. The guideline is a line drawn between each row of items.
</theme_item>
<theme_item name="hseparation" type="int" default="4">
diff --git a/doc/classes/JSON.xml b/doc/classes/JSON.xml
index 7baff7aa39..b95aaed143 100644
--- a/doc/classes/JSON.xml
+++ b/doc/classes/JSON.xml
@@ -1,45 +1,88 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="JSON" inherits="Object" version="4.0">
+<class name="JSON" inherits="RefCounted" version="4.0">
<brief_description>
- Helper class for parsing JSON data.
+ Helper class for creating and parsing JSON data.
</brief_description>
<description>
- Helper class for parsing JSON data. For usage example and other important hints, see [JSONParseResult].
+ The [JSON] enables all data types to be converted to and from a JSON string. This useful for serializing data to save to a file or send over the network.
+ [method stringify] is used to convert any data type into a JSON string.
+ [method parse] is used to convert any existing JSON data into a [Variant] that can be used within Godot. If successfully parsed, use [method get_data] to retrieve the [Variant], and use [code]typeof[/code] to check if the Variant's type is what you expect. JSON Objects are converted into a [Dictionary], but JSON data can be used to store [Array]s, numbers, [String]s and even just a boolean.
+ [b]Example[/b]
+ [codeblock]
+ var data_to_send = ["a", "b", "c"]
+ var json = JSON.new()
+ var json_string = json.stringify(data_to_send)
+ # Save data
+ # ...
+ # Retrieve data
+ var error = json.parse(json_string)
+ if error == OK:
+ var data_received = json.get_data()
+ if typeof(data_received) == TYPE_ARRAY:
+ print(data_received) # Prints array
+ else:
+ print("Unexpected data")
+ else:
+ print("JSON Parse Error: ", json.get_error_message(), " in ", json_string, " at line ", json.get_error_line())
+ [/codeblock]
</description>
<tutorials>
</tutorials>
<methods>
+ <method name="get_data" qualifiers="const">
+ <return type="Variant">
+ </return>
+ <description>
+ Returns the [Variant] containing the data of a successful [method parse].
+ [b]Note:[/b] It will return [code]Null[/code] if the last call to parse was unsuccessful or [method parse] has not yet been called.
+ </description>
+ </method>
+ <method name="get_error_line" qualifiers="const">
+ <return type="int">
+ </return>
+ <description>
+ Returns [code]0[/code] if the last call to [method parse] was successful, or the line number where the parse failed.
+ </description>
+ </method>
+ <method name="get_error_message" qualifiers="const">
+ <return type="String">
+ </return>
+ <description>
+ Returns an empty string if the last call to [method parse] was successful, or the error message if it failed.
+ </description>
+ </method>
<method name="parse">
- <return type="JSONParseResult">
+ <return type="int" enum="Error">
</return>
- <argument index="0" name="json" type="String">
+ <argument index="0" name="json_string" type="String">
</argument>
<description>
- Parses a JSON-encoded string and returns a [JSONParseResult] containing the result.
+ Attempts to parse the [code]json_string[/code] provided.
+ Returns an [enum Error]. If the parse was successful, it returns [code]OK[/code] and the result can be retrieved using [method get_data]. If unsuccessful, use [method get_error_line] and [method get_error_message] for identifying the source of the failure.
</description>
</method>
- <method name="print">
+ <method name="stringify">
<return type="String">
</return>
- <argument index="0" name="value" type="Variant">
+ <argument index="0" name="data" type="Variant">
</argument>
<argument index="1" name="indent" type="String" default="&quot;&quot;">
</argument>
- <argument index="2" name="sort_keys" type="bool" default="false">
+ <argument index="2" name="sort_keys" type="bool" default="true">
</argument>
<argument index="3" name="full_precision" type="bool" default="false">
</argument>
<description>
Converts a [Variant] var to JSON text and returns the result. Useful for serializing data to store or send over the network.
[b]Note:[/b] The JSON specification does not define integer or float types, but only a [i]number[/i] type. Therefore, converting a Variant to JSON text will convert all numerical values to [float] types.
- [b]Note:[/b] If [code]full_precision[/code] is true, when printing floats, the unreliable digits are printed in addition to the reliable digits to guarantee exact decoding.
- Use [code]indent[/code] parameter to pretty print the output.
+ [b]Note:[/b] If [code]full_precision[/code] is true, when stringifying floats, the unreliable digits are stringified in addition to the reliable digits to guarantee exact decoding.
+ Use [code]indent[/code] parameter to pretty stringify the output.
[b]Example output:[/b]
[codeblock]
- ## JSON.print(my_dictionary)
+ ## JSON.stringify(my_dictionary)
{"name":"my_dictionary","version":"1.0.0","entities":[{"name":"entity_0","value":"value_0"},{"name":"entity_1","value":"value_1"}]}
- ## JSON.print(my_dictionary, "\t")
+ ## JSON.stringify(my_dictionary, "\t")
{
"name": "my_dictionary",
"version": "1.0.0",
diff --git a/doc/classes/JSONParseResult.xml b/doc/classes/JSONParseResult.xml
deleted file mode 100644
index 7311343b68..0000000000
--- a/doc/classes/JSONParseResult.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<class name="JSONParseResult" inherits="RefCounted" version="4.0">
- <brief_description>
- Data class wrapper for decoded JSON.
- </brief_description>
- <description>
- Returned by [method JSON.parse], [JSONParseResult] contains the decoded JSON or error information if the JSON source wasn't successfully parsed. You can check if the JSON source was successfully parsed with [code]if json_result.error == OK[/code].
- </description>
- <tutorials>
- </tutorials>
- <methods>
- </methods>
- <members>
- <member name="error" type="int" setter="set_error" getter="get_error" enum="Error">
- The error type if the JSON source was not successfully parsed. See the [enum Error] constants.
- </member>
- <member name="error_line" type="int" setter="set_error_line" getter="get_error_line" default="-1">
- The line number where the error occurred if the JSON source was not successfully parsed.
- </member>
- <member name="error_string" type="String" setter="set_error_string" getter="get_error_string" default="&quot;&quot;">
- The error message if the JSON source was not successfully parsed. See the [enum Error] constants.
- </member>
- <member name="result" type="Variant" setter="set_result" getter="get_result">
- A [Variant] containing the parsed JSON. Use [method @GlobalScope.typeof] or the [code]is[/code] keyword to check if it is what you expect. For example, if the JSON source starts with curly braces ([code]{}[/code]), a [Dictionary] will be returned. If the JSON source starts with brackets ([code][][/code]), an [Array] will be returned.
- [b]Note:[/b] The JSON specification does not define integer or float types, but only a [i]number[/i] type. Therefore, parsing a JSON text will convert all numerical values to [float] types.
- [b]Note:[/b] JSON objects do not preserve key order like Godot dictionaries, thus, you should not rely on keys being in a certain order if a dictionary is constructed from JSON. In contrast, JSON arrays retain the order of their elements:
- [codeblocks]
- [gdscript]
- var p = JSON.parse('["hello", "world", "!"]')
- if typeof(p.result) == TYPE_ARRAY:
- print(p.result[0]) # Prints "hello"
- else:
- push_error("Unexpected results.")
- [/gdscript]
- [csharp]
- JSONParseResult p = JSON.Parse("[\"hello\"], \"world\", \"!\"]");
- if (p.Result is Godot.Collections.Array)
- {
- GD.Print((p.Result as Godot.Collections.Array)[0]); // Prints "hello"
- }
- else
- {
- GD.PushError("Unexpected results.");
- }
- [/csharp]
- [/codeblocks]
- </member>
- </members>
- <constants>
- </constants>
-</class>
diff --git a/doc/classes/JSONParser.xml b/doc/classes/JSONParser.xml
deleted file mode 100644
index 991629f255..0000000000
--- a/doc/classes/JSONParser.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<class name="JSONParser" inherits="RefCounted" version="4.0">
- <brief_description>
- </brief_description>
- <description>
- </description>
- <tutorials>
- </tutorials>
- <methods>
- <method name="decode_data">
- <return type="int" enum="Error">
- </return>
- <argument index="0" name="data" type="Variant">
- </argument>
- <argument index="1" name="indent" type="String" default="&quot;&quot;">
- </argument>
- <argument index="2" name="sort_keys" type="bool" default="true">
- </argument>
- <description>
- </description>
- </method>
- <method name="get_data" qualifiers="const">
- <return type="Variant">
- </return>
- <description>
- </description>
- </method>
- <method name="get_error_line" qualifiers="const">
- <return type="int">
- </return>
- <description>
- </description>
- </method>
- <method name="get_error_text" qualifiers="const">
- <return type="String">
- </return>
- <description>
- </description>
- </method>
- <method name="get_string" qualifiers="const">
- <return type="String">
- </return>
- <description>
- </description>
- </method>
- <method name="parse_string">
- <return type="int" enum="Error">
- </return>
- <argument index="0" name="json_string" type="String">
- </argument>
- <description>
- </description>
- </method>
- </methods>
- <constants>
- </constants>
-</class>
diff --git a/doc/classes/KinematicCollision2D.xml b/doc/classes/KinematicCollision2D.xml
index 5480d7d55f..d7999f1aa0 100644
--- a/doc/classes/KinematicCollision2D.xml
+++ b/doc/classes/KinematicCollision2D.xml
@@ -21,28 +21,31 @@
<member name="collider_metadata" type="Variant" setter="" getter="get_collider_metadata">
The colliding body's metadata. See [Object].
</member>
+ <member name="collider_rid" type="RID" setter="" getter="get_collider_rid">
+ The colliding body's [RID] used by the [PhysicsServer2D].
+ </member>
<member name="collider_shape" type="Object" setter="" getter="get_collider_shape">
The colliding body's shape.
</member>
<member name="collider_shape_index" type="int" setter="" getter="get_collider_shape_index" default="0">
The colliding shape's index. See [CollisionObject2D].
</member>
- <member name="collider_velocity" type="Vector2" setter="" getter="get_collider_velocity" default="Vector2( 0, 0 )">
+ <member name="collider_velocity" type="Vector2" setter="" getter="get_collider_velocity" default="Vector2(0, 0)">
The colliding object's velocity.
</member>
<member name="local_shape" type="Object" setter="" getter="get_local_shape">
The moving object's colliding shape.
</member>
- <member name="normal" type="Vector2" setter="" getter="get_normal" default="Vector2( 0, 0 )">
+ <member name="normal" type="Vector2" setter="" getter="get_normal" default="Vector2(0, 0)">
The colliding body's shape's normal at the point of collision.
</member>
- <member name="position" type="Vector2" setter="" getter="get_position" default="Vector2( 0, 0 )">
+ <member name="position" type="Vector2" setter="" getter="get_position" default="Vector2(0, 0)">
The point of collision, in global coordinates.
</member>
- <member name="remainder" type="Vector2" setter="" getter="get_remainder" default="Vector2( 0, 0 )">
+ <member name="remainder" type="Vector2" setter="" getter="get_remainder" default="Vector2(0, 0)">
The moving object's remaining movement vector.
</member>
- <member name="travel" type="Vector2" setter="" getter="get_travel" default="Vector2( 0, 0 )">
+ <member name="travel" type="Vector2" setter="" getter="get_travel" default="Vector2(0, 0)">
The distance the moving object traveled before collision.
</member>
</members>
diff --git a/doc/classes/KinematicCollision3D.xml b/doc/classes/KinematicCollision3D.xml
index 329efab474..abdb5b4f4e 100644
--- a/doc/classes/KinematicCollision3D.xml
+++ b/doc/classes/KinematicCollision3D.xml
@@ -21,28 +21,31 @@
<member name="collider_metadata" type="Variant" setter="" getter="get_collider_metadata">
The colliding body's metadata. See [Object].
</member>
+ <member name="collider_rid" type="RID" setter="" getter="get_collider_rid">
+ The colliding body's [RID] used by the [PhysicsServer3D].
+ </member>
<member name="collider_shape" type="Object" setter="" getter="get_collider_shape">
The colliding body's shape.
</member>
<member name="collider_shape_index" type="int" setter="" getter="get_collider_shape_index" default="0">
The colliding shape's index. See [CollisionObject3D].
</member>
- <member name="collider_velocity" type="Vector3" setter="" getter="get_collider_velocity" default="Vector3( 0, 0, 0 )">
+ <member name="collider_velocity" type="Vector3" setter="" getter="get_collider_velocity" default="Vector3(0, 0, 0)">
The colliding object's velocity.
</member>
<member name="local_shape" type="Object" setter="" getter="get_local_shape">
The moving object's colliding shape.
</member>
- <member name="normal" type="Vector3" setter="" getter="get_normal" default="Vector3( 0, 0, 0 )">
+ <member name="normal" type="Vector3" setter="" getter="get_normal" default="Vector3(0, 0, 0)">
The colliding body's shape's normal at the point of collision.
</member>
- <member name="position" type="Vector3" setter="" getter="get_position" default="Vector3( 0, 0, 0 )">
+ <member name="position" type="Vector3" setter="" getter="get_position" default="Vector3(0, 0, 0)">
The point of collision, in global coordinates.
</member>
- <member name="remainder" type="Vector3" setter="" getter="get_remainder" default="Vector3( 0, 0, 0 )">
+ <member name="remainder" type="Vector3" setter="" getter="get_remainder" default="Vector3(0, 0, 0)">
The moving object's remaining movement vector.
</member>
- <member name="travel" type="Vector3" setter="" getter="get_travel" default="Vector3( 0, 0, 0 )">
+ <member name="travel" type="Vector3" setter="" getter="get_travel" default="Vector3(0, 0, 0)">
The distance the moving object traveled before collision.
</member>
</members>
diff --git a/doc/classes/Label.xml b/doc/classes/Label.xml
index 76b9686393..ee59f0c85a 100644
--- a/doc/classes/Label.xml
+++ b/doc/classes/Label.xml
@@ -98,7 +98,7 @@
<member name="structured_text_bidi_override" type="int" setter="set_structured_text_bidi_override" getter="get_structured_text_bidi_override" enum="Control.StructuredTextParser" default="0">
Set BiDi algorithm override for the structured text.
</member>
- <member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" default="[ ]">
+ <member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" default="[]">
Set additional options for BiDi override.
</member>
<member name="text" type="String" setter="set_text" getter="get_text" default="&quot;&quot;">
@@ -147,13 +147,13 @@
<theme_item name="font" type="Font">
[Font] used for the [Label]'s text.
</theme_item>
- <theme_item name="font_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="font_color" type="Color" default="Color(1, 1, 1, 1)">
Default text [Color] of the [Label].
</theme_item>
- <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)">
The tint of [Font]'s outline.
</theme_item>
- <theme_item name="font_shadow_color" type="Color" default="Color( 0, 0, 0, 0 )">
+ <theme_item name="font_shadow_color" type="Color" default="Color(0, 0, 0, 0)">
[Color] of the text's shadow effect.
</theme_item>
<theme_item name="font_size" type="int">
diff --git a/doc/classes/Light2D.xml b/doc/classes/Light2D.xml
index f6698352ab..0e71f29b58 100644
--- a/doc/classes/Light2D.xml
+++ b/doc/classes/Light2D.xml
@@ -30,7 +30,7 @@
<member name="blend_mode" type="int" setter="set_blend_mode" getter="get_blend_mode" enum="Light2D.BlendMode" default="0">
The Light2D's blend mode. See [enum BlendMode] constants for values.
</member>
- <member name="color" type="Color" setter="set_color" getter="get_color" default="Color( 1, 1, 1, 1 )">
+ <member name="color" type="Color" setter="set_color" getter="get_color" default="Color(1, 1, 1, 1)">
The Light2D's [Color].
</member>
<member name="editor_only" type="bool" setter="set_editor_only" getter="is_editor_only" default="false">
@@ -57,7 +57,7 @@
<member name="range_z_min" type="int" setter="set_z_range_min" getter="get_z_range_min" default="-1024">
Minimum [code]z[/code] value of objects that are affected by the Light2D.
</member>
- <member name="shadow_color" type="Color" setter="set_shadow_color" getter="get_shadow_color" default="Color( 0, 0, 0, 0 )">
+ <member name="shadow_color" type="Color" setter="set_shadow_color" getter="get_shadow_color" default="Color(0, 0, 0, 0)">
[Color] of shadows cast by the Light2D.
</member>
<member name="shadow_enabled" type="bool" setter="set_shadow_enabled" getter="is_shadow_enabled" default="false">
diff --git a/doc/classes/Light3D.xml b/doc/classes/Light3D.xml
index 42b9ed8ab4..815d20223d 100644
--- a/doc/classes/Light3D.xml
+++ b/doc/classes/Light3D.xml
@@ -4,7 +4,7 @@
Provides a base class for different kinds of light nodes.
</brief_description>
<description>
- Light3D is the [i]abstract[/i] base class for light nodes. As it can't be instanced, it shouldn't be used directly. Other types of light nodes inherit from it. Light3D contains the common variables and parameters used for lighting.
+ Light3D is the [i]abstract[/i] base class for light nodes. As it can't be instantiated, it shouldn't be used directly. Other types of light nodes inherit from it. Light3D contains the common variables and parameters used for lighting.
</description>
<tutorials>
<link title="3D lights and shadows">https://docs.godotengine.org/en/latest/tutorials/3d/lights_and_shadows.html</link>
@@ -42,7 +42,7 @@
<member name="light_bake_mode" type="int" setter="set_bake_mode" getter="get_bake_mode" enum="Light3D.BakeMode" default="1">
The light's bake mode. See [enum BakeMode].
</member>
- <member name="light_color" type="Color" setter="set_color" getter="get_color" default="Color( 1, 1, 1, 1 )">
+ <member name="light_color" type="Color" setter="set_color" getter="get_color" default="Color(1, 1, 1, 1)">
The light's color. An [i]overbright[/i] color can be used to achieve a result equivalent to increasing the light's [member light_energy].
</member>
<member name="light_cull_mask" type="int" setter="set_cull_mask" getter="get_cull_mask" default="4294967295">
@@ -72,7 +72,7 @@
<member name="shadow_blur" type="float" setter="set_param" getter="get_param" default="1.0">
Blurs the edges of the shadow. Can be used to hide pixel artifacts in low-resolution shadow maps. A high value can impact performance, make shadows appear grainy and can cause other unwanted artifacts. Try to keep as near default as possible.
</member>
- <member name="shadow_color" type="Color" setter="set_shadow_color" getter="get_shadow_color" default="Color( 0, 0, 0, 1 )">
+ <member name="shadow_color" type="Color" setter="set_shadow_color" getter="get_shadow_color" default="Color(0, 0, 0, 1)">
The color of shadows cast by this light.
</member>
<member name="shadow_enabled" type="bool" setter="set_shadow" getter="has_shadow" default="false">
diff --git a/doc/classes/Line2D.xml b/doc/classes/Line2D.xml
index dec5d60cbb..587d5833b9 100644
--- a/doc/classes/Line2D.xml
+++ b/doc/classes/Line2D.xml
@@ -74,7 +74,7 @@
<member name="begin_cap_mode" type="int" setter="set_begin_cap_mode" getter="get_begin_cap_mode" enum="Line2D.LineCapMode" default="0">
Controls the style of the line's first point. Use [enum LineCapMode] constants.
</member>
- <member name="default_color" type="Color" setter="set_default_color" getter="get_default_color" default="Color( 1, 1, 1, 1 )">
+ <member name="default_color" type="Color" setter="set_default_color" getter="get_default_color" default="Color(1, 1, 1, 1)">
The line's color. Will not be used if a gradient is set.
</member>
<member name="end_cap_mode" type="int" setter="set_end_cap_mode" getter="get_end_cap_mode" enum="Line2D.LineCapMode" default="0">
@@ -86,7 +86,7 @@
<member name="joint_mode" type="int" setter="set_joint_mode" getter="get_joint_mode" enum="Line2D.LineJointMode" default="0">
The style for the points between the start and the end.
</member>
- <member name="points" type="PackedVector2Array" setter="set_points" getter="get_points" default="PackedVector2Array( )">
+ <member name="points" type="PackedVector2Array" setter="set_points" getter="get_points" default="PackedVector2Array()">
The points that form the lines. The line is drawn between every point set in this array. Points are interpreted as local vectors.
</member>
<member name="round_precision" type="int" setter="set_round_precision" getter="get_round_precision" default="8">
diff --git a/doc/classes/LineEdit.xml b/doc/classes/LineEdit.xml
index e11ae7969a..f1e7c5f6e1 100644
--- a/doc/classes/LineEdit.xml
+++ b/doc/classes/LineEdit.xml
@@ -221,7 +221,7 @@
<member name="structured_text_bidi_override" type="int" setter="set_structured_text_bidi_override" getter="get_structured_text_bidi_override" enum="Control.StructuredTextParser" default="0">
Set BiDi algorithm override for the structured text.
</member>
- <member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" default="[ ]">
+ <member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" default="[]">
Set additional options for BiDi override.
</member>
<member name="text" type="String" setter="set_text" getter="get_text" default="&quot;&quot;">
@@ -359,16 +359,16 @@
</constant>
</constants>
<theme_items>
- <theme_item name="caret_color" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )">
+ <theme_item name="caret_color" type="Color" default="Color(0.94, 0.94, 0.94, 1)">
Color of the [LineEdit]'s caret (text cursor).
</theme_item>
<theme_item name="clear" type="Texture2D">
Texture for the clear button. See [member clear_button_enabled].
</theme_item>
- <theme_item name="clear_button_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )">
+ <theme_item name="clear_button_color" type="Color" default="Color(0.88, 0.88, 0.88, 1)">
Color used as default tint for the clear button.
</theme_item>
- <theme_item name="clear_button_color_pressed" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="clear_button_color_pressed" type="Color" default="Color(1, 1, 1, 1)">
Color used for the clear button when it's pressed.
</theme_item>
<theme_item name="focus" type="StyleBox">
@@ -377,19 +377,19 @@
<theme_item name="font" type="Font">
Font used for the text.
</theme_item>
- <theme_item name="font_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )">
+ <theme_item name="font_color" type="Color" default="Color(0.88, 0.88, 0.88, 1)">
Default font color.
</theme_item>
- <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)">
The tint of text outline of the [LineEdit].
</theme_item>
- <theme_item name="font_selected_color" type="Color" default="Color( 0, 0, 0, 1 )">
+ <theme_item name="font_selected_color" type="Color" default="Color(0, 0, 0, 1)">
Font color for selected text (inside the selection rectangle).
</theme_item>
<theme_item name="font_size" type="int">
Font size of the [LineEdit]'s text.
</theme_item>
- <theme_item name="font_uneditable_color" type="Color" default="Color( 0.88, 0.88, 0.88, 0.5 )">
+ <theme_item name="font_uneditable_color" type="Color" default="Color(0.88, 0.88, 0.88, 0.5)">
Font color when editing is disabled.
</theme_item>
<theme_item name="minimum_character_width" type="int" default="4">
@@ -404,7 +404,7 @@
<theme_item name="read_only" type="StyleBox">
Background used when [LineEdit] is in read-only mode ([member editable] is set to [code]false[/code]).
</theme_item>
- <theme_item name="selection_color" type="Color" default="Color( 0.49, 0.49, 0.49, 1 )">
+ <theme_item name="selection_color" type="Color" default="Color(0.49, 0.49, 0.49, 1)">
Color of the selection rectangle.
</theme_item>
</theme_items>
diff --git a/doc/classes/LineShape2D.xml b/doc/classes/LineShape2D.xml
index 58caf1b1de..434e6fba8e 100644
--- a/doc/classes/LineShape2D.xml
+++ b/doc/classes/LineShape2D.xml
@@ -14,8 +14,8 @@
<member name="distance" type="float" setter="set_distance" getter="get_distance" default="0.0">
The line's distance from the origin.
</member>
- <member name="normal" type="Vector2" setter="set_normal" getter="get_normal" default="Vector2( 0, 1 )">
- The line's normal.
+ <member name="normal" type="Vector2" setter="set_normal" getter="get_normal" default="Vector2(0, -1)">
+ The line's normal. Defaults to [code]Vector2.UP[/code].
</member>
</members>
<constants>
diff --git a/doc/classes/LinkButton.xml b/doc/classes/LinkButton.xml
index 6e2f4399b3..51b20cd04d 100644
--- a/doc/classes/LinkButton.xml
+++ b/doc/classes/LinkButton.xml
@@ -47,7 +47,7 @@
<member name="structured_text_bidi_override" type="int" setter="set_structured_text_bidi_override" getter="get_structured_text_bidi_override" enum="Control.StructuredTextParser" default="0">
Set BiDi algorithm override for the structured text.
</member>
- <member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" default="[ ]">
+ <member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" default="[]">
Set additional options for BiDi override.
</member>
<member name="text" type="String" setter="set_text" getter="get_text" default="&quot;&quot;">
@@ -78,16 +78,16 @@
<theme_item name="font" type="Font">
[Font] of the [LinkButton]'s text.
</theme_item>
- <theme_item name="font_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )">
+ <theme_item name="font_color" type="Color" default="Color(0.88, 0.88, 0.88, 1)">
Default text [Color] of the [LinkButton].
</theme_item>
- <theme_item name="font_hover_color" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )">
+ <theme_item name="font_hover_color" type="Color" default="Color(0.94, 0.94, 0.94, 1)">
Text [Color] used when the [LinkButton] is being hovered.
</theme_item>
- <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)">
The tint of text outline of the [LinkButton].
</theme_item>
- <theme_item name="font_pressed_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="font_pressed_color" type="Color" default="Color(1, 1, 1, 1)">
Text [Color] used when the [LinkButton] is being pressed.
</theme_item>
<theme_item name="font_size" type="int">
diff --git a/doc/classes/MenuButton.xml b/doc/classes/MenuButton.xml
index 7cbf9d3dfe..3b37853d70 100644
--- a/doc/classes/MenuButton.xml
+++ b/doc/classes/MenuButton.xml
@@ -56,19 +56,19 @@
<theme_item name="font" type="Font">
[Font] of the [MenuButton]'s text.
</theme_item>
- <theme_item name="font_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )">
+ <theme_item name="font_color" type="Color" default="Color(0.88, 0.88, 0.88, 1)">
Default text [Color] of the [MenuButton].
</theme_item>
- <theme_item name="font_disabled_color" type="Color" default="Color( 1, 1, 1, 0.3 )">
+ <theme_item name="font_disabled_color" type="Color" default="Color(1, 1, 1, 0.3)">
Text [Color] used when the [MenuButton] is disabled.
</theme_item>
- <theme_item name="font_hover_color" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )">
+ <theme_item name="font_hover_color" type="Color" default="Color(0.94, 0.94, 0.94, 1)">
Text [Color] used when the [MenuButton] is being hovered.
</theme_item>
- <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)">
The tint of text outline of the [MenuButton].
</theme_item>
- <theme_item name="font_pressed_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="font_pressed_color" type="Color" default="Color(1, 1, 1, 1)">
Text [Color] used when the [MenuButton] is being pressed.
</theme_item>
<theme_item name="font_size" type="int">
diff --git a/doc/classes/Mesh.xml b/doc/classes/Mesh.xml
index ed7c39d4d9..3bbdfbe62e 100644
--- a/doc/classes/Mesh.xml
+++ b/doc/classes/Mesh.xml
@@ -106,7 +106,7 @@
</method>
</methods>
<members>
- <member name="lightmap_size_hint" type="Vector2i" setter="set_lightmap_size_hint" getter="get_lightmap_size_hint" default="Vector2i( 0, 0 )">
+ <member name="lightmap_size_hint" type="Vector2i" setter="set_lightmap_size_hint" getter="get_lightmap_size_hint" default="Vector2i(0, 0)">
Sets a hint to be used for lightmap resolution.
</member>
</members>
diff --git a/doc/classes/MeshInstance3D.xml b/doc/classes/MeshInstance3D.xml
index b5ab296bd0..7c4e75793e 100644
--- a/doc/classes/MeshInstance3D.xml
+++ b/doc/classes/MeshInstance3D.xml
@@ -4,7 +4,7 @@
Node that instances meshes into a scenario.
</brief_description>
<description>
- MeshInstance3D is a node that takes a [Mesh] resource and adds it to the current scenario by creating an instance of it. This is the class most often used render 3D geometry and can be used to instance a single [Mesh] in many places. This allows reuse of geometry which can save on resources. When a [Mesh] has to be instanced more than thousands of times at close proximity, consider using a [MultiMesh] in a [MultiMeshInstance3D] instead.
+ MeshInstance3D is a node that takes a [Mesh] resource and adds it to the current scenario by creating an instance of it. This is the class most often used render 3D geometry and can be used to instance a single [Mesh] in many places. This allows reuse of geometry which can save on resources. When a [Mesh] has to be instantiated more than thousands of times at close proximity, consider using a [MultiMesh] in a [MultiMeshInstance3D] instead.
</description>
<tutorials>
<link title="3D Material Testers Demo">https://godotengine.org/asset-library/asset/123</link>
diff --git a/doc/classes/MeshTexture.xml b/doc/classes/MeshTexture.xml
index bcc9adf90f..57f2397874 100644
--- a/doc/classes/MeshTexture.xml
+++ b/doc/classes/MeshTexture.xml
@@ -14,7 +14,7 @@
<member name="base_texture" type="Texture2D" setter="set_base_texture" getter="get_base_texture">
Sets the base texture that the Mesh will use to draw.
</member>
- <member name="image_size" type="Vector2" setter="set_image_size" getter="get_image_size" default="Vector2( 0, 0 )">
+ <member name="image_size" type="Vector2" setter="set_image_size" getter="get_image_size" default="Vector2(0, 0)">
Sets the size of the image, needed for reference.
</member>
<member name="mesh" type="Mesh" setter="set_mesh" getter="get_mesh">
diff --git a/doc/classes/MethodTweener.xml b/doc/classes/MethodTweener.xml
new file mode 100644
index 0000000000..42b91abf93
--- /dev/null
+++ b/doc/classes/MethodTweener.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="MethodTweener" inherits="Tweener" version="4.0">
+ <brief_description>
+ Interpolates an abstract value and supplies it to a method called over time.
+ </brief_description>
+ <description>
+ [MethodTweener] is similar to a combination of [CallbackTweener] and [PropertyTweener]. It calls a method providing an interpolated value as a paramater. See [method Tween.tween_method] for more usage information.
+ [b]Note:[/b] [method Tween.tween_method] is the only correct way to create [MethodTweener]. Any [MethodTweener] created manually will not function correctly.
+ </description>
+ <tutorials>
+ </tutorials>
+ <methods>
+ <method name="set_delay">
+ <return type="MethodTweener">
+ </return>
+ <argument index="0" name="delay" type="float">
+ </argument>
+ <description>
+ Sets the time in seconds after which the [MethodTweener] will start interpolating. By default there's no delay.
+ </description>
+ </method>
+ <method name="set_ease">
+ <return type="MethodTweener">
+ </return>
+ <argument index="0" name="ease" type="int" enum="Tween.EaseType">
+ </argument>
+ <description>
+ Sets the type of used easing from [enum Tween.EaseType]. If not set, the default easing is used from the [Tween] that contains this Tweener.
+ </description>
+ </method>
+ <method name="set_trans">
+ <return type="MethodTweener">
+ </return>
+ <argument index="0" name="trans" type="int" enum="Tween.TransitionType">
+ </argument>
+ <description>
+ Sets the type of used transition from [enum Tween.TransitionType]. If not set, the default transition is used from the [Tween] that contains this Tweener.
+ </description>
+ </method>
+ </methods>
+ <constants>
+ </constants>
+</class>
diff --git a/doc/classes/MultiMesh.xml b/doc/classes/MultiMesh.xml
index 02628f4960..7151e58c5f 100644
--- a/doc/classes/MultiMesh.xml
+++ b/doc/classes/MultiMesh.xml
@@ -105,7 +105,7 @@
</method>
</methods>
<members>
- <member name="buffer" type="PackedFloat32Array" setter="set_buffer" getter="get_buffer" default="PackedFloat32Array( )">
+ <member name="buffer" type="PackedFloat32Array" setter="set_buffer" getter="get_buffer" default="PackedFloat32Array()">
</member>
<member name="color_array" type="PackedColorArray" setter="_set_color_array" getter="_get_color_array">
</member>
diff --git a/doc/classes/NativeExtension.xml b/doc/classes/NativeExtension.xml
new file mode 100644
index 0000000000..c48af7df7b
--- /dev/null
+++ b/doc/classes/NativeExtension.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="NativeExtension" inherits="RefCounted" version="4.0">
+ <brief_description>
+ </brief_description>
+ <description>
+ </description>
+ <tutorials>
+ </tutorials>
+ <methods>
+ <method name="close_library">
+ <return type="void">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_minimum_library_initialization_level" qualifiers="const">
+ <return type="int" enum="NativeExtension.InitializationLevel">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="initialize_library">
+ <return type="void">
+ </return>
+ <argument index="0" name="level" type="int" enum="NativeExtension.InitializationLevel">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="is_library_open" qualifiers="const">
+ <return type="bool">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="open_library">
+ <return type="int" enum="Error">
+ </return>
+ <argument index="0" name="path" type="String">
+ </argument>
+ <argument index="1" name="entry_symbol" type="String">
+ </argument>
+ <description>
+ </description>
+ </method>
+ </methods>
+ <constants>
+ <constant name="INITIALIZATION_LEVEL_CORE" value="0" enum="InitializationLevel">
+ </constant>
+ <constant name="INITIALIZATION_LEVEL_SERVERS" value="1" enum="InitializationLevel">
+ </constant>
+ <constant name="INITIALIZATION_LEVEL_SCENE" value="2" enum="InitializationLevel">
+ </constant>
+ <constant name="INITIALIZATION_LEVEL_EDITOR" value="3" enum="InitializationLevel">
+ </constant>
+ </constants>
+</class>
diff --git a/doc/classes/NativeExtensionManager.xml b/doc/classes/NativeExtensionManager.xml
new file mode 100644
index 0000000000..ba9018ff4c
--- /dev/null
+++ b/doc/classes/NativeExtensionManager.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="NativeExtensionManager" inherits="Object" version="4.0">
+ <brief_description>
+ </brief_description>
+ <description>
+ </description>
+ <tutorials>
+ </tutorials>
+ <methods>
+ <method name="get_extension">
+ <return type="NativeExtension">
+ </return>
+ <argument index="0" name="path" type="String">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="get_loaded_extensions" qualifiers="const">
+ <return type="PackedStringArray">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="load_extension">
+ <return type="int" enum="NativeExtensionManager.LoadStatus">
+ </return>
+ <argument index="0" name="path" type="String">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="reload_extension">
+ <return type="int" enum="NativeExtensionManager.LoadStatus">
+ </return>
+ <argument index="0" name="path" type="String">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="unload_extension">
+ <return type="int" enum="NativeExtensionManager.LoadStatus">
+ </return>
+ <argument index="0" name="path" type="String">
+ </argument>
+ <description>
+ </description>
+ </method>
+ </methods>
+ <constants>
+ <constant name="LOAD_STATUS_OK" value="0" enum="LoadStatus">
+ </constant>
+ <constant name="LOAD_STATUS_FAILED" value="1" enum="LoadStatus">
+ </constant>
+ <constant name="LOAD_STATUS_ALREADY_LOADED" value="2" enum="LoadStatus">
+ </constant>
+ <constant name="LOAD_STATUS_NOT_LOADED" value="3" enum="LoadStatus">
+ </constant>
+ <constant name="LOAD_STATUS_NEEDS_RESTART" value="4" enum="LoadStatus">
+ </constant>
+ </constants>
+</class>
diff --git a/doc/classes/NinePatchRect.xml b/doc/classes/NinePatchRect.xml
index d6de0ef4cf..5d59f994d3 100644
--- a/doc/classes/NinePatchRect.xml
+++ b/doc/classes/NinePatchRect.xml
@@ -53,7 +53,7 @@
<member name="patch_margin_top" type="int" setter="set_patch_margin" getter="get_patch_margin" default="0">
The height of the 9-slice's top row. A margin of 16 means the 9-slice's top corners and side will have a height of 16 pixels. You can set all 4 margin values individually to create panels with non-uniform borders.
</member>
- <member name="region_rect" type="Rect2" setter="set_region_rect" getter="get_region_rect" default="Rect2( 0, 0, 0, 0 )">
+ <member name="region_rect" type="Rect2" setter="set_region_rect" getter="get_region_rect" default="Rect2(0, 0, 0, 0)">
Rectangular region of the texture to sample from. If you're working with an atlas, use this property to define the area the 9-slice should use. All other properties are relative to this one. If the rect is empty, NinePatchRect will use the whole texture.
</member>
<member name="texture" type="Texture2D" setter="set_texture" getter="get_texture">
diff --git a/doc/classes/Node.xml b/doc/classes/Node.xml
index 653fc1b059..f185a2bc57 100644
--- a/doc/classes/Node.xml
+++ b/doc/classes/Node.xml
@@ -5,13 +5,13 @@
</brief_description>
<description>
Nodes are Godot's building blocks. They can be assigned as the child of another node, resulting in a tree arrangement. A given node can contain any number of nodes as children with the requirement that all siblings (direct children of a node) should have unique names.
- A tree of nodes is called a [i]scene[/i]. Scenes can be saved to the disk and then instanced into other scenes. This allows for very high flexibility in the architecture and data model of Godot projects.
+ A tree of nodes is called a [i]scene[/i]. Scenes can be saved to the disk and then instantiated into other scenes. This allows for very high flexibility in the architecture and data model of Godot projects.
[b]Scene tree:[/b] The [SceneTree] contains the active tree of nodes. When a node is added to the scene tree, it receives the [constant NOTIFICATION_ENTER_TREE] notification and its [method _enter_tree] callback is triggered. Child nodes are always added [i]after[/i] their parent node, i.e. the [method _enter_tree] callback of a parent node will be triggered before its child's.
Once all nodes have been added in the scene tree, they receive the [constant NOTIFICATION_READY] notification and their respective [method _ready] callbacks are triggered. For groups of nodes, the [method _ready] callback is called in reverse order, starting with the children and moving up to the parent nodes.
This means that when adding a node to the scene tree, the following order will be used for the callbacks: [method _enter_tree] of the parent, [method _enter_tree] of the children, [method _ready] of the children and finally [method _ready] of the parent (recursively for the entire scene tree).
[b]Processing:[/b] Nodes can override the "process" state, so that they receive a callback on each frame requesting them to process (do something). Normal processing (callback [method _process], toggled with [method set_process]) happens as fast as possible and is dependent on the frame rate, so the processing time [i]delta[/i] (in seconds) is passed as an argument. Physics processing (callback [method _physics_process], toggled with [method set_physics_process]) happens a fixed number of times per second (60 by default) and is useful for code related to the physics engine.
Nodes can also process input events. When present, the [method _input] function will be called for each input that the program receives. In many cases, this can be overkill (unless used for simple projects), and the [method _unhandled_input] function might be preferred; it is called when the input event was not handled by anyone else (typically, GUI [Control] nodes), ensuring that the node only receives the events that were meant for it.
- To keep track of the scene hierarchy (especially when instancing scenes into other scenes), an "owner" can be set for the node with the [member owner] property. This keeps track of who instanced what. This is mostly useful when writing editors and tools, though.
+ To keep track of the scene hierarchy (especially when instancing scenes into other scenes), an "owner" can be set for the node with the [member owner] property. This keeps track of who instantiated what. This is mostly useful when writing editors and tools, though.
Finally, when a node is freed with [method Object.free] or [method queue_free], it will also free all its children.
[b]Groups:[/b] Nodes can be added to as many groups as you want to be easy to manage, you could create groups like "enemies" or "collectables" for example, depending on your game. See [method add_to_group], [method is_in_group] and [method remove_from_group]. You can then retrieve all nodes in these groups, iterate them and even call methods on groups via the methods on [SceneTree].
[b]Networking with nodes:[/b] After connecting to a server (or making one, see [NetworkedMultiplayerENet]), it is possible to use the built-in RPC (remote procedure call) system to communicate over the network. By calling [method rpc] with a method name, it will be called locally and in all connected peers (peers = clients and the server that accepts connections). To identify which node receives the RPC call, Godot will use its [NodePath] (make sure node names are the same on all peers). Also, take a look at the high-level networking tutorial and corresponding demos.
@@ -128,7 +128,7 @@
</argument>
<description>
Adds a child node. Nodes can have any number of children, but every child must have a unique name. Child nodes are automatically deleted when the parent node is deleted, so an entire scene can be removed by deleting its topmost node.
- If [code]legible_unique_name[/code] is [code]true[/code], the child node will have a human-readable name based on the name of the node being instanced instead of its type.
+ If [code]legible_unique_name[/code] is [code]true[/code], the child node will have a human-readable name based on the name of the node being instantiated instead of its type.
[b]Note:[/b] If the child node already has a parent, the function will fail. Use [method remove_child] first to remove the node from its current parent. For example:
[codeblocks]
[gdscript]
@@ -159,7 +159,7 @@
</argument>
<description>
Adds a [code]sibling[/code] node to current's node parent, at the same level as that node, right below it.
- If [code]legible_unique_name[/code] is [code]true[/code], the child node will have a human-readable name based on the name of the node being instanced instead of its type.
+ If [code]legible_unique_name[/code] is [code]true[/code], the child node will have a human-readable name based on the name of the node being instantiated instead of its type.
Use [method add_child] instead of this method if you don't need the child node to be added below a specific node in the list of children.
</description>
</method>
@@ -182,6 +182,16 @@
Returns [code]true[/code] if the node can process while the scene tree is paused (see [member process_mode]). Always returns [code]true[/code] if the scene tree is not paused, and [code]false[/code] if the node is not in the tree.
</description>
</method>
+ <method name="create_tween">
+ <return type="Tween">
+ </return>
+ <description>
+ Creates a new [Tween] and binds it to this node. This is equivalent of doing:
+ [codeblock]
+ get_tree().create_tween().bind_node(self)
+ [/codeblock]
+ </description>
+ </method>
<method name="duplicate" qualifiers="const">
<return type="Node">
</return>
@@ -568,7 +578,7 @@
</return>
<argument index="0" name="method" type="StringName">
</argument>
- <argument index="1" name="args" type="Array" default="[ ]">
+ <argument index="1" name="args" type="Array" default="[]">
</argument>
<argument index="2" name="parent_first" type="bool" default="false">
</argument>
@@ -795,7 +805,7 @@
The override to the default [MultiplayerAPI]. Set to [code]null[/code] to use the default [SceneTree] one.
</member>
<member name="filename" type="String" setter="set_filename" getter="get_filename">
- When a scene is instanced from a file, its topmost node contains the filename from which it was loaded.
+ When a scene is instantiated from a file, its topmost node contains the filename from which it was loaded.
</member>
<member name="multiplayer" type="MultiplayerAPI" setter="" getter="get_multiplayer">
The [MultiplayerAPI] instance associated with this node. Either the [member custom_multiplayer], or the default SceneTree one (if inside tree).
@@ -874,7 +884,7 @@
Notification received when a node is unparented (parent removed it from the list of children).
</constant>
<constant name="NOTIFICATION_INSTANCED" value="20">
- Notification received when the node is instanced.
+ Notification received when the node is instantiated.
</constant>
<constant name="NOTIFICATION_DRAG_BEGIN" value="21">
Notification received when a drag begins.
diff --git a/doc/classes/Node2D.xml b/doc/classes/Node2D.xml
index 8ca945418c..cc99abf9cb 100644
--- a/doc/classes/Node2D.xml
+++ b/doc/classes/Node2D.xml
@@ -131,7 +131,7 @@
<member name="global_transform" type="Transform2D" setter="set_global_transform" getter="get_global_transform">
Global [Transform2D].
</member>
- <member name="position" type="Vector2" setter="set_position" getter="get_position" default="Vector2( 0, 0 )">
+ <member name="position" type="Vector2" setter="set_position" getter="get_position" default="Vector2(0, 0)">
Position, relative to the node's parent.
</member>
<member name="rotation" type="float" setter="set_rotation" getter="get_rotation" default="0.0">
@@ -140,7 +140,7 @@
<member name="rotation_degrees" type="float" setter="set_rotation_degrees" getter="get_rotation_degrees" default="0.0">
Rotation in degrees, relative to the node's parent.
</member>
- <member name="scale" type="Vector2" setter="set_scale" getter="get_scale" default="Vector2( 1, 1 )">
+ <member name="scale" type="Vector2" setter="set_scale" getter="get_scale" default="Vector2(1, 1)">
The node's scale. Unscaled value: [code](1, 1)[/code].
</member>
<member name="skew" type="float" setter="set_skew" getter="get_skew" default="0.0">
diff --git a/doc/classes/Node3D.xml b/doc/classes/Node3D.xml
index 1c161803db..2dc8659d5d 100644
--- a/doc/classes/Node3D.xml
+++ b/doc/classes/Node3D.xml
@@ -103,7 +103,7 @@
</return>
<argument index="0" name="target" type="Vector3">
</argument>
- <argument index="1" name="up" type="Vector3" default="Vector3( 0, 1, 0 )">
+ <argument index="1" name="up" type="Vector3" default="Vector3(0, 1, 0)">
</argument>
<description>
Rotates itself so that the local -Z axis points towards the [code]target[/code] position.
@@ -118,7 +118,7 @@
</argument>
<argument index="1" name="target" type="Vector3">
</argument>
- <argument index="2" name="up" type="Vector3" default="Vector3( 0, 1, 0 )">
+ <argument index="2" name="up" type="Vector3" default="Vector3(0, 1, 0)">
</argument>
<description>
Moves the node to the specified [code]position[/code], and then rotates itself to point toward the [code]target[/code] as per [method look_at]. Operations take place in global space.
@@ -291,23 +291,23 @@
<member name="global_transform" type="Transform3D" setter="set_global_transform" getter="get_global_transform">
World3D space (global) [Transform3D] of this node.
</member>
- <member name="position" type="Vector3" setter="set_position" getter="get_position" default="Vector3( 0, 0, 0 )">
+ <member name="position" type="Vector3" setter="set_position" getter="get_position" default="Vector3(0, 0, 0)">
Local position or translation of this node relative to the parent. This is equivalent to [code]transform.origin[/code].
</member>
<member name="rotation" type="Vector3" setter="set_rotation" getter="get_rotation">
Rotation part of the local transformation in radians, specified in terms of YXZ-Euler angles in the format (X angle, Y angle, Z angle).
[b]Note:[/b] In the mathematical sense, rotation is a matrix and not a vector. The three Euler angles, which are the three independent parameters of the Euler-angle parametrization of the rotation matrix, are stored in a [Vector3] data structure not because the rotation is a vector, but only because [Vector3] exists as a convenient data-structure to store 3 floating-point numbers. Therefore, applying affine operations on the rotation "vector" is not meaningful.
</member>
- <member name="rotation_degrees" type="Vector3" setter="set_rotation_degrees" getter="get_rotation_degrees" default="Vector3( 0, 0, 0 )">
+ <member name="rotation_degrees" type="Vector3" setter="set_rotation_degrees" getter="get_rotation_degrees" default="Vector3(0, 0, 0)">
Rotation part of the local transformation in degrees, specified in terms of YXZ-Euler angles in the format (X angle, Y angle, Z angle).
</member>
- <member name="scale" type="Vector3" setter="set_scale" getter="get_scale" default="Vector3( 1, 1, 1 )">
+ <member name="scale" type="Vector3" setter="set_scale" getter="get_scale" default="Vector3(1, 1, 1)">
Scale part of the local transformation.
</member>
<member name="top_level" type="bool" setter="set_as_top_level" getter="is_set_as_top_level" default="false">
If [code]true[/code], the node will not inherit its transformations from its parent. Node transformations are only in global space.
</member>
- <member name="transform" type="Transform3D" setter="set_transform" getter="get_transform" default="Transform3D( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )">
+ <member name="transform" type="Transform3D" setter="set_transform" getter="get_transform" default="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)">
Local space [Transform3D] of this node, with respect to the parent node.
</member>
<member name="visibility_parent" type="NodePath" setter="set_visibility_parent" getter="get_visibility_parent" default="NodePath(&quot;&quot;)">
diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml
index bfcd5b1beb..a9396306f4 100644
--- a/doc/classes/OS.xml
+++ b/doc/classes/OS.xml
@@ -94,7 +94,7 @@
</argument>
<argument index="1" name="arguments" type="PackedStringArray">
</argument>
- <argument index="2" name="output" type="Array" default="[ ]">
+ <argument index="2" name="output" type="Array" default="[]">
</argument>
<argument index="3" name="read_stderr" type="bool" default="false">
</argument>
@@ -136,6 +136,14 @@
Returns the keycode of the given string (e.g. "Escape").
</description>
</method>
+ <method name="get_cache_dir" qualifiers="const">
+ <return type="String">
+ </return>
+ <description>
+ Returns the [i]global[/i] cache data directory according to the operating system's standards. On desktop platforms, this path can be overridden by setting the [code]XDG_CACHE_HOME[/code] environment variable before starting the project. See [url=https://docs.godotengine.org/en/latest/tutorials/io/data_paths.html]File paths in Godot projects[/url] in the documentation for more information. See also [method get_config_dir] and [method get_data_dir].
+ Not to be confused with [method get_user_data_dir], which returns the [i]project-specific[/i] user data path.
+ </description>
+ </method>
<method name="get_cmdline_args">
<return type="PackedStringArray">
</return>
@@ -167,6 +175,14 @@
[/codeblocks]
</description>
</method>
+ <method name="get_config_dir" qualifiers="const">
+ <return type="String">
+ </return>
+ <description>
+ Returns the [i]global[/i] user configuration directory according to the operating system's standards. On desktop platforms, this path can be overridden by setting the [code]XDG_CONFIG_HOME[/code] environment variable before starting the project. See [url=https://docs.godotengine.org/en/latest/tutorials/io/data_paths.html]File paths in Godot projects[/url] in the documentation for more information. See also [method get_cache_dir] and [method get_data_dir].
+ Not to be confused with [method get_user_data_dir], which returns the [i]project-specific[/i] user data path.
+ </description>
+ </method>
<method name="get_connected_midi_inputs">
<return type="PackedStringArray">
</return>
@@ -176,6 +192,14 @@
[b]Note:[/b] This method is implemented on Linux, macOS and Windows.
</description>
</method>
+ <method name="get_data_dir" qualifiers="const">
+ <return type="String">
+ </return>
+ <description>
+ Returns the [i]global[/i] user data directory according to the operating system's standards. On desktop platforms, this path can be overridden by setting the [code]XDG_DATA_HOME[/code] environment variable before starting the project. See [url=https://docs.godotengine.org/en/latest/tutorials/io/data_paths.html]File paths in Godot projects[/url] in the documentation for more information. See also [method get_cache_dir] and [method get_config_dir].
+ Not to be confused with [method get_user_data_dir], which returns the [i]project-specific[/i] user data path.
+ </description>
+ </method>
<method name="get_environment" qualifiers="const">
<return type="String">
</return>
@@ -310,6 +334,7 @@
On macOS, this is [code]~/Library/Application Support/Godot/app_userdata/[project_name][/code], or [code]~/Library/Application Support/[custom_name][/code] if [code]use_custom_user_dir[/code] is set.
On Windows, this is [code]%APPDATA%\Godot\app_userdata\[project_name][/code], or [code]%APPDATA%\[custom_name][/code] if [code]use_custom_user_dir[/code] is set. [code]%APPDATA%[/code] expands to [code]%USERPROFILE%\AppData\Roaming[/code].
If the project name is empty, [code]user://[/code] falls back to [code]res://[/code].
+ Not to be confused with [method get_data_dir], which returns the [i]global[/i] (non-project-specific) user data directory.
</description>
</method>
<method name="has_environment" qualifiers="const">
diff --git a/doc/classes/Object.xml b/doc/classes/Object.xml
index f5dcd6bcdc..cdf76a3a59 100644
--- a/doc/classes/Object.xml
+++ b/doc/classes/Object.xml
@@ -92,7 +92,7 @@
</return>
<argument index="0" name="signal" type="String">
</argument>
- <argument index="1" name="arguments" type="Array" default="[ ]">
+ <argument index="1" name="arguments" type="Array" default="[]">
</argument>
<description>
Adds a user-defined [code]signal[/code]. Arguments are optional, but can be added as an [Array] of dictionaries, each containing [code]name: String[/code] and [code]type: int[/code] (see [enum Variant.Type]) entries.
@@ -173,7 +173,7 @@
</argument>
<argument index="1" name="callable" type="Callable">
</argument>
- <argument index="2" name="binds" type="Array" default="[ ]">
+ <argument index="2" name="binds" type="Array" default="[]">
</argument>
<argument index="3" name="flags" type="int" default="0">
</argument>
diff --git a/doc/classes/Occluder3D.xml b/doc/classes/Occluder3D.xml
index fc676c2b49..501c4a3ccf 100644
--- a/doc/classes/Occluder3D.xml
+++ b/doc/classes/Occluder3D.xml
@@ -9,9 +9,9 @@
<methods>
</methods>
<members>
- <member name="indices" type="PackedInt32Array" setter="set_indices" getter="get_indices" default="PackedInt32Array( )">
+ <member name="indices" type="PackedInt32Array" setter="set_indices" getter="get_indices" default="PackedInt32Array()">
</member>
- <member name="vertices" type="PackedVector3Array" setter="set_vertices" getter="get_vertices" default="PackedVector3Array( )">
+ <member name="vertices" type="PackedVector3Array" setter="set_vertices" getter="get_vertices" default="PackedVector3Array()">
</member>
</members>
<constants>
diff --git a/doc/classes/OccluderPolygon2D.xml b/doc/classes/OccluderPolygon2D.xml
index 8a59ef5cb4..28d3ed433a 100644
--- a/doc/classes/OccluderPolygon2D.xml
+++ b/doc/classes/OccluderPolygon2D.xml
@@ -17,7 +17,7 @@
<member name="cull_mode" type="int" setter="set_cull_mode" getter="get_cull_mode" enum="OccluderPolygon2D.CullMode" default="0">
The culling mode to use.
</member>
- <member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array( )">
+ <member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array()">
A [Vector2] array with the index for polygon's vertices positions.
[b]Note:[/b] The returned value is a copy of the underlying array, rather than a reference.
</member>
diff --git a/doc/classes/OptionButton.xml b/doc/classes/OptionButton.xml
index 52da08c02f..4c03c59f8b 100644
--- a/doc/classes/OptionButton.xml
+++ b/doc/classes/OptionButton.xml
@@ -250,19 +250,19 @@
<theme_item name="font" type="Font">
[Font] of the [OptionButton]'s text.
</theme_item>
- <theme_item name="font_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )">
+ <theme_item name="font_color" type="Color" default="Color(0.88, 0.88, 0.88, 1)">
Default text [Color] of the [OptionButton].
</theme_item>
- <theme_item name="font_disabled_color" type="Color" default="Color( 0.9, 0.9, 0.9, 0.2 )">
+ <theme_item name="font_disabled_color" type="Color" default="Color(0.9, 0.9, 0.9, 0.2)">
Text [Color] used when the [OptionButton] is disabled.
</theme_item>
- <theme_item name="font_hover_color" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )">
+ <theme_item name="font_hover_color" type="Color" default="Color(0.94, 0.94, 0.94, 1)">
Text [Color] used when the [OptionButton] is being hovered.
</theme_item>
- <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)">
The tint of text outline of the [OptionButton].
</theme_item>
- <theme_item name="font_pressed_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="font_pressed_color" type="Color" default="Color(1, 1, 1, 1)">
Text [Color] used when the [OptionButton] is being pressed.
</theme_item>
<theme_item name="font_size" type="int">
diff --git a/doc/classes/PackedDataContainer.xml b/doc/classes/PackedDataContainer.xml
index 296f9d3373..f72db514f0 100644
--- a/doc/classes/PackedDataContainer.xml
+++ b/doc/classes/PackedDataContainer.xml
@@ -23,7 +23,7 @@
</method>
</methods>
<members>
- <member name="__data__" type="PackedByteArray" setter="_set_data" getter="_get_data" default="PackedByteArray( )">
+ <member name="__data__" type="PackedByteArray" setter="_set_data" getter="_get_data" default="PackedByteArray()">
</member>
</members>
<constants>
diff --git a/doc/classes/PackedScene.xml b/doc/classes/PackedScene.xml
index 1d9be7f165..f39cae8be5 100644
--- a/doc/classes/PackedScene.xml
+++ b/doc/classes/PackedScene.xml
@@ -11,13 +11,13 @@
[codeblocks]
[gdscript]
# Use load() instead of preload() if the path isn't known at compile-time.
- var scene = preload("res://scene.tscn").instance()
+ var scene = preload("res://scene.tscn").instantiate()
# Add the node as a child of the node the script is attached to.
add_child(scene)
[/gdscript]
[csharp]
// C# has no preload, so you have to always use ResourceLoader.Load&lt;PackedScene&gt;().
- var scene = ResourceLoader.Load&lt;PackedScene&gt;("res://scene.tscn").Instance();
+ var scene = ResourceLoader.Load&lt;PackedScene&gt;("res://scene.tscn").Instantiate();
// Add the node as a child of the node the script is attached to.
AddChild(scene);
[/csharp]
@@ -76,7 +76,7 @@
<link title="2D Role Playing Game Demo">https://godotengine.org/asset-library/asset/520</link>
</tutorials>
<methods>
- <method name="can_instance" qualifiers="const">
+ <method name="can_instantiate" qualifiers="const">
<return type="bool">
</return>
<description>
@@ -90,7 +90,7 @@
Returns the [code]SceneState[/code] representing the scene file contents.
</description>
</method>
- <method name="instance" qualifiers="const">
+ <method name="instantiate" qualifiers="const">
<return type="Node">
</return>
<argument index="0" name="edit_state" type="int" enum="PackedScene.GenEditState" default="0">
@@ -110,21 +110,21 @@
</method>
</methods>
<members>
- <member name="_bundled" type="Dictionary" setter="_set_bundled_scene" getter="_get_bundled_scene" default="{&quot;conn_count&quot;: 0,&quot;conns&quot;: PackedInt32Array( ),&quot;editable_instances&quot;: [ ],&quot;names&quot;: PackedStringArray( ),&quot;node_count&quot;: 0,&quot;node_paths&quot;: [ ],&quot;nodes&quot;: PackedInt32Array( ),&quot;variants&quot;: [ ],&quot;version&quot;: 2}">
+ <member name="_bundled" type="Dictionary" setter="_set_bundled_scene" getter="_get_bundled_scene" default="{&quot;conn_count&quot;: 0,&quot;conns&quot;: PackedInt32Array(),&quot;editable_instances&quot;: [],&quot;names&quot;: PackedStringArray(),&quot;node_count&quot;: 0,&quot;node_paths&quot;: [],&quot;nodes&quot;: PackedInt32Array(),&quot;variants&quot;: [],&quot;version&quot;: 2}">
A dictionary representation of the scene contents.
Available keys include "rnames" and "variants" for resources, "node_count", "nodes", "node_paths" for nodes, "editable_instances" for base scene children overrides, "conn_count" and "conns" for signal connections, and "version" for the format style of the PackedScene.
</member>
</members>
<constants>
<constant name="GEN_EDIT_STATE_DISABLED" value="0" enum="GenEditState">
- If passed to [method instance], blocks edits to the scene state.
+ If passed to [method instantiate], blocks edits to the scene state.
</constant>
<constant name="GEN_EDIT_STATE_INSTANCE" value="1" enum="GenEditState">
- If passed to [method instance], provides local scene resources to the local scene.
+ If passed to [method instantiate], provides local scene resources to the local scene.
[b]Note:[/b] Only available in editor builds.
</constant>
<constant name="GEN_EDIT_STATE_MAIN" value="2" enum="GenEditState">
- If passed to [method instance], provides local scene resources to the local scene. Only the main scene should receive the main edit state.
+ If passed to [method instantiate], provides local scene resources to the local scene. Only the main scene should receive the main edit state.
[b]Note:[/b] Only available in editor builds.
</constant>
</constants>
diff --git a/doc/classes/ParallaxBackground.xml b/doc/classes/ParallaxBackground.xml
index 3b730fc4d4..b8097343f4 100644
--- a/doc/classes/ParallaxBackground.xml
+++ b/doc/classes/ParallaxBackground.xml
@@ -12,22 +12,22 @@
</methods>
<members>
<member name="layer" type="int" setter="set_layer" getter="get_layer" override="true" default="-100" />
- <member name="scroll_base_offset" type="Vector2" setter="set_scroll_base_offset" getter="get_scroll_base_offset" default="Vector2( 0, 0 )">
+ <member name="scroll_base_offset" type="Vector2" setter="set_scroll_base_offset" getter="get_scroll_base_offset" default="Vector2(0, 0)">
The base position offset for all [ParallaxLayer] children.
</member>
- <member name="scroll_base_scale" type="Vector2" setter="set_scroll_base_scale" getter="get_scroll_base_scale" default="Vector2( 1, 1 )">
+ <member name="scroll_base_scale" type="Vector2" setter="set_scroll_base_scale" getter="get_scroll_base_scale" default="Vector2(1, 1)">
The base motion scale for all [ParallaxLayer] children.
</member>
<member name="scroll_ignore_camera_zoom" type="bool" setter="set_ignore_camera_zoom" getter="is_ignore_camera_zoom" default="false">
If [code]true[/code], elements in [ParallaxLayer] child aren't affected by the zoom level of the camera.
</member>
- <member name="scroll_limit_begin" type="Vector2" setter="set_limit_begin" getter="get_limit_begin" default="Vector2( 0, 0 )">
+ <member name="scroll_limit_begin" type="Vector2" setter="set_limit_begin" getter="get_limit_begin" default="Vector2(0, 0)">
Top-left limits for scrolling to begin. If the camera is outside of this limit, the background will stop scrolling. Must be lower than [member scroll_limit_end] to work.
</member>
- <member name="scroll_limit_end" type="Vector2" setter="set_limit_end" getter="get_limit_end" default="Vector2( 0, 0 )">
+ <member name="scroll_limit_end" type="Vector2" setter="set_limit_end" getter="get_limit_end" default="Vector2(0, 0)">
Bottom-right limits for scrolling to end. If the camera is outside of this limit, the background will stop scrolling. Must be higher than [member scroll_limit_begin] to work.
</member>
- <member name="scroll_offset" type="Vector2" setter="set_scroll_offset" getter="get_scroll_offset" default="Vector2( 0, 0 )">
+ <member name="scroll_offset" type="Vector2" setter="set_scroll_offset" getter="get_scroll_offset" default="Vector2(0, 0)">
The ParallaxBackground's scroll value. Calculated automatically when using a [Camera2D], but can be used to manually manage scrolling when no camera is present.
</member>
</members>
diff --git a/doc/classes/ParallaxLayer.xml b/doc/classes/ParallaxLayer.xml
index 7210bee11c..6b1e013851 100644
--- a/doc/classes/ParallaxLayer.xml
+++ b/doc/classes/ParallaxLayer.xml
@@ -13,13 +13,13 @@
<methods>
</methods>
<members>
- <member name="motion_mirroring" type="Vector2" setter="set_mirroring" getter="get_mirroring" default="Vector2( 0, 0 )">
+ <member name="motion_mirroring" type="Vector2" setter="set_mirroring" getter="get_mirroring" default="Vector2(0, 0)">
The ParallaxLayer's [Texture2D] mirroring. Useful for creating an infinite scrolling background. If an axis is set to [code]0[/code], the [Texture2D] will not be mirrored.
</member>
- <member name="motion_offset" type="Vector2" setter="set_motion_offset" getter="get_motion_offset" default="Vector2( 0, 0 )">
+ <member name="motion_offset" type="Vector2" setter="set_motion_offset" getter="get_motion_offset" default="Vector2(0, 0)">
The ParallaxLayer's offset relative to the parent ParallaxBackground's [member ParallaxBackground.scroll_offset].
</member>
- <member name="motion_scale" type="Vector2" setter="set_motion_scale" getter="get_motion_scale" default="Vector2( 1, 1 )">
+ <member name="motion_scale" type="Vector2" setter="set_motion_scale" getter="get_motion_scale" default="Vector2(1, 1)">
Multiplies the ParallaxLayer's motion. If an axis is set to [code]0[/code], it will not scroll.
</member>
</members>
diff --git a/doc/classes/ParticlesMaterial.xml b/doc/classes/ParticlesMaterial.xml
index 3c364b621a..e8fde21032 100644
--- a/doc/classes/ParticlesMaterial.xml
+++ b/doc/classes/ParticlesMaterial.xml
@@ -141,7 +141,7 @@
</member>
<member name="collision_use_scale" type="bool" setter="set_collision_use_scale" getter="is_collision_using_scale" default="false">
</member>
- <member name="color" type="Color" setter="set_color" getter="get_color" default="Color( 1, 1, 1, 1 )">
+ <member name="color" type="Color" setter="set_color" getter="get_color" default="Color(1, 1, 1, 1)">
Each particle's initial color. If the [GPUParticles2D]'s [code]texture[/code] is defined, it will be multiplied by this color. To have particle display color in a [BaseMaterial3D] make sure to set [member BaseMaterial3D.vertex_color_use_as_albedo] to [code]true[/code].
</member>
<member name="color_ramp" type="Texture2D" setter="set_color_ramp" getter="get_color_ramp">
@@ -156,7 +156,7 @@
<member name="damping_random" type="float" setter="set_param_randomness" getter="get_param_randomness" default="0.0">
Damping randomness ratio.
</member>
- <member name="direction" type="Vector3" setter="set_direction" getter="get_direction" default="Vector3( 1, 0, 0 )">
+ <member name="direction" type="Vector3" setter="set_direction" getter="get_direction" default="Vector3(1, 0, 0)">
Unit vector specifying the particles' emission direction.
</member>
<member name="emission_box_extents" type="Vector3" setter="set_emission_box_extents" getter="get_emission_box_extents">
@@ -183,7 +183,7 @@
<member name="flatness" type="float" setter="set_flatness" getter="get_flatness" default="0.0">
Amount of [member spread] along the Y axis.
</member>
- <member name="gravity" type="Vector3" setter="set_gravity" getter="get_gravity" default="Vector3( 0, -9.8, 0 )">
+ <member name="gravity" type="Vector3" setter="set_gravity" getter="get_gravity" default="Vector3(0, -9.8, 0)">
Gravity applied to every particle.
</member>
<member name="hue_variation" type="float" setter="set_param" getter="get_param" default="0.0">
diff --git a/doc/classes/Performance.xml b/doc/classes/Performance.xml
index 9e9c5063ae..b6013fa83e 100644
--- a/doc/classes/Performance.xml
+++ b/doc/classes/Performance.xml
@@ -20,7 +20,7 @@
</argument>
<argument index="1" name="callable" type="Callable">
</argument>
- <argument index="2" name="arguments" type="Array" default="[ ]">
+ <argument index="2" name="arguments" type="Array" default="[]">
</argument>
<description>
Adds a custom monitor with name same as id. You can specify the category of monitor using '/' in id. If there are more than one '/' then default category is used. Default category is "Custom".
@@ -157,13 +157,13 @@
Largest amount of memory the message queue buffer has used, in bytes. The message queue is used for deferred functions calls and notifications.
</constant>
<constant name="OBJECT_COUNT" value="6" enum="Monitor">
- Number of objects currently instanced (including nodes).
+ Number of objects currently instantiated (including nodes).
</constant>
<constant name="OBJECT_RESOURCE_COUNT" value="7" enum="Monitor">
Number of resources currently used.
</constant>
<constant name="OBJECT_NODE_COUNT" value="8" enum="Monitor">
- Number of nodes currently instanced in the scene tree. This also includes the root node.
+ Number of nodes currently instantiated in the scene tree. This also includes the root node.
</constant>
<constant name="OBJECT_ORPHAN_NODE_COUNT" value="9" enum="Monitor">
Number of orphan nodes, i.e. nodes which are not parented to a node of the scene tree.
diff --git a/doc/classes/PhysicalBone3D.xml b/doc/classes/PhysicalBone3D.xml
index 5d15590a3f..736b44ee1c 100644
--- a/doc/classes/PhysicalBone3D.xml
+++ b/doc/classes/PhysicalBone3D.xml
@@ -20,7 +20,7 @@
</return>
<argument index="0" name="impulse" type="Vector3">
</argument>
- <argument index="1" name="position" type="Vector3" default="Vector3( 0, 0, 0 )">
+ <argument index="1" name="position" type="Vector3" default="Vector3(0, 0, 0)">
</argument>
<description>
</description>
@@ -48,7 +48,7 @@
<member name="angular_damp" type="float" setter="set_angular_damp" getter="get_angular_damp" default="-1.0">
Damps the body's rotation if greater than [code]0[/code].
</member>
- <member name="body_offset" type="Transform3D" setter="set_body_offset" getter="get_body_offset" default="Transform3D( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )">
+ <member name="body_offset" type="Transform3D" setter="set_body_offset" getter="get_body_offset" default="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)">
Sets the body's transform.
</member>
<member name="bounce" type="float" setter="set_bounce" getter="get_bounce" default="0.0">
@@ -63,13 +63,13 @@
<member name="gravity_scale" type="float" setter="set_gravity_scale" getter="get_gravity_scale" default="1.0">
This is multiplied by the global 3D gravity setting found in [b]Project &gt; Project Settings &gt; Physics &gt; 3d[/b] to produce the body's gravity. For example, a value of 1 will be normal gravity, 2 will apply double gravity, and 0.5 will apply half gravity to this object.
</member>
- <member name="joint_offset" type="Transform3D" setter="set_joint_offset" getter="get_joint_offset" default="Transform3D( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )">
+ <member name="joint_offset" type="Transform3D" setter="set_joint_offset" getter="get_joint_offset" default="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)">
Sets the joint's transform.
</member>
<member name="joint_rotation" type="Vector3" setter="set_joint_rotation" getter="get_joint_rotation">
Sets the joint's rotation in radians.
</member>
- <member name="joint_rotation_degrees" type="Vector3" setter="set_joint_rotation_degrees" getter="get_joint_rotation_degrees" default="Vector3( 0, 0, 0 )">
+ <member name="joint_rotation_degrees" type="Vector3" setter="set_joint_rotation_degrees" getter="get_joint_rotation_degrees" default="Vector3(0, 0, 0)">
Sets the joint's rotation in degrees.
</member>
<member name="joint_type" type="int" setter="set_joint_type" getter="get_joint_type" enum="PhysicalBone3D.JointType" default="0">
diff --git a/doc/classes/PhysicalSkyMaterial.xml b/doc/classes/PhysicalSkyMaterial.xml
index 381371b973..20ab998d35 100644
--- a/doc/classes/PhysicalSkyMaterial.xml
+++ b/doc/classes/PhysicalSkyMaterial.xml
@@ -19,13 +19,13 @@
<member name="exposure" type="float" setter="set_exposure" getter="get_exposure" default="0.1">
Sets the exposure of the sky. Higher exposure values make the entire sky brighter.
</member>
- <member name="ground_color" type="Color" setter="set_ground_color" getter="get_ground_color" default="Color( 1, 1, 1, 1 )">
+ <member name="ground_color" type="Color" setter="set_ground_color" getter="get_ground_color" default="Color(1, 1, 1, 1)">
Modulates the [Color] on the bottom half of the sky to represent the ground.
</member>
<member name="mie_coefficient" type="float" setter="set_mie_coefficient" getter="get_mie_coefficient" default="0.005">
Controls the strength of mie scattering for the sky. Mie scattering results from light colliding with larger particles (like water). On earth, mie scattering results in a whitish color around the sun and horizon.
</member>
- <member name="mie_color" type="Color" setter="set_mie_color" getter="get_mie_color" default="Color( 0.36, 0.56, 0.82, 1 )">
+ <member name="mie_color" type="Color" setter="set_mie_color" getter="get_mie_color" default="Color(0.36, 0.56, 0.82, 1)">
Controls the [Color] of the mie scattering effect. While not physically accurate, this allows for the creation of alien looking planets.
</member>
<member name="mie_eccentricity" type="float" setter="set_mie_eccentricity" getter="get_mie_eccentricity" default="0.8">
@@ -37,7 +37,7 @@
<member name="rayleigh_coefficient" type="float" setter="set_rayleigh_coefficient" getter="get_rayleigh_coefficient" default="2.0">
Controls the strength of the Rayleigh scattering. Rayleigh scattering results from light colliding with small particles. It is responsible for the blue color of the sky.
</member>
- <member name="rayleigh_color" type="Color" setter="set_rayleigh_color" getter="get_rayleigh_color" default="Color( 0.056, 0.14, 0.3, 1 )">
+ <member name="rayleigh_color" type="Color" setter="set_rayleigh_color" getter="get_rayleigh_color" default="Color(0.056, 0.14, 0.3, 1)">
Controls the [Color] of the Rayleigh scattering. While not physically accurate, this allows for the creation of alien looking planets. For example, setting this to a red [Color] results in a Mars looking atmosphere with a corresponding blue sunset.
</member>
<member name="sun_disk_scale" type="float" setter="set_sun_disk_scale" getter="get_sun_disk_scale" default="1.0">
diff --git a/doc/classes/PhysicsDirectBodyState2D.xml b/doc/classes/PhysicsDirectBodyState2D.xml
index 66ff16a3ce..65cb3e7f38 100644
--- a/doc/classes/PhysicsDirectBodyState2D.xml
+++ b/doc/classes/PhysicsDirectBodyState2D.xml
@@ -24,7 +24,7 @@
</return>
<argument index="0" name="force" type="Vector2">
</argument>
- <argument index="1" name="position" type="Vector2" default="Vector2( 0, 0 )">
+ <argument index="1" name="position" type="Vector2" default="Vector2(0, 0)">
</argument>
<description>
Adds a positioned force to the body. Both the force and the offset from the body origin are in global coordinates.
@@ -53,7 +53,7 @@
</return>
<argument index="0" name="impulse" type="Vector2">
</argument>
- <argument index="1" name="position" type="Vector2" default="Vector2( 0, 0 )">
+ <argument index="1" name="position" type="Vector2" default="Vector2(0, 0)">
</argument>
<description>
Applies a positioned impulse to the body. An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason, it should only be used when simulating one-time impacts (use the "_force" functions otherwise). The offset uses the rotation of the global coordinate system, but is centered at the object's origin.
diff --git a/doc/classes/PhysicsDirectBodyState3D.xml b/doc/classes/PhysicsDirectBodyState3D.xml
index 7cb3a56338..85feeef86e 100644
--- a/doc/classes/PhysicsDirectBodyState3D.xml
+++ b/doc/classes/PhysicsDirectBodyState3D.xml
@@ -12,7 +12,7 @@
<method name="add_central_force">
<return type="void">
</return>
- <argument index="0" name="force" type="Vector3" default="Vector3( 0, 0, 0 )">
+ <argument index="0" name="force" type="Vector3" default="Vector3(0, 0, 0)">
</argument>
<description>
Adds a constant directional force without affecting rotation.
@@ -24,7 +24,7 @@
</return>
<argument index="0" name="force" type="Vector3">
</argument>
- <argument index="1" name="position" type="Vector3" default="Vector3( 0, 0, 0 )">
+ <argument index="1" name="position" type="Vector3" default="Vector3(0, 0, 0)">
</argument>
<description>
Adds a positioned force to the body. Both the force and the offset from the body origin are in global coordinates.
@@ -42,7 +42,7 @@
<method name="apply_central_impulse">
<return type="void">
</return>
- <argument index="0" name="impulse" type="Vector3" default="Vector3( 0, 0, 0 )">
+ <argument index="0" name="impulse" type="Vector3" default="Vector3(0, 0, 0)">
</argument>
<description>
Applies a single directional impulse without affecting rotation.
@@ -54,7 +54,7 @@
</return>
<argument index="0" name="impulse" type="Vector3">
</argument>
- <argument index="1" name="position" type="Vector3" default="Vector3( 0, 0, 0 )">
+ <argument index="1" name="position" type="Vector3" default="Vector3(0, 0, 0)">
</argument>
<description>
Applies a positioned impulse to the body. An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason it should only be used when simulating one-time impacts. The position uses the rotation of the global coordinate system, but is centered at the object's origin.
diff --git a/doc/classes/PhysicsDirectSpaceState2D.xml b/doc/classes/PhysicsDirectSpaceState2D.xml
index b6f95305ed..6c8c957e5d 100644
--- a/doc/classes/PhysicsDirectSpaceState2D.xml
+++ b/doc/classes/PhysicsDirectSpaceState2D.xml
@@ -56,7 +56,7 @@
</argument>
<argument index="1" name="max_results" type="int" default="32">
</argument>
- <argument index="2" name="exclude" type="Array" default="[ ]">
+ <argument index="2" name="exclude" type="Array" default="[]">
</argument>
<argument index="3" name="collision_layer" type="int" default="2147483647">
</argument>
@@ -84,7 +84,7 @@
</argument>
<argument index="2" name="max_results" type="int" default="32">
</argument>
- <argument index="3" name="exclude" type="Array" default="[ ]">
+ <argument index="3" name="exclude" type="Array" default="[]">
</argument>
<argument index="4" name="collision_layer" type="int" default="2147483647">
</argument>
@@ -102,7 +102,7 @@
</argument>
<argument index="1" name="to" type="Vector2">
</argument>
- <argument index="2" name="exclude" type="Array" default="[ ]">
+ <argument index="2" name="exclude" type="Array" default="[]">
</argument>
<argument index="3" name="collision_layer" type="int" default="2147483647">
</argument>
diff --git a/doc/classes/PhysicsDirectSpaceState3D.xml b/doc/classes/PhysicsDirectSpaceState3D.xml
index 243d071c56..a69b6f07fd 100644
--- a/doc/classes/PhysicsDirectSpaceState3D.xml
+++ b/doc/classes/PhysicsDirectSpaceState3D.xml
@@ -57,7 +57,7 @@
</argument>
<argument index="1" name="to" type="Vector3">
</argument>
- <argument index="2" name="exclude" type="Array" default="[ ]">
+ <argument index="2" name="exclude" type="Array" default="[]">
</argument>
<argument index="3" name="collision_mask" type="int" default="2147483647">
</argument>
diff --git a/doc/classes/PhysicsServer2D.xml b/doc/classes/PhysicsServer2D.xml
index 4c2abcb087..33cd61eb9c 100644
--- a/doc/classes/PhysicsServer2D.xml
+++ b/doc/classes/PhysicsServer2D.xml
@@ -16,7 +16,7 @@
</argument>
<argument index="1" name="shape" type="RID">
</argument>
- <argument index="2" name="transform" type="Transform2D" default="Transform2D( 1, 0, 0, 1, 0, 0 )">
+ <argument index="2" name="transform" type="Transform2D" default="Transform2D(1, 0, 0, 1, 0, 0)">
</argument>
<argument index="3" name="disabled" type="bool" default="false">
</argument>
@@ -333,7 +333,7 @@
</argument>
<argument index="1" name="force" type="Vector2">
</argument>
- <argument index="2" name="position" type="Vector2" default="Vector2( 0, 0 )">
+ <argument index="2" name="position" type="Vector2" default="Vector2(0, 0)">
</argument>
<description>
Adds a positioned force to the applied force and torque. As with [method body_apply_impulse], both the force and the offset from the body origin are in global coordinates. A force differs from an impulse in that, while the two are forces, the impulse clears itself after being applied.
@@ -346,7 +346,7 @@
</argument>
<argument index="1" name="shape" type="RID">
</argument>
- <argument index="2" name="transform" type="Transform2D" default="Transform2D( 1, 0, 0, 1, 0, 0 )">
+ <argument index="2" name="transform" type="Transform2D" default="Transform2D(1, 0, 0, 1, 0, 0)">
</argument>
<argument index="3" name="disabled" type="bool" default="false">
</argument>
@@ -381,7 +381,7 @@
</argument>
<argument index="1" name="impulse" type="Vector2">
</argument>
- <argument index="2" name="position" type="Vector2" default="Vector2( 0, 0 )">
+ <argument index="2" name="position" type="Vector2" default="Vector2(0, 0)">
</argument>
<description>
Adds a positioned impulse to the applied force and torque. Both the force and the offset from the body origin are in global coordinates.
diff --git a/doc/classes/PhysicsServer3D.xml b/doc/classes/PhysicsServer3D.xml
index 2972d5155c..aa1f7597ea 100644
--- a/doc/classes/PhysicsServer3D.xml
+++ b/doc/classes/PhysicsServer3D.xml
@@ -16,7 +16,7 @@
</argument>
<argument index="1" name="shape" type="RID">
</argument>
- <argument index="2" name="transform" type="Transform3D" default="Transform3D( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )">
+ <argument index="2" name="transform" type="Transform3D" default="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)">
</argument>
<argument index="3" name="disabled" type="bool" default="false">
</argument>
@@ -325,7 +325,7 @@
</argument>
<argument index="1" name="force" type="Vector3">
</argument>
- <argument index="2" name="position" type="Vector3" default="Vector3( 0, 0, 0 )">
+ <argument index="2" name="position" type="Vector3" default="Vector3(0, 0, 0)">
</argument>
<description>
</description>
@@ -337,7 +337,7 @@
</argument>
<argument index="1" name="shape" type="RID">
</argument>
- <argument index="2" name="transform" type="Transform3D" default="Transform3D( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )">
+ <argument index="2" name="transform" type="Transform3D" default="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)">
</argument>
<argument index="3" name="disabled" type="bool" default="false">
</argument>
@@ -372,7 +372,7 @@
</argument>
<argument index="1" name="impulse" type="Vector3">
</argument>
- <argument index="2" name="position" type="Vector3" default="Vector3( 0, 0, 0 )">
+ <argument index="2" name="position" type="Vector3" default="Vector3(0, 0, 0)">
</argument>
<description>
Gives the body a push at a [code]position[/code] in the direction of the [code]impulse[/code].
diff --git a/doc/classes/PhysicsShapeQueryParameters2D.xml b/doc/classes/PhysicsShapeQueryParameters2D.xml
index 92bd9b136a..321a713e26 100644
--- a/doc/classes/PhysicsShapeQueryParameters2D.xml
+++ b/doc/classes/PhysicsShapeQueryParameters2D.xml
@@ -20,13 +20,13 @@
<member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" default="2147483647">
The physics layer(s) the query will take into account (as a bitmask). See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
</member>
- <member name="exclude" type="Array" setter="set_exclude" getter="get_exclude" default="[ ]">
+ <member name="exclude" type="Array" setter="set_exclude" getter="get_exclude" default="[]">
The list of objects or object [RID]s that will be excluded from collisions.
</member>
<member name="margin" type="float" setter="set_margin" getter="get_margin" default="0.0">
The collision margin for the shape.
</member>
- <member name="motion" type="Vector2" setter="set_motion" getter="get_motion" default="Vector2( 0, 0 )">
+ <member name="motion" type="Vector2" setter="set_motion" getter="get_motion" default="Vector2(0, 0)">
The motion of the shape being queried for.
</member>
<member name="shape" type="Resource" setter="set_shape" getter="get_shape">
@@ -63,7 +63,7 @@
[/csharp]
[/codeblocks]
</member>
- <member name="transform" type="Transform2D" setter="set_transform" getter="get_transform" default="Transform2D( 1, 0, 0, 1, 0, 0 )">
+ <member name="transform" type="Transform2D" setter="set_transform" getter="get_transform" default="Transform2D(1, 0, 0, 1, 0, 0)">
The queried shape's transform matrix.
</member>
</members>
diff --git a/doc/classes/PhysicsShapeQueryParameters3D.xml b/doc/classes/PhysicsShapeQueryParameters3D.xml
index 087c52a650..52916a8418 100644
--- a/doc/classes/PhysicsShapeQueryParameters3D.xml
+++ b/doc/classes/PhysicsShapeQueryParameters3D.xml
@@ -20,7 +20,7 @@
<member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="2147483647">
The physics layer(s) the query will take into account (as a bitmask). See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
</member>
- <member name="exclude" type="Array" setter="set_exclude" getter="get_exclude" default="[ ]">
+ <member name="exclude" type="Array" setter="set_exclude" getter="get_exclude" default="[]">
The list of objects or object [RID]s that will be excluded from collisions.
</member>
<member name="margin" type="float" setter="set_margin" getter="get_margin" default="0.0">
@@ -60,7 +60,7 @@
[/csharp]
[/codeblocks]
</member>
- <member name="transform" type="Transform3D" setter="set_transform" getter="get_transform" default="Transform3D( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )">
+ <member name="transform" type="Transform3D" setter="set_transform" getter="get_transform" default="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)">
The queried shape's transform matrix.
</member>
</members>
diff --git a/doc/classes/PhysicsTestMotionResult2D.xml b/doc/classes/PhysicsTestMotionResult2D.xml
index 2744aa17a1..da04ffa86a 100644
--- a/doc/classes/PhysicsTestMotionResult2D.xml
+++ b/doc/classes/PhysicsTestMotionResult2D.xml
@@ -17,15 +17,15 @@
</member>
<member name="collider_shape" type="int" setter="" getter="get_collider_shape" default="0">
</member>
- <member name="collider_velocity" type="Vector2" setter="" getter="get_collider_velocity" default="Vector2( 0, 0 )">
+ <member name="collider_velocity" type="Vector2" setter="" getter="get_collider_velocity" default="Vector2(0, 0)">
</member>
- <member name="collision_normal" type="Vector2" setter="" getter="get_collision_normal" default="Vector2( 0, 0 )">
+ <member name="collision_normal" type="Vector2" setter="" getter="get_collision_normal" default="Vector2(0, 0)">
</member>
- <member name="collision_point" type="Vector2" setter="" getter="get_collision_point" default="Vector2( 0, 0 )">
+ <member name="collision_point" type="Vector2" setter="" getter="get_collision_point" default="Vector2(0, 0)">
</member>
- <member name="motion" type="Vector2" setter="" getter="get_motion" default="Vector2( 0, 0 )">
+ <member name="motion" type="Vector2" setter="" getter="get_motion" default="Vector2(0, 0)">
</member>
- <member name="motion_remainder" type="Vector2" setter="" getter="get_motion_remainder" default="Vector2( 0, 0 )">
+ <member name="motion_remainder" type="Vector2" setter="" getter="get_motion_remainder" default="Vector2(0, 0)">
</member>
</members>
<constants>
diff --git a/doc/classes/Plane.xml b/doc/classes/Plane.xml
index 2342f00631..12869061c4 100644
--- a/doc/classes/Plane.xml
+++ b/doc/classes/Plane.xml
@@ -169,23 +169,23 @@
<description>
</description>
</method>
- <method name="operator +" qualifiers="operator">
- <return type="Plane">
+ <method name="operator ==" qualifiers="operator">
+ <return type="bool">
</return>
+ <argument index="0" name="right" type="Plane">
+ </argument>
<description>
</description>
</method>
- <method name="operator -" qualifiers="operator">
+ <method name="operator unary+" qualifiers="operator">
<return type="Plane">
</return>
<description>
</description>
</method>
- <method name="operator ==" qualifiers="operator">
- <return type="bool">
+ <method name="operator unary-" qualifiers="operator">
+ <return type="Plane">
</return>
- <argument index="0" name="right" type="Plane">
- </argument>
<description>
</description>
</method>
@@ -204,7 +204,7 @@
The distance from the origin to the plane, in the direction of [member normal]. This value is typically non-negative.
In the scalar equation of the plane [code]ax + by + cz = d[/code], this is [code]d[/code], while the [code](a, b, c)[/code] coordinates are represented by the [member normal] property.
</member>
- <member name="normal" type="Vector3" setter="" getter="" default="Vector3( 0, 0, 0 )">
+ <member name="normal" type="Vector3" setter="" getter="" default="Vector3(0, 0, 0)">
The normal of the plane, which must be normalized.
In the scalar equation of the plane [code]ax + by + cz = d[/code], this is the vector [code](a, b, c)[/code], where [code]d[/code] is the [member d] property.
</member>
@@ -219,13 +219,13 @@
</member>
</members>
<constants>
- <constant name="PLANE_YZ" value="Plane( 1, 0, 0, 0 )">
+ <constant name="PLANE_YZ" value="Plane(1, 0, 0, 0)">
A plane that extends in the Y and Z axes (normal vector points +X).
</constant>
- <constant name="PLANE_XZ" value="Plane( 0, 1, 0, 0 )">
+ <constant name="PLANE_XZ" value="Plane(0, 1, 0, 0)">
A plane that extends in the X and Z axes (normal vector points +Y).
</constant>
- <constant name="PLANE_XY" value="Plane( 0, 0, 1, 0 )">
+ <constant name="PLANE_XY" value="Plane(0, 0, 1, 0)">
A plane that extends in the X and Y axes (normal vector points +Z).
</constant>
</constants>
diff --git a/doc/classes/PlaneMesh.xml b/doc/classes/PlaneMesh.xml
index 333d687e91..c95ba29ea2 100644
--- a/doc/classes/PlaneMesh.xml
+++ b/doc/classes/PlaneMesh.xml
@@ -12,7 +12,7 @@
<methods>
</methods>
<members>
- <member name="size" type="Vector2" setter="set_size" getter="get_size" default="Vector2( 2, 2 )">
+ <member name="size" type="Vector2" setter="set_size" getter="get_size" default="Vector2(2, 2)">
Size of the generated plane.
</member>
<member name="subdivide_depth" type="int" setter="set_subdivide_depth" getter="get_subdivide_depth" default="0">
diff --git a/doc/classes/PointLight2D.xml b/doc/classes/PointLight2D.xml
index 9337bc8351..a7207a3c80 100644
--- a/doc/classes/PointLight2D.xml
+++ b/doc/classes/PointLight2D.xml
@@ -12,7 +12,7 @@
<member name="height" type="float" setter="set_height" getter="get_height" default="0.0">
The height of the light. Used with 2D normal mapping.
</member>
- <member name="offset" type="Vector2" setter="set_texture_offset" getter="get_texture_offset" default="Vector2( 0, 0 )">
+ <member name="offset" type="Vector2" setter="set_texture_offset" getter="get_texture_offset" default="Vector2(0, 0)">
The offset of the light's [member texture].
</member>
<member name="texture" type="Texture2D" setter="set_texture" getter="get_texture">
diff --git a/doc/classes/Polygon2D.xml b/doc/classes/Polygon2D.xml
index 3aca83658d..c33a1424a7 100644
--- a/doc/classes/Polygon2D.xml
+++ b/doc/classes/Polygon2D.xml
@@ -88,9 +88,9 @@
<member name="antialiased" type="bool" setter="set_antialiased" getter="get_antialiased" default="false">
If [code]true[/code], polygon edges will be anti-aliased.
</member>
- <member name="bones" type="Array" setter="_set_bones" getter="_get_bones" default="[ ]">
+ <member name="bones" type="Array" setter="_set_bones" getter="_get_bones" default="[]">
</member>
- <member name="color" type="Color" setter="set_color" getter="get_color" default="Color( 1, 1, 1, 1 )">
+ <member name="color" type="Color" setter="set_color" getter="get_color" default="Color(1, 1, 1, 1)">
The polygon's fill color. If [code]texture[/code] is defined, it will be multiplied by this color. It will also be the default color for vertices not set in [code]vertex_colors[/code].
</member>
<member name="internal_vertex_count" type="int" setter="set_internal_vertex_count" getter="get_internal_vertex_count" default="0">
@@ -101,21 +101,21 @@
<member name="invert_enable" type="bool" setter="set_invert" getter="get_invert" default="false">
If [code]true[/code], polygon will be inverted, containing the area outside the defined points and extending to the [code]invert_border[/code].
</member>
- <member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2( 0, 0 )">
+ <member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2(0, 0)">
The offset applied to each vertex.
</member>
- <member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array( )">
+ <member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array()">
The polygon's list of vertices. The final point will be connected to the first.
[b]Note:[/b] This returns a copy of the [PackedVector2Array] rather than a reference.
</member>
- <member name="polygons" type="Array" setter="set_polygons" getter="get_polygons" default="[ ]">
+ <member name="polygons" type="Array" setter="set_polygons" getter="get_polygons" default="[]">
</member>
<member name="skeleton" type="NodePath" setter="set_skeleton" getter="get_skeleton" default="NodePath(&quot;&quot;)">
</member>
<member name="texture" type="Texture2D" setter="set_texture" getter="get_texture">
The polygon's fill texture. Use [code]uv[/code] to set texture coordinates.
</member>
- <member name="texture_offset" type="Vector2" setter="set_texture_offset" getter="get_texture_offset" default="Vector2( 0, 0 )">
+ <member name="texture_offset" type="Vector2" setter="set_texture_offset" getter="get_texture_offset" default="Vector2(0, 0)">
Amount to offset the polygon's [code]texture[/code]. If [code](0, 0)[/code] the texture's origin (its top-left corner) will be placed at the polygon's [code]position[/code].
</member>
<member name="texture_rotation" type="float" setter="set_texture_rotation" getter="get_texture_rotation">
@@ -124,13 +124,13 @@
<member name="texture_rotation_degrees" type="float" setter="set_texture_rotation_degrees" getter="get_texture_rotation_degrees" default="0.0">
The texture's rotation in degrees.
</member>
- <member name="texture_scale" type="Vector2" setter="set_texture_scale" getter="get_texture_scale" default="Vector2( 1, 1 )">
+ <member name="texture_scale" type="Vector2" setter="set_texture_scale" getter="get_texture_scale" default="Vector2(1, 1)">
Amount to multiply the [code]uv[/code] coordinates when using a [code]texture[/code]. Larger values make the texture smaller, and vice versa.
</member>
- <member name="uv" type="PackedVector2Array" setter="set_uv" getter="get_uv" default="PackedVector2Array( )">
+ <member name="uv" type="PackedVector2Array" setter="set_uv" getter="get_uv" default="PackedVector2Array()">
Texture coordinates for each vertex of the polygon. There should be one [code]uv[/code] per polygon vertex. If there are fewer, undefined vertices will use [code](0, 0)[/code].
</member>
- <member name="vertex_colors" type="PackedColorArray" setter="set_vertex_colors" getter="get_vertex_colors" default="PackedColorArray( )">
+ <member name="vertex_colors" type="PackedColorArray" setter="set_vertex_colors" getter="get_vertex_colors" default="PackedColorArray()">
Color for each vertex. Colors are interpolated between vertices, resulting in smooth gradients. There should be one per polygon vertex. If there are fewer, undefined vertices will use [code]color[/code].
</member>
</members>
diff --git a/doc/classes/PopupMenu.xml b/doc/classes/PopupMenu.xml
index 418785222e..e448d18d73 100644
--- a/doc/classes/PopupMenu.xml
+++ b/doc/classes/PopupMenu.xml
@@ -717,22 +717,22 @@
<theme_item name="font" type="Font">
[Font] used for the menu items.
</theme_item>
- <theme_item name="font_accelerator_color" type="Color" default="Color( 0.7, 0.7, 0.7, 0.8 )">
+ <theme_item name="font_accelerator_color" type="Color" default="Color(0.7, 0.7, 0.7, 0.8)">
The text [Color] used for shortcuts and accelerators that show next to the menu item name when defined. See [method get_item_accelerator] for more info on accelerators.
</theme_item>
- <theme_item name="font_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )">
+ <theme_item name="font_color" type="Color" default="Color(0.88, 0.88, 0.88, 1)">
The default text [Color] for menu items' names.
</theme_item>
- <theme_item name="font_disabled_color" type="Color" default="Color( 0.4, 0.4, 0.4, 0.8 )">
+ <theme_item name="font_disabled_color" type="Color" default="Color(0.4, 0.4, 0.4, 0.8)">
[Color] used for disabled menu items' text.
</theme_item>
- <theme_item name="font_hover_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )">
+ <theme_item name="font_hover_color" type="Color" default="Color(0.88, 0.88, 0.88, 1)">
[Color] used for the hovered text.
</theme_item>
- <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)">
The tint of text outline of the menu item.
</theme_item>
- <theme_item name="font_separator_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )">
+ <theme_item name="font_separator_color" type="Color" default="Color(0.88, 0.88, 0.88, 1)">
[Color] used for labeled separators' text. See [method add_separator].
</theme_item>
<theme_item name="font_size" type="int">
diff --git a/doc/classes/PrimitiveMesh.xml b/doc/classes/PrimitiveMesh.xml
index 3892633654..ca41c367c8 100644
--- a/doc/classes/PrimitiveMesh.xml
+++ b/doc/classes/PrimitiveMesh.xml
@@ -30,7 +30,7 @@
</method>
</methods>
<members>
- <member name="custom_aabb" type="AABB" setter="set_custom_aabb" getter="get_custom_aabb" default="AABB( 0, 0, 0, 0, 0, 0 )">
+ <member name="custom_aabb" type="AABB" setter="set_custom_aabb" getter="get_custom_aabb" default="AABB(0, 0, 0, 0, 0, 0)">
Overrides the [AABB] with one defined by user for use with frustum culling. Especially useful to avoid unexpected culling when using a shader to offset vertices.
</member>
<member name="flip_faces" type="bool" setter="set_flip_faces" getter="get_flip_faces" default="false">
diff --git a/doc/classes/PrismMesh.xml b/doc/classes/PrismMesh.xml
index b2e1fdd3f0..0e66281fd1 100644
--- a/doc/classes/PrismMesh.xml
+++ b/doc/classes/PrismMesh.xml
@@ -14,7 +14,7 @@
<member name="left_to_right" type="float" setter="set_left_to_right" getter="get_left_to_right" default="0.5">
Displacement of the upper edge along the X axis. 0.0 positions edge straight above the bottom-left edge.
</member>
- <member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3( 2, 2, 2 )">
+ <member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3(2, 2, 2)">
Size of the prism.
</member>
<member name="subdivide_depth" type="int" setter="set_subdivide_depth" getter="get_subdivide_depth" default="0">
diff --git a/doc/classes/ProceduralSkyMaterial.xml b/doc/classes/ProceduralSkyMaterial.xml
index d3e1dbca27..c598a2c266 100644
--- a/doc/classes/ProceduralSkyMaterial.xml
+++ b/doc/classes/ProceduralSkyMaterial.xml
@@ -13,7 +13,7 @@
<methods>
</methods>
<members>
- <member name="ground_bottom_color" type="Color" setter="set_ground_bottom_color" getter="get_ground_bottom_color" default="Color( 0.12, 0.12, 0.13, 1 )">
+ <member name="ground_bottom_color" type="Color" setter="set_ground_bottom_color" getter="get_ground_bottom_color" default="Color(0.12, 0.12, 0.13, 1)">
Color of the ground at the bottom. Blends with [member ground_horizon_color].
</member>
<member name="ground_curve" type="float" setter="set_ground_curve" getter="get_ground_curve" default="0.02">
@@ -22,7 +22,7 @@
<member name="ground_energy" type="float" setter="set_ground_energy" getter="get_ground_energy" default="1.0">
Amount of energy contribution from the ground.
</member>
- <member name="ground_horizon_color" type="Color" setter="set_ground_horizon_color" getter="get_ground_horizon_color" default="Color( 0.37, 0.33, 0.31, 1 )">
+ <member name="ground_horizon_color" type="Color" setter="set_ground_horizon_color" getter="get_ground_horizon_color" default="Color(0.37, 0.33, 0.31, 1)">
Color of the ground at the horizon. Blends with [member ground_bottom_color].
</member>
<member name="sky_curve" type="float" setter="set_sky_curve" getter="get_sky_curve" default="0.09">
@@ -31,10 +31,10 @@
<member name="sky_energy" type="float" setter="set_sky_energy" getter="get_sky_energy" default="1.0">
Amount of energy contribution from the sky.
</member>
- <member name="sky_horizon_color" type="Color" setter="set_sky_horizon_color" getter="get_sky_horizon_color" default="Color( 0.55, 0.69, 0.81, 1 )">
+ <member name="sky_horizon_color" type="Color" setter="set_sky_horizon_color" getter="get_sky_horizon_color" default="Color(0.55, 0.69, 0.81, 1)">
Color of the sky at the horizon. Blends with [member sky_top_color].
</member>
- <member name="sky_top_color" type="Color" setter="set_sky_top_color" getter="get_sky_top_color" default="Color( 0.35, 0.46, 0.71, 1 )">
+ <member name="sky_top_color" type="Color" setter="set_sky_top_color" getter="get_sky_top_color" default="Color(0.35, 0.46, 0.71, 1)">
Color of the sky at the top. Blends with [member sky_horizon_color].
</member>
<member name="sun_angle_max" type="float" setter="set_sun_angle_max" getter="get_sun_angle_max" default="100.0">
diff --git a/doc/classes/ProgressBar.xml b/doc/classes/ProgressBar.xml
index 160b61c720..c33f6f636d 100644
--- a/doc/classes/ProgressBar.xml
+++ b/doc/classes/ProgressBar.xml
@@ -29,13 +29,13 @@
<theme_item name="font" type="Font">
Font used to draw the fill percentage if [member percent_visible] is [code]true[/code].
</theme_item>
- <theme_item name="font_color" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )">
+ <theme_item name="font_color" type="Color" default="Color(0.94, 0.94, 0.94, 1)">
The color of the text.
</theme_item>
- <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)">
The tint of text outline of the [ProgressBar].
</theme_item>
- <theme_item name="font_shadow_color" type="Color" default="Color( 0, 0, 0, 1 )">
+ <theme_item name="font_shadow_color" type="Color" default="Color(0, 0, 0, 1)">
The color of the text's shadow.
</theme_item>
<theme_item name="font_size" type="int">
diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml
index 35656d170b..1847a316e1 100644
--- a/doc/classes/ProjectSettings.xml
+++ b/doc/classes/ProjectSettings.xml
@@ -226,7 +226,7 @@
</method>
</methods>
<members>
- <member name="application/boot_splash/bg_color" type="Color" setter="" getter="" default="Color( 0.14, 0.14, 0.14, 1 )">
+ <member name="application/boot_splash/bg_color" type="Color" setter="" getter="" default="Color(0.14, 0.14, 0.14, 1)">
Background color for the boot splash.
</member>
<member name="application/boot_splash/fullsize" type="bool" setter="" getter="" default="true">
@@ -266,10 +266,12 @@
Icon set in [code].ico[/code] format used on Windows to set the game's icon. This is done automatically on start by calling [method DisplayServer.set_native_icon].
</member>
<member name="application/run/disable_stderr" type="bool" setter="" getter="" default="false">
- If [code]true[/code], disables printing to standard error in an exported build.
+ If [code]true[/code], disables printing to standard error. If [code]true[/code], this also hides error and warning messages printed by [method @GlobalScope.push_error] and [method @GlobalScope.push_warning]. See also [member application/run/disable_stdout].
+ Changes to this setting will only be applied upon restarting the application.
</member>
<member name="application/run/disable_stdout" type="bool" setter="" getter="" default="false">
- If [code]true[/code], disables printing to standard output in an exported build.
+ If [code]true[/code], disables printing to standard output. This is equivalent to starting the editor or project with the [code]--quiet[/code] command line argument. See also [member application/run/disable_stderr].
+ Changes to this setting will only be applied upon restarting the application.
</member>
<member name="application/run/flush_stdout_on_print" type="bool" setter="" getter="" default="false">
If [code]true[/code], flushes the standard output stream every time a line is printed. This affects both terminal logging and file logging.
@@ -461,7 +463,7 @@
<member name="debug/settings/visual_script/max_call_stack" type="int" setter="" getter="" default="1024">
Maximum call stack in visual scripting, to avoid infinite recursion.
</member>
- <member name="debug/shapes/collision/contact_color" type="Color" setter="" getter="" default="Color( 1, 0.2, 0.1, 0.8 )">
+ <member name="debug/shapes/collision/contact_color" type="Color" setter="" getter="" default="Color(1, 0.2, 0.1, 0.8)">
Color of the contact points between collision shapes, visible when "Visible Collision Shapes" is enabled in the Debug menu.
</member>
<member name="debug/shapes/collision/draw_2d_outlines" type="bool" setter="" getter="" default="true">
@@ -470,22 +472,22 @@
<member name="debug/shapes/collision/max_contacts_displayed" type="int" setter="" getter="" default="10000">
Maximum number of contact points between collision shapes to display when "Visible Collision Shapes" is enabled in the Debug menu.
</member>
- <member name="debug/shapes/collision/shape_color" type="Color" setter="" getter="" default="Color( 0, 0.6, 0.7, 0.42 )">
+ <member name="debug/shapes/collision/shape_color" type="Color" setter="" getter="" default="Color(0, 0.6, 0.7, 0.42)">
Color of the collision shapes, visible when "Visible Collision Shapes" is enabled in the Debug menu.
</member>
- <member name="debug/shapes/navigation/disabled_geometry_color" type="Color" setter="" getter="" default="Color( 1, 0.7, 0.1, 0.4 )">
+ <member name="debug/shapes/navigation/disabled_geometry_color" type="Color" setter="" getter="" default="Color(1, 0.7, 0.1, 0.4)">
Color of the disabled navigation geometry, visible when "Visible Navigation" is enabled in the Debug menu.
</member>
- <member name="debug/shapes/navigation/geometry_color" type="Color" setter="" getter="" default="Color( 0.1, 1, 0.7, 0.4 )">
+ <member name="debug/shapes/navigation/geometry_color" type="Color" setter="" getter="" default="Color(0.1, 1, 0.7, 0.4)">
Color of the navigation geometry, visible when "Visible Navigation" is enabled in the Debug menu.
</member>
<member name="display/mouse_cursor/custom_image" type="String" setter="" getter="" default="&quot;&quot;">
Custom image for the mouse cursor (limited to 256×256).
</member>
- <member name="display/mouse_cursor/custom_image_hotspot" type="Vector2" setter="" getter="" default="Vector2( 0, 0 )">
+ <member name="display/mouse_cursor/custom_image_hotspot" type="Vector2" setter="" getter="" default="Vector2(0, 0)">
Hotspot for the custom mouse cursor image.
</member>
- <member name="display/mouse_cursor/tooltip_position_offset" type="Vector2" setter="" getter="" default="Vector2( 10, 10 )">
+ <member name="display/mouse_cursor/tooltip_position_offset" type="Vector2" setter="" getter="" default="Vector2(10, 10)">
Position offset for tooltips, relative to the mouse cursor's hotspot.
</member>
<member name="display/window/dpi/allow_hidpi" type="bool" setter="" getter="" default="false">
@@ -551,7 +553,7 @@
prime-run %command%
[/codeblock]
</member>
- <member name="editor/script/search_in_file_extensions" type="PackedStringArray" setter="" getter="" default="PackedStringArray( &quot;gd&quot;, &quot;gdshader&quot; )">
+ <member name="editor/script/search_in_file_extensions" type="PackedStringArray" setter="" getter="" default="PackedStringArray(&quot;gd&quot;, &quot;gdshader&quot;)">
Text-based file extensions to include in the script editor's "Find in Files" feature. You can add e.g. [code]tscn[/code] if you wish to also parse your scene files, especially if you use built-in scripts which are serialized in the scene files.
</member>
<member name="editor/script/templates_search_path" type="String" setter="" getter="" default="&quot;res://script_templates&quot;">
@@ -1222,7 +1224,7 @@
[/csharp]
[/codeblocks]
</member>
- <member name="physics/2d/default_gravity_vector" type="Vector2" setter="" getter="" default="Vector2( 0, 1 )">
+ <member name="physics/2d/default_gravity_vector" type="Vector2" setter="" getter="" default="Vector2(0, 1)">
The default gravity direction in 2D.
[b]Note:[/b] This property is only read when the project starts. To change the default gravity vector at runtime, use the following code sample:
[codeblocks]
@@ -1274,7 +1276,7 @@
[/csharp]
[/codeblocks]
</member>
- <member name="physics/3d/default_gravity_vector" type="Vector3" setter="" getter="" default="Vector3( 0, -1, 0 )">
+ <member name="physics/3d/default_gravity_vector" type="Vector3" setter="" getter="" default="Vector3(0, -1, 0)">
The default gravity direction in 3D.
[b]Note:[/b] This property is only read when the project starts. To change the default gravity vector at runtime, use the following code sample:
[codeblocks]
@@ -1366,7 +1368,7 @@
<member name="rendering/driver/threads/thread_model" type="int" setter="" getter="" default="1">
Thread model for rendering. Rendering on a thread can vastly improve performance, but synchronizing to the main thread can cause a bit more jitter.
</member>
- <member name="rendering/environment/defaults/default_clear_color" type="Color" setter="" getter="" default="Color( 0.3, 0.3, 0.3, 1 )">
+ <member name="rendering/environment/defaults/default_clear_color" type="Color" setter="" getter="" default="Color(0.3, 0.3, 0.3, 1)">
Default background clear color. Overridable per [Viewport] using its [Environment]. See [member Environment.background_mode] and [member Environment.background_color] in particular. To change this default color programmatically, use [method RenderingServer.set_default_clear_color].
</member>
<member name="rendering/environment/defaults/default_environment" type="String" setter="" getter="" default="&quot;&quot;">
diff --git a/doc/classes/PropertyTweener.xml b/doc/classes/PropertyTweener.xml
new file mode 100644
index 0000000000..1e77bb33c6
--- /dev/null
+++ b/doc/classes/PropertyTweener.xml
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="PropertyTweener" inherits="Tweener" version="4.0">
+ <brief_description>
+ Interpolates an [Object]'s property over time.
+ </brief_description>
+ <description>
+ [PropertyTweener] is used to interpolate a property in an object. See [method Tween.tween_property] for more usage information.
+ [b]Note:[/b] [method Tween.tween_property] is the only correct way to create [PropertyTweener]. Any [PropertyTweener] created manually will not function correctly.
+ </description>
+ <tutorials>
+ </tutorials>
+ <methods>
+ <method name="as_relative">
+ <return type="PropertyTweener">
+ </return>
+ <description>
+ When called, the final value will be used as a relative value instead. Example:
+ [codeblock]
+ var tween = get_tree().create_tween()
+ tween.tween_property(self, "position", Vector2.RIGHT * 100, 1).as_relative() #the node will move by 100 pixels to the right
+ [/codeblock]
+ </description>
+ </method>
+ <method name="from">
+ <return type="PropertyTweener">
+ </return>
+ <argument index="0" name="value" type="Variant">
+ </argument>
+ <description>
+ Sets a custom initial value to the [PropertyTweener]. Example:
+ [codeblock]
+ var tween = get_tree().create_tween()
+ tween.tween_property(self, "position", Vector2(200, 100), 1).from(Vector2(100, 100) #this will move the node from position (100, 100) to (200, 100)
+ [/codeblock]
+ </description>
+ </method>
+ <method name="from_current">
+ <return type="PropertyTweener">
+ </return>
+ <description>
+ Makes the [PropertyTweener] use the current property value (i.e. at the time of creating this [PropertyTweener]) as a starting point. This is equivalent of using [method from] with the current value. These two calls will do the same:
+ [codeblock]
+ tween.tween_property(self, "position", Vector2(200, 100), 1).from(position)
+ tween.tween_property(self, "position", Vector2(200, 100), 1).from_current()
+ [/codeblock]
+ </description>
+ </method>
+ <method name="set_delay">
+ <return type="PropertyTweener">
+ </return>
+ <argument index="0" name="delay" type="float">
+ </argument>
+ <description>
+ Sets the time in seconds after which the [PropertyTweener] will start interpolating. By default there's no delay.
+ </description>
+ </method>
+ <method name="set_ease">
+ <return type="PropertyTweener">
+ </return>
+ <argument index="0" name="ease" type="int" enum="Tween.EaseType">
+ </argument>
+ <description>
+ Sets the type of used easing from [enum Tween.EaseType]. If not set, the default easing is used from the [Tween] that contains this Tweener.
+ </description>
+ </method>
+ <method name="set_trans">
+ <return type="PropertyTweener">
+ </return>
+ <argument index="0" name="trans" type="int" enum="Tween.TransitionType">
+ </argument>
+ <description>
+ Sets the type of used transition from [enum Tween.TransitionType]. If not set, the default transition is used from the [Tween] that contains this Tweener.
+ </description>
+ </method>
+ </methods>
+ <constants>
+ </constants>
+</class>
diff --git a/doc/classes/ProximityGroup3D.xml b/doc/classes/ProximityGroup3D.xml
index 512d55c9a0..22e397b832 100644
--- a/doc/classes/ProximityGroup3D.xml
+++ b/doc/classes/ProximityGroup3D.xml
@@ -23,7 +23,7 @@
<members>
<member name="dispatch_mode" type="int" setter="set_dispatch_mode" getter="get_dispatch_mode" enum="ProximityGroup3D.DispatchMode" default="0">
</member>
- <member name="grid_radius" type="Vector3" setter="set_grid_radius" getter="get_grid_radius" default="Vector3( 1, 1, 1 )">
+ <member name="grid_radius" type="Vector3" setter="set_grid_radius" getter="get_grid_radius" default="Vector3(1, 1, 1)">
</member>
<member name="group_name" type="String" setter="set_group_name" getter="get_group_name" default="&quot;&quot;">
</member>
diff --git a/doc/classes/QuadMesh.xml b/doc/classes/QuadMesh.xml
index 24a3d76ee2..94d638888c 100644
--- a/doc/classes/QuadMesh.xml
+++ b/doc/classes/QuadMesh.xml
@@ -13,7 +13,7 @@
<methods>
</methods>
<members>
- <member name="size" type="Vector2" setter="set_size" getter="get_size" default="Vector2( 1, 1 )">
+ <member name="size" type="Vector2" setter="set_size" getter="get_size" default="Vector2(1, 1)">
Size on the X and Y axes.
</member>
</members>
diff --git a/doc/classes/Quaternion.xml b/doc/classes/Quaternion.xml
index 678fb0d44d..06434ab268 100644
--- a/doc/classes/Quaternion.xml
+++ b/doc/classes/Quaternion.xml
@@ -83,6 +83,16 @@
Constructs a quaternion defined by the given values.
</description>
</method>
+ <method name="angle_to" qualifiers="const">
+ <return type="float">
+ </return>
+ <argument index="0" name="to" type="Quaternion">
+ </argument>
+ <description>
+ Returns the angle between this quaternion and [code]to[/code]. This is the magnitude of the angle you would need to rotate by to get from one to the other.
+ [b]Note:[/b] This method has an abnormally high amount of floating-point error, so methods such as [code]is_zero_approx[/code] will not work reliably.
+ </description>
+ </method>
<method name="cubic_slerp" qualifiers="const">
<return type="Quaternion">
</return>
@@ -167,17 +177,17 @@
</description>
</method>
<method name="operator *" qualifiers="operator">
- <return type="Quaternion">
+ <return type="Vector3">
</return>
- <argument index="0" name="right" type="Quaternion">
+ <argument index="0" name="right" type="Vector3">
</argument>
<description>
</description>
</method>
<method name="operator *" qualifiers="operator">
- <return type="Vector3">
+ <return type="Quaternion">
</return>
- <argument index="0" name="right" type="Vector3">
+ <argument index="0" name="right" type="Quaternion">
</argument>
<description>
</description>
@@ -201,12 +211,6 @@
<method name="operator +" qualifiers="operator">
<return type="Quaternion">
</return>
- <description>
- </description>
- </method>
- <method name="operator +" qualifiers="operator">
- <return type="Quaternion">
- </return>
<argument index="0" name="right" type="Quaternion">
</argument>
<description>
@@ -215,12 +219,6 @@
<method name="operator -" qualifiers="operator">
<return type="Quaternion">
</return>
- <description>
- </description>
- </method>
- <method name="operator -" qualifiers="operator">
- <return type="Quaternion">
- </return>
<argument index="0" name="right" type="Quaternion">
</argument>
<description>
@@ -258,6 +256,18 @@
<description>
</description>
</method>
+ <method name="operator unary+" qualifiers="operator">
+ <return type="Quaternion">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="operator unary-" qualifiers="operator">
+ <return type="Quaternion">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="slerp" qualifiers="const">
<return type="Quaternion">
</return>
@@ -301,7 +311,7 @@
</member>
</members>
<constants>
- <constant name="IDENTITY" value="Quaternion( 0, 0, 0, 1 )">
+ <constant name="IDENTITY" value="Quaternion(0, 0, 0, 1)">
The identity quaternion, representing no rotation. Equivalent to an identity [Basis] matrix. If a vector is transformed by an identity quaternion, it will not change.
</constant>
</constants>
diff --git a/doc/classes/RDFramebufferPass.xml b/doc/classes/RDFramebufferPass.xml
new file mode 100644
index 0000000000..c26c41f93f
--- /dev/null
+++ b/doc/classes/RDFramebufferPass.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="RDFramebufferPass" inherits="RefCounted" version="4.0">
+ <brief_description>
+ Framebuffer pass attachment description.
+ </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.
+ </description>
+ <tutorials>
+ </tutorials>
+ <methods>
+ </methods>
+ <members>
+ <member name="color_attachments" type="PackedInt32Array" setter="set_color_attachments" getter="get_color_attachments" default="PackedInt32Array()">
+ Color attachments in order starting from 0. If this attachment is not used by the shader, pass ATTACHMENT_UNUSED to skip.
+ </member>
+ <member name="depth_attachment" type="int" setter="set_depth_attachment" getter="get_depth_attachment" default="-1">
+ Depth attachment. ATTACHMENT_UNUSED should be used if no depth buffer is required for this pass.
+ </member>
+ <member name="input_attachments" type="PackedInt32Array" setter="set_input_attachments" getter="get_input_attachments" default="PackedInt32Array()">
+ Used for multipass framebuffers (more than one render pass). Converts an attachment to an input. Make sure to also supply it properly in the [RDUniform] for the uniform set.
+ </member>
+ <member name="preserve_attachments" type="PackedInt32Array" setter="set_preserve_attachments" getter="get_preserve_attachments" default="PackedInt32Array()">
+ Attachments to preserve in this pass (otherwise they are erased).
+ </member>
+ <member name="resolve_attachments" type="PackedInt32Array" setter="set_resolve_attachments" getter="get_resolve_attachments" default="PackedInt32Array()">
+ If the color attachments are multisampled, non-multisampled resolve attachments can be provided.
+ </member>
+ </members>
+ <constants>
+ <constant name="ATTACHMENT_UNUSED" value="-1">
+ </constant>
+ </constants>
+</class>
diff --git a/doc/classes/RDPipelineColorBlendState.xml b/doc/classes/RDPipelineColorBlendState.xml
index 1424a0d653..b672a053c7 100644
--- a/doc/classes/RDPipelineColorBlendState.xml
+++ b/doc/classes/RDPipelineColorBlendState.xml
@@ -9,9 +9,9 @@
<methods>
</methods>
<members>
- <member name="attachments" type="RDPipelineColorBlendStateAttachment[]" setter="set_attachments" getter="get_attachments" default="[ ]">
+ <member name="attachments" type="RDPipelineColorBlendStateAttachment[]" setter="set_attachments" getter="get_attachments" default="[]">
</member>
- <member name="blend_constant" type="Color" setter="set_blend_constant" getter="get_blend_constant" default="Color( 0, 0, 0, 1 )">
+ <member name="blend_constant" type="Color" setter="set_blend_constant" getter="get_blend_constant" default="Color(0, 0, 0, 1)">
</member>
<member name="enable_logic_op" type="bool" setter="set_enable_logic_op" getter="get_enable_logic_op" default="false">
</member>
diff --git a/doc/classes/RDPipelineMultisampleState.xml b/doc/classes/RDPipelineMultisampleState.xml
index 8c90f02301..b4345f1f8b 100644
--- a/doc/classes/RDPipelineMultisampleState.xml
+++ b/doc/classes/RDPipelineMultisampleState.xml
@@ -19,7 +19,7 @@
</member>
<member name="sample_count" type="int" setter="set_sample_count" getter="get_sample_count" enum="RenderingDevice.TextureSamples" default="0">
</member>
- <member name="sample_masks" type="int[]" setter="set_sample_masks" getter="get_sample_masks" default="[ ]">
+ <member name="sample_masks" type="int[]" setter="set_sample_masks" getter="get_sample_masks" default="[]">
</member>
</members>
<constants>
diff --git a/doc/classes/RDShaderBytecode.xml b/doc/classes/RDShaderBytecode.xml
index 7a3501004e..20bf9bdd72 100644
--- a/doc/classes/RDShaderBytecode.xml
+++ b/doc/classes/RDShaderBytecode.xml
@@ -45,15 +45,15 @@
</method>
</methods>
<members>
- <member name="bytecode_compute" type="PackedByteArray" setter="set_stage_bytecode" getter="get_stage_bytecode" default="PackedByteArray( )">
+ <member name="bytecode_compute" type="PackedByteArray" setter="set_stage_bytecode" getter="get_stage_bytecode" default="PackedByteArray()">
</member>
- <member name="bytecode_fragment" type="PackedByteArray" setter="set_stage_bytecode" getter="get_stage_bytecode" default="PackedByteArray( )">
+ <member name="bytecode_fragment" type="PackedByteArray" setter="set_stage_bytecode" getter="get_stage_bytecode" default="PackedByteArray()">
</member>
- <member name="bytecode_tesselation_control" type="PackedByteArray" setter="set_stage_bytecode" getter="get_stage_bytecode" default="PackedByteArray( )">
+ <member name="bytecode_tesselation_control" type="PackedByteArray" setter="set_stage_bytecode" getter="get_stage_bytecode" default="PackedByteArray()">
</member>
- <member name="bytecode_tesselation_evaluation" type="PackedByteArray" setter="set_stage_bytecode" getter="get_stage_bytecode" default="PackedByteArray( )">
+ <member name="bytecode_tesselation_evaluation" type="PackedByteArray" setter="set_stage_bytecode" getter="get_stage_bytecode" default="PackedByteArray()">
</member>
- <member name="bytecode_vertex" type="PackedByteArray" setter="set_stage_bytecode" getter="get_stage_bytecode" default="PackedByteArray( )">
+ <member name="bytecode_vertex" type="PackedByteArray" setter="set_stage_bytecode" getter="get_stage_bytecode" default="PackedByteArray()">
</member>
<member name="compile_error_compute" type="String" setter="set_stage_compile_error" getter="get_stage_compile_error" default="&quot;&quot;">
</member>
diff --git a/doc/classes/RayCast2D.xml b/doc/classes/RayCast2D.xml
index e30d7df63f..14b67b46df 100644
--- a/doc/classes/RayCast2D.xml
+++ b/doc/classes/RayCast2D.xml
@@ -138,7 +138,7 @@
<member name="exclude_parent" type="bool" setter="set_exclude_parent_body" getter="get_exclude_parent_body" default="true">
If [code]true[/code], the parent node will be excluded from collision detection.
</member>
- <member name="target_position" type="Vector2" setter="set_target_position" getter="get_target_position" default="Vector2( 0, 50 )">
+ <member name="target_position" type="Vector2" setter="set_target_position" getter="get_target_position" default="Vector2(0, 50)">
The ray's destination point, relative to the RayCast's [code]position[/code].
</member>
</members>
diff --git a/doc/classes/RayCast3D.xml b/doc/classes/RayCast3D.xml
index 443890438f..98c8c96403 100644
--- a/doc/classes/RayCast3D.xml
+++ b/doc/classes/RayCast3D.xml
@@ -136,7 +136,7 @@
<member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1">
The ray's collision mask. Only objects in at least one collision layer enabled in the mask will be detected. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
</member>
- <member name="debug_shape_custom_color" type="Color" setter="set_debug_shape_custom_color" getter="get_debug_shape_custom_color" default="Color( 0, 0, 0, 1 )">
+ <member name="debug_shape_custom_color" type="Color" setter="set_debug_shape_custom_color" getter="get_debug_shape_custom_color" default="Color(0, 0, 0, 1)">
The custom color to use to draw the shape in the editor and at run-time if [b]Visible Collision Shapes[/b] is enabled in the [b]Debug[/b] menu. This color will be highlighted at run-time if the [RayCast3D] is colliding with something.
If set to [code]Color(0.0, 0.0, 0.0)[/code] (by default), the color set in [member ProjectSettings.debug/shapes/collision/shape_color] is used.
</member>
@@ -149,7 +149,7 @@
<member name="exclude_parent" type="bool" setter="set_exclude_parent_body" getter="get_exclude_parent_body" default="true">
If [code]true[/code], collisions will be ignored for this RayCast3D's immediate parent.
</member>
- <member name="target_position" type="Vector3" setter="set_target_position" getter="get_target_position" default="Vector3( 0, -1, 0 )">
+ <member name="target_position" type="Vector3" setter="set_target_position" getter="get_target_position" default="Vector3(0, -1, 0)">
The ray's destination point, relative to the RayCast's [code]position[/code].
</member>
</members>
diff --git a/doc/classes/Rect2.xml b/doc/classes/Rect2.xml
index 352a18e326..627c488b01 100644
--- a/doc/classes/Rect2.xml
+++ b/doc/classes/Rect2.xml
@@ -214,13 +214,13 @@
</method>
</methods>
<members>
- <member name="end" type="Vector2" setter="" getter="" default="Vector2( 0, 0 )">
+ <member name="end" type="Vector2" setter="" getter="" default="Vector2(0, 0)">
Ending corner. This is calculated as [code]position + size[/code]. Setting this value will change the size.
</member>
- <member name="position" type="Vector2" setter="" getter="" default="Vector2( 0, 0 )">
+ <member name="position" type="Vector2" setter="" getter="" default="Vector2(0, 0)">
Beginning corner. Typically has values lower than [member end].
</member>
- <member name="size" type="Vector2" setter="" getter="" default="Vector2( 0, 0 )">
+ <member name="size" type="Vector2" setter="" getter="" default="Vector2(0, 0)">
Size from [member position] to [member end]. Typically, all components are positive.
If the size is negative, you can use [method abs] to fix it.
</member>
diff --git a/doc/classes/Rect2i.xml b/doc/classes/Rect2i.xml
index 84bef9b406..67d148084f 100644
--- a/doc/classes/Rect2i.xml
+++ b/doc/classes/Rect2i.xml
@@ -193,13 +193,13 @@
</method>
</methods>
<members>
- <member name="end" type="Vector2i" setter="" getter="" default="Vector2i( 0, 0 )">
+ <member name="end" type="Vector2i" setter="" getter="" default="Vector2i(0, 0)">
Ending corner. This is calculated as [code]position + size[/code]. Setting this value will change the size.
</member>
- <member name="position" type="Vector2i" setter="" getter="" default="Vector2i( 0, 0 )">
+ <member name="position" type="Vector2i" setter="" getter="" default="Vector2i(0, 0)">
Beginning corner. Typically has values lower than [member end].
</member>
- <member name="size" type="Vector2i" setter="" getter="" default="Vector2i( 0, 0 )">
+ <member name="size" type="Vector2i" setter="" getter="" default="Vector2i(0, 0)">
Size from [member position] to [member end]. Typically, all components are positive.
If the size is negative, you can use [method abs] to fix it.
</member>
diff --git a/doc/classes/RectangleShape2D.xml b/doc/classes/RectangleShape2D.xml
index 8e37fbad6f..f2795ae4a1 100644
--- a/doc/classes/RectangleShape2D.xml
+++ b/doc/classes/RectangleShape2D.xml
@@ -13,7 +13,7 @@
<methods>
</methods>
<members>
- <member name="size" type="Vector2" setter="set_size" getter="get_size" default="Vector2( 20, 20 )">
+ <member name="size" type="Vector2" setter="set_size" getter="get_size" default="Vector2(20, 20)">
The rectangle's width and height.
</member>
</members>
diff --git a/doc/classes/ReferenceRect.xml b/doc/classes/ReferenceRect.xml
index 1a3fbbdfc5..df9a6f0a46 100644
--- a/doc/classes/ReferenceRect.xml
+++ b/doc/classes/ReferenceRect.xml
@@ -11,7 +11,7 @@
<methods>
</methods>
<members>
- <member name="border_color" type="Color" setter="set_border_color" getter="get_border_color" default="Color( 1, 0, 0, 1 )">
+ <member name="border_color" type="Color" setter="set_border_color" getter="get_border_color" default="Color(1, 0, 0, 1)">
Sets the border [Color] of the [ReferenceRect].
</member>
<member name="border_width" type="float" setter="set_border_width" getter="get_border_width" default="1.0">
diff --git a/doc/classes/ReflectionProbe.xml b/doc/classes/ReflectionProbe.xml
index 13df17cd22..db01faced8 100644
--- a/doc/classes/ReflectionProbe.xml
+++ b/doc/classes/ReflectionProbe.xml
@@ -13,7 +13,7 @@
<methods>
</methods>
<members>
- <member name="ambient_color" type="Color" setter="set_ambient_color" getter="get_ambient_color" default="Color( 0, 0, 0, 1 )">
+ <member name="ambient_color" type="Color" setter="set_ambient_color" getter="get_ambient_color" default="Color(0, 0, 0, 1)">
</member>
<member name="ambient_color_energy" type="float" setter="set_ambient_color_energy" getter="get_ambient_color_energy" default="1.0">
</member>
@@ -28,8 +28,8 @@
<member name="enable_shadows" type="bool" setter="set_enable_shadows" getter="are_shadows_enabled" default="false">
If [code]true[/code], computes shadows in the reflection probe. This makes the reflection probe slower to render; you may want to disable this if using the [constant UPDATE_ALWAYS] [member update_mode].
</member>
- <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3( 1, 1, 1 )">
- The size of the reflection probe. The larger the extents the more space covered by the probe which will lower the perceived resolution. It is best to keep the extents only as large as you need them.
+ <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3(10, 10, 10)">
+ The size of the reflection probe. The larger the extents, the more space covered by the probe, which will lower the perceived resolution. It is best to keep the extents only as large as you need them.
</member>
<member name="intensity" type="float" setter="set_intensity" getter="get_intensity" default="1.0">
Defines the reflection intensity. Intensity modulates the strength of the reflection.
@@ -42,7 +42,7 @@
<member name="max_distance" type="float" setter="set_max_distance" getter="get_max_distance" default="0.0">
Sets the max distance away from the probe an object can be before it is culled.
</member>
- <member name="origin_offset" type="Vector3" setter="set_origin_offset" getter="get_origin_offset" default="Vector3( 0, 0, 0 )">
+ <member name="origin_offset" type="Vector3" setter="set_origin_offset" getter="get_origin_offset" default="Vector3(0, 0, 0)">
Sets the origin offset to be used when this reflection probe is in box project mode.
</member>
<member name="update_mode" type="int" setter="set_update_mode" getter="get_update_mode" enum="ReflectionProbe.UpdateMode" default="0">
diff --git a/doc/classes/RenderingDevice.xml b/doc/classes/RenderingDevice.xml
index 841d2bde72..b66b945025 100644
--- a/doc/classes/RenderingDevice.xml
+++ b/doc/classes/RenderingDevice.xml
@@ -196,15 +196,15 @@
</argument>
<argument index="4" name="final_depth_action" type="int" enum="RenderingDevice.FinalAction">
</argument>
- <argument index="5" name="clear_color_values" type="PackedColorArray" default="PackedColorArray( )">
+ <argument index="5" name="clear_color_values" type="PackedColorArray" default="PackedColorArray()">
</argument>
<argument index="6" name="clear_depth" type="float" default="1.0">
</argument>
<argument index="7" name="clear_stencil" type="int" default="0">
</argument>
- <argument index="8" name="region" type="Rect2" default="Rect2i( 0, 0, 0, 0 )">
+ <argument index="8" name="region" type="Rect2" default="Rect2i(0, 0, 0, 0)">
</argument>
- <argument index="9" name="storage_textures" type="Array" default="[ ]">
+ <argument index="9" name="storage_textures" type="Array" default="[]">
</argument>
<description>
</description>
@@ -214,7 +214,7 @@
</return>
<argument index="0" name="screen" type="int" default="0">
</argument>
- <argument index="1" name="clear_color" type="Color" default="Color( 0, 0, 0, 1 )">
+ <argument index="1" name="clear_color" type="Color" default="Color(0, 0, 0, 1)">
</argument>
<description>
</description>
@@ -234,15 +234,15 @@
</argument>
<argument index="5" name="final_depth_action" type="int" enum="RenderingDevice.FinalAction">
</argument>
- <argument index="6" name="clear_color_values" type="PackedColorArray" default="PackedColorArray( )">
+ <argument index="6" name="clear_color_values" type="PackedColorArray" default="PackedColorArray()">
</argument>
<argument index="7" name="clear_depth" type="float" default="1.0">
</argument>
<argument index="8" name="clear_stencil" type="int" default="0">
</argument>
- <argument index="9" name="region" type="Rect2" default="Rect2i( 0, 0, 0, 0 )">
+ <argument index="9" name="region" type="Rect2" default="Rect2i(0, 0, 0, 0)">
</argument>
- <argument index="10" name="storage_textures" type="RID[]" default="[ ]">
+ <argument index="10" name="storage_textures" type="RID[]" default="[]">
</argument>
<description>
</description>
@@ -316,7 +316,7 @@
</return>
<argument index="0" name="draw_list" type="int">
</argument>
- <argument index="1" name="rect" type="Rect2" default="Rect2i( 0, 0, 0, 0 )">
+ <argument index="1" name="rect" type="Rect2" default="Rect2i(0, 0, 0, 0)">
</argument>
<description>
</description>
@@ -341,13 +341,29 @@
<description>
</description>
</method>
+ <method name="draw_list_switch_to_next_pass">
+ <return type="int">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="draw_list_switch_to_next_pass_split">
+ <return type="PackedInt64Array">
+ </return>
+ <argument index="0" name="splits" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="framebuffer_create">
<return type="RID">
</return>
- <argument index="0" name="textures" type="Array">
+ <argument index="0" name="textures" type="RID[]">
</argument>
<argument index="1" name="validate_with_format" type="int" default="-1">
</argument>
+ <argument index="2" name="view_count" type="int" default="1">
+ </argument>
<description>
</description>
</method>
@@ -363,11 +379,27 @@
<description>
</description>
</method>
+ <method name="framebuffer_create_multipass">
+ <return type="RID">
+ </return>
+ <argument index="0" name="textures" type="RID[]">
+ </argument>
+ <argument index="1" name="passes" type="RDFramebufferPass[]">
+ </argument>
+ <argument index="2" name="validate_with_format" type="int" default="-1">
+ </argument>
+ <argument index="3" name="view_count" type="int" default="1">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="framebuffer_format_create">
<return type="int">
</return>
<argument index="0" name="attachments" type="RDAttachmentFormat[]">
</argument>
+ <argument index="1" name="view_count" type="int" default="1">
+ </argument>
<description>
</description>
</method>
@@ -379,11 +411,25 @@
<description>
</description>
</method>
+ <method name="framebuffer_format_create_multipass">
+ <return type="int">
+ </return>
+ <argument index="0" name="attachments" type="RDAttachmentFormat[]">
+ </argument>
+ <argument index="1" name="passes" type="RDFramebufferPass[]">
+ </argument>
+ <argument index="2" name="view_count" type="int" default="1">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="framebuffer_format_get_texture_samples">
<return type="int" enum="RenderingDevice.TextureSamples">
</return>
<argument index="0" name="format" type="int">
</argument>
+ <argument index="1" name="render_pass" type="int" default="0">
+ </argument>
<description>
</description>
</method>
@@ -488,7 +534,7 @@
</argument>
<argument index="1" name="format" type="int" enum="RenderingDevice.IndexBufferFormat">
</argument>
- <argument index="2" name="data" type="PackedByteArray" default="PackedByteArray( )">
+ <argument index="2" name="data" type="PackedByteArray" default="PackedByteArray()">
</argument>
<argument index="3" name="use_restart_indices" type="bool" default="false">
</argument>
@@ -524,6 +570,8 @@
</argument>
<argument index="8" name="dynamic_state_flags" type="int" default="0">
</argument>
+ <argument index="9" name="for_render_pass" type="int" default="0">
+ </argument>
<description>
</description>
</method>
@@ -606,7 +654,7 @@
</return>
<argument index="0" name="size_bytes" type="int">
</argument>
- <argument index="1" name="data" type="PackedByteArray" default="PackedByteArray( )">
+ <argument index="1" name="data" type="PackedByteArray" default="PackedByteArray()">
</argument>
<argument index="2" name="usage" type="int" default="0">
</argument>
@@ -632,7 +680,7 @@
</argument>
<argument index="1" name="format" type="int" enum="RenderingDevice.DataFormat">
</argument>
- <argument index="2" name="data" type="PackedByteArray" default="PackedByteArray( )">
+ <argument index="2" name="data" type="PackedByteArray" default="PackedByteArray()">
</argument>
<description>
</description>
@@ -690,7 +738,7 @@
</argument>
<argument index="1" name="view" type="RDTextureView">
</argument>
- <argument index="2" name="data" type="PackedByteArray[]" default="[ ]">
+ <argument index="2" name="data" type="PackedByteArray[]" default="[]">
</argument>
<description>
</description>
@@ -788,7 +836,7 @@
</return>
<argument index="0" name="size_bytes" type="int">
</argument>
- <argument index="1" name="data" type="PackedByteArray" default="PackedByteArray( )">
+ <argument index="1" name="data" type="PackedByteArray" default="PackedByteArray()">
</argument>
<description>
</description>
@@ -818,7 +866,7 @@
</return>
<argument index="0" name="size_bytes" type="int">
</argument>
- <argument index="1" name="data" type="PackedByteArray" default="PackedByteArray( )">
+ <argument index="1" name="data" type="PackedByteArray" default="PackedByteArray()">
</argument>
<argument index="2" name="use_as_storage" type="bool" default="false">
</argument>
diff --git a/doc/classes/RenderingServer.xml b/doc/classes/RenderingServer.xml
index 300108ff77..44e0202307 100644
--- a/doc/classes/RenderingServer.xml
+++ b/doc/classes/RenderingServer.xml
@@ -620,7 +620,7 @@
</argument>
<argument index="5" name="reflection_source" type="int" enum="RenderingServer.EnvironmentReflectionSource" default="0">
</argument>
- <argument index="6" name="ao_color" type="Color" default="Color( 0, 0, 0, 1 )">
+ <argument index="6" name="ao_color" type="Color" default="Color(0, 0, 0, 1)">
</argument>
<description>
</description>
@@ -2725,7 +2725,7 @@
</return>
<argument index="0" name="viewport" type="RID">
</argument>
- <argument index="1" name="rect" type="Rect2" default="Rect2( 0, 0, 0, 0 )">
+ <argument index="1" name="rect" type="Rect2" default="Rect2(0, 0, 0, 0)">
</argument>
<argument index="2" name="screen" type="int" default="0">
</argument>
diff --git a/doc/classes/Resource.xml b/doc/classes/Resource.xml
index 6edb3b1a11..c8800a3c25 100644
--- a/doc/classes/Resource.xml
+++ b/doc/classes/Resource.xml
@@ -4,7 +4,7 @@
Base class for all resources.
</brief_description>
<description>
- Resource is the base class for all Godot-specific resource types, serving primarily as data containers. Since they inherit from [RefCounted], resources are reference-counted and freed when no longer in use. They are also cached once loaded from disk, so that any further attempts to load a resource from a given path will return the same reference (all this in contrast to a [Node], which is not reference-counted and can be instanced from disk as many times as desired). Resources can be saved externally on disk or bundled into another object, such as a [Node] or another resource.
+ Resource is the base class for all Godot-specific resource types, serving primarily as data containers. Since they inherit from [RefCounted], resources are reference-counted and freed when no longer in use. They are also cached once loaded from disk, so that any further attempts to load a resource from a given path will return the same reference (all this in contrast to a [Node], which is not reference-counted and can be instantiated from disk as many times as desired). Resources can be saved externally on disk or bundled into another object, such as a [Node] or another resource.
[b]Note:[/b] In C#, resources will not be freed instantly after they are no longer in use. Instead, garbage collection will run periodically and will free resources that are no longer in use. This means that unused resources will linger on for a while before being removed.
</description>
<tutorials>
diff --git a/doc/classes/ResourceLoader.xml b/doc/classes/ResourceLoader.xml
index c81b21333f..682d7b97f3 100644
--- a/doc/classes/ResourceLoader.xml
+++ b/doc/classes/ResourceLoader.xml
@@ -84,7 +84,7 @@
</return>
<argument index="0" name="path" type="String">
</argument>
- <argument index="1" name="progress" type="Array" default="[ ]">
+ <argument index="1" name="progress" type="Array" default="[]">
</argument>
<description>
Returns the status of a threaded loading operation started with [method load_threaded_request] for the resource at [code]path[/code]. See [enum ThreadLoadStatus] for possible return values.
diff --git a/doc/classes/RichTextLabel.xml b/doc/classes/RichTextLabel.xml
index 7ca70f5a7a..38884a027f 100644
--- a/doc/classes/RichTextLabel.xml
+++ b/doc/classes/RichTextLabel.xml
@@ -24,7 +24,7 @@
</argument>
<argument index="2" name="height" type="int" default="0">
</argument>
- <argument index="3" name="color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="3" name="color" type="Color" default="Color(1, 1, 1, 1)">
</argument>
<argument index="4" name="inline_align" type="int" enum="VAlign" default="0">
</argument>
@@ -170,6 +170,15 @@
Terminates the current tag. Use after [code]push_*[/code] methods to close BBCodes manually. Does not need to follow [code]add_*[/code] methods.
</description>
</method>
+ <method name="push_bgcolor">
+ <return type="void">
+ </return>
+ <argument index="0" name="bgcolor" type="Color">
+ </argument>
+ <description>
+ Adds a [code][bgcolor][/code] tag to the tag stack.
+ </description>
+ </method>
<method name="push_bold">
<return type="void">
</return>
@@ -209,18 +218,27 @@
</argument>
<argument index="2" name="size" type="int">
</argument>
- <argument index="3" name="dropcap_margins" type="Rect2" default="Rect2( 0, 0, 0, 0 )">
+ <argument index="3" name="dropcap_margins" type="Rect2" default="Rect2(0, 0, 0, 0)">
</argument>
- <argument index="4" name="color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="4" name="color" type="Color" default="Color(1, 1, 1, 1)">
</argument>
<argument index="5" name="outline_size" type="int" default="0">
</argument>
- <argument index="6" name="outline_color" type="Color" default="Color( 0, 0, 0, 0 )">
+ <argument index="6" name="outline_color" type="Color" default="Color(0, 0, 0, 0)">
</argument>
<description>
Adds a [code][dropcap][/code] tag to the tag stack. Drop cap (dropped capital) is a decorative element at the beginning of a paragraph that is larger than the rest of the text.
</description>
</method>
+ <method name="push_fgcolor">
+ <return type="void">
+ </return>
+ <argument index="0" name="fgcolor" type="Color">
+ </argument>
+ <description>
+ Adds a [code][fgcolor][/code] tag to the tag stack.
+ </description>
+ </method>
<method name="push_font">
<return type="void">
</return>
@@ -450,7 +468,7 @@
The label's text in BBCode format. Is not representative of manual modifications to the internal tag stack. Erases changes made by other methods when edited.
[b]Note:[/b] It is unadvised to use the [code]+=[/code] operator with [code]bbcode_text[/code] (e.g. [code]bbcode_text += "some string"[/code]) as it replaces the whole text and can cause slowdowns. Use [method append_bbcode] for adding text instead, unless you absolutely need to close a tag that was opened in an earlier method call.
</member>
- <member name="custom_effects" type="Array" setter="set_effects" getter="get_effects" default="[ ]">
+ <member name="custom_effects" type="Array" setter="set_effects" getter="get_effects" default="[]">
The currently installed custom effects. This is an array of [RichTextEffect]s.
To add a custom effect, it's more convenient to use [method install_effect].
</member>
@@ -484,7 +502,7 @@
<member name="structured_text_bidi_override" type="int" setter="set_structured_text_bidi_override" getter="get_structured_text_bidi_override" enum="Control.StructuredTextParser" default="0">
Set BiDi algorithm override for the structured text.
</member>
- <member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" default="[ ]">
+ <member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" default="[]">
Set additional options for BiDi override.
</member>
<member name="tab_size" type="int" setter="set_tab_size" getter="get_tab_size" default="4">
@@ -592,11 +610,15 @@
</constant>
<constant name="ITEM_RAINBOW" value="20" enum="ItemType">
</constant>
- <constant name="ITEM_META" value="21" enum="ItemType">
+ <constant name="ITEM_BGCOLOR" value="21" enum="ItemType">
+ </constant>
+ <constant name="ITEM_FGCOLOR" value="22" enum="ItemType">
+ </constant>
+ <constant name="ITEM_META" value="23" enum="ItemType">
</constant>
- <constant name="ITEM_DROPCAP" value="22" enum="ItemType">
+ <constant name="ITEM_DROPCAP" value="24" enum="ItemType">
</constant>
- <constant name="ITEM_CUSTOMFX" value="23" enum="ItemType">
+ <constant name="ITEM_CUSTOMFX" value="25" enum="ItemType">
</constant>
</constants>
<theme_items>
@@ -612,19 +634,19 @@
<theme_item name="bold_italics_font_size" type="int">
The font size used for bold italics text.
</theme_item>
- <theme_item name="default_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="default_color" type="Color" default="Color(1, 1, 1, 1)">
The default text color.
</theme_item>
<theme_item name="focus" type="StyleBox">
The background The background used when the [RichTextLabel] is focused.
</theme_item>
- <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)">
The default tint of text outline.
</theme_item>
- <theme_item name="font_selected_color" type="Color" default="Color( 0, 0, 0, 1 )">
+ <theme_item name="font_selected_color" type="Color" default="Color(0, 0, 0, 1)">
The color of selected text, used when [member selection_enabled] is [code]true[/code].
</theme_item>
- <theme_item name="font_shadow_color" type="Color" default="Color( 0, 0, 0, 0 )">
+ <theme_item name="font_shadow_color" type="Color" default="Color(0, 0, 0, 0)">
The color of the font's shadow.
</theme_item>
<theme_item name="italics_font" type="Font">
@@ -654,7 +676,7 @@
<theme_item name="outline_size" type="int" default="0">
The size of the text outline.
</theme_item>
- <theme_item name="selection_color" type="Color" default="Color( 0.1, 0.1, 1, 0.8 )">
+ <theme_item name="selection_color" type="Color" default="Color(0.1, 0.1, 1, 0.8)">
The color of the selection box.
</theme_item>
<theme_item name="shadow_as_outline" type="int" default="0">
@@ -666,16 +688,16 @@
<theme_item name="shadow_offset_y" type="int" default="1">
The vertical offset of the font's shadow.
</theme_item>
- <theme_item name="table_border" type="Color" default="Color( 0, 0, 0, 0 )">
+ <theme_item name="table_border" type="Color" default="Color(0, 0, 0, 0)">
The default cell border color.
</theme_item>
- <theme_item name="table_even_row_bg" type="Color" default="Color( 0, 0, 0, 0 )">
+ <theme_item name="table_even_row_bg" type="Color" default="Color(0, 0, 0, 0)">
The default background color for even rows.
</theme_item>
<theme_item name="table_hseparation" type="int" default="3">
The horizontal separation of elements in a table.
</theme_item>
- <theme_item name="table_odd_row_bg" type="Color" default="Color( 0, 0, 0, 0 )">
+ <theme_item name="table_odd_row_bg" type="Color" default="Color(0, 0, 0, 0)">
The default background color for odd rows.
</theme_item>
<theme_item name="table_vseparation" type="int" default="3">
diff --git a/doc/classes/RigidBody2D.xml b/doc/classes/RigidBody2D.xml
index 237317daf1..64573b7282 100644
--- a/doc/classes/RigidBody2D.xml
+++ b/doc/classes/RigidBody2D.xml
@@ -39,7 +39,7 @@
</return>
<argument index="0" name="force" type="Vector2">
</argument>
- <argument index="1" name="position" type="Vector2" default="Vector2( 0, 0 )">
+ <argument index="1" name="position" type="Vector2" default="Vector2(0, 0)">
</argument>
<description>
Adds a positioned force to the body. Both the force and the offset from the body origin are in global coordinates.
@@ -57,7 +57,7 @@
<method name="apply_central_impulse">
<return type="void">
</return>
- <argument index="0" name="impulse" type="Vector2" default="Vector2( 0, 0 )">
+ <argument index="0" name="impulse" type="Vector2" default="Vector2(0, 0)">
</argument>
<description>
Applies a directional impulse without affecting rotation.
@@ -68,7 +68,7 @@
</return>
<argument index="0" name="impulse" type="Vector2">
</argument>
- <argument index="1" name="position" type="Vector2" default="Vector2( 0, 0 )">
+ <argument index="1" name="position" type="Vector2" default="Vector2(0, 0)">
</argument>
<description>
Applies a positioned impulse to the body. An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason it should only be used when simulating one-time impacts (use the "_force" functions otherwise). The position uses the rotation of the global coordinate system, but is centered at the object's origin.
@@ -109,7 +109,7 @@
<member name="angular_velocity" type="float" setter="set_angular_velocity" getter="get_angular_velocity" default="0.0">
The body's rotational velocity.
</member>
- <member name="applied_force" type="Vector2" setter="set_applied_force" getter="get_applied_force" default="Vector2( 0, 0 )">
+ <member name="applied_force" type="Vector2" setter="set_applied_force" getter="get_applied_force" default="Vector2(0, 0)">
The body's total applied force.
</member>
<member name="applied_torque" type="float" setter="set_applied_torque" getter="get_applied_torque" default="0.0">
@@ -142,7 +142,7 @@
Damps the body's [member linear_velocity]. If [code]-1[/code], the body will use the [b]Default Linear Damp[/b] in [b]Project &gt; Project Settings &gt; Physics &gt; 2d[/b].
See [member ProjectSettings.physics/2d/default_linear_damp] for more details about damping.
</member>
- <member name="linear_velocity" type="Vector2" setter="set_linear_velocity" getter="get_linear_velocity" default="Vector2( 0, 0 )">
+ <member name="linear_velocity" type="Vector2" setter="set_linear_velocity" getter="get_linear_velocity" default="Vector2(0, 0)">
The body's linear velocity.
</member>
<member name="mass" type="float" setter="set_mass" getter="get_mass" default="1.0">
diff --git a/doc/classes/RigidBody3D.xml b/doc/classes/RigidBody3D.xml
index e3349169ff..fb2b9690a3 100644
--- a/doc/classes/RigidBody3D.xml
+++ b/doc/classes/RigidBody3D.xml
@@ -40,7 +40,7 @@
</return>
<argument index="0" name="force" type="Vector3">
</argument>
- <argument index="1" name="position" type="Vector3" default="Vector3( 0, 0, 0 )">
+ <argument index="1" name="position" type="Vector3" default="Vector3(0, 0, 0)">
</argument>
<description>
Adds a constant directional force (i.e. acceleration).
@@ -71,7 +71,7 @@
</return>
<argument index="0" name="impulse" type="Vector3">
</argument>
- <argument index="1" name="position" type="Vector3" default="Vector3( 0, 0, 0 )">
+ <argument index="1" name="position" type="Vector3" default="Vector3(0, 0, 0)">
</argument>
<description>
Applies a positioned impulse to the body. An impulse is time independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason it should only be used when simulating one-time impacts. The position uses the rotation of the global coordinate system, but is centered at the object's origin.
@@ -116,7 +116,7 @@
Damps RigidBody3D's rotational forces.
See [member ProjectSettings.physics/3d/default_angular_damp] for more details about damping.
</member>
- <member name="angular_velocity" type="Vector3" setter="set_angular_velocity" getter="get_angular_velocity" default="Vector3( 0, 0, 0 )">
+ <member name="angular_velocity" type="Vector3" setter="set_angular_velocity" getter="get_angular_velocity" default="Vector3(0, 0, 0)">
RigidBody3D's rotational velocity.
</member>
<member name="can_sleep" type="bool" setter="set_can_sleep" getter="is_able_to_sleep" default="true">
@@ -143,7 +143,7 @@
The body's linear damp. Cannot be less than -1.0. If this value is different from -1.0, any linear damp derived from the world or areas will be overridden.
See [member ProjectSettings.physics/3d/default_linear_damp] for more details about damping.
</member>
- <member name="linear_velocity" type="Vector3" setter="set_linear_velocity" getter="get_linear_velocity" default="Vector3( 0, 0, 0 )">
+ <member name="linear_velocity" type="Vector3" setter="set_linear_velocity" getter="get_linear_velocity" default="Vector3(0, 0, 0)">
The body's linear velocity. Can be used sporadically, but [b]don't set this every frame[/b], because physics may run in another thread and runs at a different granularity. Use [method _integrate_forces] as your process loop for precise control of the body state.
</member>
<member name="mass" type="float" setter="set_mass" getter="get_mass" default="1.0">
diff --git a/doc/classes/SceneState.xml b/doc/classes/SceneState.xml
index f9e0ef76b9..6d804cc697 100644
--- a/doc/classes/SceneState.xml
+++ b/doc/classes/SceneState.xml
@@ -95,7 +95,7 @@
<argument index="0" name="idx" type="int">
</argument>
<description>
- Returns the node's index, which is its position relative to its siblings. This is only relevant and saved in scenes for cases where new nodes are added to an instanced or inherited scene among siblings from the base scene. Despite the name, this index is not related to the [code]idx[/code] argument used here and in other methods.
+ Returns the node's index, which is its position relative to its siblings. This is only relevant and saved in scenes for cases where new nodes are added to an instantiated or inherited scene among siblings from the base scene. Despite the name, this index is not related to the [code]idx[/code] argument used here and in other methods.
</description>
</method>
<method name="get_node_instance" qualifiers="const">
@@ -199,14 +199,14 @@
</methods>
<constants>
<constant name="GEN_EDIT_STATE_DISABLED" value="0" enum="GenEditState">
- If passed to [method PackedScene.instance], blocks edits to the scene state.
+ If passed to [method PackedScene.instantiate], blocks edits to the scene state.
</constant>
<constant name="GEN_EDIT_STATE_INSTANCE" value="1" enum="GenEditState">
- If passed to [method PackedScene.instance], provides inherited scene resources to the local scene.
+ If passed to [method PackedScene.instantiate], provides inherited scene resources to the local scene.
[b]Note:[/b] Only available in editor builds.
</constant>
<constant name="GEN_EDIT_STATE_MAIN" value="2" enum="GenEditState">
- If passed to [method PackedScene.instance], provides local scene resources to the local scene. Only the main scene should receive the main edit state.
+ If passed to [method PackedScene.instantiate], provides local scene resources to the local scene. Only the main scene should receive the main edit state.
[b]Note:[/b] Only available in editor builds.
</constant>
</constants>
diff --git a/doc/classes/SceneTree.xml b/doc/classes/SceneTree.xml
index 7a15153fc2..d327e8cbca 100644
--- a/doc/classes/SceneTree.xml
+++ b/doc/classes/SceneTree.xml
@@ -90,6 +90,13 @@
The timer will be automatically freed after its time elapses.
</description>
</method>
+ <method name="create_tween">
+ <return type="Tween">
+ </return>
+ <description>
+ Creates and returns a new [Tween].
+ </description>
+ </method>
<method name="get_first_node_in_group">
<return type="Node">
</return>
@@ -135,6 +142,13 @@
Returns a list of all nodes assigned to the given group.
</description>
</method>
+ <method name="get_processed_tweens">
+ <return type="Array">
+ </return>
+ <description>
+ Returns an array of currently exising [Tween]s in the [SceneTree] (both running and paused).
+ </description>
+ </method>
<method name="get_rpc_sender_id" qualifiers="const">
<return type="int">
</return>
diff --git a/doc/classes/Script.xml b/doc/classes/Script.xml
index 56272760bd..e7527d73e2 100644
--- a/doc/classes/Script.xml
+++ b/doc/classes/Script.xml
@@ -11,11 +11,11 @@
<link title="Scripting">https://docs.godotengine.org/en/latest/getting_started/step_by_step/scripting.html</link>
</tutorials>
<methods>
- <method name="can_instance" qualifiers="const">
+ <method name="can_instantiate" qualifiers="const">
<return type="bool">
</return>
<description>
- Returns [code]true[/code] if the script can be instanced.
+ Returns [code]true[/code] if the script can be instantiated.
</description>
</method>
<method name="get_base_script" qualifiers="const">
diff --git a/doc/classes/SegmentShape2D.xml b/doc/classes/SegmentShape2D.xml
index 31c0f7f1f3..341c5e9d20 100644
--- a/doc/classes/SegmentShape2D.xml
+++ b/doc/classes/SegmentShape2D.xml
@@ -11,10 +11,10 @@
<methods>
</methods>
<members>
- <member name="a" type="Vector2" setter="set_a" getter="get_a" default="Vector2( 0, 0 )">
+ <member name="a" type="Vector2" setter="set_a" getter="get_a" default="Vector2(0, 0)">
The segment's first point position.
</member>
- <member name="b" type="Vector2" setter="set_b" getter="get_b" default="Vector2( 0, 10 )">
+ <member name="b" type="Vector2" setter="set_b" getter="get_b" default="Vector2(0, 10)">
The segment's second point position.
</member>
</members>
diff --git a/doc/classes/Signal.xml b/doc/classes/Signal.xml
index 84efc974c0..1fd70a43fd 100644
--- a/doc/classes/Signal.xml
+++ b/doc/classes/Signal.xml
@@ -40,7 +40,7 @@
</return>
<argument index="0" name="callable" type="Callable">
</argument>
- <argument index="1" name="binds" type="Array" default="[ ]">
+ <argument index="1" name="binds" type="Array" default="[]">
</argument>
<argument index="2" name="flags" type="int" default="0">
</argument>
diff --git a/doc/classes/Skeleton3D.xml b/doc/classes/Skeleton3D.xml
index d8b35ad272..136f2f0a63 100644
--- a/doc/classes/Skeleton3D.xml
+++ b/doc/classes/Skeleton3D.xml
@@ -171,7 +171,7 @@
<method name="physical_bones_start_simulation">
<return type="void">
</return>
- <argument index="0" name="bones" type="StringName[]" default="[ ]">
+ <argument index="0" name="bones" type="StringName[]" default="[]">
</argument>
<description>
Tells the [PhysicalBone3D] nodes in the Skeleton to start simulating and reacting to the physics world.
diff --git a/doc/classes/SkeletonIK3D.xml b/doc/classes/SkeletonIK3D.xml
index dccc45d0ec..138ebe4411 100644
--- a/doc/classes/SkeletonIK3D.xml
+++ b/doc/classes/SkeletonIK3D.xml
@@ -38,7 +38,7 @@
<members>
<member name="interpolation" type="float" setter="set_interpolation" getter="get_interpolation" default="1.0">
</member>
- <member name="magnet" type="Vector3" setter="set_magnet_position" getter="get_magnet_position" default="Vector3( 0, 0, 0 )">
+ <member name="magnet" type="Vector3" setter="set_magnet_position" getter="get_magnet_position" default="Vector3(0, 0, 0)">
</member>
<member name="max_iterations" type="int" setter="set_max_iterations" getter="get_max_iterations" default="10">
</member>
@@ -48,7 +48,7 @@
</member>
<member name="root_bone" type="StringName" setter="set_root_bone" getter="get_root_bone" default="&amp;&quot;&quot;">
</member>
- <member name="target" type="Transform3D" setter="set_target_transform" getter="get_target_transform" default="Transform3D( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )">
+ <member name="target" type="Transform3D" setter="set_target_transform" getter="get_target_transform" default="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)">
</member>
<member name="target_node" type="NodePath" setter="set_target_node" getter="get_target_node" default="NodePath(&quot;&quot;)">
</member>
diff --git a/doc/classes/SkeletonModification2DJiggle.xml b/doc/classes/SkeletonModification2DJiggle.xml
index 7f8cf2d4d9..ae46acd0d0 100644
--- a/doc/classes/SkeletonModification2DJiggle.xml
+++ b/doc/classes/SkeletonModification2DJiggle.xml
@@ -208,7 +208,7 @@
<member name="damping" type="float" setter="set_damping" getter="get_damping" default="0.75">
The default amount of dampening applied to the Jiggle joints, if they are not overriden. Higher values lead to more of the calculated velocity being applied.
</member>
- <member name="gravity" type="Vector2" setter="set_gravity" getter="get_gravity" default="Vector2( 0, 6 )">
+ <member name="gravity" type="Vector2" setter="set_gravity" getter="get_gravity" default="Vector2(0, 6)">
The default amount of gravity applied to the Jiggle joints, if they are not overriden.
</member>
<member name="jiggle_data_chain_length" type="int" setter="set_jiggle_data_chain_length" getter="get_jiggle_data_chain_length" default="0">
diff --git a/doc/classes/SkeletonModification2DPhysicalBones.xml b/doc/classes/SkeletonModification2DPhysicalBones.xml
index d8aaf09a8e..2547727097 100644
--- a/doc/classes/SkeletonModification2DPhysicalBones.xml
+++ b/doc/classes/SkeletonModification2DPhysicalBones.xml
@@ -40,7 +40,7 @@
<method name="start_simulation">
<return type="void">
</return>
- <argument index="0" name="bones" type="StringName[]" default="[ ]">
+ <argument index="0" name="bones" type="StringName[]" default="[]">
</argument>
<description>
Tell the [PhysicalBone2D] nodes to start simulating and interacting with the physics world.
@@ -50,7 +50,7 @@
<method name="stop_simulation">
<return type="void">
</return>
- <argument index="0" name="bones" type="StringName[]" default="[ ]">
+ <argument index="0" name="bones" type="StringName[]" default="[]">
</argument>
<description>
Tell the [PhysicalBone2D] nodes to stop simulating and interacting with the physics world.
diff --git a/doc/classes/Sprite2D.xml b/doc/classes/Sprite2D.xml
index c320adb1be..b419b003bf 100644
--- a/doc/classes/Sprite2D.xml
+++ b/doc/classes/Sprite2D.xml
@@ -64,13 +64,13 @@
<member name="frame" type="int" setter="set_frame" getter="get_frame" default="0">
Current frame to display from sprite sheet. [member hframes] or [member vframes] must be greater than 1.
</member>
- <member name="frame_coords" type="Vector2i" setter="set_frame_coords" getter="get_frame_coords" default="Vector2i( 0, 0 )">
+ <member name="frame_coords" type="Vector2i" setter="set_frame_coords" getter="get_frame_coords" default="Vector2i(0, 0)">
Coordinates of the frame to display from sprite sheet. This is as an alias for the [member frame] property. [member hframes] or [member vframes] must be greater than 1.
</member>
<member name="hframes" type="int" setter="set_hframes" getter="get_hframes" default="1">
The number of columns in the sprite sheet.
</member>
- <member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2( 0, 0 )">
+ <member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2(0, 0)">
The texture's drawing offset.
</member>
<member name="region_enabled" type="bool" setter="set_region_enabled" getter="is_region_enabled" default="false">
@@ -79,7 +79,7 @@
<member name="region_filter_clip_enabled" type="bool" setter="set_region_filter_clip_enabled" getter="is_region_filter_clip_enabled" default="false">
If [code]true[/code], the outermost pixels get blurred out. [member region_enabled] must be [code]true[/code].
</member>
- <member name="region_rect" type="Rect2" setter="set_region_rect" getter="get_region_rect" default="Rect2( 0, 0, 0, 0 )">
+ <member name="region_rect" type="Rect2" setter="set_region_rect" getter="get_region_rect" default="Rect2(0, 0, 0, 0)">
The region of the atlas texture to display. [member region_enabled] must be [code]true[/code].
</member>
<member name="texture" type="Texture2D" setter="set_texture" getter="get_texture">
diff --git a/doc/classes/Sprite3D.xml b/doc/classes/Sprite3D.xml
index 8c4b9e7d10..f7f2ff0de1 100644
--- a/doc/classes/Sprite3D.xml
+++ b/doc/classes/Sprite3D.xml
@@ -14,7 +14,7 @@
<member name="frame" type="int" setter="set_frame" getter="get_frame" default="0">
Current frame to display from sprite sheet. [member hframes] or [member vframes] must be greater than 1.
</member>
- <member name="frame_coords" type="Vector2i" setter="set_frame_coords" getter="get_frame_coords" default="Vector2i( 0, 0 )">
+ <member name="frame_coords" type="Vector2i" setter="set_frame_coords" getter="get_frame_coords" default="Vector2i(0, 0)">
Coordinates of the frame to display from sprite sheet. This is as an alias for the [member frame] property. [member hframes] or [member vframes] must be greater than 1.
</member>
<member name="hframes" type="int" setter="set_hframes" getter="get_hframes" default="1">
@@ -23,7 +23,7 @@
<member name="region_enabled" type="bool" setter="set_region_enabled" getter="is_region_enabled" default="false">
If [code]true[/code], texture will be cut from a larger atlas texture. See [member region_rect].
</member>
- <member name="region_rect" type="Rect2" setter="set_region_rect" getter="get_region_rect" default="Rect2( 0, 0, 0, 0 )">
+ <member name="region_rect" type="Rect2" setter="set_region_rect" getter="get_region_rect" default="Rect2(0, 0, 0, 0)">
The region of the atlas texture to display. [member region_enabled] must be [code]true[/code].
</member>
<member name="texture" type="Texture2D" setter="set_texture" getter="get_texture">
diff --git a/doc/classes/SpriteBase3D.xml b/doc/classes/SpriteBase3D.xml
index 06b9c2b042..3168e2d848 100644
--- a/doc/classes/SpriteBase3D.xml
+++ b/doc/classes/SpriteBase3D.xml
@@ -66,10 +66,10 @@
<member name="flip_v" type="bool" setter="set_flip_v" getter="is_flipped_v" default="false">
If [code]true[/code], texture is flipped vertically.
</member>
- <member name="modulate" type="Color" setter="set_modulate" getter="get_modulate" default="Color( 1, 1, 1, 1 )">
+ <member name="modulate" type="Color" setter="set_modulate" getter="get_modulate" default="Color(1, 1, 1, 1)">
A color value that gets multiplied on, could be used for mood-coloring or to simulate the color of light.
</member>
- <member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2( 0, 0 )">
+ <member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2(0, 0)">
The texture's drawing offset.
</member>
<member name="opacity" type="float" setter="set_opacity" getter="get_opacity" default="1.0">
diff --git a/doc/classes/StaticBody2D.xml b/doc/classes/StaticBody2D.xml
index 298339d5fc..85915a53fe 100644
--- a/doc/classes/StaticBody2D.xml
+++ b/doc/classes/StaticBody2D.xml
@@ -18,7 +18,7 @@
<member name="constant_angular_velocity" type="float" setter="set_constant_angular_velocity" getter="get_constant_angular_velocity" default="0.0">
The body's constant angular velocity. This does not rotate the body (unless [member kinematic_motion] is enabled), but affects other bodies that touch it, as if it were rotating.
</member>
- <member name="constant_linear_velocity" type="Vector2" setter="set_constant_linear_velocity" getter="get_constant_linear_velocity" default="Vector2( 0, 0 )">
+ <member name="constant_linear_velocity" type="Vector2" setter="set_constant_linear_velocity" getter="get_constant_linear_velocity" default="Vector2(0, 0)">
The body's constant linear velocity. This does not move the body (unless [member kinematic_motion] is enabled), but affects other bodies that touch it, as if it were moving.
</member>
<member name="kinematic_motion" type="bool" setter="set_kinematic_motion_enabled" getter="is_kinematic_motion_enabled" default="false">
diff --git a/doc/classes/StaticBody3D.xml b/doc/classes/StaticBody3D.xml
index 5ffbb71522..f83d440f10 100644
--- a/doc/classes/StaticBody3D.xml
+++ b/doc/classes/StaticBody3D.xml
@@ -18,10 +18,10 @@
<methods>
</methods>
<members>
- <member name="constant_angular_velocity" type="Vector3" setter="set_constant_angular_velocity" getter="get_constant_angular_velocity" default="Vector3( 0, 0, 0 )">
+ <member name="constant_angular_velocity" type="Vector3" setter="set_constant_angular_velocity" getter="get_constant_angular_velocity" default="Vector3(0, 0, 0)">
The body's constant angular velocity. This does not rotate the body (unless [member kinematic_motion] is enabled), but affects other bodies that touch it, as if it were rotating.
</member>
- <member name="constant_linear_velocity" type="Vector3" setter="set_constant_linear_velocity" getter="get_constant_linear_velocity" default="Vector3( 0, 0, 0 )">
+ <member name="constant_linear_velocity" type="Vector3" setter="set_constant_linear_velocity" getter="get_constant_linear_velocity" default="Vector3(0, 0, 0)">
The body's constant linear velocity. This does not move the body (unless [member kinematic_motion] is enabled), but affects other bodies that touch it, as if it were moving.
</member>
<member name="kinematic_motion" type="bool" setter="set_kinematic_motion_enabled" getter="is_kinematic_motion_enabled" default="false">
diff --git a/doc/classes/StreamPeerBuffer.xml b/doc/classes/StreamPeerBuffer.xml
index 41cef9fb55..03a150b90f 100644
--- a/doc/classes/StreamPeerBuffer.xml
+++ b/doc/classes/StreamPeerBuffer.xml
@@ -49,7 +49,7 @@
</method>
</methods>
<members>
- <member name="data_array" type="PackedByteArray" setter="set_data_array" getter="get_data_array" default="PackedByteArray( )">
+ <member name="data_array" type="PackedByteArray" setter="set_data_array" getter="get_data_array" default="PackedByteArray()">
</member>
</members>
<constants>
diff --git a/doc/classes/String.xml b/doc/classes/String.xml
index d0c5f0ea86..3bf05e7c92 100644
--- a/doc/classes/String.xml
+++ b/doc/classes/String.xml
@@ -352,7 +352,7 @@
Returns [code]true[/code] if this string is a valid identifier. A valid identifier may contain only letters, digits and underscores ([code]_[/code]) and the first character may not be a digit.
</description>
</method>
- <method name="is_valid_integer" qualifiers="const">
+ <method name="is_valid_int" qualifiers="const">
<return type="bool">
</return>
<description>
diff --git a/doc/classes/StyleBoxFlat.xml b/doc/classes/StyleBoxFlat.xml
index d66ae210ec..9e02fb57c3 100644
--- a/doc/classes/StyleBoxFlat.xml
+++ b/doc/classes/StyleBoxFlat.xml
@@ -156,13 +156,13 @@
<member name="anti_aliasing_size" type="int" setter="set_aa_size" getter="get_aa_size" default="1">
This changes the size of the faded ring. Higher values can be used to achieve a "blurry" effect.
</member>
- <member name="bg_color" type="Color" setter="set_bg_color" getter="get_bg_color" default="Color( 0.6, 0.6, 0.6, 1 )">
+ <member name="bg_color" type="Color" setter="set_bg_color" getter="get_bg_color" default="Color(0.6, 0.6, 0.6, 1)">
The background color of the stylebox.
</member>
<member name="border_blend" type="bool" setter="set_border_blend" getter="get_border_blend" default="false">
If [code]true[/code], the border will fade into the background color.
</member>
- <member name="border_color" type="Color" setter="set_border_color" getter="get_border_color" default="Color( 0.8, 0.8, 0.8, 1 )">
+ <member name="border_color" type="Color" setter="set_border_color" getter="get_border_color" default="Color(0.8, 0.8, 0.8, 1)">
Sets the color of the border.
</member>
<member name="border_width_bottom" type="int" setter="set_border_width" getter="get_border_width" default="0">
@@ -209,10 +209,10 @@
<member name="expand_margin_top" type="float" setter="set_expand_margin" getter="get_expand_margin" default="0.0">
Expands the stylebox outside of the control rect on the top edge. Useful in combination with [member border_width_top] to draw a border outside the control rect.
</member>
- <member name="shadow_color" type="Color" setter="set_shadow_color" getter="get_shadow_color" default="Color( 0, 0, 0, 0.6 )">
+ <member name="shadow_color" type="Color" setter="set_shadow_color" getter="get_shadow_color" default="Color(0, 0, 0, 0.6)">
The color of the shadow. This has no effect if [member shadow_size] is lower than 1.
</member>
- <member name="shadow_offset" type="Vector2" setter="set_shadow_offset" getter="get_shadow_offset" default="Vector2( 0, 0 )">
+ <member name="shadow_offset" type="Vector2" setter="set_shadow_offset" getter="get_shadow_offset" default="Vector2(0, 0)">
The shadow offset in pixels. Adjusts the position of the shadow relatively to the stylebox.
</member>
<member name="shadow_size" type="int" setter="set_shadow_size" getter="get_shadow_size" default="0">
diff --git a/doc/classes/StyleBoxLine.xml b/doc/classes/StyleBoxLine.xml
index 4a2dbf60e4..850c656720 100644
--- a/doc/classes/StyleBoxLine.xml
+++ b/doc/classes/StyleBoxLine.xml
@@ -11,7 +11,7 @@
<methods>
</methods>
<members>
- <member name="color" type="Color" setter="set_color" getter="get_color" default="Color( 0, 0, 0, 1 )">
+ <member name="color" type="Color" setter="set_color" getter="get_color" default="Color(0, 0, 0, 1)">
The line's color.
</member>
<member name="grow_begin" type="float" setter="set_grow_begin" getter="get_grow_begin" default="1.0">
diff --git a/doc/classes/StyleBoxTexture.xml b/doc/classes/StyleBoxTexture.xml
index f4a1f1f01d..be14048126 100644
--- a/doc/classes/StyleBoxTexture.xml
+++ b/doc/classes/StyleBoxTexture.xml
@@ -116,10 +116,10 @@
A higher value means more of the source texture is considered to be part of the top border of the 3×3 box.
This is also the value used as fallback for [member StyleBox.content_margin_top] if it is negative.
</member>
- <member name="modulate_color" type="Color" setter="set_modulate" getter="get_modulate" default="Color( 1, 1, 1, 1 )">
+ <member name="modulate_color" type="Color" setter="set_modulate" getter="get_modulate" default="Color(1, 1, 1, 1)">
Modulates the color of the texture when this style box is drawn.
</member>
- <member name="region_rect" type="Rect2" setter="set_region_rect" getter="get_region_rect" default="Rect2( 0, 0, 0, 0 )">
+ <member name="region_rect" type="Rect2" setter="set_region_rect" getter="get_region_rect" default="Rect2(0, 0, 0, 0)">
Species a sub-region of the texture to use.
This is equivalent to first wrapping the texture in an [AtlasTexture] with the same region.
</member>
diff --git a/doc/classes/SubViewport.xml b/doc/classes/SubViewport.xml
index f54f22d6fa..9c5610e2c7 100644
--- a/doc/classes/SubViewport.xml
+++ b/doc/classes/SubViewport.xml
@@ -25,10 +25,10 @@
<member name="render_target_update_mode" type="int" setter="set_update_mode" getter="get_update_mode" enum="SubViewport.UpdateMode" default="2">
The update mode when the sub-viewport is used as a render target.
</member>
- <member name="size" type="Vector2i" setter="set_size" getter="get_size" default="Vector2i( 512, 512 )">
+ <member name="size" type="Vector2i" setter="set_size" getter="get_size" default="Vector2i(512, 512)">
The width and height of the sub-viewport.
</member>
- <member name="size_2d_override" type="Vector2i" setter="set_size_2d_override" getter="get_size_2d_override" default="Vector2i( 0, 0 )">
+ <member name="size_2d_override" type="Vector2i" setter="set_size_2d_override" getter="get_size_2d_override" default="Vector2i(0, 0)">
The 2D size override of the sub-viewport. If either the width or height is [code]0[/code], the override is disabled.
</member>
<member name="size_2d_override_stretch" type="bool" setter="set_size_2d_override_stretch" getter="is_size_2d_override_stretch_enabled" default="false">
diff --git a/doc/classes/SurfaceTool.xml b/doc/classes/SurfaceTool.xml
index 56b47f4a24..22d1b52479 100644
--- a/doc/classes/SurfaceTool.xml
+++ b/doc/classes/SurfaceTool.xml
@@ -45,15 +45,15 @@
</return>
<argument index="0" name="vertices" type="PackedVector3Array">
</argument>
- <argument index="1" name="uvs" type="PackedVector2Array" default="PackedVector2Array( )">
+ <argument index="1" name="uvs" type="PackedVector2Array" default="PackedVector2Array()">
</argument>
- <argument index="2" name="colors" type="PackedColorArray" default="PackedColorArray( )">
+ <argument index="2" name="colors" type="PackedColorArray" default="PackedColorArray()">
</argument>
- <argument index="3" name="uv2s" type="PackedVector2Array" default="PackedVector2Array( )">
+ <argument index="3" name="uv2s" type="PackedVector2Array" default="PackedVector2Array()">
</argument>
- <argument index="4" name="normals" type="PackedVector3Array" default="PackedVector3Array( )">
+ <argument index="4" name="normals" type="PackedVector3Array" default="PackedVector3Array()">
</argument>
- <argument index="5" name="tangents" type="Array" default="[ ]">
+ <argument index="5" name="tangents" type="Array" default="[]">
</argument>
<description>
Inserts a triangle fan made of array data into [Mesh] being constructed.
diff --git a/doc/classes/TabContainer.xml b/doc/classes/TabContainer.xml
index ddf6b465a4..3f24509ec7 100644
--- a/doc/classes/TabContainer.xml
+++ b/doc/classes/TabContainer.xml
@@ -198,19 +198,19 @@
<theme_item name="font" type="Font">
The font used to draw tab names.
</theme_item>
- <theme_item name="font_disabled_color" type="Color" default="Color( 0.9, 0.9, 0.9, 0.2 )">
+ <theme_item name="font_disabled_color" type="Color" default="Color(0.9, 0.9, 0.9, 0.2)">
Font color of disabled tabs.
</theme_item>
- <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)">
The tint of text outline of the tab name.
</theme_item>
- <theme_item name="font_selected_color" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )">
+ <theme_item name="font_selected_color" type="Color" default="Color(0.94, 0.94, 0.94, 1)">
Font color of the currently selected tab.
</theme_item>
<theme_item name="font_size" type="int">
Font size of the tab names.
</theme_item>
- <theme_item name="font_unselected_color" type="Color" default="Color( 0.69, 0.69, 0.69, 1 )">
+ <theme_item name="font_unselected_color" type="Color" default="Color(0.69, 0.69, 0.69, 1)">
Font color of the other, unselected tabs.
</theme_item>
<theme_item name="icon_separation" type="int" default="4">
diff --git a/doc/classes/Tabs.xml b/doc/classes/Tabs.xml
index d784585e20..aff104c922 100644
--- a/doc/classes/Tabs.xml
+++ b/doc/classes/Tabs.xml
@@ -362,19 +362,19 @@
<theme_item name="font" type="Font">
The font used to draw tab names.
</theme_item>
- <theme_item name="font_disabled_color" type="Color" default="Color( 0.9, 0.9, 0.9, 0.2 )">
+ <theme_item name="font_disabled_color" type="Color" default="Color(0.9, 0.9, 0.9, 0.2)">
Font color of disabled tabs.
</theme_item>
- <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)">
The tint of text outline of the tab name.
</theme_item>
- <theme_item name="font_selected_color" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )">
+ <theme_item name="font_selected_color" type="Color" default="Color(0.94, 0.94, 0.94, 1)">
Font color of the currently selected tab.
</theme_item>
<theme_item name="font_size" type="int">
Font size of the tab names.
</theme_item>
- <theme_item name="font_unselected_color" type="Color" default="Color( 0.69, 0.69, 0.69, 1 )">
+ <theme_item name="font_unselected_color" type="Color" default="Color(0.69, 0.69, 0.69, 1)">
Font color of the other, unselected tabs.
</theme_item>
<theme_item name="hseparation" type="int" default="4">
diff --git a/doc/classes/TextEdit.xml b/doc/classes/TextEdit.xml
index 2d6a052fe3..6a3c124c60 100644
--- a/doc/classes/TextEdit.xml
+++ b/doc/classes/TextEdit.xml
@@ -10,6 +10,12 @@
<tutorials>
</tutorials>
<methods>
+ <method name="_backspace" qualifiers="virtual">
+ <return type="void">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="add_gutter">
<return type="void">
</return>
@@ -18,6 +24,12 @@
<description>
</description>
</method>
+ <method name="backspace">
+ <return type="void">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="center_viewport_to_cursor">
<return type="void">
</return>
@@ -96,6 +108,12 @@
Cut's the current selection.
</description>
</method>
+ <method name="delete_selection">
+ <return type="void">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="deselect">
<return type="void">
</return>
@@ -110,6 +128,14 @@
Gets the caret pixel draw poistion.
</description>
</method>
+ <method name="get_first_non_whitespace_column" qualifiers="const">
+ <return type="int">
+ </return>
+ <argument index="0" name="line" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="get_gutter_count" qualifiers="const">
<return type="int">
</return>
@@ -140,6 +166,14 @@
<description>
</description>
</method>
+ <method name="get_indent_level" qualifiers="const">
+ <return type="int">
+ </return>
+ <argument index="0" name="line" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="get_line" qualifiers="const">
<return type="String">
</return>
@@ -274,6 +308,12 @@
Returns the selection end line.
</description>
</method>
+ <method name="get_tab_size" qualifiers="const">
+ <return type="int">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="get_visible_line_count" qualifiers="const">
<return type="int">
</return>
@@ -354,6 +394,16 @@
Triggers a right-click menu action by the specified index. See [enum MenuItems] for a list of available indexes.
</description>
</method>
+ <method name="merge_gutters">
+ <return type="void">
+ </return>
+ <argument index="0" name="from_line" type="int">
+ </argument>
+ <argument index="1" name="to_line" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="paste">
<return type="void">
</return>
@@ -611,6 +661,14 @@
<description>
</description>
</method>
+ <method name="set_tab_size">
+ <return type="void">
+ </return>
+ <argument index="0" name="size" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="undo">
<return type="void">
</return>
@@ -692,7 +750,7 @@
<member name="structured_text_bidi_override" type="int" setter="set_structured_text_bidi_override" getter="get_structured_text_bidi_override" enum="Control.StructuredTextParser" default="0">
Set BiDi algorithm override for the structured text.
</member>
- <member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" default="[ ]">
+ <member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" default="[]">
Set additional options for BiDi override.
</member>
<member name="syntax_highlighter" type="SyntaxHighlighter" setter="set_syntax_highlighter" getter="get_syntax_highlighter">
@@ -881,16 +939,16 @@
</constant>
</constants>
<theme_items>
- <theme_item name="background_color" type="Color" default="Color( 0, 0, 0, 0 )">
+ <theme_item name="background_color" type="Color" default="Color(0, 0, 0, 0)">
Sets the background [Color] of this [TextEdit].
</theme_item>
- <theme_item name="brace_mismatch_color" type="Color" default="Color( 1, 0.2, 0.2, 1 )">
+ <theme_item name="brace_mismatch_color" type="Color" default="Color(1, 0.2, 0.2, 1)">
</theme_item>
- <theme_item name="caret_background_color" type="Color" default="Color( 0, 0, 0, 1 )">
+ <theme_item name="caret_background_color" type="Color" default="Color(0, 0, 0, 1)">
</theme_item>
- <theme_item name="caret_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )">
+ <theme_item name="caret_color" type="Color" default="Color(0.88, 0.88, 0.88, 1)">
</theme_item>
- <theme_item name="current_line_color" type="Color" default="Color( 0.25, 0.25, 0.26, 0.8 )">
+ <theme_item name="current_line_color" type="Color" default="Color(0.25, 0.25, 0.26, 0.8)">
Sets the [Color] of the breakpoints. [member breakpoint_gutter] has to be enabled.
</theme_item>
<theme_item name="focus" type="StyleBox">
@@ -898,15 +956,15 @@
<theme_item name="font" type="Font">
Sets the default [Font].
</theme_item>
- <theme_item name="font_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )">
+ <theme_item name="font_color" type="Color" default="Color(0.88, 0.88, 0.88, 1)">
Sets the font [Color].
</theme_item>
- <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)">
The tint of text outline of the [TextEdit].
</theme_item>
- <theme_item name="font_readonly_color" type="Color" default="Color( 0.88, 0.88, 0.88, 0.5 )">
+ <theme_item name="font_readonly_color" type="Color" default="Color(0.88, 0.88, 0.88, 0.5)">
</theme_item>
- <theme_item name="font_selected_color" type="Color" default="Color( 0, 0, 0, 1 )">
+ <theme_item name="font_selected_color" type="Color" default="Color(0, 0, 0, 1)">
Sets the [Color] of the selected text. [member override_selected_font_color] has to be enabled.
</theme_item>
<theme_item name="font_size" type="int">
@@ -924,7 +982,7 @@
<theme_item name="read_only" type="StyleBox">
Sets the [StyleBox] of this [TextEdit] when [member readonly] is enabled.
</theme_item>
- <theme_item name="selection_color" type="Color" default="Color( 0.49, 0.49, 0.49, 1 )">
+ <theme_item name="selection_color" type="Color" default="Color(0.49, 0.49, 0.49, 1)">
Sets the highlight [Color] of text selections.
</theme_item>
<theme_item name="space" type="Texture2D">
@@ -933,7 +991,7 @@
<theme_item name="tab" type="Texture2D">
Sets a custom [Texture2D] for tab text characters.
</theme_item>
- <theme_item name="word_highlighted_color" type="Color" default="Color( 0.8, 0.9, 0.9, 0.15 )">
+ <theme_item name="word_highlighted_color" type="Color" default="Color(0.8, 0.9, 0.9, 0.15)">
Sets the highlight [Color] of multiple occurrences. [member highlight_all_occurrences] has to be enabled.
</theme_item>
</theme_items>
diff --git a/doc/classes/TextLine.xml b/doc/classes/TextLine.xml
index ddbae0e977..318c3be794 100644
--- a/doc/classes/TextLine.xml
+++ b/doc/classes/TextLine.xml
@@ -56,7 +56,7 @@
</argument>
<argument index="1" name="pos" type="Vector2">
</argument>
- <argument index="2" name="color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="2" name="color" type="Color" default="Color(1, 1, 1, 1)">
</argument>
<description>
Draw text into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box.
@@ -71,7 +71,7 @@
</argument>
<argument index="2" name="outline_size" type="int" default="1">
</argument>
- <argument index="3" name="color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="3" name="color" type="Color" default="Color(1, 1, 1, 1)">
</argument>
<description>
Draw text into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box.
diff --git a/doc/classes/TextParagraph.xml b/doc/classes/TextParagraph.xml
index e9afe47ee8..d67a9bcb85 100644
--- a/doc/classes/TextParagraph.xml
+++ b/doc/classes/TextParagraph.xml
@@ -63,9 +63,9 @@
</argument>
<argument index="1" name="pos" type="Vector2">
</argument>
- <argument index="2" name="color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="2" name="color" type="Color" default="Color(1, 1, 1, 1)">
</argument>
- <argument index="3" name="dc_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="3" name="dc_color" type="Color" default="Color(1, 1, 1, 1)">
</argument>
<description>
Draw all lines of the text and drop cap into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box.
@@ -78,7 +78,7 @@
</argument>
<argument index="1" name="pos" type="Vector2">
</argument>
- <argument index="2" name="color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="2" name="color" type="Color" default="Color(1, 1, 1, 1)">
</argument>
<description>
Draw drop cap into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box.
@@ -93,7 +93,7 @@
</argument>
<argument index="2" name="outline_size" type="int" default="1">
</argument>
- <argument index="3" name="color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="3" name="color" type="Color" default="Color(1, 1, 1, 1)">
</argument>
<description>
Draw drop cap outline into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box.
@@ -108,7 +108,7 @@
</argument>
<argument index="2" name="line" type="int">
</argument>
- <argument index="3" name="color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="3" name="color" type="Color" default="Color(1, 1, 1, 1)">
</argument>
<description>
Draw single line of text into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box.
@@ -125,7 +125,7 @@
</argument>
<argument index="3" name="outline_size" type="int" default="1">
</argument>
- <argument index="4" name="color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="4" name="color" type="Color" default="Color(1, 1, 1, 1)">
</argument>
<description>
Draw outline of the single line of text into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box.
@@ -140,9 +140,9 @@
</argument>
<argument index="2" name="outline_size" type="int" default="1">
</argument>
- <argument index="3" name="color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="3" name="color" type="Color" default="Color(1, 1, 1, 1)">
</argument>
- <argument index="4" name="dc_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="4" name="dc_color" type="Color" default="Color(1, 1, 1, 1)">
</argument>
<description>
Draw outlines of all lines of the text and drop cap into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box.
@@ -344,7 +344,7 @@
</argument>
<argument index="2" name="size" type="int">
</argument>
- <argument index="3" name="dropcap_margins" type="Rect2" default="Rect2( 0, 0, 0, 0 )">
+ <argument index="3" name="dropcap_margins" type="Rect2" default="Rect2(0, 0, 0, 0)">
</argument>
<argument index="4" name="opentype_features" type="Dictionary" default="{
}">
diff --git a/doc/classes/TextServer.xml b/doc/classes/TextServer.xml
index 9a96d8699c..c943946ab3 100644
--- a/doc/classes/TextServer.xml
+++ b/doc/classes/TextServer.xml
@@ -149,7 +149,7 @@
</argument>
<argument index="4" name="index" type="int">
</argument>
- <argument index="5" name="color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="5" name="color" type="Color" default="Color(1, 1, 1, 1)">
</argument>
<description>
Draws single glyph into a canvas item at the position, using [code]font[/code] at the size [code]size[/code].
@@ -171,7 +171,7 @@
</argument>
<argument index="5" name="index" type="int">
</argument>
- <argument index="6" name="color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="6" name="color" type="Color" default="Color(1, 1, 1, 1)">
</argument>
<description>
Draws single glyph outline of size [code]outline_size[/code] into a canvas item at the position, using [code]font[/code] at the size [code]size[/code].
@@ -788,7 +788,7 @@
</argument>
<argument index="4" name="clip_r" type="float" default="-1">
</argument>
- <argument index="5" name="color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="5" name="color" type="Color" default="Color(1, 1, 1, 1)">
</argument>
<description>
Draw shaped text into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the leftmost point of the baseline (for horizontal layout) or topmost point of the baseline (for vertical layout).
@@ -809,7 +809,7 @@
</argument>
<argument index="5" name="outline_size" type="int" default="1">
</argument>
- <argument index="6" name="color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="6" name="color" type="Color" default="Color(1, 1, 1, 1)">
</argument>
<description>
Draw the outline of the shaped text into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the leftmost point of the baseline (for horizontal layout) or topmost point of the baseline (for vertical layout).
diff --git a/doc/classes/Texture2D.xml b/doc/classes/Texture2D.xml
index c33f32c9e4..35b719ae48 100644
--- a/doc/classes/Texture2D.xml
+++ b/doc/classes/Texture2D.xml
@@ -19,7 +19,7 @@
</argument>
<argument index="1" name="position" type="Vector2">
</argument>
- <argument index="2" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="2" name="modulate" type="Color" default="Color(1, 1, 1, 1)">
</argument>
<argument index="3" name="transpose" type="bool" default="false">
</argument>
@@ -36,7 +36,7 @@
</argument>
<argument index="2" name="tile" type="bool">
</argument>
- <argument index="3" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="3" name="modulate" type="Color" default="Color(1, 1, 1, 1)">
</argument>
<argument index="4" name="transpose" type="bool" default="false">
</argument>
@@ -53,7 +53,7 @@
</argument>
<argument index="2" name="src_rect" type="Rect2">
</argument>
- <argument index="3" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="3" name="modulate" type="Color" default="Color(1, 1, 1, 1)">
</argument>
<argument index="4" name="transpose" type="bool" default="false">
</argument>
diff --git a/doc/classes/TextureProgressBar.xml b/doc/classes/TextureProgressBar.xml
index b40759578f..59cde536ad 100644
--- a/doc/classes/TextureProgressBar.xml
+++ b/doc/classes/TextureProgressBar.xml
@@ -36,7 +36,7 @@
<member name="nine_patch_stretch" type="bool" setter="set_nine_patch_stretch" getter="get_nine_patch_stretch" default="false">
If [code]true[/code], Godot treats the bar's textures like in [NinePatchRect]. Use the [code]stretch_margin_*[/code] properties like [member stretch_margin_bottom] to set up the nine patch's 3×3 grid. When using a radial [member fill_mode], this setting will enable stretching.
</member>
- <member name="radial_center_offset" type="Vector2" setter="set_radial_center_offset" getter="get_radial_center_offset" default="Vector2( 0, 0 )">
+ <member name="radial_center_offset" type="Vector2" setter="set_radial_center_offset" getter="get_radial_center_offset" default="Vector2(0, 0)">
Offsets [member texture_progress] if [member fill_mode] is [constant FILL_CLOCKWISE] or [constant FILL_COUNTER_CLOCKWISE].
</member>
<member name="radial_fill_degrees" type="float" setter="set_fill_degrees" getter="get_fill_degrees" default="360.0">
@@ -68,13 +68,13 @@
<member name="texture_under" type="Texture2D" setter="set_under_texture" getter="get_under_texture">
[Texture2D] that draws under the progress bar. The bar's background.
</member>
- <member name="tint_over" type="Color" setter="set_tint_over" getter="get_tint_over" default="Color( 1, 1, 1, 1 )">
+ <member name="tint_over" type="Color" setter="set_tint_over" getter="get_tint_over" default="Color(1, 1, 1, 1)">
Multiplies the color of the bar's [code]texture_over[/code] texture. The effect is similar to [member CanvasItem.modulate], except it only affects this specific texture instead of the entire node.
</member>
- <member name="tint_progress" type="Color" setter="set_tint_progress" getter="get_tint_progress" default="Color( 1, 1, 1, 1 )">
+ <member name="tint_progress" type="Color" setter="set_tint_progress" getter="get_tint_progress" default="Color(1, 1, 1, 1)">
Multiplies the color of the bar's [code]texture_progress[/code] texture.
</member>
- <member name="tint_under" type="Color" setter="set_tint_under" getter="get_tint_under" default="Color( 1, 1, 1, 1 )">
+ <member name="tint_under" type="Color" setter="set_tint_under" getter="get_tint_under" default="Color(1, 1, 1, 1)">
Multiplies the color of the bar's [code]texture_under[/code] texture.
</member>
</members>
diff --git a/doc/classes/TileData.xml b/doc/classes/TileData.xml
index efcbdf2e95..bb793024eb 100644
--- a/doc/classes/TileData.xml
+++ b/doc/classes/TileData.xml
@@ -7,7 +7,7 @@
<tutorials>
</tutorials>
<methods>
- <method name="add_collision_shape">
+ <method name="add_collision_polygon">
<return type="void">
</return>
<argument index="0" name="layer_id" type="int">
@@ -15,27 +15,27 @@
<description>
</description>
</method>
- <method name="get_collision_shape_one_way_margin" qualifiers="const">
+ <method name="get_collision_polygon_one_way_margin" qualifiers="const">
<return type="float">
</return>
<argument index="0" name="layer_id" type="int">
</argument>
- <argument index="1" name="shape_index" type="int">
+ <argument index="1" name="polygon_index" type="int">
</argument>
<description>
</description>
</method>
- <method name="get_collision_shape_shape" qualifiers="const">
- <return type="Shape2D">
+ <method name="get_collision_polygon_points" qualifiers="const">
+ <return type="PackedVector2Array">
</return>
<argument index="0" name="layer_id" type="int">
</argument>
- <argument index="1" name="shape_index" type="int">
+ <argument index="1" name="polygon_index" type="int">
</argument>
<description>
</description>
</method>
- <method name="get_collision_shapes_count" qualifiers="const">
+ <method name="get_collision_polygons_count" qualifiers="const">
<return type="int">
</return>
<argument index="0" name="layer_id" type="int">
@@ -83,68 +83,68 @@
<description>
</description>
</method>
- <method name="is_collision_shape_one_way" qualifiers="const">
+ <method name="is_collision_polygon_one_way" qualifiers="const">
<return type="bool">
</return>
<argument index="0" name="layer_id" type="int">
</argument>
- <argument index="1" name="shape_index" type="int">
+ <argument index="1" name="polygon_index" type="int">
</argument>
<description>
</description>
</method>
- <method name="remove_collision_shape">
+ <method name="remove_collision_polygon">
<return type="void">
</return>
<argument index="0" name="layer_id" type="int">
</argument>
- <argument index="1" name="shape_index" type="int">
+ <argument index="1" name="polygon_index" type="int">
</argument>
<description>
</description>
</method>
- <method name="set_collision_shape_one_way">
+ <method name="set_collision_polygon_one_way">
<return type="void">
</return>
<argument index="0" name="layer_id" type="int">
</argument>
- <argument index="1" name="shape_index" type="int">
+ <argument index="1" name="polygon_index" type="int">
</argument>
<argument index="2" name="one_way" type="bool">
</argument>
<description>
</description>
</method>
- <method name="set_collision_shape_one_way_margin">
+ <method name="set_collision_polygon_one_way_margin">
<return type="void">
</return>
<argument index="0" name="layer_id" type="int">
</argument>
- <argument index="1" name="shape_index" type="int">
+ <argument index="1" name="polygon_index" type="int">
</argument>
<argument index="2" name="one_way_margin" type="float">
</argument>
<description>
</description>
</method>
- <method name="set_collision_shape_shape">
+ <method name="set_collision_polygon_points">
<return type="void">
</return>
<argument index="0" name="layer_id" type="int">
</argument>
- <argument index="1" name="shape_index" type="int">
+ <argument index="1" name="polygon_index" type="int">
</argument>
- <argument index="2" name="shape" type="Shape2D">
+ <argument index="2" name="polygon" type="PackedVector2Array">
</argument>
<description>
</description>
</method>
- <method name="set_collision_shapes_count">
+ <method name="set_collision_polygons_count">
<return type="void">
</return>
<argument index="0" name="layer_id" type="int">
</argument>
- <argument index="1" name="shapes_count" type="int">
+ <argument index="1" name="polygons_count" type="int">
</argument>
<description>
</description>
@@ -219,13 +219,13 @@
</member>
<member name="flip_v" type="bool" setter="set_flip_v" getter="get_flip_v" default="false">
</member>
- <member name="modulate" type="Color" setter="set_modulate" getter="get_modulate" default="Color( 1, 1, 1, 1 )">
+ <member name="modulate" type="Color" setter="set_modulate" getter="get_modulate" default="Color(1, 1, 1, 1)">
</member>
<member name="probability" type="float" setter="set_probability" getter="get_probability" default="1.0">
</member>
<member name="terrain_set" type="int" setter="set_terrain_set" getter="get_terrain_set" default="-1">
</member>
- <member name="texture_offset" type="Vector2i" setter="set_texture_offset" getter="get_texture_offset" default="Vector2i( 0, 0 )">
+ <member name="texture_offset" type="Vector2i" setter="set_texture_offset" getter="get_texture_offset" default="Vector2i(0, 0)">
</member>
<member name="transpose" type="bool" setter="set_transpose" getter="get_transpose" default="false">
</member>
diff --git a/doc/classes/TileMap.xml b/doc/classes/TileMap.xml
index 93d5dd8037..5a4068ec86 100644
--- a/doc/classes/TileMap.xml
+++ b/doc/classes/TileMap.xml
@@ -103,7 +103,7 @@
</argument>
<argument index="1" name="source_id" type="int" default="-1">
</argument>
- <argument index="2" name="atlas_coords" type="Vector2i" default="Vector2i( -1, -1 )">
+ <argument index="2" name="atlas_coords" type="Vector2i" default="Vector2i(-1, -1)">
</argument>
<argument index="3" name="alternative_tile" type="int" default="-1">
</argument>
diff --git a/doc/classes/TileSet.xml b/doc/classes/TileSet.xml
index 2015b1f1cd..55f232c004 100644
--- a/doc/classes/TileSet.xml
+++ b/doc/classes/TileSet.xml
@@ -287,9 +287,7 @@
</member>
<member name="tile_shape" type="int" setter="set_tile_shape" getter="get_tile_shape" enum="TileSet.TileShape" default="0">
</member>
- <member name="tile_size" type="Vector2i" setter="set_tile_size" getter="get_tile_size" default="Vector2i( 16, 16 )">
- </member>
- <member name="tile_skew" type="Vector2" setter="set_tile_skew" getter="get_tile_skew" default="Vector2( 0, 0 )">
+ <member name="tile_size" type="Vector2i" setter="set_tile_size" getter="get_tile_size" default="Vector2i(16, 16)">
</member>
<member name="uv_clipping" type="bool" setter="set_uv_clipping" getter="is_uv_clipping" default="false">
</member>
diff --git a/doc/classes/TileSetAtlasSource.xml b/doc/classes/TileSetAtlasSource.xml
index a7a304ca27..8482c356d7 100644
--- a/doc/classes/TileSetAtlasSource.xml
+++ b/doc/classes/TileSetAtlasSource.xml
@@ -12,9 +12,9 @@
</return>
<argument index="0" name="atlas_coords" type="Vector2i">
</argument>
- <argument index="1" name="new_atlas_coords" type="Vector2i" default="Vector2i( -1, -1 )">
+ <argument index="1" name="new_atlas_coords" type="Vector2i" default="Vector2i(-1, -1)">
</argument>
- <argument index="2" name="new_size" type="Vector2i" default="Vector2i( -1, -1 )">
+ <argument index="2" name="new_size" type="Vector2i" default="Vector2i(-1, -1)">
</argument>
<description>
</description>
@@ -40,7 +40,7 @@
</return>
<argument index="0" name="atlas_coords" type="Vector2i">
</argument>
- <argument index="1" name="size" type="Vector2i" default="Vector2i( 1, 1 )">
+ <argument index="1" name="size" type="Vector2i" default="Vector2i(1, 1)">
</argument>
<description>
</description>
@@ -154,9 +154,9 @@
</return>
<argument index="0" name="atlas_coords" type="Vector2i">
</argument>
- <argument index="1" name="new_atlas_coords" type="Vector2i" default="Vector2i( -1, -1 )">
+ <argument index="1" name="new_atlas_coords" type="Vector2i" default="Vector2i(-1, -1)">
</argument>
- <argument index="2" name="new_size" type="Vector2i" default="Vector2i( -1, -1 )">
+ <argument index="2" name="new_size" type="Vector2i" default="Vector2i(-1, -1)">
</argument>
<description>
</description>
@@ -193,13 +193,13 @@
</method>
</methods>
<members>
- <member name="margins" type="Vector2i" setter="set_margins" getter="get_margins" default="Vector2i( 0, 0 )">
+ <member name="margins" type="Vector2i" setter="set_margins" getter="get_margins" default="Vector2i(0, 0)">
</member>
- <member name="separation" type="Vector2i" setter="set_separation" getter="get_separation" default="Vector2i( 0, 0 )">
+ <member name="separation" type="Vector2i" setter="set_separation" getter="get_separation" default="Vector2i(0, 0)">
</member>
<member name="texture" type="Texture2D" setter="set_texture" getter="get_texture">
</member>
- <member name="tile_size" type="Vector2i" setter="set_texture_region_size" getter="get_texture_region_size" default="Vector2i( 16, 16 )">
+ <member name="tile_size" type="Vector2i" setter="set_texture_region_size" getter="get_texture_region_size" default="Vector2i(16, 16)">
</member>
</members>
<constants>
diff --git a/doc/classes/Transform2D.xml b/doc/classes/Transform2D.xml
index 0dbf95376a..4f9b59c188 100644
--- a/doc/classes/Transform2D.xml
+++ b/doc/classes/Transform2D.xml
@@ -132,7 +132,7 @@
<method name="looking_at" qualifiers="const">
<return type="Transform2D">
</return>
- <argument index="0" name="target" type="Vector2" default="Transform2D( 1, 0, 0, 1, 0, 0 )">
+ <argument index="0" name="target" type="Vector2" default="Transform2D(1, 0, 0, 1, 0, 0)">
</argument>
<description>
Returns a copy of the transform rotated such that it's rotation on the X-axis points towards the [code]target[/code] position.
@@ -148,9 +148,17 @@
</description>
</method>
<method name="operator *" qualifiers="operator">
- <return type="PackedVector2Array">
+ <return type="Vector2">
</return>
- <argument index="0" name="right" type="PackedVector2Array">
+ <argument index="0" name="right" type="Vector2">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="operator *" qualifiers="operator">
+ <return type="Rect2">
+ </return>
+ <argument index="0" name="right" type="Rect2">
</argument>
<description>
</description>
@@ -164,19 +172,29 @@
</description>
</method>
<method name="operator *" qualifiers="operator">
- <return type="Rect2">
+ <return type="PackedVector2Array">
</return>
- <argument index="0" name="right" type="Rect2">
+ <argument index="0" name="right" type="PackedVector2Array">
</argument>
<description>
</description>
</method>
<method name="operator *" qualifiers="operator">
- <return type="Vector2">
+ <return type="Transform2D">
</return>
- <argument index="0" name="right" type="Vector2">
+ <argument index="0" name="right" type="float">
+ </argument>
+ <description>
+ This operator multiplies all components of the [Transform2D], including the origin vector, which scales it uniformly.
+ </description>
+ </method>
+ <method name="operator *" qualifiers="operator">
+ <return type="Transform2D">
+ </return>
+ <argument index="0" name="right" type="int">
</argument>
<description>
+ This operator multiplies all components of the [Transform2D], including the origin vector, which scales it uniformly.
</description>
</method>
<method name="operator ==" qualifiers="operator">
@@ -241,24 +259,24 @@
</method>
</methods>
<members>
- <member name="origin" type="Vector2" setter="" getter="" default="Vector2( 0, 0 )">
+ <member name="origin" type="Vector2" setter="" getter="" default="Vector2(0, 0)">
The origin vector (column 2, the third column). Equivalent to array index [code]2[/code]. The origin vector represents translation.
</member>
- <member name="x" type="Vector2" setter="" getter="" default="Vector2( 1, 0 )">
+ <member name="x" type="Vector2" setter="" getter="" default="Vector2(1, 0)">
The basis matrix's X vector (column 0). Equivalent to array index [code]0[/code].
</member>
- <member name="y" type="Vector2" setter="" getter="" default="Vector2( 0, 1 )">
+ <member name="y" type="Vector2" setter="" getter="" default="Vector2(0, 1)">
The basis matrix's Y vector (column 1). Equivalent to array index [code]1[/code].
</member>
</members>
<constants>
- <constant name="IDENTITY" value="Transform2D( 1, 0, 0, 1, 0, 0 )">
+ <constant name="IDENTITY" value="Transform2D(1, 0, 0, 1, 0, 0)">
The identity [Transform2D] with no translation, rotation or scaling applied. When applied to other data structures, [constant IDENTITY] performs no transformation.
</constant>
- <constant name="FLIP_X" value="Transform2D( -1, 0, 0, 1, 0, 0 )">
+ <constant name="FLIP_X" value="Transform2D(-1, 0, 0, 1, 0, 0)">
The [Transform2D] that will flip something along the X axis.
</constant>
- <constant name="FLIP_Y" value="Transform2D( 1, 0, 0, -1, 0, 0 )">
+ <constant name="FLIP_Y" value="Transform2D(1, 0, 0, -1, 0, 0)">
The [Transform2D] that will flip something along the Y axis.
</constant>
</constants>
diff --git a/doc/classes/Transform3D.xml b/doc/classes/Transform3D.xml
index 0d49255523..5410cbced7 100644
--- a/doc/classes/Transform3D.xml
+++ b/doc/classes/Transform3D.xml
@@ -97,7 +97,7 @@
</return>
<argument index="0" name="target" type="Vector3">
</argument>
- <argument index="1" name="up" type="Vector3" default="Vector3( 0, 1, 0 )">
+ <argument index="1" name="up" type="Vector3" default="Vector3(0, 1, 0)">
</argument>
<description>
Returns a copy of the transform rotated such that its -Z axis points towards the [code]target[/code] position.
@@ -145,6 +145,24 @@
<description>
</description>
</method>
+ <method name="operator *" qualifiers="operator">
+ <return type="Transform3D">
+ </return>
+ <argument index="0" name="right" type="float">
+ </argument>
+ <description>
+ This operator multiplies all components of the [Transform3D], including the origin vector, which scales it uniformly.
+ </description>
+ </method>
+ <method name="operator *" qualifiers="operator">
+ <return type="Transform3D">
+ </return>
+ <argument index="0" name="right" type="int">
+ </argument>
+ <description>
+ This operator multiplies all components of the [Transform3D], including the origin vector, which scales it uniformly.
+ </description>
+ </method>
<method name="operator ==" qualifiers="operator">
<return type="bool">
</return>
@@ -192,24 +210,24 @@
</method>
</methods>
<members>
- <member name="basis" type="Basis" setter="" getter="" default="Basis( 1, 0, 0, 0, 1, 0, 0, 0, 1 )">
+ <member name="basis" type="Basis" setter="" getter="" default="Basis(1, 0, 0, 0, 1, 0, 0, 0, 1)">
The basis is a matrix containing 3 [Vector3] as its columns: X axis, Y axis, and Z axis. These vectors can be interpreted as the basis vectors of local coordinate system traveling with the object.
</member>
- <member name="origin" type="Vector3" setter="" getter="" default="Vector3( 0, 0, 0 )">
+ <member name="origin" type="Vector3" setter="" getter="" default="Vector3(0, 0, 0)">
The translation offset of the transform (column 3, the fourth column). Equivalent to array index [code]3[/code].
</member>
</members>
<constants>
- <constant name="IDENTITY" value="Transform3D( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )">
+ <constant name="IDENTITY" value="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)">
[Transform3D] with no translation, rotation or scaling applied. When applied to other data structures, [constant IDENTITY] performs no transformation.
</constant>
- <constant name="FLIP_X" value="Transform3D( -1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )">
+ <constant name="FLIP_X" value="Transform3D(-1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)">
[Transform3D] with mirroring applied perpendicular to the YZ plane.
</constant>
- <constant name="FLIP_Y" value="Transform3D( 1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0 )">
+ <constant name="FLIP_Y" value="Transform3D(1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0)">
[Transform3D] with mirroring applied perpendicular to the XZ plane.
</constant>
- <constant name="FLIP_Z" value="Transform3D( 1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0 )">
+ <constant name="FLIP_Z" value="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0)">
[Transform3D] with mirroring applied perpendicular to the XY plane.
</constant>
</constants>
diff --git a/doc/classes/Tree.xml b/doc/classes/Tree.xml
index fe83bf9c2d..be770e6e03 100644
--- a/doc/classes/Tree.xml
+++ b/doc/classes/Tree.xml
@@ -232,7 +232,7 @@
Returns the last pressed button's index.
</description>
</method>
- <method name="get_root">
+ <method name="get_root" qualifiers="const">
<return type="TreeItem">
</return>
<description>
@@ -272,26 +272,26 @@
<description>
</description>
</method>
- <method name="set_column_expand">
+ <method name="set_column_custom_minimum_width">
<return type="void">
</return>
<argument index="0" name="column" type="int">
</argument>
- <argument index="1" name="expand" type="bool">
+ <argument index="1" name="min_width" type="int">
</argument>
<description>
- If [code]true[/code], the column will have the "Expand" flag of [Control]. Columns that have the "Expand" flag will use their "min_width" in a similar fashion to [member Control.size_flags_stretch_ratio].
+ Overrides the calculated minimum width of a column. It can be set to `0` to restore the default behavior. Columns that have the "Expand" flag will use their "min_width" in a similar fashion to [member Control.size_flags_stretch_ratio].
</description>
</method>
- <method name="set_column_min_width">
+ <method name="set_column_expand">
<return type="void">
</return>
<argument index="0" name="column" type="int">
</argument>
- <argument index="1" name="min_width" type="int">
+ <argument index="1" name="expand" type="bool">
</argument>
<description>
- Sets the minimum width of a column. Columns that have the "Expand" flag will use their "min_width" in a similar fashion to [member Control.size_flags_stretch_ratio].
+ If [code]true[/code], the column will have the "Expand" flag of [Control]. Columns that have the "Expand" flag will use their "min_width" in a similar fashion to [member Control.size_flags_stretch_ratio].
</description>
</method>
<method name="set_column_title">
@@ -372,6 +372,12 @@
If [code]true[/code], the tree's root is hidden.
</member>
<member name="rect_clip_content" type="bool" setter="set_clip_contents" getter="is_clipping_contents" override="true" default="true" />
+ <member name="scroll_horizontal_enabled" type="bool" setter="set_h_scroll_enabled" getter="is_h_scroll_enabled" default="true">
+ If [code]true[/code], enables horizontal scrolling.
+ </member>
+ <member name="scroll_vertical_enabled" type="bool" setter="set_v_scroll_enabled" getter="is_v_scroll_enabled" default="true">
+ If [code]true[/code], enables vertical scrolling.
+ </member>
<member name="select_mode" type="int" setter="set_select_mode" getter="get_select_mode" enum="Tree.SelectMode" default="0">
Allows single or multiple selection. See the [enum SelectMode] constants.
</member>
@@ -533,7 +539,7 @@
<theme_item name="checked" type="Texture2D">
The check icon to display when the [constant TreeItem.CELL_MODE_CHECK] mode cell is checked.
</theme_item>
- <theme_item name="children_hl_line_color" type="Color" default="Color( 0.27, 0.27, 0.27, 1 )">
+ <theme_item name="children_hl_line_color" type="Color" default="Color(0.27, 0.27, 0.27, 1)">
The [Color] of the relationship lines between the selected [TreeItem] and its children.
</theme_item>
<theme_item name="children_hl_line_width" type="int" default="1">
@@ -548,7 +554,7 @@
<theme_item name="custom_button" type="StyleBox">
Default [StyleBox] for a [constant TreeItem.CELL_MODE_CUSTOM] mode cell.
</theme_item>
- <theme_item name="custom_button_font_highlight" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )">
+ <theme_item name="custom_button_font_highlight" type="Color" default="Color(0.94, 0.94, 0.94, 1)">
Text [Color] for a [constant TreeItem.CELL_MODE_CUSTOM] mode cell when it's hovered.
</theme_item>
<theme_item name="custom_button_hover" type="StyleBox">
@@ -563,25 +569,25 @@
<theme_item name="draw_relationship_lines" type="int" default="0">
Draws the relationship lines if not zero, this acts as a boolean. Relationship lines are drawn at the start of child items to show hierarchy.
</theme_item>
- <theme_item name="drop_position_color" type="Color" default="Color( 1, 0.3, 0.2, 1 )">
+ <theme_item name="drop_position_color" type="Color" default="Color(1, 0.3, 0.2, 1)">
[Color] used to draw possible drop locations. See [enum DropModeFlags] constants for further description of drop locations.
</theme_item>
<theme_item name="font" type="Font">
[Font] of the item's text.
</theme_item>
- <theme_item name="font_color" type="Color" default="Color( 0.69, 0.69, 0.69, 1 )">
+ <theme_item name="font_color" type="Color" default="Color(0.69, 0.69, 0.69, 1)">
Default text [Color] of the item.
</theme_item>
- <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)">
The tint of text outline of the item.
</theme_item>
- <theme_item name="font_selected_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="font_selected_color" type="Color" default="Color(1, 1, 1, 1)">
Text [Color] used when the item is selected.
</theme_item>
<theme_item name="font_size" type="int">
Font size of the item's text.
</theme_item>
- <theme_item name="guide_color" type="Color" default="Color( 0, 0, 0, 0.1 )">
+ <theme_item name="guide_color" type="Color" default="Color(0, 0, 0, 0.1)">
[Color] of the guideline.
</theme_item>
<theme_item name="hseparation" type="int" default="4">
@@ -593,7 +599,7 @@
<theme_item name="outline_size" type="int" default="0">
The size of the text outline.
</theme_item>
- <theme_item name="parent_hl_line_color" type="Color" default="Color( 0.27, 0.27, 0.27, 1 )">
+ <theme_item name="parent_hl_line_color" type="Color" default="Color(0.27, 0.27, 0.27, 1)">
The [Color] of the relationship lines between the selected [TreeItem] and its parents.
</theme_item>
<theme_item name="parent_hl_line_margin" type="int" default="0">
@@ -602,7 +608,7 @@
<theme_item name="parent_hl_line_width" type="int" default="1">
The width of the relationship lines between the selected [TreeItem] and its parents.
</theme_item>
- <theme_item name="relationship_line_color" type="Color" default="Color( 0.27, 0.27, 0.27, 1 )">
+ <theme_item name="relationship_line_color" type="Color" default="Color(0.27, 0.27, 0.27, 1)">
The default [Color] of the relationship lines.
</theme_item>
<theme_item name="relationship_line_width" type="int" default="1">
@@ -623,7 +629,7 @@
<theme_item name="selected_focus" type="StyleBox">
[StyleBox] for the selected items, used when the [Tree] is being focused.
</theme_item>
- <theme_item name="title_button_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )">
+ <theme_item name="title_button_color" type="Color" default="Color(0.88, 0.88, 0.88, 1)">
Default text [Color] of the title button.
</theme_item>
<theme_item name="title_button_font" type="Font">
diff --git a/doc/classes/TreeItem.xml b/doc/classes/TreeItem.xml
index 0256d83fea..85c9caa101 100644
--- a/doc/classes/TreeItem.xml
+++ b/doc/classes/TreeItem.xml
@@ -192,7 +192,7 @@
Returns [code]true[/code] if [code]expand_right[/code] is set.
</description>
</method>
- <method name="get_first_child">
+ <method name="get_first_child" qualifiers="const">
<return type="TreeItem">
</return>
<description>
@@ -260,7 +260,7 @@
Returns the metadata value that was set for the given column using [method set_metadata].
</description>
</method>
- <method name="get_next">
+ <method name="get_next" qualifiers="const">
<return type="TreeItem">
</return>
<description>
@@ -288,7 +288,7 @@
Returns OpenType feature [code]tag[/code] of the item's text.
</description>
</method>
- <method name="get_parent">
+ <method name="get_parent" qualifiers="const">
<return type="TreeItem">
</return>
<description>
@@ -391,7 +391,7 @@
Returns the given column's tooltip.
</description>
</method>
- <method name="get_tree">
+ <method name="get_tree" qualifiers="const">
<return type="Tree">
</return>
<description>
diff --git a/doc/classes/Tween.xml b/doc/classes/Tween.xml
index 00cca40093..253822cf32 100644
--- a/doc/classes/Tween.xml
+++ b/doc/classes/Tween.xml
@@ -1,453 +1,397 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="Tween" inherits="Node" version="4.0">
+<class name="Tween" inherits="RefCounted" version="4.0">
<brief_description>
- Smoothly animates a node's properties over time.
+ Lightweight object used for general-purpose animation via script, using [Tweener]s.
</brief_description>
<description>
- Tweens are useful for animations requiring a numerical property to be interpolated over a range of values. The name [i]tween[/i] comes from [i]in-betweening[/i], an animation technique where you specify [i]keyframes[/i] and the computer interpolates the frames that appear between them.
- [Tween] is more suited than [AnimationPlayer] for animations where you don't know the final values in advance. For example, interpolating a dynamically-chosen camera zoom value is best done with a [Tween] node; it would be difficult to do the same thing with an [AnimationPlayer] node.
- Here is a brief usage example that makes a 2D node move smoothly between two positions:
- [codeblocks]
- [gdscript]
- var tween = get_node("Tween")
- tween.interpolate_property($Node2D, "position",
- Vector2(0, 0), Vector2(100, 100), 1,
- Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
- tween.start()
- [/gdscript]
- [csharp]
- var tween = GetNode&lt;Tween&gt;("Tween");
- tween.InterpolateProperty(GetNode&lt;Node2D&gt;("Node2D"), "position",
- new Vector2(0, 0), new Vector2(100, 100), 1,
- Tween.TransitionType.Linear, Tween.EaseType.InOut);
- tween.Start();
- [/csharp]
- [/codeblocks]
- Many methods require a property name, such as [code]"position"[/code] above. You can find the correct property name by hovering over the property in the Inspector. You can also provide the components of a property directly by using [code]"property:component"[/code] (e.g. [code]position:x[/code]), where it would only apply to that particular component.
- Many of the methods accept [code]trans_type[/code] and [code]ease_type[/code]. The first accepts an [enum TransitionType] constant, and refers to the way the timing of the animation is handled (see [url=https://easings.net/]easings.net[/url] for some examples). The second accepts an [enum EaseType] constant, and controls where the [code]trans_type[/code] is applied to the interpolation (in the beginning, the end, or both). If you don't know which transition and easing to pick, you can try different [enum TransitionType] constants with [constant EASE_IN_OUT], and use the one that looks best.
+ Tweens are mostly useful for animations requiring a numerical property to be interpolated over a range of values. The name [i]tween[/i] comes from [i]in-betweening[/i], an animation technique where you specify [i]keyframes[/i] and the computer interpolates the frames that appear between them.
+ [Tween] is more suited than [AnimationPlayer] for animations where you don't know the final values in advance. For example, interpolating a dynamically-chosen camera zoom value is best done with a [Tween]; it would be difficult to do the same thing with an [AnimationPlayer] node. Tweens are also more light-weight than [AnimationPlayer], so they are very much suited for simple animations or general tasks that don't require visual tweaking provided by the editor. They can be used in a fire-and-forget manner for some logic that normally would be done by code. You can e.g. make something shoot periodically by using a looped [CallbackTweener] with a delay.
+ A [Tween] can be created by using either [method SceneTree.create_tween] or [method Node.create_tween]. [Tween]s created manually (i.e. by using [code]Tween.new()[/code]) are invalid. They can't be used for tweening values, but you can do manual interpolation with [method interpolate_value].
+ A [Tween] animation is composed of a sequence of [Tweener]s, which by default are executed one after another. You can create a sequence by appending [Tweener]s to the [Tween]. Animating something with a [Tweener] is called tweening. Example tweening sequence looks like this:
+ [codeblock]
+ var tween = get_tree().create_tween()
+ tween.tween_property($Sprite, "modulate", Color.red, 1)
+ tween.tween_property($Sprite, "scale", Vector2(), 1)
+ tween.tween_callback($Sprite.queue_free)
+ [/codeblock]
+ This sequence will make the [code]$Sprite[/code] node turn red, then shrink and finally the [method Node.queue_free] is called to remove the sprite. See methods [method tween_property], [method tween_interval], [method tween_callback] and [method tween_method] for more usage information.
+ When a [Tweener] is created with one of the [code]tween_*[/code] methods, a chained method call can be used to tweak the properties of this [Tweener]. For example, if you want to set different transition type in the above example, you can do:
+ [codeblock]
+ var tween = get_tree().create_tween()
+ tween.tween_property($Sprite, "modulate", Color.red, 1).set_trans(Tween.TRANS_SINE)
+ tween.tween_property($Sprite, "scale", Vector2(), 1).set_trans(Tween.TRANS_BOUNCE)
+ tween.tween_callback($Sprite.queue_free)
+ [/codeblock]
+ Most of the [Tween] methods can be chained this way too. In this example the [Tween] is bound and have set a default transition:
+ [codeblock]
+ var tween = get_tree().create_tween().bind_node(self).set_trans(Tween.TRANS_ELASTIC)
+ tween.tween_property($Sprite, "modulate", Color.red, 1)
+ tween.tween_property($Sprite, "scale", Vector2(), 1)
+ tween.tween_callback($Sprite.queue_free)
+ [/codeblock]
+ Another interesting use for [Tween]s is animating arbitrary set of objects:
+ [codeblock]
+ var tween = create_tween()
+ for sprite in get_children():
+ tween.tween_property(sprite, "position", Vector2(), 1)
+ [/codeblock]
+ In the example above, all children of a node are moved one after another to position (0, 0).
+ Some [Tweener]s use transitions and eases. The first accepts an [enum TransitionType] constant, and refers to the way the timing of the animation is handled (see [url=https://easings.net/]easings.net[/url] for some examples). The second accepts an [enum EaseType] constant, and controls where the [code]trans_type[/code] is applied to the interpolation (in the beginning, the end, or both). If you don't know which transition and easing to pick, you can try different [enum TransitionType] constants with [constant EASE_IN_OUT], and use the one that looks best.
[url=https://raw.githubusercontent.com/godotengine/godot-docs/master/img/tween_cheatsheet.png]Tween easing and transition types cheatsheet[/url]
+ [b]Note:[/b] All [Tween]s will automatically start by default. To prevent a [Tween] from autostarting, you can call [method stop] immediately after it was created.
</description>
<tutorials>
</tutorials>
<methods>
- <method name="follow_method">
- <return type="void">
+ <method name="bind_node">
+ <return type="Tween">
</return>
- <argument index="0" name="object" type="Object">
- </argument>
- <argument index="1" name="method" type="StringName">
- </argument>
- <argument index="2" name="initial_val" type="Variant">
- </argument>
- <argument index="3" name="target" type="Object">
- </argument>
- <argument index="4" name="target_method" type="StringName">
- </argument>
- <argument index="5" name="duration" type="float">
- </argument>
- <argument index="6" name="trans_type" type="int" enum="Tween.TransitionType" default="0">
- </argument>
- <argument index="7" name="ease_type" type="int" enum="Tween.EaseType" default="2">
- </argument>
- <argument index="8" name="delay" type="float" default="0">
+ <argument index="0" name="node" type="Node">
</argument>
<description>
- Follows [code]method[/code] of [code]object[/code] and applies the returned value on [code]target_method[/code] of [code]target[/code], beginning from [code]initial_val[/code] for [code]duration[/code] seconds, [code]delay[/code] later. Methods are called with consecutive values.
- Use [enum TransitionType] for [code]trans_type[/code] and [enum EaseType] for [code]ease_type[/code] parameters. These values control the timing and direction of the interpolation. See the class description for more information.
+ Binds this [Tween] with the given [code]node[/code]. [Tween]s are processed directly by the [SceneTree], so they run independently of the animated nodes. When you bind a [Node] with the [Tween], the [Tween] will halt the animation when the object is not inside tree and the [Tween] will be automatically killed when the bound object is freed. Also [constant TWEEN_PAUSE_BOUND] will make the pausing behavior dependent on the bound node.
+ For a shorter way to create and bind a [Tween], you can use [method Node.create_tween].
</description>
</method>
- <method name="follow_property">
- <return type="void">
+ <method name="chain">
+ <return type="Tween">
</return>
- <argument index="0" name="object" type="Object">
- </argument>
- <argument index="1" name="property" type="NodePath">
- </argument>
- <argument index="2" name="initial_val" type="Variant">
- </argument>
- <argument index="3" name="target" type="Object">
- </argument>
- <argument index="4" name="target_property" type="NodePath">
- </argument>
- <argument index="5" name="duration" type="float">
- </argument>
- <argument index="6" name="trans_type" type="int" enum="Tween.TransitionType" default="0">
- </argument>
- <argument index="7" name="ease_type" type="int" enum="Tween.EaseType" default="2">
- </argument>
- <argument index="8" name="delay" type="float" default="0">
- </argument>
<description>
- Follows [code]property[/code] of [code]object[/code] and applies it on [code]target_property[/code] of [code]target[/code], beginning from [code]initial_val[/code] for [code]duration[/code] seconds, [code]delay[/code] seconds later.
- Use [enum TransitionType] for [code]trans_type[/code] and [enum EaseType] for [code]ease_type[/code] parameters. These values control the timing and direction of the interpolation. See the class description for more information.
+ Used to chain two [Tweener]s after [method set_parallel] is called with [code]true[/code].
+ [codeblock]
+ var tween = create_tween().set_parallel(true)
+ tween.tween_property(...)
+ tween.tween_property(...) #will run parallelly with above
+ tween.chain().tween_property(...) #will run after two above are finished
+ [/codeblock]
</description>
</method>
- <method name="get_runtime" qualifiers="const">
- <return type="float">
+ <method name="custom_step">
+ <return type="bool">
</return>
+ <argument index="0" name="delta" type="float">
+ </argument>
<description>
- Returns the total time needed for all tweens to end. If you have two tweens, one lasting 10 seconds and the other 20 seconds, it would return 20 seconds, as by that time all tweens would have finished.
+ Processes the [Tween] by given [code]delta[/code] value, in seconds. Mostly useful when the [Tween] is paused, for controlling it manually. Can also be used to end the [Tween] animation immediately, by using [code]delta[/code] longer than the whole duration.
+ Returns [code]true[/code] if the [Tween] still has [Tweener]s that haven't finished.
+ [b]Note:[/b] The [Tween] will become invalid after finished, but you can call [method stop] after the step, to keep it and reset.
</description>
</method>
- <method name="interpolate_callback">
- <return type="void">
+ <method name="interpolate_value">
+ <return type="Variant">
</return>
- <argument index="0" name="object" type="Object">
- </argument>
- <argument index="1" name="duration" type="float">
+ <argument index="0" name="trans_type" type="Variant">
</argument>
- <argument index="2" name="callback" type="String">
+ <argument index="1" name="ease_type" type="Variant">
</argument>
- <argument index="3" name="arg1" type="Variant" default="null">
+ <argument index="2" name="elapsed_time" type="float">
</argument>
- <argument index="4" name="arg2" type="Variant" default="null">
+ <argument index="3" name="initial_value" type="float">
</argument>
- <argument index="5" name="arg3" type="Variant" default="null">
+ <argument index="4" name="delta_value" type="int" enum="Tween.TransitionType">
</argument>
- <argument index="6" name="arg4" type="Variant" default="null">
- </argument>
- <argument index="7" name="arg5" type="Variant" default="null">
+ <argument index="5" name="duration" type="int" enum="Tween.EaseType">
</argument>
<description>
- Calls [code]callback[/code] of [code]object[/code] after [code]duration[/code]. [code]arg1[/code]-[code]arg5[/code] are arguments to be passed to the callback.
+ This method can be used for manual interpolation of a value, when you don't want [Tween] to do animating for you. It's similar to [method @GlobalScope.lerp], but with support for custom transition and easing.
+ [code]elapsed_time[/code] is the time in seconds that passed after the interping started and it's used to control the position of the interpolation. E.g. when it's equal to half of the [code]duration[/code], the interpolated value will be halfway between initial and final values. This value can also be greater than [code]duration[/code] or lower than 0, which will extrapolate the value.
+ [code]initial_value[/code] is the starting value of the interpolation.
+ [code]delta_value[/code] is the change of the value in the interpolation, i.e. it's equal to [code]final_value - initial_value[/code].
+ [code]duration[/code] is the total time of the interpolation.
</description>
</method>
- <method name="interpolate_deferred_callback">
- <return type="void">
+ <method name="is_running">
+ <return type="bool">
</return>
- <argument index="0" name="object" type="Object">
- </argument>
- <argument index="1" name="duration" type="float">
- </argument>
- <argument index="2" name="callback" type="String">
- </argument>
- <argument index="3" name="arg1" type="Variant" default="null">
- </argument>
- <argument index="4" name="arg2" type="Variant" default="null">
- </argument>
- <argument index="5" name="arg3" type="Variant" default="null">
- </argument>
- <argument index="6" name="arg4" type="Variant" default="null">
- </argument>
- <argument index="7" name="arg5" type="Variant" default="null">
- </argument>
<description>
- Calls [code]callback[/code] of [code]object[/code] after [code]duration[/code] on the main thread (similar to [method Object.call_deferred]). [code]arg1[/code]-[code]arg5[/code] are arguments to be passed to the callback.
+ Returns whether the [Tween] is currently running, i.e. it wasn't paused and it's not finished.
</description>
</method>
- <method name="interpolate_method">
- <return type="void">
+ <method name="is_valid">
+ <return type="bool">
</return>
- <argument index="0" name="object" type="Object">
- </argument>
- <argument index="1" name="method" type="StringName">
- </argument>
- <argument index="2" name="initial_val" type="Variant">
- </argument>
- <argument index="3" name="final_val" type="Variant">
- </argument>
- <argument index="4" name="duration" type="float">
- </argument>
- <argument index="5" name="trans_type" type="int" enum="Tween.TransitionType" default="0">
- </argument>
- <argument index="6" name="ease_type" type="int" enum="Tween.EaseType" default="2">
- </argument>
- <argument index="7" name="delay" type="float" default="0">
- </argument>
<description>
- Animates [code]method[/code] of [code]object[/code] from [code]initial_val[/code] to [code]final_val[/code] for [code]duration[/code] seconds, [code]delay[/code] seconds later. Methods are called with consecutive values.
- Use [enum TransitionType] for [code]trans_type[/code] and [enum EaseType] for [code]ease_type[/code] parameters. These values control the timing and direction of the interpolation. See the class description for more information.
+ Returns whether the [Tween] is valid. A valid [Tween] is a [Tween] contained by the scene tree (i.e. the array from [method SceneTree.get_processed_tweens] will contain this [Tween]). [Tween] might become invalid when it has finished tweening or was killed, also when created with [code]Tween.new()[/code]. Invalid [Tween] can't have [Tweener]s appended, because it can't animate them. You can however still use [method interpolate_value].
</description>
</method>
- <method name="interpolate_property">
+ <method name="kill">
<return type="void">
</return>
- <argument index="0" name="object" type="Object">
- </argument>
- <argument index="1" name="property" type="NodePath">
- </argument>
- <argument index="2" name="initial_val" type="Variant">
- </argument>
- <argument index="3" name="final_val" type="Variant">
- </argument>
- <argument index="4" name="duration" type="float">
- </argument>
- <argument index="5" name="trans_type" type="int" enum="Tween.TransitionType" default="0">
- </argument>
- <argument index="6" name="ease_type" type="int" enum="Tween.EaseType" default="2">
- </argument>
- <argument index="7" name="delay" type="float" default="0">
- </argument>
<description>
- Animates [code]property[/code] of [code]object[/code] from [code]initial_val[/code] to [code]final_val[/code] for [code]duration[/code] seconds, [code]delay[/code] seconds later. Setting the initial value to [code]null[/code] uses the current value of the property.
- Use [enum TransitionType] for [code]trans_type[/code] and [enum EaseType] for [code]ease_type[/code] parameters. These values control the timing and direction of the interpolation. See the class description for more information.
+ Aborts all tweening operations and invalidates the [Tween].
</description>
</method>
- <method name="is_active" qualifiers="const">
- <return type="bool">
+ <method name="parallel">
+ <return type="Tween">
</return>
<description>
- Returns [code]true[/code] if any tweens are currently running.
- [b]Note:[/b] This method doesn't consider tweens that have ended.
+ Makes the next [Tweener] run parallely to the previous one. Example:
+ [codeblock]
+ var tween = create_tween()
+ tween.tween_property(...)
+ tween.parallel().tween_property(...)
+ tween.parallel().tween_property(...)
+ [/codeblock]
+ All [Tweener]s in the example will run at the same time.
+ You can make the [Tween] parallel by default by using [method set_parallel].
</description>
</method>
- <method name="remove">
+ <method name="pause">
<return type="void">
</return>
- <argument index="0" name="object" type="Object">
- </argument>
- <argument index="1" name="key" type="StringName" default="&quot;&quot;">
- </argument>
<description>
- Stops animation and removes a tween, given its object and property/method pair. By default, all tweens are removed, unless [code]key[/code] is specified.
+ Pauses the tweening. The animation can be resumed by using [method play].
</description>
</method>
- <method name="remove_all">
+ <method name="play">
<return type="void">
</return>
<description>
- Stops animation and removes all tweens.
+ Resumes a paused or stopped [Tween].
</description>
</method>
- <method name="reset">
- <return type="void">
+ <method name="set_ease">
+ <return type="Tween">
</return>
- <argument index="0" name="object" type="Object">
- </argument>
- <argument index="1" name="key" type="StringName" default="&quot;&quot;">
+ <argument index="0" name="ease" type="int" enum="Tween.EaseType">
</argument>
<description>
- Resets a tween to its initial value (the one given, not the one before the tween), given its object and property/method pair. By default, all tweens are removed, unless [code]key[/code] is specified.
+ Sets the default ease type for [PropertyTweener]s and [MethodTweener]s animated by this [Tween].
</description>
</method>
- <method name="reset_all">
- <return type="void">
+ <method name="set_loops">
+ <return type="Tween">
</return>
+ <argument index="0" name="loops" type="int" default="0">
+ </argument>
<description>
- Resets all tweens to their initial values (the ones given, not those before the tween).
+ Sets the number of times the tweening sequence will be repeated, i.e. [code]set_loops(2)[/code] will run the animation twice.
+ Calling this method without arguments will make the [Tween] run infinitely, until it is either killed by [method kill] or by freeing bound node, or all the animated objects have been freed (which makes further animation impossible).
</description>
</method>
- <method name="resume">
- <return type="void">
+ <method name="set_parallel">
+ <return type="Tween">
</return>
- <argument index="0" name="object" type="Object">
- </argument>
- <argument index="1" name="key" type="StringName" default="&quot;&quot;">
+ <argument index="0" name="parallel" type="bool" default="true">
</argument>
<description>
- Continues animating a stopped tween, given its object and property/method pair. By default, all tweens are resumed, unless [code]key[/code] is specified.
+ If [code]parallel[/code] is [code]true[/code], the [Tweener]s appended after this method will by default run simultanously, as opposed to sequentially.
</description>
</method>
- <method name="resume_all">
- <return type="void">
+ <method name="set_pause_mode">
+ <return type="Tween">
</return>
+ <argument index="0" name="mode" type="int" enum="Tween.TweenPauseMode">
+ </argument>
<description>
- Continues animating all stopped tweens.
+ Determines the behavior of the [Tween] when the [SceneTree] is paused. Check [enum TweenPauseMode] for options.
+ Default value is [constant TWEEN_PAUSE_BOUND].
</description>
</method>
- <method name="seek">
- <return type="void">
+ <method name="set_process_mode">
+ <return type="Tween">
</return>
- <argument index="0" name="time" type="float">
+ <argument index="0" name="mode" type="int" enum="Tween.TweenProcessMode">
</argument>
<description>
- Sets the interpolation to the given [code]time[/code] in seconds.
+ Determines whether the [Tween] should run during idle frame (see [method Node._process]) or physics frame (see [method Node._physics_process].
+ Default value is [constant TWEEN_PROCESS_IDLE].
</description>
</method>
- <method name="set_active">
- <return type="void">
+ <method name="set_speed_scale">
+ <return type="Tween">
</return>
- <argument index="0" name="active" type="bool">
+ <argument index="0" name="speed" type="float">
</argument>
<description>
- Activates/deactivates the tween. See also [method stop_all] and [method resume_all].
+ Scales the speed of tweening. This affects all [Tweener]s and their delays.
</description>
</method>
- <method name="start">
- <return type="void">
+ <method name="set_trans">
+ <return type="Tween">
</return>
+ <argument index="0" name="trans" type="int" enum="Tween.TransitionType">
+ </argument>
<description>
- Starts the tween. You can define animations both before and after this.
+ Sets the default transition type for [PropertyTweener]s and [MethodTweener]s animated by this [Tween].
</description>
</method>
<method name="stop">
<return type="void">
</return>
- <argument index="0" name="object" type="Object">
- </argument>
- <argument index="1" name="key" type="StringName" default="&quot;&quot;">
- </argument>
<description>
- Stops a tween, given its object and property/method pair. By default, all tweens are stopped, unless [code]key[/code] is specified.
+ Stops the tweening and resets the [Tween] to its initial state. This will not remove any appended [Tweener]s.
</description>
</method>
- <method name="stop_all">
- <return type="void">
+ <method name="tween_callback">
+ <return type="CallbackTweener">
</return>
+ <argument index="0" name="callback" type="Callable">
+ </argument>
<description>
- Stops animating all tweens.
+ Creates and appends a [CallbackTweener]. This method can be used to call an arbitrary method in any object. Use [method Callable.bind] to bind additional arguments for the call.
+ Example: object that keeps shooting every 1 second.
+ [codeblock]
+ var tween = get_tree().create_tween().set_loops()
+ tween.tween_callback(shoot).set_delay(1)
+ [/codeblock]
+ Example: turning a sprite red and then blue, with 2 second delay.
+ [codeblock]
+ var tween = get_tree().create_tween()
+ tween.tween_callback($Sprite.set_modulate.bind(Color.red)).set_delay(2)
+ tween.tween_callback($Sprite.set_modulate.bind(Color.blue)).set_delay(2)
+ [/codeblock]
</description>
</method>
- <method name="targeting_method">
- <return type="void">
+ <method name="tween_interval">
+ <return type="IntervalTweener">
</return>
- <argument index="0" name="object" type="Object">
- </argument>
- <argument index="1" name="method" type="StringName">
- </argument>
- <argument index="2" name="initial" type="Object">
- </argument>
- <argument index="3" name="initial_method" type="StringName">
- </argument>
- <argument index="4" name="final_val" type="Variant">
+ <argument index="0" name="time" type="float">
</argument>
- <argument index="5" name="duration" type="float">
+ <description>
+ Creates and appends an [IntervalTweener]. This method can be used to create delays in the tween animation, as an alternative for using the delay in other [Tweener]s or when there's no animation (in which case the [Tween] acts as a timer). [code]time[/code] is the length of the interval, in seconds.
+ Example: creating an interval in code execution.
+ [codeblock]
+ #... some code
+ var tween = create_tween()
+ tween.tween_interval(2)
+ await tween.finished
+ #... more code
+ [/codeblock]
+ Example: creating an object that moves back and forth and jumps every few seconds.
+ [codeblock]
+ var tween = create_tween().set_loops()
+ tween.tween_property("position:x", 200, 1).as_relative()
+ tween.tween_callback(jump)
+ tween.tween_interval(2)
+ tween.tween_property("position:x", -200, 1).as_relative()
+ tween.tween_callback(jump)
+ tween.tween_interval(2)
+ [/codeblock]
+ </description>
+ </method>
+ <method name="tween_method">
+ <return type="MethodTweener">
+ </return>
+ <argument index="0" name="method" type="Callable">
</argument>
- <argument index="6" name="trans_type" type="int" enum="Tween.TransitionType" default="0">
+ <argument index="1" name="from" type="float">
</argument>
- <argument index="7" name="ease_type" type="int" enum="Tween.EaseType" default="2">
+ <argument index="2" name="to" type="float">
</argument>
- <argument index="8" name="delay" type="float" default="0">
+ <argument index="3" name="duration" type="float">
</argument>
<description>
- Animates [code]method[/code] of [code]object[/code] from the value returned by [code]initial_method[/code] to [code]final_val[/code] for [code]duration[/code] seconds, [code]delay[/code] seconds later. Methods are animated by calling them with consecutive values.
- Use [enum TransitionType] for [code]trans_type[/code] and [enum EaseType] for [code]ease_type[/code] parameters. These values control the timing and direction of the interpolation. See the class description for more information.
+ Creates and appends a [MethodTweener]. This method is similar to a combination of [method tween_callback] and [method tween_property]. It calls a method over time with a tweened value provided as an argument. The value is tweened between [code]from[/code] and [code]to[/code] over the time specified by [code]duration[/code], in seconds. Use [method Callable.bind] to bind additional arguments for the call. You can use [method MethodTweener.set_ease] and [method MethodTweener.set_trans] to tweak the easing and transition of the value or [method MethodTweener.set_delay] to delay the tweening.
+ Example: making a 3D object look from one point to another point.
+ [codeblock]
+ var tween = create_tween()
+ tween.tween_method(look_at.bind(Vector3.UP), Vector3(-1, 0, -1), Vector3(1, 0, -1), 1) #the look_at() method takes up vector as second argument
+ [/codeblock]
+ Example: setting a text of a [Label], using an intermediate method and after a delay.
+ [codeblock]
+ func _ready():
+ var tween = create_tween()
+ tween.tween_method(set_label_text, 0, 10, 1).set_delay(1)
+
+ func set_label_text(value: int):
+ $Label.text = "Counting " + str(value)
+ [/codeblock]
</description>
</method>
- <method name="targeting_property">
- <return type="void">
+ <method name="tween_property">
+ <return type="PropertyTweener">
</return>
<argument index="0" name="object" type="Object">
</argument>
<argument index="1" name="property" type="NodePath">
</argument>
- <argument index="2" name="initial" type="Object">
- </argument>
- <argument index="3" name="initial_val" type="NodePath">
- </argument>
- <argument index="4" name="final_val" type="Variant">
+ <argument index="2" name="final_val" type="Variant">
</argument>
- <argument index="5" name="duration" type="float">
+ <argument index="3" name="duration" type="float">
</argument>
- <argument index="6" name="trans_type" type="int" enum="Tween.TransitionType" default="0">
- </argument>
- <argument index="7" name="ease_type" type="int" enum="Tween.EaseType" default="2">
- </argument>
- <argument index="8" name="delay" type="float" default="0">
- </argument>
- <description>
- Animates [code]property[/code] of [code]object[/code] from the current value of the [code]initial_val[/code] property of [code]initial[/code] to [code]final_val[/code] for [code]duration[/code] seconds, [code]delay[/code] seconds later.
- Use [enum TransitionType] for [code]trans_type[/code] and [enum EaseType] for [code]ease_type[/code] parameters. These values control the timing and direction of the interpolation. See the class description for more information.
- </description>
- </method>
- <method name="tell" qualifiers="const">
- <return type="float">
- </return>
<description>
- Returns the current time of the tween.
+ Creates and appends a [PropertyTweener]. This method tweens a [code]property[/code] of an [code]object[/code] between an initial value and [code]final_val[/code] in a span of time equal to [code]duration[/code], in seconds. The initial value by default is a value at the time the tweening of the [PropertyTweener] start. For example:
+ [codeblock]
+ var tween = create_tween()
+ tween.tween_property($Sprite, "position", Vector2(100, 200)
+ tween.tween_property($Sprite, "position", Vector2(200, 300)
+ [/codeblock]
+ will move the sprite to position (100, 200) and then to (200, 300). If you use [method PropertyTweener.from] or [method PropertyTweener.from_current], the starting position will be overwritten by the given value instead. See other methods in [PropertyTweener] to see how the tweening can be tweaked further.
+ [b]Note:[/b] You can find the correct property name by hovering over the property in the Inspector. You can also provide the components of a property directly by using [code]"property:component"[/code] (eg. [code]position:x[/code]), where it would only apply to that particular component.
+ Example: moving object twice from the same position, with different transition types.
+ [codeblock]
+ var tween = create_tween()
+ tween.tween_property($Sprite, "position", Vector2.RIGHT * 300).as_relative().set_trans(Tween.TRANS_SINE)
+ tween.tween_property($Sprite, "position", Vector2.RIGHT * 300).as_relative().from_current().set_trans(Tween.TRANS_EXPO)
+ [/codeblock]
</description>
</method>
</methods>
- <members>
- <member name="playback_process_mode" type="int" setter="set_tween_process_mode" getter="get_tween_process_mode" enum="Tween.TweenProcessMode" default="1">
- The tween's animation process thread. See [enum TweenProcessMode].
- </member>
- <member name="playback_speed" type="float" setter="set_speed_scale" getter="get_speed_scale" default="1.0">
- The tween's speed multiplier. For example, set it to [code]1.0[/code] for normal speed, [code]2.0[/code] for two times normal speed, or [code]0.5[/code] for half of the normal speed. A value of [code]0[/code] pauses the animation, but see also [method set_active] or [method stop_all] for this.
- </member>
- <member name="repeat" type="bool" setter="set_repeat" getter="is_repeat" default="false">
- If [code]true[/code], the tween loops.
- </member>
- </members>
<signals>
- <signal name="tween_all_completed">
+ <signal name="finished">
<description>
- Emitted when all processes in a tween end.
+ Emitted when the [Tween] has finished all tweening. Never emitted when the [Tween] is set to infinite looping (see [method set_loops]).
+ [b]Note:[/b] The [Tween] is removed (invalidated) after this signal is emitted, but it doesn't happen immediately, but on the next processing frame. Calling [method stop] inside the signal callback will preserve the [Tween].
</description>
</signal>
- <signal name="tween_completed">
- <argument index="0" name="object" type="Object">
- </argument>
- <argument index="1" name="key" type="NodePath">
+ <signal name="loop_finished">
+ <argument index="0" name="loop_count" type="int">
</argument>
<description>
- Emitted when a tween ends.
+ Emitted when a full loop is complete (see [method set_loops]), providing the loop index. This signal is not emitted after final loop, use [signal finished] instead for this case.
</description>
</signal>
- <signal name="tween_started">
- <argument index="0" name="object" type="Object">
- </argument>
- <argument index="1" name="key" type="NodePath">
+ <signal name="step_finished">
+ <argument index="0" name="idx" type="int">
</argument>
<description>
- Emitted when a tween starts.
- </description>
- </signal>
- <signal name="tween_step">
- <argument index="0" name="object" type="Object">
- </argument>
- <argument index="1" name="key" type="NodePath">
- </argument>
- <argument index="2" name="elapsed" type="float">
- </argument>
- <argument index="3" name="value" type="Object">
- </argument>
- <description>
- Emitted at each step of the animation.
+ Emitted when one step of the [Tween] is complete, providing the step index. One step is either a single [Tweener] or a group of [Tweener]s running parallelly.
</description>
</signal>
</signals>
<constants>
<constant name="TWEEN_PROCESS_PHYSICS" value="0" enum="TweenProcessMode">
- The tween updates with the [code]_physics_process[/code] callback.
+ The [Tween] updates during physics frame.
</constant>
<constant name="TWEEN_PROCESS_IDLE" value="1" enum="TweenProcessMode">
- The tween updates with the [code]_process[/code] callback.
+ The [Tween] updates during idle
+ </constant>
+ <constant name="TWEEN_PAUSE_BOUND" value="0" enum="TweenPauseMode">
+ </constant>
+ <constant name="TWEEN_PAUSE_STOP" value="1" enum="TweenPauseMode">
+ </constant>
+ <constant name="TWEEN_PAUSE_PROCESS" value="2" enum="TweenPauseMode">
</constant>
<constant name="TRANS_LINEAR" value="0" enum="TransitionType">
- The animation is interpolated linearly.
</constant>
<constant name="TRANS_SINE" value="1" enum="TransitionType">
- The animation is interpolated using a sine function.
</constant>
<constant name="TRANS_QUINT" value="2" enum="TransitionType">
- The animation is interpolated with a quintic (to the power of 5) function.
</constant>
<constant name="TRANS_QUART" value="3" enum="TransitionType">
- The animation is interpolated with a quartic (to the power of 4) function.
</constant>
<constant name="TRANS_QUAD" value="4" enum="TransitionType">
- The animation is interpolated with a quadratic (to the power of 2) function.
</constant>
<constant name="TRANS_EXPO" value="5" enum="TransitionType">
- The animation is interpolated with an exponential (to the power of x) function.
</constant>
<constant name="TRANS_ELASTIC" value="6" enum="TransitionType">
- The animation is interpolated with elasticity, wiggling around the edges.
</constant>
<constant name="TRANS_CUBIC" value="7" enum="TransitionType">
- The animation is interpolated with a cubic (to the power of 3) function.
</constant>
<constant name="TRANS_CIRC" value="8" enum="TransitionType">
- The animation is interpolated with a function using square roots.
</constant>
<constant name="TRANS_BOUNCE" value="9" enum="TransitionType">
- The animation is interpolated by bouncing at the end.
</constant>
<constant name="TRANS_BACK" value="10" enum="TransitionType">
- The animation is interpolated backing out at ends.
</constant>
<constant name="EASE_IN" value="0" enum="EaseType">
- The interpolation starts slowly and speeds up towards the end.
</constant>
<constant name="EASE_OUT" value="1" enum="EaseType">
- The interpolation starts quickly and slows down towards the end.
</constant>
<constant name="EASE_IN_OUT" value="2" enum="EaseType">
- A combination of [constant EASE_IN] and [constant EASE_OUT]. The interpolation is slowest at both ends.
</constant>
<constant name="EASE_OUT_IN" value="3" enum="EaseType">
- A combination of [constant EASE_IN] and [constant EASE_OUT]. The interpolation is fastest at both ends.
</constant>
</constants>
</class>
diff --git a/doc/classes/Tweener.xml b/doc/classes/Tweener.xml
new file mode 100644
index 0000000000..5cd502ced9
--- /dev/null
+++ b/doc/classes/Tweener.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="Tweener" inherits="RefCounted" version="4.0">
+ <brief_description>
+ Abstract class for all Tweeners used by [Tween].
+ </brief_description>
+ <description>
+ Tweeners are objects that perform a specific animating task, e.g. interpolating a property or calling a method at a given time. A [Tweener] can't be created manually, you need to use a dedicated method from [Tween] or [Node].
+ </description>
+ <tutorials>
+ </tutorials>
+ <methods>
+ </methods>
+ <signals>
+ <signal name="finished">
+ <description>
+ Emited when the [Tweener] has just finished its job.
+ </description>
+ </signal>
+ </signals>
+ <constants>
+ </constants>
+</class>
diff --git a/doc/classes/Vector2.xml b/doc/classes/Vector2.xml
index 1390a5e45b..498aefbef0 100644
--- a/doc/classes/Vector2.xml
+++ b/doc/classes/Vector2.xml
@@ -304,12 +304,6 @@
<method name="operator +" qualifiers="operator">
<return type="Vector2">
</return>
- <description>
- </description>
- </method>
- <method name="operator +" qualifiers="operator">
- <return type="Vector2">
- </return>
<argument index="0" name="right" type="Vector2">
</argument>
<description>
@@ -318,12 +312,6 @@
<method name="operator -" qualifiers="operator">
<return type="Vector2">
</return>
- <description>
- </description>
- </method>
- <method name="operator -" qualifiers="operator">
- <return type="Vector2">
- </return>
<argument index="0" name="right" type="Vector2">
</argument>
<description>
@@ -401,6 +389,18 @@
<description>
</description>
</method>
+ <method name="operator unary+" qualifiers="operator">
+ <return type="Vector2">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="operator unary-" qualifiers="operator">
+ <return type="Vector2">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="orthogonal" qualifiers="const">
<return type="Vector2">
</return>
@@ -513,25 +513,25 @@
<constant name="AXIS_Y" value="1">
Enumerated value for the Y axis.
</constant>
- <constant name="ZERO" value="Vector2( 0, 0 )">
+ <constant name="ZERO" value="Vector2(0, 0)">
Zero vector, a vector with all components set to [code]0[/code].
</constant>
- <constant name="ONE" value="Vector2( 1, 1 )">
+ <constant name="ONE" value="Vector2(1, 1)">
One vector, a vector with all components set to [code]1[/code].
</constant>
- <constant name="INF" value="Vector2( inf, inf )">
+ <constant name="INF" value="Vector2(inf, inf)">
Infinity vector, a vector with all components set to [constant @GDScript.INF].
</constant>
- <constant name="LEFT" value="Vector2( -1, 0 )">
+ <constant name="LEFT" value="Vector2(-1, 0)">
Left unit vector. Represents the direction of left.
</constant>
- <constant name="RIGHT" value="Vector2( 1, 0 )">
+ <constant name="RIGHT" value="Vector2(1, 0)">
Right unit vector. Represents the direction of right.
</constant>
- <constant name="UP" value="Vector2( 0, -1 )">
+ <constant name="UP" value="Vector2(0, -1)">
Up unit vector. Y is down in 2D, so this vector points -Y.
</constant>
- <constant name="DOWN" value="Vector2( 0, 1 )">
+ <constant name="DOWN" value="Vector2(0, 1)">
Down unit vector. Y is down in 2D, so this vector points +Y.
</constant>
</constants>
diff --git a/doc/classes/Vector2i.xml b/doc/classes/Vector2i.xml
index 6efb52b712..5f190de8ca 100644
--- a/doc/classes/Vector2i.xml
+++ b/doc/classes/Vector2i.xml
@@ -126,12 +126,6 @@
<method name="operator +" qualifiers="operator">
<return type="Vector2i">
</return>
- <description>
- </description>
- </method>
- <method name="operator +" qualifiers="operator">
- <return type="Vector2i">
- </return>
<argument index="0" name="right" type="Vector2i">
</argument>
<description>
@@ -140,12 +134,6 @@
<method name="operator -" qualifiers="operator">
<return type="Vector2i">
</return>
- <description>
- </description>
- </method>
- <method name="operator -" qualifiers="operator">
- <return type="Vector2i">
- </return>
<argument index="0" name="right" type="Vector2i">
</argument>
<description>
@@ -223,6 +211,18 @@
<description>
</description>
</method>
+ <method name="operator unary+" qualifiers="operator">
+ <return type="Vector2i">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="operator unary-" qualifiers="operator">
+ <return type="Vector2i">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="sign" qualifiers="const">
<return type="Vector2i">
</return>
@@ -246,22 +246,22 @@
<constant name="AXIS_Y" value="1">
Enumerated value for the Y axis.
</constant>
- <constant name="ZERO" value="Vector2i( 0, 0 )">
+ <constant name="ZERO" value="Vector2i(0, 0)">
Zero vector, a vector with all components set to [code]0[/code].
</constant>
- <constant name="ONE" value="Vector2i( 1, 1 )">
+ <constant name="ONE" value="Vector2i(1, 1)">
One vector, a vector with all components set to [code]1[/code].
</constant>
- <constant name="LEFT" value="Vector2i( -1, 0 )">
+ <constant name="LEFT" value="Vector2i(-1, 0)">
Left unit vector. Represents the direction of left.
</constant>
- <constant name="RIGHT" value="Vector2i( 1, 0 )">
+ <constant name="RIGHT" value="Vector2i(1, 0)">
Right unit vector. Represents the direction of right.
</constant>
- <constant name="UP" value="Vector2i( 0, -1 )">
+ <constant name="UP" value="Vector2i(0, -1)">
Up unit vector. Y is down in 2D, so this vector points -Y.
</constant>
- <constant name="DOWN" value="Vector2i( 0, 1 )">
+ <constant name="DOWN" value="Vector2i(0, 1)">
Down unit vector. Y is down in 2D, so this vector points +Y.
</constant>
</constants>
diff --git a/doc/classes/Vector3.xml b/doc/classes/Vector3.xml
index b6effd441b..1361666c18 100644
--- a/doc/classes/Vector3.xml
+++ b/doc/classes/Vector3.xml
@@ -173,7 +173,7 @@
<return type="Vector3">
</return>
<description>
- Returns the inverse of the vector. This is the same as [code]Vector3( 1.0 / v.x, 1.0 / v.y, 1.0 / v.z )[/code].
+ Returns the inverse of the vector. This is the same as [code]Vector3(1.0 / v.x, 1.0 / v.y, 1.0 / v.z)[/code].
</description>
</method>
<method name="is_equal_approx" qualifiers="const">
@@ -318,12 +318,6 @@
<method name="operator +" qualifiers="operator">
<return type="Vector3">
</return>
- <description>
- </description>
- </method>
- <method name="operator +" qualifiers="operator">
- <return type="Vector3">
- </return>
<argument index="0" name="right" type="Vector3">
</argument>
<description>
@@ -332,12 +326,6 @@
<method name="operator -" qualifiers="operator">
<return type="Vector3">
</return>
- <description>
- </description>
- </method>
- <method name="operator -" qualifiers="operator">
- <return type="Vector3">
- </return>
<argument index="0" name="right" type="Vector3">
</argument>
<description>
@@ -415,6 +403,18 @@
<description>
</description>
</method>
+ <method name="operator unary+" qualifiers="operator">
+ <return type="Vector3">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="operator unary-" qualifiers="operator">
+ <return type="Vector3">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="outer" qualifiers="const">
<return type="Basis">
</return>
@@ -556,31 +556,31 @@
<constant name="AXIS_Z" value="2">
Enumerated value for the Z axis. Returned by [method max_axis] and [method min_axis].
</constant>
- <constant name="ZERO" value="Vector3( 0, 0, 0 )">
+ <constant name="ZERO" value="Vector3(0, 0, 0)">
Zero vector, a vector with all components set to [code]0[/code].
</constant>
- <constant name="ONE" value="Vector3( 1, 1, 1 )">
+ <constant name="ONE" value="Vector3(1, 1, 1)">
One vector, a vector with all components set to [code]1[/code].
</constant>
- <constant name="INF" value="Vector3( inf, inf, inf )">
+ <constant name="INF" value="Vector3(inf, inf, inf)">
Infinity vector, a vector with all components set to [constant @GDScript.INF].
</constant>
- <constant name="LEFT" value="Vector3( -1, 0, 0 )">
+ <constant name="LEFT" value="Vector3(-1, 0, 0)">
Left unit vector. Represents the local direction of left, and the global direction of west.
</constant>
- <constant name="RIGHT" value="Vector3( 1, 0, 0 )">
+ <constant name="RIGHT" value="Vector3(1, 0, 0)">
Right unit vector. Represents the local direction of right, and the global direction of east.
</constant>
- <constant name="UP" value="Vector3( 0, 1, 0 )">
+ <constant name="UP" value="Vector3(0, 1, 0)">
Up unit vector.
</constant>
- <constant name="DOWN" value="Vector3( 0, -1, 0 )">
+ <constant name="DOWN" value="Vector3(0, -1, 0)">
Down unit vector.
</constant>
- <constant name="FORWARD" value="Vector3( 0, 0, -1 )">
+ <constant name="FORWARD" value="Vector3(0, 0, -1)">
Forward unit vector. Represents the local direction of forward, and the global direction of north.
</constant>
- <constant name="BACK" value="Vector3( 0, 0, 1 )">
+ <constant name="BACK" value="Vector3(0, 0, 1)">
Back unit vector. Represents the local direction of back, and the global direction of south.
</constant>
</constants>
diff --git a/doc/classes/Vector3i.xml b/doc/classes/Vector3i.xml
index 6e8a34b692..e08bafa665 100644
--- a/doc/classes/Vector3i.xml
+++ b/doc/classes/Vector3i.xml
@@ -134,12 +134,6 @@
<method name="operator +" qualifiers="operator">
<return type="Vector3i">
</return>
- <description>
- </description>
- </method>
- <method name="operator +" qualifiers="operator">
- <return type="Vector3i">
- </return>
<argument index="0" name="right" type="Vector3i">
</argument>
<description>
@@ -148,12 +142,6 @@
<method name="operator -" qualifiers="operator">
<return type="Vector3i">
</return>
- <description>
- </description>
- </method>
- <method name="operator -" qualifiers="operator">
- <return type="Vector3i">
- </return>
<argument index="0" name="right" type="Vector3i">
</argument>
<description>
@@ -231,6 +219,18 @@
<description>
</description>
</method>
+ <method name="operator unary+" qualifiers="operator">
+ <return type="Vector3i">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="operator unary-" qualifiers="operator">
+ <return type="Vector3i">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="sign" qualifiers="const">
<return type="Vector3i">
</return>
@@ -260,28 +260,28 @@
<constant name="AXIS_Z" value="2">
Enumerated value for the Z axis.
</constant>
- <constant name="ZERO" value="Vector3i( 0, 0, 0 )">
+ <constant name="ZERO" value="Vector3i(0, 0, 0)">
Zero vector, a vector with all components set to [code]0[/code].
</constant>
- <constant name="ONE" value="Vector3i( 1, 1, 1 )">
+ <constant name="ONE" value="Vector3i(1, 1, 1)">
One vector, a vector with all components set to [code]1[/code].
</constant>
- <constant name="LEFT" value="Vector3i( -1, 0, 0 )">
+ <constant name="LEFT" value="Vector3i(-1, 0, 0)">
Left unit vector. Represents the local direction of left, and the global direction of west.
</constant>
- <constant name="RIGHT" value="Vector3i( 1, 0, 0 )">
+ <constant name="RIGHT" value="Vector3i(1, 0, 0)">
Right unit vector. Represents the local direction of right, and the global direction of east.
</constant>
- <constant name="UP" value="Vector3i( 0, 1, 0 )">
+ <constant name="UP" value="Vector3i(0, 1, 0)">
Up unit vector.
</constant>
- <constant name="DOWN" value="Vector3i( 0, -1, 0 )">
+ <constant name="DOWN" value="Vector3i(0, -1, 0)">
Down unit vector.
</constant>
- <constant name="FORWARD" value="Vector3i( 0, 0, -1 )">
+ <constant name="FORWARD" value="Vector3i(0, 0, -1)">
Forward unit vector. Represents the local direction of forward, and the global direction of north.
</constant>
- <constant name="BACK" value="Vector3i( 0, 0, 1 )">
+ <constant name="BACK" value="Vector3i(0, 0, 1)">
Back unit vector. Represents the local direction of back, and the global direction of south.
</constant>
</constants>
diff --git a/doc/classes/VisibleOnScreenNotifier2D.xml b/doc/classes/VisibleOnScreenNotifier2D.xml
index f2f3bc9144..daad200ca8 100644
--- a/doc/classes/VisibleOnScreenNotifier2D.xml
+++ b/doc/classes/VisibleOnScreenNotifier2D.xml
@@ -21,7 +21,7 @@
</method>
</methods>
<members>
- <member name="rect" type="Rect2" setter="set_rect" getter="get_rect" default="Rect2( -10, -10, 20, 20 )">
+ <member name="rect" type="Rect2" setter="set_rect" getter="get_rect" default="Rect2(-10, -10, 20, 20)">
The VisibleOnScreenNotifier2D's bounding rectangle.
</member>
</members>
diff --git a/doc/classes/VisibleOnScreenNotifier3D.xml b/doc/classes/VisibleOnScreenNotifier3D.xml
index 859dacd716..85ff324fbf 100644
--- a/doc/classes/VisibleOnScreenNotifier3D.xml
+++ b/doc/classes/VisibleOnScreenNotifier3D.xml
@@ -21,7 +21,7 @@
</method>
</methods>
<members>
- <member name="aabb" type="AABB" setter="set_aabb" getter="get_aabb" default="AABB( -1, -1, -1, 2, 2, 2 )">
+ <member name="aabb" type="AABB" setter="set_aabb" getter="get_aabb" default="AABB(-1, -1, -1, 2, 2, 2)">
The VisibleOnScreenNotifier3D's bounding box.
</member>
</members>
diff --git a/doc/classes/VisualShader.xml b/doc/classes/VisualShader.xml
index 775ac88eff..19b4acd8f1 100644
--- a/doc/classes/VisualShader.xml
+++ b/doc/classes/VisualShader.xml
@@ -206,7 +206,7 @@
</method>
</methods>
<members>
- <member name="graph_offset" type="Vector2" setter="set_graph_offset" getter="get_graph_offset" default="Vector2( 0, 0 )">
+ <member name="graph_offset" type="Vector2" setter="set_graph_offset" getter="get_graph_offset" default="Vector2(0, 0)">
The offset vector of the whole graph.
</member>
<member name="version" type="String" setter="set_version" getter="get_version" default="&quot;&quot;">
diff --git a/doc/classes/VisualShaderNodeColorConstant.xml b/doc/classes/VisualShaderNodeColorConstant.xml
index 8644013ef2..fa1a11c488 100644
--- a/doc/classes/VisualShaderNodeColorConstant.xml
+++ b/doc/classes/VisualShaderNodeColorConstant.xml
@@ -12,7 +12,7 @@
<methods>
</methods>
<members>
- <member name="constant" type="Color" setter="set_constant" getter="get_constant" default="Color( 1, 1, 1, 1 )">
+ <member name="constant" type="Color" setter="set_constant" getter="get_constant" default="Color(1, 1, 1, 1)">
A [Color] constant which represents a state of this node.
</member>
</members>
diff --git a/doc/classes/VisualShaderNodeColorUniform.xml b/doc/classes/VisualShaderNodeColorUniform.xml
index 90ef381b76..bdaf301f09 100644
--- a/doc/classes/VisualShaderNodeColorUniform.xml
+++ b/doc/classes/VisualShaderNodeColorUniform.xml
@@ -11,7 +11,7 @@
<methods>
</methods>
<members>
- <member name="default_value" type="Color" setter="set_default_value" getter="get_default_value" default="Color( 1, 1, 1, 1 )">
+ <member name="default_value" type="Color" setter="set_default_value" getter="get_default_value" default="Color(1, 1, 1, 1)">
A default value to be assigned within the shader.
</member>
<member name="default_value_enabled" type="bool" setter="set_default_value_enabled" getter="is_default_value_enabled" default="false">
diff --git a/doc/classes/VisualShaderNodeResizableBase.xml b/doc/classes/VisualShaderNodeResizableBase.xml
index 9f827a96cc..9052f6854b 100644
--- a/doc/classes/VisualShaderNodeResizableBase.xml
+++ b/doc/classes/VisualShaderNodeResizableBase.xml
@@ -9,7 +9,7 @@
<methods>
</methods>
<members>
- <member name="size" type="Vector2" setter="set_size" getter="get_size" default="Vector2( 0, 0 )">
+ <member name="size" type="Vector2" setter="set_size" getter="get_size" default="Vector2(0, 0)">
The size of the node in the visual shader graph.
</member>
</members>
diff --git a/doc/classes/VisualShaderNodeTransformConstant.xml b/doc/classes/VisualShaderNodeTransformConstant.xml
index 550ed829c9..30178752d0 100644
--- a/doc/classes/VisualShaderNodeTransformConstant.xml
+++ b/doc/classes/VisualShaderNodeTransformConstant.xml
@@ -11,7 +11,7 @@
<methods>
</methods>
<members>
- <member name="constant" type="Transform3D" setter="set_constant" getter="get_constant" default="Transform3D( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )">
+ <member name="constant" type="Transform3D" setter="set_constant" getter="get_constant" default="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)">
A [Transform3D] constant which represents the state of this node.
</member>
</members>
diff --git a/doc/classes/VisualShaderNodeTransformUniform.xml b/doc/classes/VisualShaderNodeTransformUniform.xml
index 1f1cc4b630..2f7818ec8a 100644
--- a/doc/classes/VisualShaderNodeTransformUniform.xml
+++ b/doc/classes/VisualShaderNodeTransformUniform.xml
@@ -11,7 +11,7 @@
<methods>
</methods>
<members>
- <member name="default_value" type="Transform3D" setter="set_default_value" getter="get_default_value" default="Transform3D( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )">
+ <member name="default_value" type="Transform3D" setter="set_default_value" getter="get_default_value" default="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)">
A default value to be assigned within the shader.
</member>
<member name="default_value_enabled" type="bool" setter="set_default_value_enabled" getter="is_default_value_enabled" default="false">
diff --git a/doc/classes/VisualShaderNodeVec3Constant.xml b/doc/classes/VisualShaderNodeVec3Constant.xml
index b01bb514fe..28c3d22345 100644
--- a/doc/classes/VisualShaderNodeVec3Constant.xml
+++ b/doc/classes/VisualShaderNodeVec3Constant.xml
@@ -11,7 +11,7 @@
<methods>
</methods>
<members>
- <member name="constant" type="Vector3" setter="set_constant" getter="get_constant" default="Vector3( 0, 0, 0 )">
+ <member name="constant" type="Vector3" setter="set_constant" getter="get_constant" default="Vector3(0, 0, 0)">
A [Vector3] constant which represents the state of this node.
</member>
</members>
diff --git a/doc/classes/VisualShaderNodeVec3Uniform.xml b/doc/classes/VisualShaderNodeVec3Uniform.xml
index cd1500f5a1..215e2cfbea 100644
--- a/doc/classes/VisualShaderNodeVec3Uniform.xml
+++ b/doc/classes/VisualShaderNodeVec3Uniform.xml
@@ -11,7 +11,7 @@
<methods>
</methods>
<members>
- <member name="default_value" type="Vector3" setter="set_default_value" getter="get_default_value" default="Vector3( 0, 0, 0 )">
+ <member name="default_value" type="Vector3" setter="set_default_value" getter="get_default_value" default="Vector3(0, 0, 0)">
A default value to be assigned within the shader.
</member>
<member name="default_value_enabled" type="bool" setter="set_default_value_enabled" getter="is_default_value_enabled" default="false">
diff --git a/doc/classes/VoxelGI.xml b/doc/classes/VoxelGI.xml
index fa5035349e..5b395becb7 100644
--- a/doc/classes/VoxelGI.xml
+++ b/doc/classes/VoxelGI.xml
@@ -36,7 +36,7 @@
<member name="data" type="VoxelGIData" setter="set_probe_data" getter="get_probe_data">
The [VoxelGIData] resource that holds the data for this [VoxelGI].
</member>
- <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3( 10, 10, 10 )">
+ <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3(10, 10, 10)">
The size of the area covered by the [VoxelGI]. If you make the extents larger without increasing the subdivisions with [member subdiv], the size of each cell will increase and result in lower detailed lighting.
</member>
<member name="subdiv" type="int" setter="set_subdiv" getter="get_subdiv" enum="VoxelGI.Subdiv" default="1">
diff --git a/doc/classes/Window.xml b/doc/classes/Window.xml
index 9c320747d1..6ae5a5f449 100644
--- a/doc/classes/Window.xml
+++ b/doc/classes/Window.xml
@@ -218,7 +218,7 @@
<method name="popup">
<return type="void">
</return>
- <argument index="0" name="rect" type="Rect2i" default="Rect2i( 0, 0, 0, 0 )">
+ <argument index="0" name="rect" type="Rect2i" default="Rect2i(0, 0, 0, 0)">
</argument>
<description>
</description>
@@ -226,7 +226,7 @@
<method name="popup_centered">
<return type="void">
</return>
- <argument index="0" name="minsize" type="Vector2i" default="Vector2i( 0, 0 )">
+ <argument index="0" name="minsize" type="Vector2i" default="Vector2i(0, 0)">
</argument>
<description>
</description>
@@ -234,7 +234,7 @@
<method name="popup_centered_clamped">
<return type="void">
</return>
- <argument index="0" name="minsize" type="Vector2i" default="Vector2i( 0, 0 )">
+ <argument index="0" name="minsize" type="Vector2i" default="Vector2i(0, 0)">
</argument>
<argument index="1" name="fallback_ratio" type="float" default="0.75">
</argument>
@@ -322,21 +322,21 @@
</member>
<member name="content_scale_mode" type="int" setter="set_content_scale_mode" getter="get_content_scale_mode" enum="Window.ContentScaleMode" default="0">
</member>
- <member name="content_scale_size" type="Vector2i" setter="set_content_scale_size" getter="get_content_scale_size" default="Vector2i( 0, 0 )">
+ <member name="content_scale_size" type="Vector2i" setter="set_content_scale_size" getter="get_content_scale_size" default="Vector2i(0, 0)">
</member>
<member name="current_screen" type="int" setter="set_current_screen" getter="get_current_screen" default="0">
</member>
<member name="exclusive" type="bool" setter="set_exclusive" getter="is_exclusive" default="false">
</member>
- <member name="max_size" type="Vector2i" setter="set_max_size" getter="get_max_size" default="Vector2i( 0, 0 )">
+ <member name="max_size" type="Vector2i" setter="set_max_size" getter="get_max_size" default="Vector2i(0, 0)">
</member>
- <member name="min_size" type="Vector2i" setter="set_min_size" getter="get_min_size" default="Vector2i( 0, 0 )">
+ <member name="min_size" type="Vector2i" setter="set_min_size" getter="get_min_size" default="Vector2i(0, 0)">
</member>
<member name="mode" type="int" setter="set_mode" getter="get_mode" enum="Window.Mode" default="0">
</member>
- <member name="position" type="Vector2i" setter="set_position" getter="get_position" default="Vector2i( 0, 0 )">
+ <member name="position" type="Vector2i" setter="set_position" getter="get_position" default="Vector2i(0, 0)">
</member>
- <member name="size" type="Vector2i" setter="set_size" getter="get_size" default="Vector2i( 100, 100 )">
+ <member name="size" type="Vector2i" setter="set_size" getter="get_size" default="Vector2i(100, 100)">
</member>
<member name="theme" type="Theme" setter="set_theme" getter="get_theme">
</member>
@@ -472,7 +472,7 @@
</theme_item>
<theme_item name="scaleborder_size" type="int" default="4">
</theme_item>
- <theme_item name="title_color" type="Color" default="Color( 0, 0, 0, 1 )">
+ <theme_item name="title_color" type="Color" default="Color(0, 0, 0, 1)">
</theme_item>
<theme_item name="title_font" type="Font">
</theme_item>
@@ -481,7 +481,7 @@
</theme_item>
<theme_item name="title_height" type="int" default="20">
</theme_item>
- <theme_item name="title_outline_modulate" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="title_outline_modulate" type="Color" default="Color(1, 1, 1, 1)">
The color of the title outline.
</theme_item>
<theme_item name="title_outline_size" type="int" default="0">
diff --git a/doc/classes/WorldEnvironment.xml b/doc/classes/WorldEnvironment.xml
index c1cf639ec0..6aa2db00b4 100644
--- a/doc/classes/WorldEnvironment.xml
+++ b/doc/classes/WorldEnvironment.xml
@@ -5,7 +5,7 @@
</brief_description>
<description>
The [WorldEnvironment] node is used to configure the default [Environment] for the scene.
- The parameters defined in the [WorldEnvironment] can be overridden by an [Environment] node set on the current [Camera3D]. Additionally, only one [WorldEnvironment] may be instanced in a given scene at a time.
+ The parameters defined in the [WorldEnvironment] can be overridden by an [Environment] node set on the current [Camera3D]. Additionally, only one [WorldEnvironment] may be instantiated in a given scene at a time.
The [WorldEnvironment] allows the user to specify default lighting parameters (e.g. ambient lighting), various post-processing effects (e.g. SSAO, DOF, Tonemapping), and how to draw the background (e.g. solid color, skybox). Usually, these are added in order to improve the realism/color balance of the scene.
</description>
<tutorials>
diff --git a/doc/classes/WorldMarginShape3D.xml b/doc/classes/WorldMarginShape3D.xml
index a91447056b..9a26f254f1 100644
--- a/doc/classes/WorldMarginShape3D.xml
+++ b/doc/classes/WorldMarginShape3D.xml
@@ -11,7 +11,7 @@
<methods>
</methods>
<members>
- <member name="plane" type="Plane" setter="set_plane" getter="get_plane" default="Plane( 0, 1, 0, 0 )">
+ <member name="plane" type="Plane" setter="set_plane" getter="get_plane" default="Plane(0, 1, 0, 0)">
The [Plane] used by the [WorldMarginShape3D] for collision.
</member>
</members>
diff --git a/doc/classes/float.xml b/doc/classes/float.xml
index f75c130039..585c847d22 100644
--- a/doc/classes/float.xml
+++ b/doc/classes/float.xml
@@ -145,16 +145,6 @@
<method name="operator +" qualifiers="operator">
<return type="float">
</return>
- <description>
- Unary plus operator. Doesn't have any effect.
- [codeblock]
- var a = +2.5 # a is 2.5.
- [/codeblock]
- </description>
- </method>
- <method name="operator +" qualifiers="operator">
- <return type="float">
- </return>
<argument index="0" name="right" type="float">
</argument>
<description>
@@ -173,17 +163,6 @@
<method name="operator -" qualifiers="operator">
<return type="float">
</return>
- <description>
- Unary minus operator. Negates the number.
- [codeblock]
- var a = -2.5 # a is -2.5.
- print(-a) # 2.5
- [/codeblock]
- </description>
- </method>
- <method name="operator -" qualifiers="operator">
- <return type="float">
- </return>
<argument index="0" name="right" type="float">
</argument>
<description>
@@ -308,6 +287,18 @@
Returns [code]true[/code] if this [float] is greater than or equal to the given [int].
</description>
</method>
+ <method name="operator unary+" qualifiers="operator">
+ <return type="float">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="operator unary-" qualifiers="operator">
+ <return type="float">
+ </return>
+ <description>
+ </description>
+ </method>
</methods>
<constants>
</constants>
diff --git a/doc/classes/int.xml b/doc/classes/int.xml
index b0ad963998..95918c9007 100644
--- a/doc/classes/int.xml
+++ b/doc/classes/int.xml
@@ -126,21 +126,21 @@
</description>
</method>
<method name="operator *" qualifiers="operator">
- <return type="float">
+ <return type="int">
</return>
- <argument index="0" name="right" type="float">
+ <argument index="0" name="right" type="int">
</argument>
<description>
- Multiplies an [int] and a [float]. The result is a [float].
+ Multiplies two [int]s.
</description>
</method>
<method name="operator *" qualifiers="operator">
- <return type="int">
+ <return type="float">
</return>
- <argument index="0" name="right" type="int">
+ <argument index="0" name="right" type="float">
</argument>
<description>
- Multiplies two [int]s.
+ Multiplies an [int] and a [float]. The result is a [float].
</description>
</method>
<method name="operator *" qualifiers="operator">
@@ -204,16 +204,6 @@
</description>
</method>
<method name="operator +" qualifiers="operator">
- <return type="int">
- </return>
- <description>
- Unary plus operator. Doesn't have any effect.
- [codeblock]
- var a = +1 # a is 1.
- [/codeblock]
- </description>
- </method>
- <method name="operator +" qualifiers="operator">
<return type="float">
</return>
<argument index="0" name="right" type="float">
@@ -232,17 +222,6 @@
</description>
</method>
<method name="operator -" qualifiers="operator">
- <return type="int">
- </return>
- <description>
- Unary minus operator. Negates the number.
- [codeblock]
- var a = -1 # a is -1.
- print(-a) # 1
- [/codeblock]
- </description>
- </method>
- <method name="operator -" qualifiers="operator">
<return type="float">
</return>
<argument index="0" name="right" type="float">
@@ -414,6 +393,18 @@
[/codeblock]
</description>
</method>
+ <method name="operator unary+" qualifiers="operator">
+ <return type="int">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="operator unary-" qualifiers="operator">
+ <return type="int">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="operator |" qualifiers="operator">
<return type="int">
</return>
diff --git a/doc/translations/ar.po b/doc/translations/ar.po
index 77a3d39f27..4199bca6c7 100644
--- a/doc/translations/ar.po
+++ b/doc/translations/ar.po
@@ -701,7 +701,7 @@ msgid ""
"the FileSystem dock into the script.\n"
"[codeblock]\n"
"# Instance a scene.\n"
-"var diamond = preload(\"res://diamond.tscn\").instance()\n"
+"var diamond = preload(\"res://diamond.tscn\").instantiate()\n"
"[/codeblock]"
msgstr ""
@@ -13825,7 +13825,7 @@ msgid ""
"Example of usage with custom scene instance:\n"
"[codeblock]\n"
"func _make_custom_tooltip(for_text):\n"
-" var tooltip = preload(\"SomeTooltipScene.tscn\").instance()\n"
+" var tooltip = preload(\"SomeTooltipScene.tscn\").instantiate()\n"
" tooltip.get_node(\"Label\").text = for_text\n"
" return tooltip\n"
"[/codeblock]"
@@ -34691,7 +34691,7 @@ msgid ""
"[codeblock]\n"
"# Use `load()` instead of `preload()` if the path isn't known at compile-"
"time.\n"
-"var scene = preload(\"res://scene.tscn\").instance()\n"
+"var scene = preload(\"res://scene.tscn\").instantiate()\n"
"# Add the node as a child of the node the script is attached to.\n"
"add_child(scene)\n"
"[/codeblock]\n"
diff --git a/doc/translations/ca.po b/doc/translations/ca.po
index 8ea801181d..c72cba18bc 100644
--- a/doc/translations/ca.po
+++ b/doc/translations/ca.po
@@ -732,7 +732,7 @@ msgid ""
"the FileSystem dock into the script.\n"
"[codeblock]\n"
"# Instance a scene.\n"
-"var diamond = preload(\"res://diamond.tscn\").instance()\n"
+"var diamond = preload(\"res://diamond.tscn\").instantiate()\n"
"[/codeblock]"
msgstr ""
@@ -13856,7 +13856,7 @@ msgid ""
"Example of usage with custom scene instance:\n"
"[codeblock]\n"
"func _make_custom_tooltip(for_text):\n"
-" var tooltip = preload(\"SomeTooltipScene.tscn\").instance()\n"
+" var tooltip = preload(\"SomeTooltipScene.tscn\").instantiate()\n"
" tooltip.get_node(\"Label\").text = for_text\n"
" return tooltip\n"
"[/codeblock]"
@@ -34722,7 +34722,7 @@ msgid ""
"[codeblock]\n"
"# Use `load()` instead of `preload()` if the path isn't known at compile-"
"time.\n"
-"var scene = preload(\"res://scene.tscn\").instance()\n"
+"var scene = preload(\"res://scene.tscn\").instantiate()\n"
"# Add the node as a child of the node the script is attached to.\n"
"add_child(scene)\n"
"[/codeblock]\n"
diff --git a/doc/translations/classes.pot b/doc/translations/classes.pot
index f138276364..321e67f759 100644
--- a/doc/translations/classes.pot
+++ b/doc/translations/classes.pot
@@ -702,7 +702,7 @@ msgid ""
"the FileSystem dock into the script.\n"
"[codeblock]\n"
"# Instance a scene.\n"
-"var diamond = preload(\"res://diamond.tscn\").instance()\n"
+"var diamond = preload(\"res://diamond.tscn\").instantiate()\n"
"[/codeblock]"
msgstr ""
@@ -13826,7 +13826,7 @@ msgid ""
"Example of usage with custom scene instance:\n"
"[codeblock]\n"
"func _make_custom_tooltip(for_text):\n"
-" var tooltip = preload(\"SomeTooltipScene.tscn\").instance()\n"
+" var tooltip = preload(\"SomeTooltipScene.tscn\").instantiate()\n"
" tooltip.get_node(\"Label\").text = for_text\n"
" return tooltip\n"
"[/codeblock]"
@@ -34692,7 +34692,7 @@ msgid ""
"[codeblock]\n"
"# Use `load()` instead of `preload()` if the path isn't known at compile-"
"time.\n"
-"var scene = preload(\"res://scene.tscn\").instance()\n"
+"var scene = preload(\"res://scene.tscn\").instantiate()\n"
"# Add the node as a child of the node the script is attached to.\n"
"add_child(scene)\n"
"[/codeblock]\n"
diff --git a/doc/translations/cs.po b/doc/translations/cs.po
index a267656497..3584fc5062 100644
--- a/doc/translations/cs.po
+++ b/doc/translations/cs.po
@@ -1058,7 +1058,7 @@ msgid ""
"the FileSystem dock into the script.\n"
"[codeblock]\n"
"# Instance a scene.\n"
-"var diamond = preload(\"res://diamond.tscn\").instance()\n"
+"var diamond = preload(\"res://diamond.tscn\").instantiate()\n"
"[/codeblock]"
msgstr ""
@@ -14318,7 +14318,7 @@ msgid ""
"Example of usage with custom scene instance:\n"
"[codeblock]\n"
"func _make_custom_tooltip(for_text):\n"
-" var tooltip = preload(\"SomeTooltipScene.tscn\").instance()\n"
+" var tooltip = preload(\"SomeTooltipScene.tscn\").instantiate()\n"
" tooltip.get_node(\"Label\").text = for_text\n"
" return tooltip\n"
"[/codeblock]"
@@ -35192,7 +35192,7 @@ msgid ""
"[codeblock]\n"
"# Use `load()` instead of `preload()` if the path isn't known at compile-"
"time.\n"
-"var scene = preload(\"res://scene.tscn\").instance()\n"
+"var scene = preload(\"res://scene.tscn\").instantiate()\n"
"# Add the node as a child of the node the script is attached to.\n"
"add_child(scene)\n"
"[/codeblock]\n"
diff --git a/doc/translations/de.po b/doc/translations/de.po
index 181d64d525..76eff809ff 100644
--- a/doc/translations/de.po
+++ b/doc/translations/de.po
@@ -992,7 +992,7 @@ msgid ""
"the FileSystem dock into the script.\n"
"[codeblock]\n"
"# Instance a scene.\n"
-"var diamond = preload(\"res://diamond.tscn\").instance()\n"
+"var diamond = preload(\"res://diamond.tscn\").instantiate()\n"
"[/codeblock]"
msgstr ""
@@ -14154,7 +14154,7 @@ msgid ""
"Example of usage with custom scene instance:\n"
"[codeblock]\n"
"func _make_custom_tooltip(for_text):\n"
-" var tooltip = preload(\"SomeTooltipScene.tscn\").instance()\n"
+" var tooltip = preload(\"SomeTooltipScene.tscn\").instantiate()\n"
" tooltip.get_node(\"Label\").text = for_text\n"
" return tooltip\n"
"[/codeblock]"
@@ -35118,7 +35118,7 @@ msgid ""
"[codeblock]\n"
"# Use `load()` instead of `preload()` if the path isn't known at compile-"
"time.\n"
-"var scene = preload(\"res://scene.tscn\").instance()\n"
+"var scene = preload(\"res://scene.tscn\").instantiate()\n"
"# Add the node as a child of the node the script is attached to.\n"
"add_child(scene)\n"
"[/codeblock]\n"
diff --git a/doc/translations/es.po b/doc/translations/es.po
index 7df36316b7..44b3b22597 100644
--- a/doc/translations/es.po
+++ b/doc/translations/es.po
@@ -1119,7 +1119,7 @@ msgid ""
"the FileSystem dock into the script.\n"
"[codeblock]\n"
"# Instance a scene.\n"
-"var diamond = preload(\"res://diamond.tscn\").instance()\n"
+"var diamond = preload(\"res://diamond.tscn\").instantiate()\n"
"[/codeblock]"
msgstr ""
@@ -18123,7 +18123,7 @@ msgid ""
"Example of usage with custom scene instance:\n"
"[codeblock]\n"
"func _make_custom_tooltip(for_text):\n"
-" var tooltip = preload(\"SomeTooltipScene.tscn\").instance()\n"
+" var tooltip = preload(\"SomeTooltipScene.tscn\").instantiate()\n"
" tooltip.get_node(\"Label\").text = for_text\n"
" return tooltip\n"
"[/codeblock]"
@@ -18150,7 +18150,7 @@ msgstr ""
"Ejemplo de uso con una instancia de una escena personalizada<\n"
"[codeblock]\n"
"func _make_custom_tooltip(for_text):\n"
-" var sugerencia = preload(\"algunaEscenaSugerencia.tscn\").instance()\n"
+" var sugerencia = preload(\"algunaEscenaSugerencia.tscn\").instantiate()\n"
" tooltip.get_node(\"etiqueta\").text = para_texto\n"
" return sugerencia\n"
"[/codeblock]"
@@ -46659,7 +46659,7 @@ msgid ""
"[codeblock]\n"
"# Use `load()` instead of `preload()` if the path isn't known at compile-"
"time.\n"
-"var scene = preload(\"res://scene.tscn\").instance()\n"
+"var scene = preload(\"res://scene.tscn\").instantiate()\n"
"# Add the node as a child of the node the script is attached to.\n"
"add_child(scene)\n"
"[/codeblock]\n"
diff --git a/doc/translations/fa.po b/doc/translations/fa.po
index e440146dd3..2a185fadc5 100644
--- a/doc/translations/fa.po
+++ b/doc/translations/fa.po
@@ -707,7 +707,7 @@ msgid ""
"the FileSystem dock into the script.\n"
"[codeblock]\n"
"# Instance a scene.\n"
-"var diamond = preload(\"res://diamond.tscn\").instance()\n"
+"var diamond = preload(\"res://diamond.tscn\").instantiate()\n"
"[/codeblock]"
msgstr ""
@@ -13831,7 +13831,7 @@ msgid ""
"Example of usage with custom scene instance:\n"
"[codeblock]\n"
"func _make_custom_tooltip(for_text):\n"
-" var tooltip = preload(\"SomeTooltipScene.tscn\").instance()\n"
+" var tooltip = preload(\"SomeTooltipScene.tscn\").instantiate()\n"
" tooltip.get_node(\"Label\").text = for_text\n"
" return tooltip\n"
"[/codeblock]"
@@ -34697,7 +34697,7 @@ msgid ""
"[codeblock]\n"
"# Use `load()` instead of `preload()` if the path isn't known at compile-"
"time.\n"
-"var scene = preload(\"res://scene.tscn\").instance()\n"
+"var scene = preload(\"res://scene.tscn\").instantiate()\n"
"# Add the node as a child of the node the script is attached to.\n"
"add_child(scene)\n"
"[/codeblock]\n"
diff --git a/doc/translations/fi.po b/doc/translations/fi.po
index 92ec4f29dd..a5f470c60b 100644
--- a/doc/translations/fi.po
+++ b/doc/translations/fi.po
@@ -720,7 +720,7 @@ msgid ""
"the FileSystem dock into the script.\n"
"[codeblock]\n"
"# Instance a scene.\n"
-"var diamond = preload(\"res://diamond.tscn\").instance()\n"
+"var diamond = preload(\"res://diamond.tscn\").instantiate()\n"
"[/codeblock]"
msgstr ""
@@ -13844,7 +13844,7 @@ msgid ""
"Example of usage with custom scene instance:\n"
"[codeblock]\n"
"func _make_custom_tooltip(for_text):\n"
-" var tooltip = preload(\"SomeTooltipScene.tscn\").instance()\n"
+" var tooltip = preload(\"SomeTooltipScene.tscn\").instantiate()\n"
" tooltip.get_node(\"Label\").text = for_text\n"
" return tooltip\n"
"[/codeblock]"
@@ -34710,7 +34710,7 @@ msgid ""
"[codeblock]\n"
"# Use `load()` instead of `preload()` if the path isn't known at compile-"
"time.\n"
-"var scene = preload(\"res://scene.tscn\").instance()\n"
+"var scene = preload(\"res://scene.tscn\").instantiate()\n"
"# Add the node as a child of the node the script is attached to.\n"
"add_child(scene)\n"
"[/codeblock]\n"
diff --git a/doc/translations/fr.po b/doc/translations/fr.po
index 7717474c0f..2d9b1db565 100644
--- a/doc/translations/fr.po
+++ b/doc/translations/fr.po
@@ -1017,7 +1017,7 @@ msgid ""
"the FileSystem dock into the script.\n"
"[codeblock]\n"
"# Instance a scene.\n"
-"var diamond = preload(\"res://diamond.tscn\").instance()\n"
+"var diamond = preload(\"res://diamond.tscn\").instantiate()\n"
"[/codeblock]"
msgstr ""
@@ -14162,7 +14162,7 @@ msgid ""
"Example of usage with custom scene instance:\n"
"[codeblock]\n"
"func _make_custom_tooltip(for_text):\n"
-" var tooltip = preload(\"SomeTooltipScene.tscn\").instance()\n"
+" var tooltip = preload(\"SomeTooltipScene.tscn\").instantiate()\n"
" tooltip.get_node(\"Label\").text = for_text\n"
" return tooltip\n"
"[/codeblock]"
@@ -35061,7 +35061,7 @@ msgid ""
"[codeblock]\n"
"# Use `load()` instead of `preload()` if the path isn't known at compile-"
"time.\n"
-"var scene = preload(\"res://scene.tscn\").instance()\n"
+"var scene = preload(\"res://scene.tscn\").instantiate()\n"
"# Add the node as a child of the node the script is attached to.\n"
"add_child(scene)\n"
"[/codeblock]\n"
diff --git a/doc/translations/id.po b/doc/translations/id.po
index edfd392f4f..cd841fc553 100644
--- a/doc/translations/id.po
+++ b/doc/translations/id.po
@@ -733,7 +733,7 @@ msgid ""
"the FileSystem dock into the script.\n"
"[codeblock]\n"
"# Instance a scene.\n"
-"var diamond = preload(\"res://diamond.tscn\").instance()\n"
+"var diamond = preload(\"res://diamond.tscn\").instantiate()\n"
"[/codeblock]"
msgstr ""
@@ -13857,7 +13857,7 @@ msgid ""
"Example of usage with custom scene instance:\n"
"[codeblock]\n"
"func _make_custom_tooltip(for_text):\n"
-" var tooltip = preload(\"SomeTooltipScene.tscn\").instance()\n"
+" var tooltip = preload(\"SomeTooltipScene.tscn\").instantiate()\n"
" tooltip.get_node(\"Label\").text = for_text\n"
" return tooltip\n"
"[/codeblock]"
@@ -34723,7 +34723,7 @@ msgid ""
"[codeblock]\n"
"# Use `load()` instead of `preload()` if the path isn't known at compile-"
"time.\n"
-"var scene = preload(\"res://scene.tscn\").instance()\n"
+"var scene = preload(\"res://scene.tscn\").instantiate()\n"
"# Add the node as a child of the node the script is attached to.\n"
"add_child(scene)\n"
"[/codeblock]\n"
diff --git a/doc/translations/it.po b/doc/translations/it.po
index 353eae4116..aa085f6158 100644
--- a/doc/translations/it.po
+++ b/doc/translations/it.po
@@ -985,7 +985,7 @@ msgid ""
"the FileSystem dock into the script.\n"
"[codeblock]\n"
"# Instance a scene.\n"
-"var diamond = preload(\"res://diamond.tscn\").instance()\n"
+"var diamond = preload(\"res://diamond.tscn\").instantiate()\n"
"[/codeblock]"
msgstr ""
@@ -14115,7 +14115,7 @@ msgid ""
"Example of usage with custom scene instance:\n"
"[codeblock]\n"
"func _make_custom_tooltip(for_text):\n"
-" var tooltip = preload(\"SomeTooltipScene.tscn\").instance()\n"
+" var tooltip = preload(\"SomeTooltipScene.tscn\").instantiate()\n"
" tooltip.get_node(\"Label\").text = for_text\n"
" return tooltip\n"
"[/codeblock]"
@@ -34990,7 +34990,7 @@ msgid ""
"[codeblock]\n"
"# Use `load()` instead of `preload()` if the path isn't known at compile-"
"time.\n"
-"var scene = preload(\"res://scene.tscn\").instance()\n"
+"var scene = preload(\"res://scene.tscn\").instantiate()\n"
"# Add the node as a child of the node the script is attached to.\n"
"add_child(scene)\n"
"[/codeblock]\n"
diff --git a/doc/translations/ja.po b/doc/translations/ja.po
index 1424b24153..ee900d58c2 100644
--- a/doc/translations/ja.po
+++ b/doc/translations/ja.po
@@ -1091,7 +1091,7 @@ msgid ""
"the FileSystem dock into the script.\n"
"[codeblock]\n"
"# Instance a scene.\n"
-"var diamond = preload(\"res://diamond.tscn\").instance()\n"
+"var diamond = preload(\"res://diamond.tscn\").instantiate()\n"
"[/codeblock]"
msgstr ""
@@ -15045,7 +15045,7 @@ msgid ""
"Example of usage with custom scene instance:\n"
"[codeblock]\n"
"func _make_custom_tooltip(for_text):\n"
-" var tooltip = preload(\"SomeTooltipScene.tscn\").instance()\n"
+" var tooltip = preload(\"SomeTooltipScene.tscn\").instantiate()\n"
" tooltip.get_node(\"Label\").text = for_text\n"
" return tooltip\n"
"[/codeblock]"
@@ -35964,7 +35964,7 @@ msgid ""
"[codeblock]\n"
"# Use `load()` instead of `preload()` if the path isn't known at compile-"
"time.\n"
-"var scene = preload(\"res://scene.tscn\").instance()\n"
+"var scene = preload(\"res://scene.tscn\").instantiate()\n"
"# Add the node as a child of the node the script is attached to.\n"
"add_child(scene)\n"
"[/codeblock]\n"
diff --git a/doc/translations/ko.po b/doc/translations/ko.po
index 8e8aef2eaf..60416fb63c 100644
--- a/doc/translations/ko.po
+++ b/doc/translations/ko.po
@@ -709,7 +709,7 @@ msgid ""
"the FileSystem dock into the script.\n"
"[codeblock]\n"
"# Instance a scene.\n"
-"var diamond = preload(\"res://diamond.tscn\").instance()\n"
+"var diamond = preload(\"res://diamond.tscn\").instantiate()\n"
"[/codeblock]"
msgstr ""
@@ -13833,7 +13833,7 @@ msgid ""
"Example of usage with custom scene instance:\n"
"[codeblock]\n"
"func _make_custom_tooltip(for_text):\n"
-" var tooltip = preload(\"SomeTooltipScene.tscn\").instance()\n"
+" var tooltip = preload(\"SomeTooltipScene.tscn\").instantiate()\n"
" tooltip.get_node(\"Label\").text = for_text\n"
" return tooltip\n"
"[/codeblock]"
@@ -34699,7 +34699,7 @@ msgid ""
"[codeblock]\n"
"# Use `load()` instead of `preload()` if the path isn't known at compile-"
"time.\n"
-"var scene = preload(\"res://scene.tscn\").instance()\n"
+"var scene = preload(\"res://scene.tscn\").instantiate()\n"
"# Add the node as a child of the node the script is attached to.\n"
"add_child(scene)\n"
"[/codeblock]\n"
diff --git a/doc/translations/nl.po b/doc/translations/nl.po
index 096e59f497..c0dc01c653 100644
--- a/doc/translations/nl.po
+++ b/doc/translations/nl.po
@@ -735,7 +735,7 @@ msgid ""
"the FileSystem dock into the script.\n"
"[codeblock]\n"
"# Instance a scene.\n"
-"var diamond = preload(\"res://diamond.tscn\").instance()\n"
+"var diamond = preload(\"res://diamond.tscn\").instantiate()\n"
"[/codeblock]"
msgstr ""
@@ -13859,7 +13859,7 @@ msgid ""
"Example of usage with custom scene instance:\n"
"[codeblock]\n"
"func _make_custom_tooltip(for_text):\n"
-" var tooltip = preload(\"SomeTooltipScene.tscn\").instance()\n"
+" var tooltip = preload(\"SomeTooltipScene.tscn\").instantiate()\n"
" tooltip.get_node(\"Label\").text = for_text\n"
" return tooltip\n"
"[/codeblock]"
@@ -34725,7 +34725,7 @@ msgid ""
"[codeblock]\n"
"# Use `load()` instead of `preload()` if the path isn't known at compile-"
"time.\n"
-"var scene = preload(\"res://scene.tscn\").instance()\n"
+"var scene = preload(\"res://scene.tscn\").instantiate()\n"
"# Add the node as a child of the node the script is attached to.\n"
"add_child(scene)\n"
"[/codeblock]\n"
diff --git a/doc/translations/pl.po b/doc/translations/pl.po
index 5ef41b155a..2664f263cb 100644
--- a/doc/translations/pl.po
+++ b/doc/translations/pl.po
@@ -737,7 +737,7 @@ msgid ""
"the FileSystem dock into the script.\n"
"[codeblock]\n"
"# Instance a scene.\n"
-"var diamond = preload(\"res://diamond.tscn\").instance()\n"
+"var diamond = preload(\"res://diamond.tscn\").instantiate()\n"
"[/codeblock]"
msgstr ""
@@ -13877,7 +13877,7 @@ msgid ""
"Example of usage with custom scene instance:\n"
"[codeblock]\n"
"func _make_custom_tooltip(for_text):\n"
-" var tooltip = preload(\"SomeTooltipScene.tscn\").instance()\n"
+" var tooltip = preload(\"SomeTooltipScene.tscn\").instantiate()\n"
" tooltip.get_node(\"Label\").text = for_text\n"
" return tooltip\n"
"[/codeblock]"
@@ -34744,7 +34744,7 @@ msgid ""
"[codeblock]\n"
"# Use `load()` instead of `preload()` if the path isn't known at compile-"
"time.\n"
-"var scene = preload(\"res://scene.tscn\").instance()\n"
+"var scene = preload(\"res://scene.tscn\").instantiate()\n"
"# Add the node as a child of the node the script is attached to.\n"
"add_child(scene)\n"
"[/codeblock]\n"
diff --git a/doc/translations/pt_BR.po b/doc/translations/pt_BR.po
index ef62950d51..f86bed9585 100644
--- a/doc/translations/pt_BR.po
+++ b/doc/translations/pt_BR.po
@@ -748,7 +748,7 @@ msgid ""
"the FileSystem dock into the script.\n"
"[codeblock]\n"
"# Instance a scene.\n"
-"var diamond = preload(\"res://diamond.tscn\").instance()\n"
+"var diamond = preload(\"res://diamond.tscn\").instantiate()\n"
"[/codeblock]"
msgstr ""
@@ -13872,7 +13872,7 @@ msgid ""
"Example of usage with custom scene instance:\n"
"[codeblock]\n"
"func _make_custom_tooltip(for_text):\n"
-" var tooltip = preload(\"SomeTooltipScene.tscn\").instance()\n"
+" var tooltip = preload(\"SomeTooltipScene.tscn\").instantiate()\n"
" tooltip.get_node(\"Label\").text = for_text\n"
" return tooltip\n"
"[/codeblock]"
@@ -34738,7 +34738,7 @@ msgid ""
"[codeblock]\n"
"# Use `load()` instead of `preload()` if the path isn't known at compile-"
"time.\n"
-"var scene = preload(\"res://scene.tscn\").instance()\n"
+"var scene = preload(\"res://scene.tscn\").instantiate()\n"
"# Add the node as a child of the node the script is attached to.\n"
"add_child(scene)\n"
"[/codeblock]\n"
diff --git a/doc/translations/ro.po b/doc/translations/ro.po
index 5f018aa497..b25c3911cc 100644
--- a/doc/translations/ro.po
+++ b/doc/translations/ro.po
@@ -709,7 +709,7 @@ msgid ""
"the FileSystem dock into the script.\n"
"[codeblock]\n"
"# Instance a scene.\n"
-"var diamond = preload(\"res://diamond.tscn\").instance()\n"
+"var diamond = preload(\"res://diamond.tscn\").instantiate()\n"
"[/codeblock]"
msgstr ""
@@ -13833,7 +13833,7 @@ msgid ""
"Example of usage with custom scene instance:\n"
"[codeblock]\n"
"func _make_custom_tooltip(for_text):\n"
-" var tooltip = preload(\"SomeTooltipScene.tscn\").instance()\n"
+" var tooltip = preload(\"SomeTooltipScene.tscn\").instantiate()\n"
" tooltip.get_node(\"Label\").text = for_text\n"
" return tooltip\n"
"[/codeblock]"
@@ -34699,7 +34699,7 @@ msgid ""
"[codeblock]\n"
"# Use `load()` instead of `preload()` if the path isn't known at compile-"
"time.\n"
-"var scene = preload(\"res://scene.tscn\").instance()\n"
+"var scene = preload(\"res://scene.tscn\").instantiate()\n"
"# Add the node as a child of the node the script is attached to.\n"
"add_child(scene)\n"
"[/codeblock]\n"
diff --git a/doc/translations/ru.po b/doc/translations/ru.po
index 0d227beff7..cf5289d7f9 100644
--- a/doc/translations/ru.po
+++ b/doc/translations/ru.po
@@ -1072,7 +1072,7 @@ msgid ""
"the FileSystem dock into the script.\n"
"[codeblock]\n"
"# Instance a scene.\n"
-"var diamond = preload(\"res://diamond.tscn\").instance()\n"
+"var diamond = preload(\"res://diamond.tscn\").instantiate()\n"
"[/codeblock]"
msgstr ""
@@ -14338,7 +14338,7 @@ msgid ""
"Example of usage with custom scene instance:\n"
"[codeblock]\n"
"func _make_custom_tooltip(for_text):\n"
-" var tooltip = preload(\"SomeTooltipScene.tscn\").instance()\n"
+" var tooltip = preload(\"SomeTooltipScene.tscn\").instantiate()\n"
" tooltip.get_node(\"Label\").text = for_text\n"
" return tooltip\n"
"[/codeblock]"
@@ -35238,7 +35238,7 @@ msgid ""
"[codeblock]\n"
"# Use `load()` instead of `preload()` if the path isn't known at compile-"
"time.\n"
-"var scene = preload(\"res://scene.tscn\").instance()\n"
+"var scene = preload(\"res://scene.tscn\").instantiate()\n"
"# Add the node as a child of the node the script is attached to.\n"
"add_child(scene)\n"
"[/codeblock]\n"
diff --git a/doc/translations/sr_Cyrl.po b/doc/translations/sr_Cyrl.po
index d53711d996..06399d5e87 100644
--- a/doc/translations/sr_Cyrl.po
+++ b/doc/translations/sr_Cyrl.po
@@ -719,7 +719,7 @@ msgid ""
"the FileSystem dock into the script.\n"
"[codeblock]\n"
"# Instance a scene.\n"
-"var diamond = preload(\"res://diamond.tscn\").instance()\n"
+"var diamond = preload(\"res://diamond.tscn\").instantiate()\n"
"[/codeblock]"
msgstr ""
@@ -13843,7 +13843,7 @@ msgid ""
"Example of usage with custom scene instance:\n"
"[codeblock]\n"
"func _make_custom_tooltip(for_text):\n"
-" var tooltip = preload(\"SomeTooltipScene.tscn\").instance()\n"
+" var tooltip = preload(\"SomeTooltipScene.tscn\").instantiate()\n"
" tooltip.get_node(\"Label\").text = for_text\n"
" return tooltip\n"
"[/codeblock]"
@@ -34709,7 +34709,7 @@ msgid ""
"[codeblock]\n"
"# Use `load()` instead of `preload()` if the path isn't known at compile-"
"time.\n"
-"var scene = preload(\"res://scene.tscn\").instance()\n"
+"var scene = preload(\"res://scene.tscn\").instantiate()\n"
"# Add the node as a child of the node the script is attached to.\n"
"add_child(scene)\n"
"[/codeblock]\n"
diff --git a/doc/translations/th.po b/doc/translations/th.po
index 7686e22f19..cdf1c6d7e2 100644
--- a/doc/translations/th.po
+++ b/doc/translations/th.po
@@ -725,7 +725,7 @@ msgid ""
"the FileSystem dock into the script.\n"
"[codeblock]\n"
"# Instance a scene.\n"
-"var diamond = preload(\"res://diamond.tscn\").instance()\n"
+"var diamond = preload(\"res://diamond.tscn\").instantiate()\n"
"[/codeblock]"
msgstr ""
@@ -13849,7 +13849,7 @@ msgid ""
"Example of usage with custom scene instance:\n"
"[codeblock]\n"
"func _make_custom_tooltip(for_text):\n"
-" var tooltip = preload(\"SomeTooltipScene.tscn\").instance()\n"
+" var tooltip = preload(\"SomeTooltipScene.tscn\").instantiate()\n"
" tooltip.get_node(\"Label\").text = for_text\n"
" return tooltip\n"
"[/codeblock]"
@@ -34715,7 +34715,7 @@ msgid ""
"[codeblock]\n"
"# Use `load()` instead of `preload()` if the path isn't known at compile-"
"time.\n"
-"var scene = preload(\"res://scene.tscn\").instance()\n"
+"var scene = preload(\"res://scene.tscn\").instantiate()\n"
"# Add the node as a child of the node the script is attached to.\n"
"add_child(scene)\n"
"[/codeblock]\n"
diff --git a/doc/translations/tr.po b/doc/translations/tr.po
index df9897f1d6..646a3fb5b3 100644
--- a/doc/translations/tr.po
+++ b/doc/translations/tr.po
@@ -701,7 +701,7 @@ msgid ""
"the FileSystem dock into the script.\n"
"[codeblock]\n"
"# Instance a scene.\n"
-"var diamond = preload(\"res://diamond.tscn\").instance()\n"
+"var diamond = preload(\"res://diamond.tscn\").instantiate()\n"
"[/codeblock]"
msgstr ""
@@ -13825,7 +13825,7 @@ msgid ""
"Example of usage with custom scene instance:\n"
"[codeblock]\n"
"func _make_custom_tooltip(for_text):\n"
-" var tooltip = preload(\"SomeTooltipScene.tscn\").instance()\n"
+" var tooltip = preload(\"SomeTooltipScene.tscn\").instantiate()\n"
" tooltip.get_node(\"Label\").text = for_text\n"
" return tooltip\n"
"[/codeblock]"
@@ -34691,7 +34691,7 @@ msgid ""
"[codeblock]\n"
"# Use `load()` instead of `preload()` if the path isn't known at compile-"
"time.\n"
-"var scene = preload(\"res://scene.tscn\").instance()\n"
+"var scene = preload(\"res://scene.tscn\").instantiate()\n"
"# Add the node as a child of the node the script is attached to.\n"
"add_child(scene)\n"
"[/codeblock]\n"
diff --git a/doc/translations/uk.po b/doc/translations/uk.po
index d1296da87a..c2232d81ab 100644
--- a/doc/translations/uk.po
+++ b/doc/translations/uk.po
@@ -787,7 +787,7 @@ msgid ""
"the FileSystem dock into the script.\n"
"[codeblock]\n"
"# Instance a scene.\n"
-"var diamond = preload(\"res://diamond.tscn\").instance()\n"
+"var diamond = preload(\"res://diamond.tscn\").instantiate()\n"
"[/codeblock]"
msgstr ""
@@ -13911,7 +13911,7 @@ msgid ""
"Example of usage with custom scene instance:\n"
"[codeblock]\n"
"func _make_custom_tooltip(for_text):\n"
-" var tooltip = preload(\"SomeTooltipScene.tscn\").instance()\n"
+" var tooltip = preload(\"SomeTooltipScene.tscn\").instantiate()\n"
" tooltip.get_node(\"Label\").text = for_text\n"
" return tooltip\n"
"[/codeblock]"
@@ -34777,7 +34777,7 @@ msgid ""
"[codeblock]\n"
"# Use `load()` instead of `preload()` if the path isn't known at compile-"
"time.\n"
-"var scene = preload(\"res://scene.tscn\").instance()\n"
+"var scene = preload(\"res://scene.tscn\").instantiate()\n"
"# Add the node as a child of the node the script is attached to.\n"
"add_child(scene)\n"
"[/codeblock]\n"
diff --git a/doc/translations/zh_Hans.po b/doc/translations/zh_Hans.po
index edfb11dec1..40d1eb68bc 100644
--- a/doc/translations/zh_Hans.po
+++ b/doc/translations/zh_Hans.po
@@ -934,7 +934,7 @@ msgid ""
"the FileSystem dock into the script.\n"
"[codeblock]\n"
"# Instance a scene.\n"
-"var diamond = preload(\"res://diamond.tscn\").instance()\n"
+"var diamond = preload(\"res://diamond.tscn\").instantiate()\n"
"[/codeblock]"
msgstr ""
@@ -14058,7 +14058,7 @@ msgid ""
"Example of usage with custom scene instance:\n"
"[codeblock]\n"
"func _make_custom_tooltip(for_text):\n"
-" var tooltip = preload(\"SomeTooltipScene.tscn\").instance()\n"
+" var tooltip = preload(\"SomeTooltipScene.tscn\").instantiate()\n"
" tooltip.get_node(\"Label\").text = for_text\n"
" return tooltip\n"
"[/codeblock]"
@@ -34928,7 +34928,7 @@ msgid ""
"[codeblock]\n"
"# Use `load()` instead of `preload()` if the path isn't known at compile-"
"time.\n"
-"var scene = preload(\"res://scene.tscn\").instance()\n"
+"var scene = preload(\"res://scene.tscn\").instantiate()\n"
"# Add the node as a child of the node the script is attached to.\n"
"add_child(scene)\n"
"[/codeblock]\n"
diff --git a/doc/translations/zh_Hant.po b/doc/translations/zh_Hant.po
index 3afec7ead8..13515dff67 100644
--- a/doc/translations/zh_Hant.po
+++ b/doc/translations/zh_Hant.po
@@ -738,7 +738,7 @@ msgid ""
"the FileSystem dock into the script.\n"
"[codeblock]\n"
"# Instance a scene.\n"
-"var diamond = preload(\"res://diamond.tscn\").instance()\n"
+"var diamond = preload(\"res://diamond.tscn\").instantiate()\n"
"[/codeblock]"
msgstr ""
@@ -13862,7 +13862,7 @@ msgid ""
"Example of usage with custom scene instance:\n"
"[codeblock]\n"
"func _make_custom_tooltip(for_text):\n"
-" var tooltip = preload(\"SomeTooltipScene.tscn\").instance()\n"
+" var tooltip = preload(\"SomeTooltipScene.tscn\").instantiate()\n"
" tooltip.get_node(\"Label\").text = for_text\n"
" return tooltip\n"
"[/codeblock]"
@@ -34728,7 +34728,7 @@ msgid ""
"[codeblock]\n"
"# Use `load()` instead of `preload()` if the path isn't known at compile-"
"time.\n"
-"var scene = preload(\"res://scene.tscn\").instance()\n"
+"var scene = preload(\"res://scene.tscn\").instantiate()\n"
"# Add the node as a child of the node the script is attached to.\n"
"add_child(scene)\n"
"[/codeblock]\n"
diff --git a/drivers/png/image_loader_png.cpp b/drivers/png/image_loader_png.cpp
index 8cc76b01e1..f7f7f2dd22 100644
--- a/drivers/png/image_loader_png.cpp
+++ b/drivers/png/image_loader_png.cpp
@@ -59,7 +59,7 @@ void ImageLoaderPNG::get_recognized_extensions(List<String> *p_extensions) const
Ref<Image> ImageLoaderPNG::load_mem_png(const uint8_t *p_png, int p_size) {
Ref<Image> img;
- img.instance();
+ img.instantiate();
// the value of p_force_linear does not matter since it only applies to 16 bit
Error err = PNGDriverCommon::png_to_image(p_png, p_size, false, img);
diff --git a/drivers/register_driver_types.cpp b/drivers/register_driver_types.cpp
index 18262c74c4..83702ea2cc 100644
--- a/drivers/register_driver_types.cpp
+++ b/drivers/register_driver_types.cpp
@@ -40,7 +40,7 @@ void register_core_driver_types() {
image_loader_png = memnew(ImageLoaderPNG);
ImageLoader::add_image_format_loader(image_loader_png);
- resource_saver_png.instance();
+ resource_saver_png.instantiate();
ResourceSaver::add_resource_format_saver(resource_saver_png);
}
diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp
index c69b516f37..6c4e590586 100644
--- a/drivers/vulkan/rendering_device_vulkan.cpp
+++ b/drivers/vulkan/rendering_device_vulkan.cpp
@@ -3244,12 +3244,7 @@ bool RenderingDeviceVulkan::texture_is_format_supported_for_usage(DataFormat p_f
/**** ATTACHMENT ****/
/********************/
-VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentFormat> &p_format, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, int *r_color_attachment_count, uint32_t p_view_count) {
- Vector<VkAttachmentDescription> attachments;
- Vector<VkAttachmentReference> color_references;
- Vector<VkAttachmentReference> depth_stencil_references;
- Vector<VkAttachmentReference> resolve_references;
-
+VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentFormat> &p_attachments, const Vector<FramebufferPass> &p_passes, InitialAction p_initial_action, FinalAction p_final_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, uint32_t p_view_count, Vector<TextureSamples> *r_samples) {
// Set up dependencies from/to external equivalent to the default (implicit) one, and then amend them
const VkPipelineStageFlags default_access_mask = VK_ACCESS_INPUT_ATTACHMENT_READ_BIT |
VK_ACCESS_COLOR_ATTACHMENT_READ_BIT |
@@ -3262,27 +3257,31 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF
{ 0, VK_SUBPASS_EXTERNAL, VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, default_access_mask, 0, 0 } };
VkSubpassDependency &dependency_from_external = dependencies[0];
VkSubpassDependency &dependency_to_external = dependencies[1];
+ LocalVector<int32_t> attachment_last_pass;
+ attachment_last_pass.resize(p_attachments.size());
- for (int i = 0; i < p_format.size(); i++) {
- ERR_FAIL_INDEX_V(p_format[i].format, DATA_FORMAT_MAX, VK_NULL_HANDLE);
- ERR_FAIL_INDEX_V(p_format[i].samples, TEXTURE_SAMPLES_MAX, VK_NULL_HANDLE);
- ERR_FAIL_COND_V_MSG(!(p_format[i].usage_flags & (TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | TEXTURE_USAGE_RESOLVE_ATTACHMENT_BIT)),
+ Vector<VkAttachmentDescription> attachments;
+
+ for (int i = 0; i < p_attachments.size(); i++) {
+ ERR_FAIL_INDEX_V(p_attachments[i].format, DATA_FORMAT_MAX, VK_NULL_HANDLE);
+ ERR_FAIL_INDEX_V(p_attachments[i].samples, TEXTURE_SAMPLES_MAX, VK_NULL_HANDLE);
+ ERR_FAIL_COND_V_MSG(!(p_attachments[i].usage_flags & (TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | TEXTURE_USAGE_RESOLVE_ATTACHMENT_BIT)),
VK_NULL_HANDLE, "Texture format for index (" + itos(i) + ") requires an attachment (depth, stencil or resolve) bit set.");
VkAttachmentDescription description = {};
description.flags = 0;
- description.format = vulkan_formats[p_format[i].format];
- description.samples = rasterization_sample_count[p_format[i].samples];
+ description.format = vulkan_formats[p_attachments[i].format];
+ description.samples = rasterization_sample_count[p_attachments[i].samples];
- bool is_depth_stencil = p_format[i].usage_flags & TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
- bool is_sampled = p_format[i].usage_flags & TEXTURE_USAGE_SAMPLING_BIT;
- bool is_storage = p_format[i].usage_flags & TEXTURE_USAGE_STORAGE_BIT;
+ bool is_sampled = p_attachments[i].usage_flags & TEXTURE_USAGE_SAMPLING_BIT;
+ bool is_storage = p_attachments[i].usage_flags & TEXTURE_USAGE_STORAGE_BIT;
+ bool is_depth = p_attachments[i].usage_flags & TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
// For each UNDEFINED, assume the prior use was a *read*, as we'd be discarding the output of a write
// Also, each UNDEFINED will do an immediate layout transition (write), s.t. we must ensure execution synchronization vs.
// the read. If this is a performance issue, one could track the actual last accessor of each resource, adding only that
// stage
- switch (is_depth_stencil ? p_initial_depth_action : p_initial_color_action) {
+ switch (is_depth ? p_initial_depth_action : p_initial_action) {
case INITIAL_ACTION_CLEAR_REGION:
case INITIAL_ACTION_CLEAR: {
description.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
@@ -3291,11 +3290,11 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF
dependency_from_external.srcStageMask |= reading_stages;
} break;
case INITIAL_ACTION_KEEP: {
- if (p_format[i].usage_flags & TEXTURE_USAGE_COLOR_ATTACHMENT_BIT) {
+ if (p_attachments[i].usage_flags & TEXTURE_USAGE_COLOR_ATTACHMENT_BIT) {
description.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
description.initialLayout = is_sampled ? VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL : (is_storage ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
description.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
- } else if (p_format[i].usage_flags & TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
+ } else if (p_attachments[i].usage_flags & TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
description.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
description.initialLayout = is_sampled ? VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL : (is_storage ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
description.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
@@ -3308,11 +3307,11 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF
}
} break;
case INITIAL_ACTION_DROP: {
- if (p_format[i].usage_flags & TEXTURE_USAGE_COLOR_ATTACHMENT_BIT) {
+ if (p_attachments[i].usage_flags & TEXTURE_USAGE_COLOR_ATTACHMENT_BIT) {
description.loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
description.initialLayout = is_sampled ? VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL : (is_storage ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
description.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
- } else if (p_format[i].usage_flags & TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
+ } else if (p_attachments[i].usage_flags & TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
description.loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
description.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; //don't care what is there
description.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
@@ -3326,11 +3325,11 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF
} break;
case INITIAL_ACTION_CLEAR_REGION_CONTINUE:
case INITIAL_ACTION_CONTINUE: {
- if (p_format[i].usage_flags & TEXTURE_USAGE_COLOR_ATTACHMENT_BIT) {
+ if (p_attachments[i].usage_flags & TEXTURE_USAGE_COLOR_ATTACHMENT_BIT) {
description.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
description.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
description.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
- } else if (p_format[i].usage_flags & TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
+ } else if (p_attachments[i].usage_flags & TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
description.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
description.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
description.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
@@ -3346,14 +3345,14 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF
}
}
- switch (is_depth_stencil ? p_final_depth_action : p_final_color_action) {
+ switch (is_depth ? p_final_depth_action : p_final_action) {
case FINAL_ACTION_READ: {
- if (p_format[i].usage_flags & TEXTURE_USAGE_COLOR_ATTACHMENT_BIT) {
+ if (p_attachments[i].usage_flags & TEXTURE_USAGE_COLOR_ATTACHMENT_BIT) {
description.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
description.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
description.finalLayout = is_sampled ? VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL : (is_storage ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
update_external_dependency_for_store(dependency_to_external, is_sampled, is_storage, false);
- } else if (p_format[i].usage_flags & TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
+ } else if (p_attachments[i].usage_flags & TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
description.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
description.stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE;
description.finalLayout = is_sampled ? VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL : (is_storage ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
@@ -3366,11 +3365,11 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF
}
} break;
case FINAL_ACTION_DISCARD: {
- if (p_format[i].usage_flags & TEXTURE_USAGE_COLOR_ATTACHMENT_BIT) {
+ if (p_attachments[i].usage_flags & TEXTURE_USAGE_COLOR_ATTACHMENT_BIT) {
description.storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
description.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
description.finalLayout = is_sampled ? VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL : (is_storage ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
- } else if (p_format[i].usage_flags & TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
+ } else if (p_attachments[i].usage_flags & TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
description.storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
description.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
description.finalLayout = is_sampled ? VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL : (is_storage ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
@@ -3381,11 +3380,11 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF
}
} break;
case FINAL_ACTION_CONTINUE: {
- if (p_format[i].usage_flags & TEXTURE_USAGE_COLOR_ATTACHMENT_BIT) {
+ if (p_attachments[i].usage_flags & TEXTURE_USAGE_COLOR_ATTACHMENT_BIT) {
description.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
description.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
description.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
- } else if (p_format[i].usage_flags & TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
+ } else if (p_attachments[i].usage_flags & TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
description.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
description.stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE;
description.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
@@ -3401,27 +3400,194 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF
}
}
+ attachment_last_pass[i] = -1;
+
attachments.push_back(description);
+ }
+
+ LocalVector<VkSubpassDescription> subpasses;
+ LocalVector<LocalVector<VkAttachmentReference>> color_reference_array;
+ LocalVector<LocalVector<VkAttachmentReference>> input_reference_array;
+ LocalVector<LocalVector<VkAttachmentReference>> resolve_reference_array;
+ LocalVector<LocalVector<uint32_t>> preserve_reference_array;
+ LocalVector<VkAttachmentReference> depth_reference_array;
- VkAttachmentReference reference;
- reference.attachment = i;
+ subpasses.resize(p_passes.size());
+ color_reference_array.resize(p_passes.size());
+ input_reference_array.resize(p_passes.size());
+ resolve_reference_array.resize(p_passes.size());
+ preserve_reference_array.resize(p_passes.size());
+ depth_reference_array.resize(p_passes.size());
- if (p_format[i].usage_flags & TEXTURE_USAGE_COLOR_ATTACHMENT_BIT) {
- reference.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
+ LocalVector<VkSubpassDependency> subpass_dependencies;
+
+ for (int i = 0; i < p_passes.size(); i++) {
+ const FramebufferPass *pass = &p_passes[i];
+
+ LocalVector<VkAttachmentReference> &color_references = color_reference_array[i];
+
+ TextureSamples texture_samples = TEXTURE_SAMPLES_1;
+ bool is_multisample_first = true;
+
+ for (int j = 0; j < pass->color_attachments.size(); j++) {
+ int32_t attachment = pass->color_attachments[j];
+ VkAttachmentReference reference;
+ if (attachment == FramebufferPass::ATTACHMENT_UNUSED) {
+ reference.attachment = VK_ATTACHMENT_UNUSED;
+ reference.layout = VK_IMAGE_LAYOUT_UNDEFINED;
+ } else {
+ ERR_FAIL_INDEX_V_MSG(attachment, p_attachments.size(), VK_NULL_HANDLE, "Invalid framebuffer format attachment(" + itos(attachment) + "), in pass (" + itos(i) + "), color attachment (" + itos(j) + ").");
+ ERR_FAIL_COND_V_MSG(!(p_attachments[attachment].usage_flags & TEXTURE_USAGE_COLOR_ATTACHMENT_BIT), VK_NULL_HANDLE, "Invalid framebuffer format attachment(" + itos(attachment) + "), in pass (" + itos(i) + "), it's marked as depth, but it's not usable as color attachment.");
+ ERR_FAIL_COND_V_MSG(attachment_last_pass[attachment] == i, VK_NULL_HANDLE, "Invalid framebuffer format attachment(" + itos(attachment) + "), in pass (" + itos(i) + "), it already was used for something else before in this pass.");
+
+ if (is_multisample_first) {
+ texture_samples = p_attachments[attachment].samples;
+ is_multisample_first = false;
+ } else {
+ ERR_FAIL_COND_V_MSG(texture_samples != p_attachments[attachment].samples, VK_NULL_HANDLE, "Invalid framebuffer format attachment(" + itos(attachment) + "), in pass (" + itos(i) + "), if an attachment is marked as multisample, all of them should be multisample and use the same number of samples.");
+ }
+ reference.attachment = attachment;
+ reference.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
+ attachment_last_pass[attachment] = i;
+ }
color_references.push_back(reference);
- } else if (p_format[i].usage_flags & TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
- reference.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
- depth_stencil_references.push_back(reference);
- } else if (p_format[i].usage_flags & TEXTURE_USAGE_RESOLVE_ATTACHMENT_BIT) {
- reference.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
+ }
+
+ LocalVector<VkAttachmentReference> &input_references = input_reference_array[i];
+
+ for (int j = 0; j < pass->input_attachments.size(); j++) {
+ int32_t attachment = pass->input_attachments[j];
+ VkAttachmentReference reference;
+ if (attachment == FramebufferPass::ATTACHMENT_UNUSED) {
+ reference.attachment = VK_ATTACHMENT_UNUSED;
+ reference.layout = VK_IMAGE_LAYOUT_UNDEFINED;
+ } else {
+ ERR_FAIL_INDEX_V_MSG(attachment, p_attachments.size(), VK_NULL_HANDLE, "Invalid framebuffer format attachment(" + itos(attachment) + "), in pass (" + itos(i) + "), input attachment (" + itos(j) + ").");
+ ERR_FAIL_COND_V_MSG(!(p_attachments[attachment].usage_flags & TEXTURE_USAGE_COLOR_ATTACHMENT_BIT), VK_NULL_HANDLE, "Invalid framebuffer format attachment(" + itos(attachment) + "), in pass (" + itos(i) + "), it's marked as depth, but it's not usable as input attachment.");
+ ERR_FAIL_COND_V_MSG(attachment_last_pass[attachment] == i, VK_NULL_HANDLE, "Invalid framebuffer format attachment(" + itos(attachment) + "), in pass (" + itos(i) + "), it already was used for something else before in this pass.");
+ reference.attachment = attachment;
+ reference.layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
+ attachment_last_pass[attachment] = i;
+ }
+ input_references.push_back(reference);
+ }
+
+ LocalVector<VkAttachmentReference> &resolve_references = resolve_reference_array[i];
+
+ if (pass->resolve_attachments.size() > 0) {
+ ERR_FAIL_COND_V_MSG(pass->resolve_attachments.size() != pass->color_attachments.size(), VK_NULL_HANDLE, "The amount of resolve attachments (" + itos(pass->resolve_attachments.size()) + ") must match the number of color attachments (" + itos(pass->color_attachments.size()) + ").");
+ ERR_FAIL_COND_V_MSG(texture_samples == TEXTURE_SAMPLES_1, VK_NULL_HANDLE, "Resolve attachments specified, but color attachments are not multisample.");
+ }
+ for (int j = 0; j < pass->resolve_attachments.size(); j++) {
+ int32_t attachment = pass->resolve_attachments[j];
+ VkAttachmentReference reference;
+ if (attachment == FramebufferPass::ATTACHMENT_UNUSED) {
+ reference.attachment = VK_ATTACHMENT_UNUSED;
+ reference.layout = VK_IMAGE_LAYOUT_UNDEFINED;
+ } else {
+ ERR_FAIL_INDEX_V_MSG(attachment, p_attachments.size(), VK_NULL_HANDLE, "Invalid framebuffer format attachment(" + itos(attachment) + "), in pass (" + itos(i) + "), resolve attachment (" + itos(j) + ").");
+ ERR_FAIL_COND_V_MSG(pass->color_attachments[j] == FramebufferPass::ATTACHMENT_UNUSED, VK_NULL_HANDLE, "Invalid framebuffer format attachment(" + itos(attachment) + "), in pass (" + itos(i) + "), resolve attachment (" + itos(j) + "), the respective color attachment is marked as unused.");
+ ERR_FAIL_COND_V_MSG(!(p_attachments[attachment].usage_flags & TEXTURE_USAGE_COLOR_ATTACHMENT_BIT), VK_NULL_HANDLE, "Invalid framebuffer format attachment(" + itos(attachment) + "), in pass (" + itos(i) + "), it's marked as depth, but it's not usable as resolve attachment.");
+ ERR_FAIL_COND_V_MSG(attachment_last_pass[attachment] == i, VK_NULL_HANDLE, "Invalid framebuffer format attachment(" + itos(attachment) + "), in pass (" + itos(i) + "), it already was used for something else before in this pass.");
+ bool multisample = p_attachments[attachment].samples > TEXTURE_SAMPLES_1;
+ ERR_FAIL_COND_V_MSG(multisample, VK_NULL_HANDLE, "Invalid framebuffer format attachment(" + itos(attachment) + "), in pass (" + itos(i) + "), resolve attachments can't be multisample.");
+ reference.attachment = attachment;
+ reference.layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
+ attachment_last_pass[attachment] = i;
+ }
resolve_references.push_back(reference);
- // if resolves are done, we need to ensure the copy is safe
- dependency_to_external.dstStageMask |= VK_PIPELINE_STAGE_TRANSFER_BIT;
- dependency_to_external.dstAccessMask |= VK_ACCESS_TRANSFER_READ_BIT;
+ }
+
+ LocalVector<uint32_t> &preserve_references = preserve_reference_array[i];
+
+ for (int j = 0; j < pass->preserve_attachments.size(); j++) {
+ int32_t attachment = pass->preserve_attachments[j];
+
+ ERR_FAIL_COND_V_MSG(attachment == FramebufferPass::ATTACHMENT_UNUSED, VK_NULL_HANDLE, "Invalid framebuffer format attachment(" + itos(attachment) + "), in pass (" + itos(i) + "), preserve attachment (" + itos(j) + "). Preserve attachments can't be unused.");
+
+ ERR_FAIL_INDEX_V_MSG(attachment, p_attachments.size(), VK_NULL_HANDLE, "Invalid framebuffer format attachment(" + itos(attachment) + "), in pass (" + itos(i) + "), preserve attachment (" + itos(j) + ").");
+ ERR_FAIL_COND_V_MSG(attachment_last_pass[attachment] == i, VK_NULL_HANDLE, "Invalid framebuffer format attachment(" + itos(attachment) + "), in pass (" + itos(i) + "), it already was used for something else before in this pass.");
+
+ attachment_last_pass[attachment] = i;
+
+ preserve_references.push_back(attachment);
+ }
+
+ VkAttachmentReference &depth_stencil_reference = depth_reference_array[i];
+
+ if (pass->depth_attachment != FramebufferPass::ATTACHMENT_UNUSED) {
+ int32_t attachment = pass->depth_attachment;
+ ERR_FAIL_INDEX_V_MSG(attachment, p_attachments.size(), VK_NULL_HANDLE, "Invalid framebuffer depth format attachment(" + itos(attachment) + "), in pass (" + itos(i) + "), depth attachment.");
+ ERR_FAIL_COND_V_MSG(!(p_attachments[attachment].usage_flags & TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT), VK_NULL_HANDLE, "Invalid framebuffer depth format attachment(" + itos(attachment) + "), in pass (" + itos(i) + "), it's marked as depth, but it's not a depth attachment.");
+ ERR_FAIL_COND_V_MSG(attachment_last_pass[attachment] == i, VK_NULL_HANDLE, "Invalid framebuffer depth format attachment(" + itos(attachment) + "), in pass (" + itos(i) + "), it already was used for something else before in this pass.");
+ depth_stencil_reference.attachment = attachment;
+ depth_stencil_reference.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
+ attachment_last_pass[attachment] = i;
+
+ if (is_multisample_first) {
+ texture_samples = p_attachments[attachment].samples;
+ is_multisample_first = false;
+ } else {
+ ERR_FAIL_COND_V_MSG(texture_samples != p_attachments[attachment].samples, VK_NULL_HANDLE, "Invalid framebuffer depth format attachment(" + itos(attachment) + "), in pass (" + itos(i) + "), if an attachment is marked as multisample, all of them should be multisample and use the same number of samples including the depth.");
+ }
+
+ } else {
+ depth_stencil_reference.attachment = VK_ATTACHMENT_UNUSED;
+ depth_stencil_reference.layout = VK_IMAGE_LAYOUT_UNDEFINED;
+ }
+
+ VkSubpassDescription &subpass = subpasses[i];
+ subpass.flags = 0;
+ subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
+ subpass.inputAttachmentCount = input_references.size();
+ if (input_references.size()) {
+ subpass.pInputAttachments = input_references.ptr();
+ } else {
+ subpass.pInputAttachments = nullptr;
+ }
+ subpass.colorAttachmentCount = color_references.size();
+ if (color_references.size()) {
+ subpass.pColorAttachments = color_references.ptr();
+ } else {
+ subpass.pColorAttachments = nullptr;
+ }
+ if (depth_stencil_reference.attachment != VK_ATTACHMENT_UNUSED) {
+ subpass.pDepthStencilAttachment = &depth_stencil_reference;
+ } else {
+ subpass.pDepthStencilAttachment = nullptr;
+ }
+
+ if (resolve_references.size()) {
+ subpass.pResolveAttachments = resolve_references.ptr();
} else {
- ERR_FAIL_V_MSG(VK_NULL_HANDLE, "Texture index " + itos(i) + " is neither color, depth stencil or resolve so it can't be used as attachment.");
+ subpass.pResolveAttachments = nullptr;
+ }
+
+ subpass.preserveAttachmentCount = preserve_references.size();
+ if (preserve_references.size()) {
+ subpass.pPreserveAttachments = preserve_references.ptr();
+ } else {
+ subpass.pPreserveAttachments = nullptr;
+ }
+
+ if (r_samples) {
+ r_samples->push_back(texture_samples);
}
+ if (i > 0) {
+ VkSubpassDependency dependency;
+ dependency.srcSubpass = i - 1;
+ dependency.dstSubpass = i;
+ dependency.srcStageMask = 0;
+ dependency.srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT;
+ dependency.dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
+
+ dependency.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
+ dependency.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT;
+ dependency.dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT;
+ subpass_dependencies.push_back(dependency);
+ }
+ /*
// NOTE: Big Mallet Approach -- any layout transition causes a full barrier
if (reference.layout != description.initialLayout) {
// NOTE: this should be smarter based on the texture's knowledge of its previous role
@@ -3433,41 +3599,28 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF
dependency_to_external.dstStageMask |= VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
dependency_to_external.dstAccessMask |= VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT;
}
+ */
}
- ERR_FAIL_COND_V_MSG(depth_stencil_references.size() > 1, VK_NULL_HANDLE,
- "Formats can only have one depth/stencil attachment, supplied (" + itos(depth_stencil_references.size()) + ").");
-
- ERR_FAIL_COND_V_MSG(resolve_references.size() > 1, VK_NULL_HANDLE,
- "Formats can only have one resolve attachment, supplied (" + itos(resolve_references.size()) + ").");
-
- VkSubpassDescription subpass;
- subpass.flags = 0;
- subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
- subpass.inputAttachmentCount = 0; //unsupported for now
- subpass.pInputAttachments = nullptr;
- subpass.colorAttachmentCount = color_references.size();
- subpass.pColorAttachments = color_references.ptr();
- subpass.pDepthStencilAttachment = depth_stencil_references.ptr();
- subpass.pResolveAttachments = resolve_references.ptr();
- subpass.preserveAttachmentCount = 0;
- subpass.pPreserveAttachments = nullptr;
-
VkRenderPassCreateInfo render_pass_create_info;
render_pass_create_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
render_pass_create_info.pNext = nullptr;
render_pass_create_info.flags = 0;
render_pass_create_info.attachmentCount = attachments.size();
render_pass_create_info.pAttachments = attachments.ptr();
- render_pass_create_info.subpassCount = 1;
- render_pass_create_info.pSubpasses = &subpass;
+ render_pass_create_info.subpassCount = subpasses.size();
+ render_pass_create_info.pSubpasses = subpasses.ptr();
// Commenting this because it seems it just avoids raster and compute to work at the same time.
// Other barriers seem to be protecting the render pass fine.
// render_pass_create_info.dependencyCount = 2;
// render_pass_create_info.pDependencies = dependencies;
- render_pass_create_info.dependencyCount = 0;
- render_pass_create_info.pDependencies = nullptr;
+ render_pass_create_info.dependencyCount = subpass_dependencies.size();
+ if (subpass_dependencies.size()) {
+ render_pass_create_info.pDependencies = subpass_dependencies.ptr();
+ } else {
+ render_pass_create_info.pDependencies = nullptr;
+ }
const uint32_t view_mask = (1 << p_view_count) - 1;
const uint32_t correlation_mask = (1 << p_view_count) - 1;
@@ -3498,17 +3651,29 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF
VkResult res = vkCreateRenderPass(device, &render_pass_create_info, nullptr, &render_pass);
ERR_FAIL_COND_V_MSG(res, VK_NULL_HANDLE, "vkCreateRenderPass failed with error " + itos(res) + ".");
- if (r_color_attachment_count) {
- *r_color_attachment_count = color_references.size();
- }
return render_pass;
}
RenderingDevice::FramebufferFormatID RenderingDeviceVulkan::framebuffer_format_create(const Vector<AttachmentFormat> &p_format, uint32_t p_view_count) {
+ FramebufferPass pass;
+ for (int i = 0; i < p_format.size(); i++) {
+ if (p_format[i].usage_flags & TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
+ pass.depth_attachment = i;
+ } else {
+ pass.color_attachments.push_back(i);
+ }
+ }
+
+ Vector<FramebufferPass> passes;
+ passes.push_back(pass);
+ return framebuffer_format_create_multipass(p_format, passes, p_view_count);
+}
+RenderingDevice::FramebufferFormatID RenderingDeviceVulkan::framebuffer_format_create_multipass(const Vector<AttachmentFormat> &p_attachments, Vector<FramebufferPass> &p_passes, uint32_t p_view_count) {
_THREAD_SAFE_METHOD_
FramebufferFormatKey key;
- key.attachments = p_format;
+ key.attachments = p_attachments;
+ key.passes = p_passes;
key.view_count = p_view_count;
const Map<FramebufferFormatKey, FramebufferFormatID>::Element *E = framebuffer_format_cache.find(key);
@@ -3517,8 +3682,8 @@ RenderingDevice::FramebufferFormatID RenderingDeviceVulkan::framebuffer_format_c
return E->get();
}
- int color_references;
- VkRenderPass render_pass = _render_pass_create(p_format, INITIAL_ACTION_CLEAR, FINAL_ACTION_READ, INITIAL_ACTION_CLEAR, FINAL_ACTION_READ, &color_references, p_view_count); //actions don't matter for this use case
+ Vector<TextureSamples> samples;
+ VkRenderPass render_pass = _render_pass_create(p_attachments, p_passes, INITIAL_ACTION_CLEAR, FINAL_ACTION_READ, INITIAL_ACTION_CLEAR, FINAL_ACTION_READ, p_view_count, &samples); //actions don't matter for this use case
if (render_pass == VK_NULL_HANDLE) { //was likely invalid
return INVALID_ID;
@@ -3528,9 +3693,8 @@ RenderingDevice::FramebufferFormatID RenderingDeviceVulkan::framebuffer_format_c
E = framebuffer_format_cache.insert(key, id);
FramebufferFormat fb_format;
fb_format.E = E;
- fb_format.color_attachments = color_references;
fb_format.render_pass = render_pass;
- fb_format.samples = p_format[0].samples;
+ fb_format.pass_samples = samples;
fb_format.view_count = p_view_count;
framebuffer_formats[id] = fb_format;
return id;
@@ -3538,6 +3702,7 @@ RenderingDevice::FramebufferFormatID RenderingDeviceVulkan::framebuffer_format_c
RenderingDevice::FramebufferFormatID RenderingDeviceVulkan::framebuffer_format_create_empty(TextureSamples p_samples) {
FramebufferFormatKey key;
+ key.passes.push_back(FramebufferPass());
const Map<FramebufferFormatKey, FramebufferFormatID>::Element *E = framebuffer_format_cache.find(key);
if (E) {
@@ -3583,18 +3748,18 @@ RenderingDevice::FramebufferFormatID RenderingDeviceVulkan::framebuffer_format_c
FramebufferFormat fb_format;
fb_format.E = E;
- fb_format.color_attachments = 0;
fb_format.render_pass = render_pass;
- fb_format.samples = p_samples;
+ fb_format.pass_samples.push_back(p_samples);
framebuffer_formats[id] = fb_format;
return id;
}
-RenderingDevice::TextureSamples RenderingDeviceVulkan::framebuffer_format_get_texture_samples(FramebufferFormatID p_format) {
+RenderingDevice::TextureSamples RenderingDeviceVulkan::framebuffer_format_get_texture_samples(FramebufferFormatID p_format, uint32_t p_pass) {
Map<FramebufferFormatID, FramebufferFormat>::Element *E = framebuffer_formats.find(p_format);
ERR_FAIL_COND_V(!E, TEXTURE_SAMPLES_1);
+ ERR_FAIL_COND_V(p_pass >= uint32_t(E->get().pass_samples.size()), TEXTURE_SAMPLES_1);
- return E->get().samples;
+ return E->get().pass_samples[p_pass];
}
/***********************/
@@ -3615,6 +3780,30 @@ RID RenderingDeviceVulkan::framebuffer_create_empty(const Size2i &p_size, Textur
RID RenderingDeviceVulkan::framebuffer_create(const Vector<RID> &p_texture_attachments, FramebufferFormatID p_format_check, uint32_t p_view_count) {
_THREAD_SAFE_METHOD_
+ FramebufferPass pass;
+
+ for (int i = 0; i < p_texture_attachments.size(); i++) {
+ Texture *texture = texture_owner.getornull(p_texture_attachments[i]);
+ ERR_FAIL_COND_V_MSG(!texture, RID(), "Texture index supplied for framebuffer (" + itos(i) + ") is not a valid texture.");
+
+ ERR_FAIL_COND_V_MSG(texture->layers != p_view_count, RID(), "Layers of our texture doesn't match view count for this framebuffer");
+
+ if (texture->usage_flags & TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
+ pass.depth_attachment = i;
+ } else {
+ pass.color_attachments.push_back(i);
+ }
+ }
+
+ Vector<FramebufferPass> passes;
+ passes.push_back(pass);
+
+ return framebuffer_create_multipass(p_texture_attachments, passes, p_format_check, p_view_count);
+}
+
+RID RenderingDeviceVulkan::framebuffer_create_multipass(const Vector<RID> &p_texture_attachments, Vector<FramebufferPass> &p_passes, FramebufferFormatID p_format_check, uint32_t p_view_count) {
+ _THREAD_SAFE_METHOD_
+
Vector<AttachmentFormat> attachments;
Size2i size;
@@ -3639,7 +3828,7 @@ RID RenderingDeviceVulkan::framebuffer_create(const Vector<RID> &p_texture_attac
attachments.push_back(af);
}
- FramebufferFormatID format_id = framebuffer_format_create(attachments, p_view_count);
+ FramebufferFormatID format_id = framebuffer_format_create_multipass(attachments, p_passes, p_view_count);
if (format_id == INVALID_ID) {
return RID();
}
@@ -4401,8 +4590,9 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages
"Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_stages[i].shader_stage]) + "' failed obtaining output variables.");
for (uint32_t j = 0; j < ov_count; j++) {
- if (output_vars[j]) {
- fragment_outputs = MAX(fragment_outputs, output_vars[j]->location + 1);
+ const SpvReflectInterfaceVariable *refvar = output_vars[j];
+ if (refvar != nullptr && refvar->built_in != SpvBuiltInFragDepth) {
+ fragment_outputs |= 1 << refvar->location;
}
}
}
@@ -4453,7 +4643,7 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages
Shader shader;
shader.vertex_input_mask = vertex_input_mask;
- shader.fragment_outputs = fragment_outputs;
+ shader.fragment_output_mask = fragment_outputs;
shader.push_constant = push_constant;
shader.is_compute = is_compute;
shader.compute_local_size[0] = compute_local_size[0];
@@ -5194,6 +5384,49 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms,
write.pTexelBufferView = nullptr;
} break;
case UNIFORM_TYPE_INPUT_ATTACHMENT: {
+ ERR_FAIL_COND_V_MSG(shader->is_compute, RID(), "InputAttachment (binding: " + itos(uniform.binding) + ") supplied for compute shader (this is not allowed).");
+
+ if (uniform.ids.size() != set_uniform.length) {
+ if (set_uniform.length > 1) {
+ ERR_FAIL_V_MSG(RID(), "InputAttachment (binding: " + itos(uniform.binding) + ") is an array of (" + itos(set_uniform.length) + ") textures, so it should be provided equal number of texture IDs to satisfy it (IDs provided: " + itos(uniform.ids.size()) + ").");
+ } else {
+ ERR_FAIL_V_MSG(RID(), "InputAttachment (binding: " + itos(uniform.binding) + ") should provide one ID referencing a texture (IDs provided: " + itos(uniform.ids.size()) + ").");
+ }
+ }
+
+ Vector<VkDescriptorImageInfo> image_info;
+
+ for (int j = 0; j < uniform.ids.size(); j++) {
+ Texture *texture = texture_owner.getornull(uniform.ids[j]);
+
+ ERR_FAIL_COND_V_MSG(!texture, RID(),
+ "InputAttachment (binding: " + itos(uniform.binding) + ", index " + itos(j) + ") is not a valid texture.");
+
+ ERR_FAIL_COND_V_MSG(!(texture->usage_flags & TEXTURE_USAGE_SAMPLING_BIT), RID(),
+ "InputAttachment (binding: " + itos(uniform.binding) + ", index " + itos(j) + ") needs the TEXTURE_USAGE_SAMPLING_BIT usage flag set in order to be used as uniform.");
+
+ VkDescriptorImageInfo img_info;
+ img_info.sampler = VK_NULL_HANDLE;
+ img_info.imageView = texture->view;
+
+ if (texture->owner.is_valid()) {
+ texture = texture_owner.getornull(texture->owner);
+ ERR_FAIL_COND_V(!texture, RID()); //bug, should never happen
+ }
+
+ img_info.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
+
+ image_info.push_back(img_info);
+ }
+
+ write.dstArrayElement = 0;
+ write.descriptorCount = uniform.ids.size();
+ write.descriptorType = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT;
+ write.pImageInfo = image_infos.push_back(image_info)->get().ptr();
+ write.pBufferInfo = nullptr;
+ write.pTexelBufferView = nullptr;
+
+ type_size = uniform.ids.size();
} break;
default: {
}
@@ -5404,7 +5637,7 @@ Vector<uint8_t> RenderingDeviceVulkan::buffer_get_data(RID p_buffer) {
/**** RENDER PIPELINE ****/
/*************************/
-RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferFormatID p_framebuffer_format, VertexFormatID p_vertex_format, RenderPrimitive p_render_primitive, const PipelineRasterizationState &p_rasterization_state, const PipelineMultisampleState &p_multisample_state, const PipelineDepthStencilState &p_depth_stencil_state, const PipelineColorBlendState &p_blend_state, int p_dynamic_state_flags) {
+RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferFormatID p_framebuffer_format, VertexFormatID p_vertex_format, RenderPrimitive p_render_primitive, const PipelineRasterizationState &p_rasterization_state, const PipelineMultisampleState &p_multisample_state, const PipelineDepthStencilState &p_depth_stencil_state, const PipelineColorBlendState &p_blend_state, int p_dynamic_state_flags, uint32_t p_for_render_pass) {
_THREAD_SAFE_METHOD_
//needs a shader
@@ -5423,8 +5656,16 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma
{ //validate shader vs framebuffer
- ERR_FAIL_COND_V_MSG(shader->fragment_outputs != fb_format.color_attachments, RID(),
- "Mismatch fragment output bindings (" + itos(shader->fragment_outputs) + ") and framebuffer color buffers (" + itos(fb_format.color_attachments) + ") when binding both in render pipeline.");
+ ERR_FAIL_COND_V_MSG(p_for_render_pass >= uint32_t(fb_format.E->key().passes.size()), RID(), "Render pass requested for pipeline creation (" + itos(p_for_render_pass) + ") is out of bounds");
+ const FramebufferPass &pass = fb_format.E->key().passes[p_for_render_pass];
+ uint32_t output_mask = 0;
+ for (int i = 0; i < pass.color_attachments.size(); i++) {
+ if (pass.color_attachments[i] != FramebufferPass::ATTACHMENT_UNUSED) {
+ output_mask |= 1 << i;
+ }
+ }
+ ERR_FAIL_COND_V_MSG(shader->fragment_output_mask != output_mask, RID(),
+ "Mismatch fragment shader output mask (" + itos(shader->fragment_output_mask) + ") and framebuffer color output mask (" + itos(output_mask) + ") when binding both in render pipeline.");
}
//vertex
VkPipelineVertexInputStateCreateInfo pipeline_vertex_input_state_create_info;
@@ -5609,44 +5850,53 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma
ERR_FAIL_INDEX_V(p_blend_state.logic_op, LOGIC_OP_MAX, RID());
color_blend_state_create_info.logicOp = logic_operations[p_blend_state.logic_op];
- ERR_FAIL_COND_V(fb_format.color_attachments != p_blend_state.attachments.size(), RID());
-
Vector<VkPipelineColorBlendAttachmentState> attachment_states;
+ {
+ const FramebufferPass &pass = fb_format.E->key().passes[p_for_render_pass];
+
+ for (int i = 0; i < pass.color_attachments.size(); i++) {
+ if (pass.color_attachments[i] != FramebufferPass::ATTACHMENT_UNUSED) {
+ int idx = attachment_states.size();
+
+ ERR_FAIL_INDEX_V(idx, p_blend_state.attachments.size(), RID());
+ VkPipelineColorBlendAttachmentState state;
+ state.blendEnable = p_blend_state.attachments[idx].enable_blend;
+
+ ERR_FAIL_INDEX_V(p_blend_state.attachments[idx].src_color_blend_factor, BLEND_FACTOR_MAX, RID());
+ state.srcColorBlendFactor = blend_factors[p_blend_state.attachments[idx].src_color_blend_factor];
+ ERR_FAIL_INDEX_V(p_blend_state.attachments[idx].dst_color_blend_factor, BLEND_FACTOR_MAX, RID());
+ state.dstColorBlendFactor = blend_factors[p_blend_state.attachments[idx].dst_color_blend_factor];
+ ERR_FAIL_INDEX_V(p_blend_state.attachments[idx].color_blend_op, BLEND_OP_MAX, RID());
+ state.colorBlendOp = blend_operations[p_blend_state.attachments[idx].color_blend_op];
+
+ ERR_FAIL_INDEX_V(p_blend_state.attachments[idx].src_alpha_blend_factor, BLEND_FACTOR_MAX, RID());
+ state.srcAlphaBlendFactor = blend_factors[p_blend_state.attachments[idx].src_alpha_blend_factor];
+ ERR_FAIL_INDEX_V(p_blend_state.attachments[idx].dst_alpha_blend_factor, BLEND_FACTOR_MAX, RID());
+ state.dstAlphaBlendFactor = blend_factors[p_blend_state.attachments[idx].dst_alpha_blend_factor];
+ ERR_FAIL_INDEX_V(p_blend_state.attachments[idx].alpha_blend_op, BLEND_OP_MAX, RID());
+ state.alphaBlendOp = blend_operations[p_blend_state.attachments[idx].alpha_blend_op];
+
+ state.colorWriteMask = 0;
+ if (p_blend_state.attachments[idx].write_r) {
+ state.colorWriteMask |= VK_COLOR_COMPONENT_R_BIT;
+ }
+ if (p_blend_state.attachments[idx].write_g) {
+ state.colorWriteMask |= VK_COLOR_COMPONENT_G_BIT;
+ }
+ if (p_blend_state.attachments[idx].write_b) {
+ state.colorWriteMask |= VK_COLOR_COMPONENT_B_BIT;
+ }
+ if (p_blend_state.attachments[idx].write_a) {
+ state.colorWriteMask |= VK_COLOR_COMPONENT_A_BIT;
+ }
- for (int i = 0; i < p_blend_state.attachments.size(); i++) {
- VkPipelineColorBlendAttachmentState state;
- state.blendEnable = p_blend_state.attachments[i].enable_blend;
-
- ERR_FAIL_INDEX_V(p_blend_state.attachments[i].src_color_blend_factor, BLEND_FACTOR_MAX, RID());
- state.srcColorBlendFactor = blend_factors[p_blend_state.attachments[i].src_color_blend_factor];
- ERR_FAIL_INDEX_V(p_blend_state.attachments[i].dst_color_blend_factor, BLEND_FACTOR_MAX, RID());
- state.dstColorBlendFactor = blend_factors[p_blend_state.attachments[i].dst_color_blend_factor];
- ERR_FAIL_INDEX_V(p_blend_state.attachments[i].color_blend_op, BLEND_OP_MAX, RID());
- state.colorBlendOp = blend_operations[p_blend_state.attachments[i].color_blend_op];
-
- ERR_FAIL_INDEX_V(p_blend_state.attachments[i].src_alpha_blend_factor, BLEND_FACTOR_MAX, RID());
- state.srcAlphaBlendFactor = blend_factors[p_blend_state.attachments[i].src_alpha_blend_factor];
- ERR_FAIL_INDEX_V(p_blend_state.attachments[i].dst_alpha_blend_factor, BLEND_FACTOR_MAX, RID());
- state.dstAlphaBlendFactor = blend_factors[p_blend_state.attachments[i].dst_alpha_blend_factor];
- ERR_FAIL_INDEX_V(p_blend_state.attachments[i].alpha_blend_op, BLEND_OP_MAX, RID());
- state.alphaBlendOp = blend_operations[p_blend_state.attachments[i].alpha_blend_op];
-
- state.colorWriteMask = 0;
- if (p_blend_state.attachments[i].write_r) {
- state.colorWriteMask |= VK_COLOR_COMPONENT_R_BIT;
- }
- if (p_blend_state.attachments[i].write_g) {
- state.colorWriteMask |= VK_COLOR_COMPONENT_G_BIT;
- }
- if (p_blend_state.attachments[i].write_b) {
- state.colorWriteMask |= VK_COLOR_COMPONENT_B_BIT;
- }
- if (p_blend_state.attachments[i].write_a) {
- state.colorWriteMask |= VK_COLOR_COMPONENT_A_BIT;
+ attachment_states.push_back(state);
+ idx++;
+ };
}
- attachment_states.push_back(state);
- };
+ ERR_FAIL_COND_V(attachment_states.size() != p_blend_state.attachments.size(), RID());
+ }
color_blend_state_create_info.attachmentCount = attachment_states.size();
color_blend_state_create_info.pAttachments = attachment_states.ptr();
@@ -5719,7 +5969,7 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma
graphics_pipeline_create_info.layout = shader->pipeline_layout;
graphics_pipeline_create_info.renderPass = fb_format.render_pass;
- graphics_pipeline_create_info.subpass = 0;
+ graphics_pipeline_create_info.subpass = p_for_render_pass;
graphics_pipeline_create_info.basePipelineHandle = VK_NULL_HANDLE;
graphics_pipeline_create_info.basePipelineIndex = 0;
@@ -5736,6 +5986,7 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma
#ifdef DEBUG_ENABLED
pipeline.validation.dynamic_state = p_dynamic_state_flags;
pipeline.validation.framebuffer_format = p_framebuffer_format;
+ pipeline.validation.render_pass = p_for_render_pass;
pipeline.validation.vertex_format = p_vertex_format;
pipeline.validation.uses_restart_indices = input_assembly_create_info.primitiveRestartEnable;
@@ -5874,13 +6125,14 @@ RenderingDevice::DrawListID RenderingDeviceVulkan::draw_list_begin_for_screen(Di
ERR_FAIL_COND_V_MSG(compute_list != nullptr, INVALID_ID, "Only one draw/compute list can be active at the same time.");
VkCommandBuffer command_buffer = frames[frame].draw_command_buffer;
- draw_list = memnew(DrawList);
- draw_list->command_buffer = command_buffer;
+
+ Size2i size = Size2i(context->window_get_width(p_screen), context->window_get_height(p_screen));
+
+ _draw_list_allocate(Rect2i(Vector2i(), size), 0, 0);
#ifdef DEBUG_ENABLED
- draw_list->validation.framebuffer_format = screen_get_framebuffer_format();
+ draw_list_framebuffer_format = screen_get_framebuffer_format();
#endif
- draw_list_count = 0;
- draw_list_split = false;
+ draw_list_subpass_count = 1;
VkRenderPassBeginInfo render_pass_begin;
render_pass_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
@@ -5888,8 +6140,8 @@ RenderingDevice::DrawListID RenderingDeviceVulkan::draw_list_begin_for_screen(Di
render_pass_begin.renderPass = context->window_get_render_pass(p_screen);
render_pass_begin.framebuffer = context->window_get_framebuffer(p_screen);
- render_pass_begin.renderArea.extent.width = context->window_get_width(p_screen);
- render_pass_begin.renderArea.extent.height = context->window_get_height(p_screen);
+ render_pass_begin.renderArea.extent.width = size.width;
+ render_pass_begin.renderArea.extent.height = size.height;
render_pass_begin.renderArea.offset.x = 0;
render_pass_begin.renderArea.offset.y = 0;
@@ -5929,7 +6181,7 @@ RenderingDevice::DrawListID RenderingDeviceVulkan::draw_list_begin_for_screen(Di
return int64_t(ID_TYPE_DRAW_LIST) << ID_BASE_SHIFT;
}
-Error RenderingDeviceVulkan::_draw_list_setup_framebuffer(Framebuffer *p_framebuffer, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, VkFramebuffer *r_framebuffer, VkRenderPass *r_render_pass) {
+Error RenderingDeviceVulkan::_draw_list_setup_framebuffer(Framebuffer *p_framebuffer, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, VkFramebuffer *r_framebuffer, VkRenderPass *r_render_pass, uint32_t *r_subpass_count) {
Framebuffer::VersionKey vk;
vk.initial_color_action = p_initial_color_action;
vk.final_color_action = p_final_color_action;
@@ -5941,7 +6193,7 @@ Error RenderingDeviceVulkan::_draw_list_setup_framebuffer(Framebuffer *p_framebu
//need to create this version
Framebuffer::Version version;
- version.render_pass = _render_pass_create(framebuffer_formats[p_framebuffer->format_id].E->key().attachments, p_initial_color_action, p_final_color_action, p_initial_depth_action, p_final_depth_action, nullptr, p_framebuffer->view_count);
+ version.render_pass = _render_pass_create(framebuffer_formats[p_framebuffer->format_id].E->key().attachments, framebuffer_formats[p_framebuffer->format_id].E->key().passes, p_initial_color_action, p_final_color_action, p_initial_depth_action, p_final_depth_action, p_framebuffer->view_count);
VkFramebufferCreateInfo framebuffer_create_info;
framebuffer_create_info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
@@ -5965,11 +6217,14 @@ Error RenderingDeviceVulkan::_draw_list_setup_framebuffer(Framebuffer *p_framebu
VkResult err = vkCreateFramebuffer(device, &framebuffer_create_info, nullptr, &version.framebuffer);
ERR_FAIL_COND_V_MSG(err, ERR_CANT_CREATE, "vkCreateFramebuffer failed with error " + itos(err) + ".");
+ version.subpass_count = framebuffer_formats[p_framebuffer->format_id].E->key().passes.size();
+
p_framebuffer->framebuffers.insert(vk, version);
}
const Framebuffer::Version &version = p_framebuffer->framebuffers[vk];
*r_framebuffer = version.framebuffer;
*r_render_pass = version.render_pass;
+ *r_subpass_count = version.subpass_count;
return OK;
}
@@ -6159,15 +6414,23 @@ RenderingDevice::DrawListID RenderingDeviceVulkan::draw_list_begin(RID p_framebu
if (p_initial_color_action == INITIAL_ACTION_CLEAR) { //check clear values
- int color_attachments = framebuffer_formats[framebuffer->format_id].color_attachments;
- ERR_FAIL_COND_V_MSG(p_clear_color_values.size() != color_attachments, INVALID_ID,
- "Clear color values supplied (" + itos(p_clear_color_values.size()) + ") differ from the amount required for framebuffer (" + itos(color_attachments) + ").");
+ int color_count = 0;
+ for (int i = 0; i < framebuffer->texture_ids.size(); i++) {
+ Texture *texture = texture_owner.getornull(framebuffer->texture_ids[i]);
+
+ if (texture->usage_flags & TEXTURE_USAGE_COLOR_ATTACHMENT_BIT) {
+ color_count++;
+ }
+ }
+
+ ERR_FAIL_COND_V_MSG(p_clear_color_values.size() != color_count, INVALID_ID,
+ "Clear color values supplied (" + itos(p_clear_color_values.size()) + ") differ from the amount required for framebuffer color attachments (" + itos(color_count) + ").");
}
VkFramebuffer vkframebuffer;
VkRenderPass render_pass;
- Error err = _draw_list_setup_framebuffer(framebuffer, p_initial_color_action, p_final_color_action, p_initial_depth_action, p_final_depth_action, &vkframebuffer, &render_pass);
+ Error err = _draw_list_setup_framebuffer(framebuffer, p_initial_color_action, p_final_color_action, p_initial_depth_action, p_final_depth_action, &vkframebuffer, &render_pass, &draw_list_subpass_count);
ERR_FAIL_COND_V(err != OK, INVALID_ID);
VkCommandBuffer command_buffer = frames[frame].draw_command_buffer;
@@ -6177,13 +6440,14 @@ RenderingDevice::DrawListID RenderingDeviceVulkan::draw_list_begin(RID p_framebu
return INVALID_ID;
}
- draw_list = memnew(DrawList);
- draw_list->command_buffer = command_buffer;
+ draw_list_render_pass = render_pass;
+ draw_list_vkframebuffer = vkframebuffer;
+
+ _draw_list_allocate(Rect2i(viewport_offset, viewport_size), 0, 0);
#ifdef DEBUG_ENABLED
- draw_list->validation.framebuffer_format = framebuffer->format_id;
+ draw_list_framebuffer_format = framebuffer->format_id;
#endif
- draw_list_count = 0;
- draw_list_split = false;
+ draw_list_current_subpass = 0;
if (needs_clear_color || needs_clear_depth) {
_draw_list_insert_clear_region(draw_list, framebuffer, viewport_offset, viewport_size, needs_clear_color, p_clear_color_values, needs_clear_depth, p_clear_depth, p_clear_stencil);
@@ -6207,7 +6471,6 @@ RenderingDevice::DrawListID RenderingDeviceVulkan::draw_list_begin(RID p_framebu
vkCmdSetScissor(command_buffer, 0, 1, &scissor);
- draw_list->viewport = Rect2i(viewport_offset, viewport_size);
return int64_t(ID_TYPE_DRAW_LIST) << ID_BASE_SHIFT;
}
@@ -6249,47 +6512,23 @@ Error RenderingDeviceVulkan::draw_list_begin_split(RID p_framebuffer, uint32_t p
if (p_initial_color_action == INITIAL_ACTION_CLEAR) { //check clear values
- int color_attachments = framebuffer_formats[framebuffer->format_id].color_attachments;
- ERR_FAIL_COND_V_MSG(p_clear_color_values.size() != color_attachments, ERR_INVALID_PARAMETER,
- "Clear color values supplied (" + itos(p_clear_color_values.size()) + ") differ from the amount required for framebuffer (" + itos(color_attachments) + ").");
- }
-
- if (p_splits > (uint32_t)split_draw_list_allocators.size()) {
- uint32_t from = split_draw_list_allocators.size();
- split_draw_list_allocators.resize(p_splits);
- for (uint32_t i = from; i < p_splits; i++) {
- VkCommandPoolCreateInfo cmd_pool_info;
- cmd_pool_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
- cmd_pool_info.pNext = nullptr;
- cmd_pool_info.queueFamilyIndex = context->get_graphics_queue();
- cmd_pool_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
-
- VkResult res = vkCreateCommandPool(device, &cmd_pool_info, nullptr, &split_draw_list_allocators.write[i].command_pool);
- ERR_FAIL_COND_V_MSG(res, ERR_CANT_CREATE, "vkCreateCommandPool failed with error " + itos(res) + ".");
-
- for (int j = 0; j < frame_count; j++) {
- VkCommandBuffer command_buffer;
-
- VkCommandBufferAllocateInfo cmdbuf;
- //no command buffer exists, create it.
- cmdbuf.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
- cmdbuf.pNext = nullptr;
- cmdbuf.commandPool = split_draw_list_allocators[i].command_pool;
- cmdbuf.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY;
- cmdbuf.commandBufferCount = 1;
-
- VkResult err = vkAllocateCommandBuffers(device, &cmdbuf, &command_buffer);
- ERR_FAIL_COND_V_MSG(err, ERR_CANT_CREATE, "vkAllocateCommandBuffers failed with error " + itos(err) + ".");
+ int color_count = 0;
+ for (int i = 0; i < framebuffer->texture_ids.size(); i++) {
+ Texture *texture = texture_owner.getornull(framebuffer->texture_ids[i]);
- split_draw_list_allocators.write[i].command_buffers.push_back(command_buffer);
+ if (texture->usage_flags & TEXTURE_USAGE_COLOR_ATTACHMENT_BIT) {
+ color_count++;
}
}
+
+ ERR_FAIL_COND_V_MSG(p_clear_color_values.size() != color_count, ERR_INVALID_PARAMETER,
+ "Clear color values supplied (" + itos(p_clear_color_values.size()) + ") differ from the amount required for framebuffer (" + itos(color_count) + ").");
}
VkFramebuffer vkframebuffer;
VkRenderPass render_pass;
- Error err = _draw_list_setup_framebuffer(framebuffer, p_initial_color_action, p_final_color_action, p_initial_depth_action, p_final_depth_action, &vkframebuffer, &render_pass);
+ Error err = _draw_list_setup_framebuffer(framebuffer, p_initial_color_action, p_final_color_action, p_initial_depth_action, p_final_depth_action, &vkframebuffer, &render_pass, &draw_list_subpass_count);
ERR_FAIL_COND_V(err != OK, ERR_CANT_CREATE);
VkCommandBuffer frame_command_buffer = frames[frame].draw_command_buffer;
@@ -6299,53 +6538,24 @@ Error RenderingDeviceVulkan::draw_list_begin_split(RID p_framebuffer, uint32_t p
return ERR_CANT_CREATE;
}
- draw_list = memnew_arr(DrawList, p_splits);
- draw_list_count = p_splits;
- draw_list_split = true;
-
- for (uint32_t i = 0; i < p_splits; i++) {
- //take a command buffer and initialize it
- VkCommandBuffer command_buffer = split_draw_list_allocators[i].command_buffers[frame];
-
- VkCommandBufferInheritanceInfo inheritance_info;
- inheritance_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO;
- inheritance_info.pNext = nullptr;
- inheritance_info.renderPass = render_pass;
- inheritance_info.subpass = 0;
- inheritance_info.framebuffer = vkframebuffer;
- inheritance_info.occlusionQueryEnable = false;
- inheritance_info.queryFlags = 0; //?
- inheritance_info.pipelineStatistics = 0;
-
- VkCommandBufferBeginInfo cmdbuf_begin;
- cmdbuf_begin.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
- cmdbuf_begin.pNext = nullptr;
- cmdbuf_begin.flags = VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
- cmdbuf_begin.pInheritanceInfo = &inheritance_info;
-
- VkResult res = vkResetCommandBuffer(command_buffer, 0);
- if (res) {
- memdelete_arr(draw_list);
- draw_list = nullptr;
- ERR_FAIL_V_MSG(ERR_CANT_CREATE, "vkResetCommandBuffer failed with error " + itos(res) + ".");
- }
-
- res = vkBeginCommandBuffer(command_buffer, &cmdbuf_begin);
- if (res) {
- memdelete_arr(draw_list);
- draw_list = nullptr;
- ERR_FAIL_V_MSG(ERR_CANT_CREATE, "vkBeginCommandBuffer failed with error " + itos(res) + ".");
- }
+ draw_list_current_subpass = 0;
- draw_list[i].command_buffer = command_buffer;
#ifdef DEBUG_ENABLED
- draw_list[i].validation.framebuffer_format = framebuffer->format_id;
+ draw_list_framebuffer_format = framebuffer->format_id;
#endif
+ draw_list_render_pass = render_pass;
+ draw_list_vkframebuffer = vkframebuffer;
- if (i == 0 && (needs_clear_color || needs_clear_depth)) {
- _draw_list_insert_clear_region(draw_list, framebuffer, viewport_offset, viewport_size, needs_clear_color, p_clear_color_values, needs_clear_depth, p_clear_depth, p_clear_stencil);
- }
+ err = _draw_list_allocate(Rect2i(viewport_offset, viewport_size), p_splits, 0);
+ if (err != OK) {
+ return err;
+ }
+ if (needs_clear_color || needs_clear_depth) {
+ _draw_list_insert_clear_region(&draw_list[0], framebuffer, viewport_offset, viewport_size, needs_clear_color, p_clear_color_values, needs_clear_depth, p_clear_depth, p_clear_stencil);
+ }
+
+ for (uint32_t i = 0; i < p_splits; i++) {
VkViewport viewport;
viewport.x = viewport_offset.x;
viewport.y = viewport_offset.y;
@@ -6354,7 +6564,7 @@ Error RenderingDeviceVulkan::draw_list_begin_split(RID p_framebuffer, uint32_t p
viewport.minDepth = 0;
viewport.maxDepth = 1.0;
- vkCmdSetViewport(command_buffer, 0, 1, &viewport);
+ vkCmdSetViewport(draw_list[i].command_buffer, 0, 1, &viewport);
VkRect2D scissor;
scissor.offset.x = viewport_offset.x;
@@ -6362,10 +6572,8 @@ Error RenderingDeviceVulkan::draw_list_begin_split(RID p_framebuffer, uint32_t p
scissor.extent.width = viewport_size.width;
scissor.extent.height = viewport_size.height;
- vkCmdSetScissor(command_buffer, 0, 1, &scissor);
+ vkCmdSetScissor(draw_list[i].command_buffer, 0, 1, &scissor);
r_split_ids[i] = (int64_t(ID_TYPE_SPLIT_DRAW_LIST) << ID_BASE_SHIFT) + i;
-
- draw_list[i].viewport = Rect2i(viewport_offset, viewport_size);
}
return OK;
@@ -6410,7 +6618,7 @@ void RenderingDeviceVulkan::draw_list_bind_render_pipeline(DrawListID p_list, RI
const RenderPipeline *pipeline = render_pipeline_owner.getornull(p_render_pipeline);
ERR_FAIL_COND(!pipeline);
#ifdef DEBUG_ENABLED
- ERR_FAIL_COND(pipeline->validation.framebuffer_format != dl->validation.framebuffer_format);
+ ERR_FAIL_COND(pipeline->validation.framebuffer_format != draw_list_framebuffer_format && pipeline->validation.render_pass != draw_list_current_subpass);
#endif
if (p_render_pipeline == dl->state.pipeline) {
@@ -6749,30 +6957,162 @@ void RenderingDeviceVulkan::draw_list_disable_scissor(DrawListID p_list) {
vkCmdSetScissor(dl->command_buffer, 0, 1, &scissor);
}
-void RenderingDeviceVulkan::draw_list_end(uint32_t p_post_barrier) {
- _THREAD_SAFE_METHOD_
+RenderingDevice::DrawListID RenderingDeviceVulkan::draw_list_switch_to_next_pass() {
+ ERR_FAIL_COND_V(draw_list == nullptr, INVALID_ID);
+ ERR_FAIL_COND_V(draw_list_current_subpass >= draw_list_subpass_count - 1, INVALID_FORMAT_ID);
- ERR_FAIL_COND_MSG(!draw_list, "Immediate draw list is already inactive.");
+ draw_list_current_subpass++;
+
+ Rect2i viewport;
+ _draw_list_free(&viewport);
+
+ vkCmdNextSubpass(frames[frame].draw_command_buffer, VK_SUBPASS_CONTENTS_INLINE);
+
+ _draw_list_allocate(viewport, 0, draw_list_current_subpass);
+
+ return int64_t(ID_TYPE_DRAW_LIST) << ID_BASE_SHIFT;
+}
+Error RenderingDeviceVulkan::draw_list_switch_to_next_pass_split(uint32_t p_splits, DrawListID *r_split_ids) {
+ ERR_FAIL_COND_V(draw_list == nullptr, ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V(draw_list_current_subpass >= draw_list_subpass_count - 1, ERR_INVALID_PARAMETER);
+
+ draw_list_current_subpass++;
+
+ Rect2i viewport;
+ _draw_list_free(&viewport);
+
+ vkCmdNextSubpass(frames[frame].draw_command_buffer, VK_SUBPASS_CONTENTS_INLINE);
+
+ _draw_list_allocate(viewport, p_splits, draw_list_current_subpass);
+
+ for (uint32_t i = 0; i < p_splits; i++) {
+ r_split_ids[i] = (int64_t(ID_TYPE_SPLIT_DRAW_LIST) << ID_BASE_SHIFT) + i;
+ }
+
+ return OK;
+}
+Error RenderingDeviceVulkan::_draw_list_allocate(const Rect2i &p_viewport, uint32_t p_splits, uint32_t p_subpass) {
+ if (p_splits == 0) {
+ draw_list = memnew(DrawList);
+ draw_list->command_buffer = frames[frame].draw_command_buffer;
+ draw_list->viewport = p_viewport;
+ draw_list_count = 0;
+ draw_list_split = false;
+ } else {
+ if (p_splits > (uint32_t)split_draw_list_allocators.size()) {
+ uint32_t from = split_draw_list_allocators.size();
+ split_draw_list_allocators.resize(p_splits);
+ for (uint32_t i = from; i < p_splits; i++) {
+ VkCommandPoolCreateInfo cmd_pool_info;
+ cmd_pool_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
+ cmd_pool_info.pNext = nullptr;
+ cmd_pool_info.queueFamilyIndex = context->get_graphics_queue();
+ cmd_pool_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
+
+ VkResult res = vkCreateCommandPool(device, &cmd_pool_info, nullptr, &split_draw_list_allocators.write[i].command_pool);
+ ERR_FAIL_COND_V_MSG(res, ERR_CANT_CREATE, "vkCreateCommandPool failed with error " + itos(res) + ".");
+
+ for (int j = 0; j < frame_count; j++) {
+ VkCommandBuffer command_buffer;
+
+ VkCommandBufferAllocateInfo cmdbuf;
+ //no command buffer exists, create it.
+ cmdbuf.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
+ cmdbuf.pNext = nullptr;
+ cmdbuf.commandPool = split_draw_list_allocators[i].command_pool;
+ cmdbuf.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY;
+ cmdbuf.commandBufferCount = 1;
+
+ VkResult err = vkAllocateCommandBuffers(device, &cmdbuf, &command_buffer);
+ ERR_FAIL_COND_V_MSG(err, ERR_CANT_CREATE, "vkAllocateCommandBuffers failed with error " + itos(err) + ".");
+
+ split_draw_list_allocators.write[i].command_buffers.push_back(command_buffer);
+ }
+ }
+ }
+ draw_list = memnew_arr(DrawList, p_splits);
+ draw_list_count = p_splits;
+ draw_list_split = true;
+
+ for (uint32_t i = 0; i < p_splits; i++) {
+ //take a command buffer and initialize it
+ VkCommandBuffer command_buffer = split_draw_list_allocators[i].command_buffers[frame];
+
+ VkCommandBufferInheritanceInfo inheritance_info;
+ inheritance_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO;
+ inheritance_info.pNext = nullptr;
+ inheritance_info.renderPass = draw_list_render_pass;
+ inheritance_info.subpass = p_subpass;
+ inheritance_info.framebuffer = draw_list_vkframebuffer;
+ inheritance_info.occlusionQueryEnable = false;
+ inheritance_info.queryFlags = 0; //?
+ inheritance_info.pipelineStatistics = 0;
+
+ VkCommandBufferBeginInfo cmdbuf_begin;
+ cmdbuf_begin.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
+ cmdbuf_begin.pNext = nullptr;
+ cmdbuf_begin.flags = VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
+ cmdbuf_begin.pInheritanceInfo = &inheritance_info;
+
+ VkResult res = vkResetCommandBuffer(command_buffer, 0);
+ if (res) {
+ memdelete_arr(draw_list);
+ draw_list = nullptr;
+ ERR_FAIL_V_MSG(ERR_CANT_CREATE, "vkResetCommandBuffer failed with error " + itos(res) + ".");
+ }
+
+ res = vkBeginCommandBuffer(command_buffer, &cmdbuf_begin);
+ if (res) {
+ memdelete_arr(draw_list);
+ draw_list = nullptr;
+ ERR_FAIL_V_MSG(ERR_CANT_CREATE, "vkBeginCommandBuffer failed with error " + itos(res) + ".");
+ }
+
+ draw_list[i].command_buffer = command_buffer;
+ draw_list[i].viewport = p_viewport;
+ }
+ }
+
+ return OK;
+}
+
+void RenderingDeviceVulkan::_draw_list_free(Rect2i *r_last_viewport) {
if (draw_list_split) {
//send all command buffers
VkCommandBuffer *command_buffers = (VkCommandBuffer *)alloca(sizeof(VkCommandBuffer) * draw_list_count);
for (uint32_t i = 0; i < draw_list_count; i++) {
vkEndCommandBuffer(draw_list[i].command_buffer);
command_buffers[i] = draw_list[i].command_buffer;
+ if (r_last_viewport) {
+ if (i == 0 || draw_list[i].viewport_set) {
+ *r_last_viewport = draw_list[i].viewport;
+ }
+ }
}
vkCmdExecuteCommands(frames[frame].draw_command_buffer, draw_list_count, command_buffers);
- vkCmdEndRenderPass(frames[frame].draw_command_buffer);
memdelete_arr(draw_list);
draw_list = nullptr;
} else {
+ if (r_last_viewport) {
+ *r_last_viewport = draw_list->viewport;
+ }
//just end the list
- vkCmdEndRenderPass(draw_list->command_buffer);
memdelete(draw_list);
draw_list = nullptr;
}
+}
+
+void RenderingDeviceVulkan::draw_list_end(uint32_t p_post_barrier) {
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND_MSG(!draw_list, "Immediate draw list is already inactive.");
+
+ _draw_list_free();
+
+ vkCmdEndRenderPass(frames[frame].draw_command_buffer);
for (int i = 0; i < draw_list_bound_textures.size(); i++) {
Texture *texture = texture_owner.getornull(draw_list_bound_textures[i]);
diff --git a/drivers/vulkan/rendering_device_vulkan.h b/drivers/vulkan/rendering_device_vulkan.h
index f4fe9cf956..9f5830103d 100644
--- a/drivers/vulkan/rendering_device_vulkan.h
+++ b/drivers/vulkan/rendering_device_vulkan.h
@@ -234,12 +234,87 @@ class RenderingDeviceVulkan : public RenderingDevice {
struct FramebufferFormatKey {
Vector<AttachmentFormat> attachments;
+ Vector<FramebufferPass> passes;
uint32_t view_count = 1;
bool operator<(const FramebufferFormatKey &p_key) const {
if (view_count != p_key.view_count) {
return view_count < p_key.view_count;
}
+ uint32_t pass_size = passes.size();
+ uint32_t key_pass_size = p_key.passes.size();
+ if (pass_size != key_pass_size) {
+ return pass_size < key_pass_size;
+ }
+ const FramebufferPass *pass_ptr = passes.ptr();
+ const FramebufferPass *key_pass_ptr = p_key.passes.ptr();
+
+ for (uint32_t i = 0; i < pass_size; i++) {
+ { //compare color attachments
+ uint32_t attachment_size = pass_ptr[i].color_attachments.size();
+ uint32_t key_attachment_size = key_pass_ptr[i].color_attachments.size();
+ if (attachment_size != key_attachment_size) {
+ return attachment_size < key_attachment_size;
+ }
+ const int32_t *pass_attachment_ptr = pass_ptr[i].color_attachments.ptr();
+ const int32_t *key_pass_attachment_ptr = key_pass_ptr[i].color_attachments.ptr();
+
+ for (uint32_t j = 0; j < attachment_size; j++) {
+ if (pass_attachment_ptr[j] != key_pass_attachment_ptr[j]) {
+ return pass_attachment_ptr[j] < key_pass_attachment_ptr[j];
+ }
+ }
+ }
+ { //compare input attachments
+ uint32_t attachment_size = pass_ptr[i].input_attachments.size();
+ uint32_t key_attachment_size = key_pass_ptr[i].input_attachments.size();
+ if (attachment_size != key_attachment_size) {
+ return attachment_size < key_attachment_size;
+ }
+ const int32_t *pass_attachment_ptr = pass_ptr[i].input_attachments.ptr();
+ const int32_t *key_pass_attachment_ptr = key_pass_ptr[i].input_attachments.ptr();
+
+ for (uint32_t j = 0; j < attachment_size; j++) {
+ if (pass_attachment_ptr[j] != key_pass_attachment_ptr[j]) {
+ return pass_attachment_ptr[j] < key_pass_attachment_ptr[j];
+ }
+ }
+ }
+ { //compare resolve attachments
+ uint32_t attachment_size = pass_ptr[i].resolve_attachments.size();
+ uint32_t key_attachment_size = key_pass_ptr[i].resolve_attachments.size();
+ if (attachment_size != key_attachment_size) {
+ return attachment_size < key_attachment_size;
+ }
+ const int32_t *pass_attachment_ptr = pass_ptr[i].resolve_attachments.ptr();
+ const int32_t *key_pass_attachment_ptr = key_pass_ptr[i].resolve_attachments.ptr();
+
+ for (uint32_t j = 0; j < attachment_size; j++) {
+ if (pass_attachment_ptr[j] != key_pass_attachment_ptr[j]) {
+ return pass_attachment_ptr[j] < key_pass_attachment_ptr[j];
+ }
+ }
+ }
+ { //compare preserve attachments
+ uint32_t attachment_size = pass_ptr[i].preserve_attachments.size();
+ uint32_t key_attachment_size = key_pass_ptr[i].preserve_attachments.size();
+ if (attachment_size != key_attachment_size) {
+ return attachment_size < key_attachment_size;
+ }
+ const int32_t *pass_attachment_ptr = pass_ptr[i].preserve_attachments.ptr();
+ const int32_t *key_pass_attachment_ptr = key_pass_ptr[i].preserve_attachments.ptr();
+
+ for (uint32_t j = 0; j < attachment_size; j++) {
+ if (pass_attachment_ptr[j] != key_pass_attachment_ptr[j]) {
+ return pass_attachment_ptr[j] < key_pass_attachment_ptr[j];
+ }
+ }
+ }
+ if (pass_ptr[i].depth_attachment != key_pass_ptr[i].depth_attachment) {
+ return pass_ptr[i].depth_attachment < key_pass_ptr[i].depth_attachment;
+ }
+ }
+
int as = attachments.size();
int bs = p_key.attachments.size();
if (as != bs) {
@@ -266,16 +341,14 @@ class RenderingDeviceVulkan : public RenderingDevice {
}
};
- VkRenderPass _render_pass_create(const Vector<AttachmentFormat> &p_format, InitialAction p_initial_action, FinalAction p_final_action, InitialAction p_initial_depth_action, FinalAction p_final_depthcolor_action, int *r_color_attachment_count = nullptr, uint32_t p_view_count = 1);
-
+ VkRenderPass _render_pass_create(const Vector<AttachmentFormat> &p_attachments, const Vector<FramebufferPass> &p_passes, InitialAction p_initial_action, FinalAction p_final_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, uint32_t p_view_count = 1, Vector<TextureSamples> *r_samples = nullptr);
// This is a cache and it's never freed, it ensures
// IDs for a given format are always unique.
Map<FramebufferFormatKey, FramebufferFormatID> framebuffer_format_cache;
struct FramebufferFormat {
const Map<FramebufferFormatKey, FramebufferFormatID>::Element *E;
VkRenderPass render_pass = VK_NULL_HANDLE; //here for constructing shaders, never used, see section (7.2. Render Pass Compatibility from Vulkan spec)
- int color_attachments = 0; //used for pipeline validation
- TextureSamples samples;
+ Vector<TextureSamples> pass_samples;
uint32_t view_count = 1; // number of views
};
@@ -289,6 +362,7 @@ class RenderingDeviceVulkan : public RenderingDevice {
InitialAction initial_depth_action;
FinalAction final_depth_action;
uint32_t view_count;
+
bool operator<(const VersionKey &p_key) const {
if (initial_color_action == p_key.initial_color_action) {
if (final_color_action == p_key.final_color_action) {
@@ -316,6 +390,7 @@ class RenderingDeviceVulkan : public RenderingDevice {
struct Version {
VkFramebuffer framebuffer = VK_NULL_HANDLE;
VkRenderPass render_pass = VK_NULL_HANDLE; //this one is owned
+ uint32_t subpass_count = 1;
};
Map<VersionKey, Version> framebuffers;
@@ -536,7 +611,7 @@ class RenderingDeviceVulkan : public RenderingDevice {
};
uint32_t vertex_input_mask = 0; //inputs used, this is mostly for validation
- int fragment_outputs = 0;
+ uint32_t fragment_output_mask = 0;
struct PushConstant {
uint32_t push_constant_size = 0;
@@ -680,6 +755,7 @@ class RenderingDeviceVulkan : public RenderingDevice {
#ifdef DEBUG_ENABLED
struct Validation {
FramebufferFormatID framebuffer_format = 0;
+ uint32_t render_pass = 0;
uint32_t dynamic_state = 0;
VertexFormatID vertex_format = 0;
bool uses_restart_indices = false;
@@ -735,6 +811,7 @@ class RenderingDeviceVulkan : public RenderingDevice {
struct DrawList {
VkCommandBuffer command_buffer = VK_NULL_HANDLE; // If persistent, this is owned, otherwise it's shared with the ringbuffer.
Rect2i viewport;
+ bool viewport_set = false;
struct SetState {
uint32_t pipeline_expected_format = 0;
@@ -758,7 +835,6 @@ class RenderingDeviceVulkan : public RenderingDevice {
#ifdef DEBUG_ENABLED
struct Validation {
bool active = true; // Means command buffer was not closed, so you can keep adding things.
- FramebufferFormatID framebuffer_format = INVALID_ID;
// Actual render pass values.
uint32_t dynamic_state = 0;
VertexFormatID vertex_format = INVALID_ID;
@@ -794,7 +870,15 @@ class RenderingDeviceVulkan : public RenderingDevice {
};
DrawList *draw_list = nullptr; // One for regular draw lists, multiple for split.
+ uint32_t draw_list_subpass_count = 0;
uint32_t draw_list_count = 0;
+ VkRenderPass draw_list_render_pass;
+ VkFramebuffer draw_list_vkframebuffer;
+#ifdef DEBUG_ENABLED
+ FramebufferFormatID draw_list_framebuffer_format = INVALID_ID;
+#endif
+ uint32_t draw_list_current_subpass = 0;
+
bool draw_list_split = false;
Vector<RID> draw_list_bound_textures;
Vector<RID> draw_list_storage_textures;
@@ -802,10 +886,12 @@ class RenderingDeviceVulkan : public RenderingDevice {
bool draw_list_unbind_depth_textures = false;
void _draw_list_insert_clear_region(DrawList *draw_list, Framebuffer *framebuffer, Point2i viewport_offset, Point2i viewport_size, bool p_clear_color, const Vector<Color> &p_clear_colors, bool p_clear_depth, float p_depth, uint32_t p_stencil);
- Error _draw_list_setup_framebuffer(Framebuffer *p_framebuffer, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, VkFramebuffer *r_framebuffer, VkRenderPass *r_render_pass);
+ Error _draw_list_setup_framebuffer(Framebuffer *p_framebuffer, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, VkFramebuffer *r_framebuffer, VkRenderPass *r_render_pass, uint32_t *r_subpass_count);
Error _draw_list_render_pass_begin(Framebuffer *framebuffer, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, const Vector<Color> &p_clear_colors, float p_clear_depth, uint32_t p_clear_stencil, Point2i viewport_offset, Point2i viewport_size, VkFramebuffer vkframebuffer, VkRenderPass render_pass, VkCommandBuffer command_buffer, VkSubpassContents subpass_contents, const Vector<RID> &p_storage_textures);
_FORCE_INLINE_ DrawList *_get_draw_list_ptr(DrawListID p_id);
Buffer *_get_buffer_from_owner(RID p_buffer, VkPipelineStageFlags &dst_stage_mask, VkAccessFlags &dst_access, uint32_t p_post_barrier);
+ Error _draw_list_allocate(const Rect2i &p_viewport, uint32_t p_splits, uint32_t p_subpass);
+ void _draw_list_free(Rect2i *r_last_viewport = nullptr);
/**********************/
/**** COMPUTE LIST ****/
@@ -951,10 +1037,12 @@ public:
/*********************/
virtual FramebufferFormatID framebuffer_format_create(const Vector<AttachmentFormat> &p_format, uint32_t p_view_count = 1);
+ virtual FramebufferFormatID framebuffer_format_create_multipass(const Vector<AttachmentFormat> &p_attachments, Vector<FramebufferPass> &p_passes, uint32_t p_view_count = 1);
virtual FramebufferFormatID framebuffer_format_create_empty(TextureSamples p_samples = TEXTURE_SAMPLES_1);
- virtual TextureSamples framebuffer_format_get_texture_samples(FramebufferFormatID p_format);
+ virtual TextureSamples framebuffer_format_get_texture_samples(FramebufferFormatID p_format, uint32_t p_pass = 0);
virtual RID framebuffer_create(const Vector<RID> &p_texture_attachments, FramebufferFormatID p_format_check = INVALID_ID, uint32_t p_view_count = 1);
+ virtual RID framebuffer_create_multipass(const Vector<RID> &p_texture_attachments, Vector<FramebufferPass> &p_passes, FramebufferFormatID p_format_check = INVALID_ID, uint32_t p_view_count = 1);
virtual RID framebuffer_create_empty(const Size2i &p_size, TextureSamples p_samples = TEXTURE_SAMPLES_1, FramebufferFormatID p_format_check = INVALID_ID);
virtual FramebufferFormatID framebuffer_get_format(RID p_framebuffer);
@@ -1005,7 +1093,7 @@ public:
/**** RENDER PIPELINE ****/
/*************************/
- virtual RID render_pipeline_create(RID p_shader, FramebufferFormatID p_framebuffer_format, VertexFormatID p_vertex_format, RenderPrimitive p_render_primitive, const PipelineRasterizationState &p_rasterization_state, const PipelineMultisampleState &p_multisample_state, const PipelineDepthStencilState &p_depth_stencil_state, const PipelineColorBlendState &p_blend_state, int p_dynamic_state_flags = 0);
+ virtual RID render_pipeline_create(RID p_shader, FramebufferFormatID p_framebuffer_format, VertexFormatID p_vertex_format, RenderPrimitive p_render_primitive, const PipelineRasterizationState &p_rasterization_state, const PipelineMultisampleState &p_multisample_state, const PipelineDepthStencilState &p_depth_stencil_state, const PipelineColorBlendState &p_blend_state, int p_dynamic_state_flags = 0, uint32_t p_for_render_pass = 0);
virtual bool render_pipeline_is_valid(RID p_pipeline);
/**************************/
@@ -1044,6 +1132,9 @@ public:
virtual void draw_list_enable_scissor(DrawListID p_list, const Rect2 &p_rect);
virtual void draw_list_disable_scissor(DrawListID p_list);
+ virtual DrawListID draw_list_switch_to_next_pass();
+ virtual Error draw_list_switch_to_next_pass_split(uint32_t p_splits, DrawListID *r_split_ids);
+
virtual void draw_list_end(uint32_t p_post_barrier = BARRIER_MASK_ALL);
/***********************/
diff --git a/drivers/vulkan/vulkan_context.cpp b/drivers/vulkan/vulkan_context.cpp
index 6ed43b5d31..9939611a83 100644
--- a/drivers/vulkan/vulkan_context.cpp
+++ b/drivers/vulkan/vulkan_context.cpp
@@ -1013,11 +1013,11 @@ Error VulkanContext::_create_device() {
return OK;
}
-Error VulkanContext::_initialize_queues(VkSurfaceKHR surface) {
+Error VulkanContext::_initialize_queues(VkSurfaceKHR p_surface) {
// Iterate over each queue to learn whether it supports presenting:
VkBool32 *supportsPresent = (VkBool32 *)malloc(queue_family_count * sizeof(VkBool32));
for (uint32_t i = 0; i < queue_family_count; i++) {
- fpGetPhysicalDeviceSurfaceSupportKHR(gpu, i, surface, &supportsPresent[i]);
+ fpGetPhysicalDeviceSurfaceSupportKHR(gpu, i, p_surface, &supportsPresent[i]);
}
// Search for a graphics and a present queue in the array of queue
@@ -1091,10 +1091,10 @@ Error VulkanContext::_initialize_queues(VkSurfaceKHR surface) {
// Get the list of VkFormat's that are supported:
uint32_t formatCount;
- VkResult err = fpGetPhysicalDeviceSurfaceFormatsKHR(gpu, surface, &formatCount, nullptr);
+ VkResult err = fpGetPhysicalDeviceSurfaceFormatsKHR(gpu, p_surface, &formatCount, nullptr);
ERR_FAIL_COND_V(err, ERR_CANT_CREATE);
VkSurfaceFormatKHR *surfFormats = (VkSurfaceFormatKHR *)malloc(formatCount * sizeof(VkSurfaceFormatKHR));
- err = fpGetPhysicalDeviceSurfaceFormatsKHR(gpu, surface, &formatCount, surfFormats);
+ err = fpGetPhysicalDeviceSurfaceFormatsKHR(gpu, p_surface, &formatCount, surfFormats);
if (err) {
free(surfFormats);
ERR_FAIL_V(ERR_CANT_CREATE);
@@ -1169,9 +1169,6 @@ Error VulkanContext::_create_semaphores() {
err = vkCreateFence(device, &fence_ci, nullptr, &fences[i]);
ERR_FAIL_COND_V(err, ERR_CANT_CREATE);
- err = vkCreateSemaphore(device, &semaphoreCreateInfo, nullptr, &image_acquired_semaphores[i]);
- ERR_FAIL_COND_V(err, ERR_CANT_CREATE);
-
err = vkCreateSemaphore(device, &semaphoreCreateInfo, nullptr, &draw_complete_semaphores[i]);
ERR_FAIL_COND_V(err, ERR_CANT_CREATE);
@@ -1201,6 +1198,19 @@ Error VulkanContext::_window_create(DisplayServer::WindowID p_window_id, VkSurfa
// is created.
Error err = _initialize_queues(p_surface);
ERR_FAIL_COND_V(err != OK, ERR_CANT_CREATE);
+ } else {
+ // make sure any of the surfaces supports present (validation layer complains if this is not done).
+ bool any_supports_present = false;
+ for (uint32_t i = 0; i < queue_family_count; i++) {
+ VkBool32 supports;
+ fpGetPhysicalDeviceSurfaceSupportKHR(gpu, i, p_surface, &supports);
+ if (supports) {
+ any_supports_present = true;
+ break;
+ }
+ }
+
+ ERR_FAIL_COND_V_MSG(!any_supports_present, ERR_CANT_CREATE, "Surface passed for sub-window creation does not support presenting");
}
Window window;
@@ -1210,6 +1220,17 @@ Error VulkanContext::_window_create(DisplayServer::WindowID p_window_id, VkSurfa
Error err = _update_swap_chain(&window);
ERR_FAIL_COND_V(err != OK, ERR_CANT_CREATE);
+ VkSemaphoreCreateInfo semaphoreCreateInfo = {
+ /*sType*/ VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO,
+ /*pNext*/ nullptr,
+ /*flags*/ 0,
+ };
+
+ for (uint32_t i = 0; i < FRAME_LAG; i++) {
+ VkResult vkerr = vkCreateSemaphore(device, &semaphoreCreateInfo, nullptr, &window.image_acquired_semaphores[i]);
+ ERR_FAIL_COND_V(vkerr, ERR_CANT_CREATE);
+ }
+
windows[p_window_id] = window;
return OK;
}
@@ -1249,6 +1270,10 @@ VkFramebuffer VulkanContext::window_get_framebuffer(DisplayServer::WindowID p_wi
void VulkanContext::window_destroy(DisplayServer::WindowID p_window_id) {
ERR_FAIL_COND(!windows.has(p_window_id));
_clean_up_swap_chain(&windows[p_window_id]);
+ for (uint32_t i = 0; i < FRAME_LAG; i++) {
+ vkDestroySemaphore(device, windows[p_window_id].image_acquired_semaphores[i], nullptr);
+ }
+
vkDestroySurfaceKHR(inst, windows[p_window_id].surface, nullptr);
windows.erase(p_window_id);
}
@@ -1703,6 +1728,8 @@ Error VulkanContext::prepare_buffers() {
for (Map<int, Window>::Element *E = windows.front(); E; E = E->next()) {
Window *w = &E->get();
+ w->semaphore_acquired = false;
+
if (w->swapchain == VK_NULL_HANDLE) {
continue;
}
@@ -1711,7 +1738,7 @@ Error VulkanContext::prepare_buffers() {
// Get the index of the next available swapchain image:
err =
fpAcquireNextImageKHR(device, w->swapchain, UINT64_MAX,
- image_acquired_semaphores[frame_index], VK_NULL_HANDLE, &w->current_buffer);
+ w->image_acquired_semaphores[frame_index], VK_NULL_HANDLE, &w->current_buffer);
if (err == VK_ERROR_OUT_OF_DATE_KHR) {
// swapchain is out of date (e.g. the window was resized) and
@@ -1724,8 +1751,10 @@ Error VulkanContext::prepare_buffers() {
// presentation engine will still present the image correctly.
print_verbose("Vulkan: Early suboptimal swapchain.");
break;
+ } else if (err != VK_SUCCESS) {
+ ERR_BREAK(ERR_CANT_CREATE);
} else {
- ERR_FAIL_COND_V(err, ERR_CANT_CREATE);
+ w->semaphore_acquired = true;
}
} while (err != VK_SUCCESS);
}
@@ -1775,14 +1804,25 @@ Error VulkanContext::swap_buffers() {
commands_to_submit = command_buffer_count;
}
+ VkSemaphore *semaphores_to_acquire = (VkSemaphore *)alloca(windows.size() * sizeof(VkSemaphore));
+ uint32_t semaphores_to_acquire_count = 0;
+
+ for (Map<int, Window>::Element *E = windows.front(); E; E = E->next()) {
+ Window *w = &E->get();
+
+ if (w->semaphore_acquired) {
+ semaphores_to_acquire[semaphores_to_acquire_count++] = w->image_acquired_semaphores[frame_index];
+ }
+ }
+
VkPipelineStageFlags pipe_stage_flags;
VkSubmitInfo submit_info;
submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
submit_info.pNext = nullptr;
submit_info.pWaitDstStageMask = &pipe_stage_flags;
pipe_stage_flags = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
- submit_info.waitSemaphoreCount = 1;
- submit_info.pWaitSemaphores = &image_acquired_semaphores[frame_index];
+ submit_info.waitSemaphoreCount = semaphores_to_acquire_count;
+ submit_info.pWaitSemaphores = semaphores_to_acquire;
submit_info.commandBufferCount = commands_to_submit;
submit_info.pCommandBuffers = commands_ptr;
submit_info.signalSemaphoreCount = 1;
@@ -2134,7 +2174,6 @@ VulkanContext::~VulkanContext() {
if (device_initialized) {
for (uint32_t i = 0; i < FRAME_LAG; i++) {
vkDestroyFence(device, fences[i], nullptr);
- vkDestroySemaphore(device, image_acquired_semaphores[i], nullptr);
vkDestroySemaphore(device, draw_complete_semaphores[i], nullptr);
if (separate_present_queue) {
vkDestroySemaphore(device, image_ownership_semaphores[i], nullptr);
diff --git a/drivers/vulkan/vulkan_context.h b/drivers/vulkan/vulkan_context.h
index 738ead4f96..8f1005d07f 100644
--- a/drivers/vulkan/vulkan_context.h
+++ b/drivers/vulkan/vulkan_context.h
@@ -70,7 +70,6 @@ private:
};
VkInstance inst = VK_NULL_HANDLE;
- VkSurfaceKHR surface = VK_NULL_HANDLE;
VkPhysicalDevice gpu = VK_NULL_HANDLE;
VkPhysicalDeviceProperties gpu_props;
uint32_t queue_family_count = 0;
@@ -101,7 +100,6 @@ private:
VkQueue present_queue = VK_NULL_HANDLE;
VkColorSpaceKHR color_space;
VkFormat format;
- VkSemaphore image_acquired_semaphores[FRAME_LAG];
VkSemaphore draw_complete_semaphores[FRAME_LAG];
VkSemaphore image_ownership_semaphores[FRAME_LAG];
int frame_index = 0;
@@ -121,6 +119,8 @@ private:
VkSwapchainKHR swapchain = VK_NULL_HANDLE;
SwapchainImageResources *swapchain_image_resources = VK_NULL_HANDLE;
VkPresentModeKHR presentMode = VK_PRESENT_MODE_FIFO_KHR;
+ VkSemaphore image_acquired_semaphores[FRAME_LAG];
+ bool semaphore_acquired = false;
uint32_t current_buffer = 0;
int width = 0;
int height = 0;
@@ -208,7 +208,7 @@ private:
Error _create_physical_device();
- Error _initialize_queues(VkSurfaceKHR surface);
+ Error _initialize_queues(VkSurfaceKHR p_surface);
Error _create_device();
diff --git a/editor/action_map_editor.cpp b/editor/action_map_editor.cpp
index b0b79ca069..fe1401bdf9 100644
--- a/editor/action_map_editor.cpp
+++ b/editor/action_map_editor.cpp
@@ -310,7 +310,7 @@ void InputEventConfigurationDialog::_update_input_list() {
MouseButton mouse_buttons[9] = { MOUSE_BUTTON_LEFT, MOUSE_BUTTON_RIGHT, MOUSE_BUTTON_MIDDLE, MOUSE_BUTTON_WHEEL_UP, MOUSE_BUTTON_WHEEL_DOWN, MOUSE_BUTTON_WHEEL_LEFT, MOUSE_BUTTON_WHEEL_RIGHT, MOUSE_BUTTON_XBUTTON1, MOUSE_BUTTON_XBUTTON2 };
for (int i = 0; i < 9; i++) {
Ref<InputEventMouseButton> mb;
- mb.instance();
+ mb.instantiate();
mb->set_button_index(mouse_buttons[i]);
String desc = get_event_text(mb);
@@ -333,8 +333,8 @@ void InputEventConfigurationDialog::_update_input_list() {
for (int i = 0; i < JOY_BUTTON_MAX; i++) {
Ref<InputEventJoypadButton> joyb;
- joyb.instance();
- joyb->set_button_index(i);
+ joyb.instantiate();
+ joyb->set_button_index((JoyButton)i);
String desc = get_event_text(joyb);
if (!search_term.is_empty() && desc.findn(search_term) == -1) {
@@ -358,8 +358,8 @@ void InputEventConfigurationDialog::_update_input_list() {
int axis = i / 2;
int direction = (i & 1) ? 1 : -1;
Ref<InputEventJoypadMotion> joym;
- joym.instance();
- joym->set_axis(axis);
+ joym.instantiate();
+ joym->set_axis((JoyAxis)axis);
joym->set_axis_value(direction);
String desc = get_event_text(joym);
@@ -458,7 +458,7 @@ void InputEventConfigurationDialog::_input_list_item_selected() {
case InputEventConfigurationDialog::INPUT_KEY: {
int kc = selected->get_meta("__keycode");
Ref<InputEventKey> k;
- k.instance();
+ k.instantiate();
if (physical_key_checkbox->is_pressed()) {
k->set_physical_keycode(kc);
@@ -481,8 +481,8 @@ void InputEventConfigurationDialog::_input_list_item_selected() {
case InputEventConfigurationDialog::INPUT_MOUSE_BUTTON: {
int idx = selected->get_meta("__index");
Ref<InputEventMouseButton> mb;
- mb.instance();
- mb->set_button_index(idx);
+ mb.instantiate();
+ mb->set_button_index((MouseButton)idx);
// Maintain modifier state from checkboxes
mb->set_alt_pressed(mod_checkboxes[MOD_ALT]->is_pressed());
mb->set_shift_pressed(mod_checkboxes[MOD_SHIFT]->is_pressed());
@@ -495,7 +495,7 @@ void InputEventConfigurationDialog::_input_list_item_selected() {
} break;
case InputEventConfigurationDialog::INPUT_JOY_BUTTON: {
int idx = selected->get_meta("__index");
- Ref<InputEventJoypadButton> jb = InputEventJoypadButton::create_reference(idx);
+ Ref<InputEventJoypadButton> jb = InputEventJoypadButton::create_reference((JoyButton)idx);
_set_event(jb);
} break;
case InputEventConfigurationDialog::INPUT_JOY_MOTION: {
@@ -503,8 +503,8 @@ void InputEventConfigurationDialog::_input_list_item_selected() {
int value = selected->get_meta("__value");
Ref<InputEventJoypadMotion> jm;
- jm.instance();
- jm->set_axis(axis);
+ jm.instantiate();
+ jm->set_axis((JoyAxis)axis);
jm->set_axis_value(value);
_set_event(jm);
} break;
@@ -1125,9 +1125,9 @@ ActionMapEditor::ActionMapEditor() {
action_tree->set_column_title(0, TTR("Action"));
action_tree->set_column_title(1, TTR("Deadzone"));
action_tree->set_column_expand(1, false);
- action_tree->set_column_min_width(1, 80 * EDSCALE);
+ action_tree->set_column_custom_minimum_width(1, 80 * EDSCALE);
action_tree->set_column_expand(2, false);
- action_tree->set_column_min_width(2, 50 * EDSCALE);
+ action_tree->set_column_custom_minimum_width(2, 50 * EDSCALE);
action_tree->connect("item_edited", callable_mp(this, &ActionMapEditor::_action_edited));
action_tree->connect("item_activated", callable_mp(this, &ActionMapEditor::_tree_item_activated));
action_tree->connect("button_pressed", callable_mp(this, &ActionMapEditor::_tree_button_pressed));
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp
index 4196bc8940..f61fb6bab3 100644
--- a/editor/animation_track_editor.cpp
+++ b/editor/animation_track_editor.cpp
@@ -3760,7 +3760,7 @@ Ref<Animation> AnimationTrackEditor::_create_and_get_reset_animation() {
return player->get_animation("RESET");
} else {
Ref<Animation> reset_anim;
- reset_anim.instance();
+ reset_anim.instantiate();
reset_anim->set_length(ANIM_MIN_LENGTH);
undo_redo->add_do_method(player, "add_animation", "RESET", reset_anim);
undo_redo->add_do_method(AnimationPlayerEditor::singleton, "_animation_player_changed", player);
@@ -5983,7 +5983,7 @@ AnimationTrackEditor::AnimationTrackEditor() {
//default plugins
Ref<AnimationTrackEditDefaultPlugin> def_plugin;
- def_plugin.instance();
+ def_plugin.instantiate();
add_track_edit_plugin(def_plugin);
//dialogs
diff --git a/editor/audio_stream_preview.cpp b/editor/audio_stream_preview.cpp
index 539657afd7..ad6e3ac1dc 100644
--- a/editor/audio_stream_preview.cpp
+++ b/editor/audio_stream_preview.cpp
@@ -192,7 +192,7 @@ Ref<AudioStreamPreview> AudioStreamPreviewGenerator::generate_preview(const Ref<
}
}
- preview->preview.instance();
+ preview->preview.instantiate();
preview->preview->preview = maxmin;
preview->preview->length = len_s;
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index 7f91ae28a4..3e4f382383 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -105,6 +105,11 @@ void FindReplaceBar::_notification(int p_what) {
hide_button->set_custom_minimum_size(hide_button->get_normal_texture()->get_size());
} else if (p_what == NOTIFICATION_THEME_CHANGED) {
matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color("font_color", "Label") : get_theme_color("error_color", "Editor"));
+ } else if (p_what == NOTIFICATION_PREDELETE) {
+ if (base_text_editor) {
+ base_text_editor->remove_find_replace_bar();
+ base_text_editor = nullptr;
+ }
}
}
@@ -595,6 +600,10 @@ void FindReplaceBar::set_text_edit(CodeTextEditor *p_text_editor) {
text_editor = nullptr;
}
+ if (!p_text_editor) {
+ return;
+ }
+
results_count = -1;
base_text_editor = p_text_editor;
text_editor = base_text_editor->get_text_editor();
@@ -930,7 +939,7 @@ void CodeTextEditor::update_editor_settings() {
text_editor->set_highlight_current_line(EditorSettings::get_singleton()->get("text_editor/highlighting/highlight_current_line"));
text_editor->set_indent_using_spaces(EditorSettings::get_singleton()->get("text_editor/indent/type"));
text_editor->set_indent_size(EditorSettings::get_singleton()->get("text_editor/indent/size"));
- text_editor->set_auto_indent(EditorSettings::get_singleton()->get("text_editor/indent/auto_indent"));
+ text_editor->set_auto_indent_enabled(EditorSettings::get_singleton()->get("text_editor/indent/auto_indent"));
text_editor->set_draw_tabs(EditorSettings::get_singleton()->get("text_editor/indent/draw_tabs"));
text_editor->set_draw_spaces(EditorSettings::get_singleton()->get("text_editor/indent/draw_spaces"));
text_editor->set_smooth_scroll_enabled(EditorSettings::get_singleton()->get("text_editor/navigation/smooth_scrolling"));
@@ -1255,7 +1264,7 @@ void CodeTextEditor::_delete_line(int p_line) {
text_editor->cursor_set_line(1);
text_editor->cursor_set_column(0);
}
- text_editor->backspace_at_cursor();
+ text_editor->backspace();
text_editor->unfold_line(p_line);
text_editor->cursor_set_line(p_line);
}
@@ -1612,15 +1621,19 @@ void CodeTextEditor::validate_script() {
idle->start();
}
-void CodeTextEditor::_warning_label_gui_input(const Ref<InputEvent> &p_event) {
- Ref<InputEventMouseButton> mb = p_event;
- if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) {
- _warning_button_pressed();
- }
+void CodeTextEditor::_error_button_pressed() {
+ _set_show_errors_panel(!is_errors_panel_opened);
+ _set_show_warnings_panel(false);
}
void CodeTextEditor::_warning_button_pressed() {
_set_show_warnings_panel(!is_warnings_panel_opened);
+ _set_show_errors_panel(false);
+}
+
+void CodeTextEditor::_set_show_errors_panel(bool p_show) {
+ is_errors_panel_opened = p_show;
+ emit_signal("show_errors_panel", p_show);
}
void CodeTextEditor::_set_show_warnings_panel(bool p_show) {
@@ -1653,6 +1666,7 @@ void CodeTextEditor::_notification(int p_what) {
_update_font();
} break;
case NOTIFICATION_ENTER_TREE: {
+ error_button->set_icon(get_theme_icon("StatusError", "EditorIcons"));
warning_button->set_icon(get_theme_icon("NodeWarning", "EditorIcons"));
add_theme_constant_override("separation", 4 * EDSCALE);
} break;
@@ -1662,16 +1676,28 @@ void CodeTextEditor::_notification(int p_what) {
}
set_process_input(is_visible_in_tree());
} break;
+ case NOTIFICATION_PREDELETE: {
+ if (find_replace_bar) {
+ find_replace_bar->set_text_edit(nullptr);
+ }
+ } break;
default:
break;
}
}
-void CodeTextEditor::set_warning_nb(int p_warning_nb) {
- warning_count_label->set_text(itos(p_warning_nb));
- warning_count_label->set_visible(p_warning_nb > 0);
- warning_button->set_visible(p_warning_nb > 0);
- if (!p_warning_nb) {
+void CodeTextEditor::set_error_count(int p_error_count) {
+ error_button->set_text(itos(p_error_count));
+ error_button->set_visible(p_error_count > 0);
+ if (!p_error_count) {
+ _set_show_errors_panel(false);
+ }
+}
+
+void CodeTextEditor::set_warning_count(int p_warning_count) {
+ warning_button->set_text(itos(p_warning_count));
+ warning_button->set_visible(p_warning_count > 0);
+ if (!p_warning_count) {
_set_show_warnings_panel(false);
}
}
@@ -1738,6 +1764,7 @@ void CodeTextEditor::_bind_methods() {
ADD_SIGNAL(MethodInfo("validate_script"));
ADD_SIGNAL(MethodInfo("load_theme_settings"));
+ ADD_SIGNAL(MethodInfo("show_errors_panel"));
ADD_SIGNAL(MethodInfo("show_warnings_panel"));
}
@@ -1796,7 +1823,7 @@ CodeTextEditor::CodeTextEditor() {
text_editor->set_draw_line_numbers(true);
text_editor->set_brace_matching(true);
- text_editor->set_auto_indent(true);
+ text_editor->set_auto_indent_enabled(true);
status_bar = memnew(HBoxContainer);
add_child(status_bar);
@@ -1835,6 +1862,22 @@ CodeTextEditor::CodeTextEditor() {
error->set_mouse_filter(MOUSE_FILTER_STOP);
error->connect("gui_input", callable_mp(this, &CodeTextEditor::_error_pressed));
+ // Errors
+ error_button = memnew(Button);
+ error_button->set_flat(true);
+ status_bar->add_child(error_button);
+ error_button->set_v_size_flags(SIZE_EXPAND | SIZE_SHRINK_CENTER);
+ error_button->set_default_cursor_shape(CURSOR_POINTING_HAND);
+ error_button->connect("pressed", callable_mp(this, &CodeTextEditor::_error_button_pressed));
+ error_button->set_tooltip(TTR("Errors"));
+
+ error_button->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor"));
+ error_button->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("status_source", "EditorFonts"));
+ error_button->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("status_source_size", "EditorFonts"));
+
+ is_errors_panel_opened = false;
+ set_error_count(0);
+
// Warnings
warning_button = memnew(Button);
warning_button->set_flat(true);
@@ -1844,20 +1887,12 @@ CodeTextEditor::CodeTextEditor() {
warning_button->connect("pressed", callable_mp(this, &CodeTextEditor::_warning_button_pressed));
warning_button->set_tooltip(TTR("Warnings"));
- warning_count_label = memnew(Label);
- status_bar->add_child(warning_count_label);
- warning_count_label->set_v_size_flags(SIZE_EXPAND | SIZE_SHRINK_CENTER);
- warning_count_label->set_align(Label::ALIGN_RIGHT);
- warning_count_label->set_default_cursor_shape(CURSOR_POINTING_HAND);
- warning_count_label->set_mouse_filter(MOUSE_FILTER_STOP);
- warning_count_label->set_tooltip(TTR("Warnings"));
- warning_count_label->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("warning_color", "Editor"));
- warning_count_label->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("status_source", "EditorFonts"));
- warning_count_label->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("status_source_size", "EditorFonts"));
- warning_count_label->connect("gui_input", callable_mp(this, &CodeTextEditor::_warning_label_gui_input));
+ warning_button->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("warning_color", "Editor"));
+ warning_button->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("status_source", "EditorFonts"));
+ warning_button->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("status_source_size", "EditorFonts"));
is_warnings_panel_opened = false;
- set_warning_nb(0);
+ set_warning_count(0);
// Line and column
line_and_col_txt = memnew(Label);
diff --git a/editor/code_editor.h b/editor/code_editor.h
index f368305e85..28b09e0a5d 100644
--- a/editor/code_editor.h
+++ b/editor/code_editor.h
@@ -145,8 +145,8 @@ class CodeTextEditor : public VBoxContainer {
HBoxContainer *status_bar;
Button *toggle_scripts_button;
+ Button *error_button;
Button *warning_button;
- Label *warning_count_label;
Label *line_and_col_txt;
@@ -184,8 +184,9 @@ class CodeTextEditor : public VBoxContainer {
CodeTextEditorCodeCompleteFunc code_complete_func;
void *code_complete_ud;
- void _warning_label_gui_input(const Ref<InputEvent> &p_event);
+ void _error_button_pressed();
void _warning_button_pressed();
+ void _set_show_errors_panel(bool p_show);
void _set_show_warnings_panel(bool p_show);
void _error_pressed(const Ref<InputEvent> &p_event);
@@ -205,6 +206,7 @@ protected:
static void _bind_methods();
bool is_warnings_panel_opened;
+ bool is_errors_panel_opened;
public:
void trim_trailing_whitespace();
@@ -238,7 +240,8 @@ public:
Variant get_edit_state();
void set_edit_state(const Variant &p_state);
- void set_warning_nb(int p_warning_nb);
+ void set_error_count(int p_error_count);
+ void set_warning_count(int p_warning_count);
void update_editor_settings();
void set_error(const String &p_error);
diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp
index 968b24893c..027cee3f1c 100644
--- a/editor/create_dialog.cpp
+++ b/editor/create_dialog.cpp
@@ -130,7 +130,7 @@ bool CreateDialog::_should_hide_type(const String &p_type) const {
}
if (ClassDB::class_exists(p_type)) {
- if (!ClassDB::can_instance(p_type)) {
+ if (!ClassDB::can_instantiate(p_type)) {
return true; // Can't create abstract class.
}
@@ -234,8 +234,8 @@ void CreateDialog::_configure_search_option_item(TreeItem *r_item, const String
r_item->set_text(0, p_type);
}
- bool can_instance = (p_cpp_type && ClassDB::can_instance(p_type)) || !p_cpp_type;
- if (!can_instance) {
+ bool can_instantiate = (p_cpp_type && ClassDB::can_instantiate(p_type)) || !p_cpp_type;
+ if (!can_instantiate) {
r_item->set_custom_color(0, search_options->get_theme_color("disabled_font_color", "Editor"));
r_item->set_icon(0, EditorNode::get_singleton()->get_class_icon(p_type, "NodeDisabled"));
r_item->set_selectable(0, false);
@@ -247,7 +247,7 @@ void CreateDialog::_configure_search_option_item(TreeItem *r_item, const String
r_item->set_collapsed(false);
} else {
// Don't collapse the root node or an abstract node on the first tree level.
- bool should_collapse = p_type != base_type && (r_item->get_parent()->get_text(0) != base_type || can_instance);
+ bool should_collapse = p_type != base_type && (r_item->get_parent()->get_text(0) != base_type || can_instantiate);
if (should_collapse && bool(EditorSettings::get_singleton()->get("docks/scene_tree/start_create_dialog_fully_expanded"))) {
should_collapse = false; // Collapse all nodes anyway.
@@ -432,7 +432,7 @@ Variant CreateDialog::instance_selected() {
obj = EditorNode::get_editor_data().instance_custom_type(selected->get_text(0), custom);
}
} else {
- obj = ClassDB::instance(selected->get_text(0));
+ obj = ClassDB::instantiate(selected->get_text(0));
}
// Check if any Object-type property should be instantiated.
@@ -442,7 +442,7 @@ Variant CreateDialog::instance_selected() {
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
PropertyInfo pi = E->get();
if (pi.type == Variant::OBJECT && pi.usage & PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT) {
- Object *prop = ClassDB::instance(pi.class_name);
+ Object *prop = ClassDB::instantiate(pi.class_name);
((Object *)obj)->set(pi.name, prop);
}
}
diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp
index ded0ee3aa7..5f90680115 100644
--- a/editor/debugger/editor_debugger_node.cpp
+++ b/editor/debugger/editor_debugger_node.cpp
@@ -65,7 +65,7 @@ EditorDebuggerNode::EditorDebuggerNode() {
add_child(tabs);
Ref<StyleBoxEmpty> empty;
- empty.instance();
+ empty.instantiate();
tabs->add_theme_style_override("panel", empty);
auto_switch_remote_scene_tree = EDITOR_DEF("debugger/auto_switch_to_remote_scene_tree", false);
diff --git a/editor/debugger/editor_debugger_server.cpp b/editor/debugger/editor_debugger_server.cpp
index 662f247062..e8524e0702 100644
--- a/editor/debugger/editor_debugger_server.cpp
+++ b/editor/debugger/editor_debugger_server.cpp
@@ -60,7 +60,7 @@ EditorDebuggerServer *EditorDebuggerServerTCP::create(const String &p_protocol)
}
EditorDebuggerServerTCP::EditorDebuggerServerTCP() {
- server.instance();
+ server.instantiate();
}
Error EditorDebuggerServerTCP::start() {
diff --git a/editor/debugger/editor_network_profiler.cpp b/editor/debugger/editor_network_profiler.cpp
index 2d57dff69d..af83baeff8 100644
--- a/editor/debugger/editor_network_profiler.cpp
+++ b/editor/debugger/editor_network_profiler.cpp
@@ -178,19 +178,19 @@ EditorNetworkProfiler::EditorNetworkProfiler() {
counters_display->set_column_titles_visible(true);
counters_display->set_column_title(0, TTR("Node"));
counters_display->set_column_expand(0, true);
- counters_display->set_column_min_width(0, 60 * EDSCALE);
+ counters_display->set_column_custom_minimum_width(0, 60 * EDSCALE);
counters_display->set_column_title(1, TTR("Incoming RPC"));
counters_display->set_column_expand(1, false);
- counters_display->set_column_min_width(1, 120 * EDSCALE);
+ counters_display->set_column_custom_minimum_width(1, 120 * EDSCALE);
counters_display->set_column_title(2, TTR("Incoming RSET"));
counters_display->set_column_expand(2, false);
- counters_display->set_column_min_width(2, 120 * EDSCALE);
+ counters_display->set_column_custom_minimum_width(2, 120 * EDSCALE);
counters_display->set_column_title(3, TTR("Outgoing RPC"));
counters_display->set_column_expand(3, false);
- counters_display->set_column_min_width(3, 120 * EDSCALE);
+ counters_display->set_column_custom_minimum_width(3, 120 * EDSCALE);
counters_display->set_column_title(4, TTR("Outgoing RSET"));
counters_display->set_column_expand(4, false);
- counters_display->set_column_min_width(4, 120 * EDSCALE);
+ counters_display->set_column_custom_minimum_width(4, 120 * EDSCALE);
add_child(counters_display);
frame_delay = memnew(Timer);
diff --git a/editor/debugger/editor_profiler.cpp b/editor/debugger/editor_profiler.cpp
index d60e2783ec..449aaa42ff 100644
--- a/editor/debugger/editor_profiler.cpp
+++ b/editor/debugger/editor_profiler.cpp
@@ -305,12 +305,12 @@ void EditorProfiler::_update_plot() {
}
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create(w, h, false, Image::FORMAT_RGBA8, graph_image);
if (reset_texture) {
if (graph_texture.is_null()) {
- graph_texture.instance();
+ graph_texture.instantiate();
}
graph_texture->create_from_image(img);
}
@@ -631,13 +631,13 @@ EditorProfiler::EditorProfiler() {
variables->set_column_titles_visible(true);
variables->set_column_title(0, TTR("Name"));
variables->set_column_expand(0, true);
- variables->set_column_min_width(0, 60 * EDSCALE);
+ variables->set_column_custom_minimum_width(0, 60 * EDSCALE);
variables->set_column_title(1, TTR("Time"));
variables->set_column_expand(1, false);
- variables->set_column_min_width(1, 100 * EDSCALE);
+ variables->set_column_custom_minimum_width(1, 100 * EDSCALE);
variables->set_column_title(2, TTR("Calls"));
variables->set_column_expand(2, false);
- variables->set_column_min_width(2, 60 * EDSCALE);
+ variables->set_column_custom_minimum_width(2, 60 * EDSCALE);
variables->connect("item_edited", callable_mp(this, &EditorProfiler::_item_edited));
graph = memnew(TextureRect);
diff --git a/editor/debugger/editor_visual_profiler.cpp b/editor/debugger/editor_visual_profiler.cpp
index 5bb10b3794..d3948dee97 100644
--- a/editor/debugger/editor_visual_profiler.cpp
+++ b/editor/debugger/editor_visual_profiler.cpp
@@ -299,12 +299,12 @@ void EditorVisualProfiler::_update_plot() {
}
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create(w, h, false, Image::FORMAT_RGBA8, graph_image);
if (reset_texture) {
if (graph_texture.is_null()) {
- graph_texture.instance();
+ graph_texture.instantiate();
}
graph_texture->create_from_image(img);
}
@@ -773,13 +773,13 @@ EditorVisualProfiler::EditorVisualProfiler() {
variables->set_column_titles_visible(true);
variables->set_column_title(0, TTR("Name"));
variables->set_column_expand(0, true);
- variables->set_column_min_width(0, 60);
+ variables->set_column_custom_minimum_width(0, 60);
variables->set_column_title(1, TTR("CPU"));
variables->set_column_expand(1, false);
- variables->set_column_min_width(1, 60 * EDSCALE);
+ variables->set_column_custom_minimum_width(1, 60 * EDSCALE);
variables->set_column_title(2, TTR("GPU"));
variables->set_column_expand(2, false);
- variables->set_column_min_width(2, 60 * EDSCALE);
+ variables->set_column_custom_minimum_width(2, 60 * EDSCALE);
variables->connect("cell_selected", callable_mp(this, &EditorVisualProfiler::_item_selected));
graph = memnew(TextureRect);
diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp
index 7493cc2a8d..0d3fd8c7f6 100644
--- a/editor/debugger/script_editor_debugger.cpp
+++ b/editor/debugger/script_editor_debugger.cpp
@@ -1643,7 +1643,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
error_tree->set_columns(2);
error_tree->set_column_expand(0, false);
- error_tree->set_column_min_width(0, 140);
+ error_tree->set_column_custom_minimum_width(0, 140);
error_tree->set_column_expand(1, true);
@@ -1731,13 +1731,13 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
vmem_tree->set_column_expand(0, true);
vmem_tree->set_column_expand(1, false);
vmem_tree->set_column_title(1, TTR("Type"));
- vmem_tree->set_column_min_width(1, 100 * EDSCALE);
+ vmem_tree->set_column_custom_minimum_width(1, 100 * EDSCALE);
vmem_tree->set_column_expand(2, false);
vmem_tree->set_column_title(2, TTR("Format"));
- vmem_tree->set_column_min_width(2, 150 * EDSCALE);
+ vmem_tree->set_column_custom_minimum_width(2, 150 * EDSCALE);
vmem_tree->set_column_expand(3, false);
vmem_tree->set_column_title(3, TTR("Usage"));
- vmem_tree->set_column_min_width(3, 80 * EDSCALE);
+ vmem_tree->set_column_custom_minimum_width(3, 80 * EDSCALE);
vmem_tree->set_hide_root(true);
tabs->add_child(vmem_vb);
diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp
index 7534b419fe..74a8ad9077 100644
--- a/editor/dependency_editor.cpp
+++ b/editor/dependency_editor.cpp
@@ -769,7 +769,7 @@ OrphanResourcesDialog::OrphanResourcesDialog() {
files = memnew(Tree);
files->set_columns(2);
files->set_column_titles_visible(true);
- files->set_column_min_width(1, 100);
+ files->set_column_custom_minimum_width(1, 100);
files->set_column_expand(0, true);
files->set_column_expand(1, false);
files->set_column_title(0, TTR("Resource"));
diff --git a/editor/doc_tools.cpp b/editor/doc_tools.cpp
index d3df4d91a6..befafec6cb 100644
--- a/editor/doc_tools.cpp
+++ b/editor/doc_tools.cpp
@@ -206,14 +206,14 @@ static Variant get_documentation_default_value(const StringName &p_class_name, c
Variant default_value = Variant();
r_default_value_valid = false;
- if (ClassDB::can_instance(p_class_name)) {
+ if (ClassDB::can_instantiate(p_class_name)) {
default_value = ClassDB::class_get_default_property_value(p_class_name, p_property_name, &r_default_value_valid);
} else {
- // Cannot get default value of classes that can't be instanced
+ // Cannot get default value of classes that can't be instantiated
List<StringName> inheriting_classes;
ClassDB::get_direct_inheriters_from_class(p_class_name, &inheriting_classes);
for (List<StringName>::Element *E2 = inheriting_classes.front(); E2; E2 = E2->next()) {
- if (ClassDB::can_instance(E2->get())) {
+ if (ClassDB::can_instantiate(E2->get())) {
default_value = ClassDB::class_get_default_property_value(E2->get(), p_property_name, &r_default_value_valid);
if (r_default_value_valid) {
break;
diff --git a/editor/editor_atlas_packer.cpp b/editor/editor_atlas_packer.cpp
index 1b4a505edb..85541c093a 100644
--- a/editor/editor_atlas_packer.cpp
+++ b/editor/editor_atlas_packer.cpp
@@ -105,7 +105,7 @@ void EditorAtlasPacker::chart_pack(Vector<Chart> &charts, int &r_width, int &r_h
}
Ref<BitMap> src_bitmap;
- src_bitmap.instance();
+ src_bitmap.instantiate();
src_bitmap->create(aabb.size / divide_by);
int w = src_bitmap->get_size().width;
diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp
index e08334c00e..3e3428ad93 100644
--- a/editor/editor_audio_buses.cpp
+++ b/editor/editor_audio_buses.cpp
@@ -525,7 +525,7 @@ void EditorAudioBus::_effect_add(int p_which) {
StringName name = effect_options->get_item_metadata(p_which);
- Object *fx = ClassDB::instance(name);
+ Object *fx = ClassDB::instantiate(name);
ERR_FAIL_COND(!fx);
AudioEffect *afx = Object::cast_to<AudioEffect>(fx);
ERR_FAIL_COND(!afx);
@@ -921,7 +921,7 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) {
ClassDB::get_inheriters_from_class("AudioEffect", &effects);
effects.sort_custom<StringName::AlphCompare>();
for (List<StringName>::Element *E = effects.front(); E; E = E->next()) {
- if (!ClassDB::can_instance(E->get())) {
+ if (!ClassDB::can_instantiate(E->get())) {
continue;
}
@@ -1238,7 +1238,7 @@ void EditorAudioBuses::_file_dialog_callback(const String &p_string) {
} else if (file_dialog->get_file_mode() == EditorFileDialog::FILE_MODE_SAVE_FILE) {
if (new_layout) {
Ref<AudioBusLayout> empty_state;
- empty_state.instance();
+ empty_state.instantiate();
AudioServer::get_singleton()->set_bus_layout(empty_state);
}
diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp
index 304c2fe532..306a88047a 100644
--- a/editor/editor_autoload_settings.cpp
+++ b/editor/editor_autoload_settings.cpp
@@ -349,14 +349,14 @@ Node *EditorAutoloadSettings::_create_autoload(const String &p_path) {
Node *n = nullptr;
if (res->is_class("PackedScene")) {
Ref<PackedScene> ps = res;
- n = ps->instance();
+ n = ps->instantiate();
} else if (res->is_class("Script")) {
Ref<Script> s = res;
StringName ibt = s->get_instance_base_type();
bool valid_type = ClassDB::is_parent_class(ibt, "Node");
ERR_FAIL_COND_V_MSG(!valid_type, nullptr, "Script does not inherit a Node: " + p_path + ".");
- Object *obj = ClassDB::instance(ibt);
+ Object *obj = ClassDB::instantiate(ibt);
ERR_FAIL_COND_V_MSG(obj == nullptr, nullptr, "Cannot instance script for autoload, expected 'Node' inheritance, got: " + String(ibt) + ".");
@@ -882,19 +882,19 @@ EditorAutoloadSettings::EditorAutoloadSettings() {
tree->set_column_title(0, TTR("Name"));
tree->set_column_expand(0, true);
- tree->set_column_min_width(0, 100 * EDSCALE);
+ tree->set_column_custom_minimum_width(0, 100 * EDSCALE);
tree->set_column_title(1, TTR("Path"));
tree->set_column_expand(1, true);
- tree->set_column_min_width(1, 100 * EDSCALE);
+ tree->set_column_custom_minimum_width(1, 100 * EDSCALE);
tree->set_column_title(2, TTR("Global Variable"));
tree->set_column_expand(2, false);
// Reserve enough space for translations of "Global Variable" which may be longer.
- tree->set_column_min_width(2, 150 * EDSCALE);
+ tree->set_column_custom_minimum_width(2, 150 * EDSCALE);
tree->set_column_expand(3, false);
- tree->set_column_min_width(3, 120 * EDSCALE);
+ tree->set_column_custom_minimum_width(3, 120 * EDSCALE);
tree->connect("cell_selected", callable_mp(this, &EditorAutoloadSettings::_autoload_selected));
tree->connect("item_edited", callable_mp(this, &EditorAutoloadSettings::_autoload_edited));
diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp
index 56c6a416af..3823d7e14f 100644
--- a/editor/editor_data.cpp
+++ b/editor/editor_data.cpp
@@ -476,7 +476,7 @@ Variant EditorData::instance_custom_type(const String &p_type, const String &p_i
if (get_custom_types()[p_inherits][i].name == p_type) {
Ref<Script> script = get_custom_types()[p_inherits][i].script;
- Variant ob = ClassDB::instance(p_inherits);
+ Variant ob = ClassDB::instantiate(p_inherits);
ERR_FAIL_COND_V(!ob, Variant());
Node *n = Object::cast_to<Node>(ob);
if (n) {
@@ -603,7 +603,7 @@ bool EditorData::check_and_update_scene(int p_idx) {
if (must_reload) {
Ref<PackedScene> pscene;
- pscene.instance();
+ pscene.instantiate();
EditorProgress ep("update_scene", TTR("Updating Scene"), 2);
ep.step(TTR("Storing local changes..."), 0);
@@ -611,7 +611,7 @@ bool EditorData::check_and_update_scene(int p_idx) {
Error err = pscene->pack(edited_scene[p_idx].root);
ERR_FAIL_COND_V(err != OK, false);
ep.step(TTR("Updating scene..."), 1);
- Node *new_scene = pscene->instance(PackedScene::GEN_EDIT_STATE_MAIN);
+ Node *new_scene = pscene->instantiate(PackedScene::GEN_EDIT_STATE_MAIN);
ERR_FAIL_COND_V(!new_scene, false);
//transfer selection
@@ -908,7 +908,7 @@ StringName EditorData::script_class_get_base(const String &p_class) const {
Variant EditorData::script_class_instance(const String &p_class) {
if (ScriptServer::is_global_class(p_class)) {
- Variant obj = ClassDB::instance(ScriptServer::get_global_class_native_base(p_class));
+ Variant obj = ClassDB::instantiate(ScriptServer::get_global_class_native_base(p_class));
if (obj) {
Ref<Script> script = script_class_load_script(p_class);
if (script.is_valid()) {
diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp
index 7c5a06107d..fc483b46b7 100644
--- a/editor/editor_export.cpp
+++ b/editor/editor_export.cpp
@@ -430,7 +430,7 @@ bool EditorExportPlatform::exists_export_template(String template_file_name, Str
Ref<EditorExportPreset> EditorExportPlatform::create_preset() {
Ref<EditorExportPreset> preset;
- preset.instance();
+ preset.instantiate();
preset->platform = Ref<EditorExportPlatform>(this);
List<ExportOption> options;
@@ -873,7 +873,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
if (FileAccess::exists(path + ".import")) {
//file is imported, replace by what it imports
Ref<ConfigFile> config;
- config.instance();
+ config.instantiate();
err = config->load(path + ".import");
if (err != OK) {
ERR_PRINT("Could not parse: '" + path + "', not exported.");
@@ -1391,7 +1391,7 @@ EditorExport *EditorExport::singleton = nullptr;
void EditorExport::_save() {
Ref<ConfigFile> config;
- config.instance();
+ config.instantiate();
for (int i = 0; i < export_presets.size(); i++) {
Ref<EditorExportPreset> preset = export_presets[i];
String section = "preset." + itos(i);
@@ -1546,7 +1546,7 @@ void EditorExport::_notification(int p_what) {
void EditorExport::load_config() {
Ref<ConfigFile> config;
- config.instance();
+ config.instantiate();
Error err = config->load("res://export_presets.cfg");
if (err != OK) {
return;
diff --git a/editor/editor_feature_profile.cpp b/editor/editor_feature_profile.cpp
index 51c6b473ad..58d2b6e86e 100644
--- a/editor/editor_feature_profile.cpp
+++ b/editor/editor_feature_profile.cpp
@@ -161,21 +161,21 @@ String EditorFeatureProfile::get_feature_description(Feature p_feature) {
}
Error EditorFeatureProfile::save_to_file(const String &p_path) {
- Dictionary json;
- json["type"] = "feature_profile";
+ Dictionary data;
+ data["type"] = "feature_profile";
Array dis_classes;
for (Set<StringName>::Element *E = disabled_classes.front(); E; E = E->next()) {
dis_classes.push_back(String(E->get()));
}
dis_classes.sort();
- json["disabled_classes"] = dis_classes;
+ data["disabled_classes"] = dis_classes;
Array dis_editors;
for (Set<StringName>::Element *E = disabled_editors.front(); E; E = E->next()) {
dis_editors.push_back(String(E->get()));
}
dis_editors.sort();
- json["disabled_editors"] = dis_editors;
+ data["disabled_editors"] = dis_editors;
Array dis_props;
@@ -185,7 +185,7 @@ Error EditorFeatureProfile::save_to_file(const String &p_path) {
}
}
- json["disabled_properties"] = dis_props;
+ data["disabled_properties"] = dis_props;
Array dis_features;
for (int i = 0; i < FEATURE_MAX; i++) {
@@ -194,12 +194,13 @@ Error EditorFeatureProfile::save_to_file(const String &p_path) {
}
}
- json["disabled_features"] = dis_features;
+ data["disabled_features"] = dis_features;
FileAccessRef f = FileAccess::open(p_path, FileAccess::WRITE);
ERR_FAIL_COND_V_MSG(!f, ERR_CANT_CREATE, "Cannot create file '" + p_path + "'.");
- String text = JSON::print(json, "\t");
+ JSON json;
+ String text = json.stringify(data, "\t");
f->store_string(text);
f->close();
return OK;
@@ -212,26 +213,24 @@ Error EditorFeatureProfile::load_from_file(const String &p_path) {
return err;
}
- String err_str;
- int err_line;
- Variant v;
- err = JSON::parse(text, v, err_str, err_line);
+ JSON json;
+ err = json.parse(text);
if (err != OK) {
- ERR_PRINT("Error parsing '" + p_path + "' on line " + itos(err_line) + ": " + err_str);
+ ERR_PRINT("Error parsing '" + p_path + "' on line " + itos(json.get_error_line()) + ": " + json.get_error_message());
return ERR_PARSE_ERROR;
}
- Dictionary json = v;
+ Dictionary data = json.get_data();
- if (!json.has("type") || String(json["type"]) != "feature_profile") {
+ if (!data.has("type") || String(data["type"]) != "feature_profile") {
ERR_PRINT("Error parsing '" + p_path + "', it's not a feature profile.");
return ERR_PARSE_ERROR;
}
disabled_classes.clear();
- if (json.has("disabled_classes")) {
- Array disabled_classes_arr = json["disabled_classes"];
+ if (data.has("disabled_classes")) {
+ Array disabled_classes_arr = data["disabled_classes"];
for (int i = 0; i < disabled_classes_arr.size(); i++) {
disabled_classes.insert(disabled_classes_arr[i]);
}
@@ -239,8 +238,8 @@ Error EditorFeatureProfile::load_from_file(const String &p_path) {
disabled_editors.clear();
- if (json.has("disabled_editors")) {
- Array disabled_editors_arr = json["disabled_editors"];
+ if (data.has("disabled_editors")) {
+ Array disabled_editors_arr = data["disabled_editors"];
for (int i = 0; i < disabled_editors_arr.size(); i++) {
disabled_editors.insert(disabled_editors_arr[i]);
}
@@ -248,16 +247,16 @@ Error EditorFeatureProfile::load_from_file(const String &p_path) {
disabled_properties.clear();
- if (json.has("disabled_properties")) {
- Array disabled_properties_arr = json["disabled_properties"];
+ if (data.has("disabled_properties")) {
+ Array disabled_properties_arr = data["disabled_properties"];
for (int i = 0; i < disabled_properties_arr.size(); i++) {
String s = disabled_properties_arr[i];
set_disable_class_property(s.get_slice(":", 0), s.get_slice(":", 1), true);
}
}
- if (json.has("disabled_features")) {
- Array disabled_features_arr = json["disabled_features"];
+ if (data.has("disabled_features")) {
+ Array disabled_features_arr = data["disabled_features"];
for (int i = 0; i < FEATURE_MAX; i++) {
bool found = false;
String f = feature_identifiers[i];
@@ -312,7 +311,7 @@ void EditorFeatureProfileManager::_notification(int p_what) {
if (p_what == NOTIFICATION_READY) {
current_profile = EDITOR_GET("_default_feature_profile");
if (current_profile != String()) {
- current.instance();
+ current.instantiate();
Error err = current->load_from_file(EditorSettings::get_singleton()->get_feature_profiles_dir().plus_file(current_profile + ".profile"));
if (err != OK) {
ERR_PRINT("Error loading default feature profile: " + current_profile);
@@ -474,7 +473,7 @@ void EditorFeatureProfileManager::_create_new_profile() {
}
Ref<EditorFeatureProfile> new_profile;
- new_profile.instance();
+ new_profile.instantiate();
new_profile->save_to_file(file);
_update_profile_list(name);
@@ -731,7 +730,7 @@ void EditorFeatureProfileManager::_update_selected_profile() {
ERR_FAIL_COND(current.is_null()); //nothing selected, current should never be null
} else {
//reload edited, if different from current
- edited.instance();
+ edited.instantiate();
Error err = edited->load_from_file(EditorSettings::get_singleton()->get_feature_profiles_dir().plus_file(profile + ".profile"));
ERR_FAIL_COND_MSG(err != OK, "Error when loading EditorSettings from file '" + EditorSettings::get_singleton()->get_feature_profiles_dir().plus_file(profile + ".profile") + "'.");
}
@@ -780,7 +779,7 @@ void EditorFeatureProfileManager::_import_profiles(const Vector<String> &p_paths
//test it first
for (int i = 0; i < p_paths.size(); i++) {
Ref<EditorFeatureProfile> profile;
- profile.instance();
+ profile.instantiate();
Error err = profile->load_from_file(p_paths[i]);
String basefile = p_paths[i].get_file();
if (err != OK) {
@@ -799,7 +798,7 @@ void EditorFeatureProfileManager::_import_profiles(const Vector<String> &p_paths
//do it second
for (int i = 0; i < p_paths.size(); i++) {
Ref<EditorFeatureProfile> profile;
- profile.instance();
+ profile.instantiate();
Error err = profile->load_from_file(p_paths[i]);
ERR_CONTINUE(err != OK);
String basefile = p_paths[i].get_file();
diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp
index f3cee7576d..fe4c6f490d 100644
--- a/editor/editor_file_dialog.cpp
+++ b/editor/editor_file_dialog.cpp
@@ -1544,7 +1544,7 @@ EditorFileDialog::EditorFileDialog() {
pathhb->add_child(memnew(VSeparator));
Ref<ButtonGroup> view_mode_group;
- view_mode_group.instance();
+ view_mode_group.instantiate();
mode_thumbnails = memnew(Button);
mode_thumbnails->set_flat(true);
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp
index c61b097ccd..a2507f3cf2 100644
--- a/editor/editor_file_system.cpp
+++ b/editor/editor_file_system.cpp
@@ -1475,8 +1475,6 @@ void EditorFileSystem::update_file(const String &p_file) {
if (cpos == -1) {
// The file did not exist, it was added.
-
- late_added_files.insert(p_file); // Remember that it was added. This mean it will be scanned and imported on editor restart.
int idx = 0;
String file_name = p_file.get_file();
@@ -1526,7 +1524,7 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector
Map<String, String> base_paths;
for (int i = 0; i < p_files.size(); i++) {
Ref<ConfigFile> config;
- config.instance();
+ config.instantiate();
Error err = config->load(p_files[i] + ".import");
ERR_CONTINUE(err != OK);
ERR_CONTINUE(!config->has_section_key("remap", "importer"));
@@ -1708,7 +1706,7 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName
//use existing
if (p_custom_options == nullptr) {
Ref<ConfigFile> cf;
- cf.instance();
+ cf.instantiate();
Error err = cf->load(p_file + ".import");
if (err == OK) {
if (cf->has_section("params")) {
@@ -1723,9 +1721,6 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName
}
}
}
-
- } else {
- late_added_files.insert(p_file); //imported files do not call update_file(), but just in case..
}
if (importer_name == "keep") {
@@ -2073,7 +2068,7 @@ void EditorFileSystem::_move_group_files(EditorFileSystemDirectory *efd, const S
files[i]->import_group_file = p_new_location;
Ref<ConfigFile> config;
- config.instance();
+ config.instantiate();
String path = efd->get_file_path(i) + ".import";
Error err = config->load(path);
if (err != OK) {
diff --git a/editor/editor_file_system.h b/editor/editor_file_system.h
index 04879bad6d..37eee13c16 100644
--- a/editor/editor_file_system.h
+++ b/editor/editor_file_system.h
@@ -148,7 +148,6 @@ class EditorFileSystem : public Node {
void _scan_filesystem();
- Set<String> late_added_files; //keep track of files that were added, these will be re-scanned
Set<String> late_update_files;
void _save_late_updated_files();
diff --git a/editor/editor_folding.cpp b/editor/editor_folding.cpp
index 4030aecbf5..5d6c415d39 100644
--- a/editor/editor_folding.cpp
+++ b/editor/editor_folding.cpp
@@ -50,7 +50,7 @@ Vector<String> EditorFolding::_get_unfolds(const Object *p_object) {
void EditorFolding::save_resource_folding(const RES &p_resource, const String &p_path) {
Ref<ConfigFile> config;
- config.instance();
+ config.instantiate();
Vector<String> unfolds = _get_unfolds(p_resource.ptr());
config->set_value("folding", "sections_unfolded", unfolds);
@@ -70,7 +70,7 @@ void EditorFolding::_set_unfolds(Object *p_object, const Vector<String> &p_unfol
void EditorFolding::load_resource_folding(RES p_resource, const String &p_path) {
Ref<ConfigFile> config;
- config.instance();
+ config.instantiate();
String file = p_path.get_file() + "-folding-" + p_path.md5_text() + ".cfg";
file = EditorSettings::get_singleton()->get_project_settings_dir().plus_file(file);
@@ -137,7 +137,7 @@ void EditorFolding::save_scene_folding(const Node *p_scene, const String &p_path
}
Ref<ConfigFile> config;
- config.instance();
+ config.instantiate();
Array unfolds, res_unfolds;
Set<RES> resources;
@@ -155,7 +155,7 @@ void EditorFolding::save_scene_folding(const Node *p_scene, const String &p_path
void EditorFolding::load_scene_folding(Node *p_scene, const String &p_path) {
Ref<ConfigFile> config;
- config.instance();
+ config.instantiate();
String path = EditorSettings::get_singleton()->get_project_settings_dir();
String file = p_path.get_file() + "-folding-" + p_path.md5_text() + ".cfg";
diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp
index 2f5451fba3..d548196a2d 100644
--- a/editor/editor_fonts.cpp
+++ b/editor/editor_fonts.cpp
@@ -55,7 +55,7 @@
// the custom spacings might only work with Noto Sans
#define MAKE_DEFAULT_FONT(m_name) \
Ref<Font> m_name; \
- m_name.instance(); \
+ m_name.instantiate(); \
if (CustomFont.is_valid()) { \
m_name->add_data(CustomFont); \
m_name->add_data(DefaultFont); \
@@ -68,7 +68,7 @@
#define MAKE_BOLD_FONT(m_name) \
Ref<Font> m_name; \
- m_name.instance(); \
+ m_name.instantiate(); \
if (CustomFontBold.is_valid()) { \
m_name->add_data(CustomFontBold); \
m_name->add_data(DefaultFontBold); \
@@ -81,7 +81,7 @@
#define MAKE_SOURCE_FONT(m_name) \
Ref<Font> m_name; \
- m_name.instance(); \
+ m_name.instantiate(); \
if (CustomFontSource.is_valid()) { \
m_name->add_data(CustomFontSource); \
m_name->add_data(dfmono); \
@@ -129,7 +129,7 @@ void editor_register_fonts(Ref<Theme> p_theme) {
String custom_font_path = EditorSettings::get_singleton()->get("interface/editor/main_font");
Ref<FontData> CustomFont;
if (custom_font_path.length() > 0 && dir->file_exists(custom_font_path)) {
- CustomFont.instance();
+ CustomFont.instantiate();
CustomFont->load_resource(custom_font_path, default_font_size);
CustomFont->set_antialiased(font_antialiased);
CustomFont->set_hinting(font_hinting);
@@ -143,7 +143,7 @@ void editor_register_fonts(Ref<Theme> p_theme) {
String custom_font_path_bold = EditorSettings::get_singleton()->get("interface/editor/main_font_bold");
Ref<FontData> CustomFontBold;
if (custom_font_path_bold.length() > 0 && dir->file_exists(custom_font_path_bold)) {
- CustomFontBold.instance();
+ CustomFontBold.instantiate();
CustomFontBold->load_resource(custom_font_path_bold, default_font_size);
CustomFontBold->set_antialiased(font_antialiased);
CustomFontBold->set_hinting(font_hinting);
@@ -157,7 +157,7 @@ void editor_register_fonts(Ref<Theme> p_theme) {
String custom_font_path_source = EditorSettings::get_singleton()->get("interface/editor/code_font");
Ref<FontData> CustomFontSource;
if (custom_font_path_source.length() > 0 && dir->file_exists(custom_font_path_source)) {
- CustomFontSource.instance();
+ CustomFontSource.instantiate();
CustomFontSource->load_resource(custom_font_path_source, default_font_size);
CustomFontSource->set_antialiased(font_antialiased);
CustomFontSource->set_hinting(font_hinting);
@@ -178,105 +178,105 @@ void editor_register_fonts(Ref<Theme> p_theme) {
/* Droid Sans */
Ref<FontData> DefaultFont;
- DefaultFont.instance();
+ DefaultFont.instantiate();
DefaultFont->load_memory(_font_NotoSansUI_Regular, _font_NotoSansUI_Regular_size, "ttf", default_font_size);
DefaultFont->set_antialiased(font_antialiased);
DefaultFont->set_hinting(font_hinting);
DefaultFont->set_force_autohinter(true); //just looks better..i think?
Ref<FontData> DefaultFontBold;
- DefaultFontBold.instance();
+ DefaultFontBold.instantiate();
DefaultFontBold->load_memory(_font_NotoSansUI_Bold, _font_NotoSansUI_Bold_size, "ttf", default_font_size);
DefaultFontBold->set_antialiased(font_antialiased);
DefaultFontBold->set_hinting(font_hinting);
DefaultFontBold->set_force_autohinter(true); // just looks better..i think?
Ref<FontData> FontFallback;
- FontFallback.instance();
+ FontFallback.instantiate();
FontFallback->load_memory(_font_DroidSansFallback, _font_DroidSansFallback_size, "ttf", default_font_size);
FontFallback->set_antialiased(font_antialiased);
FontFallback->set_hinting(font_hinting);
FontFallback->set_force_autohinter(true); //just looks better..i think?
Ref<FontData> FontJapanese;
- FontJapanese.instance();
+ FontJapanese.instantiate();
FontJapanese->load_memory(_font_DroidSansJapanese, _font_DroidSansJapanese_size, "ttf", default_font_size);
FontJapanese->set_antialiased(font_antialiased);
FontJapanese->set_hinting(font_hinting);
FontJapanese->set_force_autohinter(true); //just looks better..i think?
Ref<FontData> FontArabic;
- FontArabic.instance();
+ FontArabic.instantiate();
FontArabic->load_memory(_font_NotoNaskhArabicUI_Regular, _font_NotoNaskhArabicUI_Regular_size, "ttf", default_font_size);
FontArabic->set_antialiased(font_antialiased);
FontArabic->set_hinting(font_hinting);
FontArabic->set_force_autohinter(true); //just looks better..i think?
Ref<FontData> FontBengali;
- FontBengali.instance();
+ FontBengali.instantiate();
FontBengali->load_memory(_font_NotoSansBengali_Regular, _font_NotoSansBengali_Regular_size, "ttf", default_font_size);
FontBengali->set_antialiased(font_antialiased);
FontBengali->set_hinting(font_hinting);
FontBengali->set_force_autohinter(true); //just looks better..i think?
Ref<FontData> FontGeorgian;
- FontGeorgian.instance();
+ FontGeorgian.instantiate();
FontGeorgian->load_memory(_font_NotoSansGeorgian_Regular, _font_NotoSansGeorgian_Regular_size, "ttf", default_font_size);
FontGeorgian->set_antialiased(font_antialiased);
FontGeorgian->set_hinting(font_hinting);
FontGeorgian->set_force_autohinter(true); //just looks better..i think?
Ref<FontData> FontHebrew;
- FontHebrew.instance();
+ FontHebrew.instantiate();
FontHebrew->load_memory(_font_NotoSansHebrew_Regular, _font_NotoSansHebrew_Regular_size, "ttf", default_font_size);
FontHebrew->set_antialiased(font_antialiased);
FontHebrew->set_hinting(font_hinting);
FontHebrew->set_force_autohinter(true); //just looks better..i think?
Ref<FontData> FontMalayalam;
- FontMalayalam.instance();
+ FontMalayalam.instantiate();
FontMalayalam->load_memory(_font_NotoSansMalayalamUI_Regular, _font_NotoSansMalayalamUI_Regular_size, "ttf", default_font_size);
FontMalayalam->set_antialiased(font_antialiased);
FontMalayalam->set_hinting(font_hinting);
FontMalayalam->set_force_autohinter(true); //just looks better..i think?
Ref<FontData> FontOriya;
- FontOriya.instance();
+ FontOriya.instantiate();
FontOriya->load_memory(_font_NotoSansOriyaUI_Regular, _font_NotoSansOriyaUI_Regular_size, "ttf", default_font_size);
FontOriya->set_antialiased(font_antialiased);
FontOriya->set_hinting(font_hinting);
FontOriya->set_force_autohinter(true); //just looks better..i think?
Ref<FontData> FontSinhala;
- FontSinhala.instance();
+ FontSinhala.instantiate();
FontSinhala->load_memory(_font_NotoSansSinhalaUI_Regular, _font_NotoSansSinhalaUI_Regular_size, "ttf", default_font_size);
FontSinhala->set_antialiased(font_antialiased);
FontSinhala->set_hinting(font_hinting);
FontSinhala->set_force_autohinter(true); //just looks better..i think?
Ref<FontData> FontTamil;
- FontTamil.instance();
+ FontTamil.instantiate();
FontTamil->load_memory(_font_NotoSansTamilUI_Regular, _font_NotoSansTamilUI_Regular_size, "ttf", default_font_size);
FontTamil->set_antialiased(font_antialiased);
FontTamil->set_hinting(font_hinting);
FontTamil->set_force_autohinter(true); //just looks better..i think?
Ref<FontData> FontTelugu;
- FontTelugu.instance();
+ FontTelugu.instantiate();
FontTelugu->load_memory(_font_NotoSansTeluguUI_Regular, _font_NotoSansTeluguUI_Regular_size, "ttf", default_font_size);
FontTelugu->set_antialiased(font_antialiased);
FontTelugu->set_hinting(font_hinting);
FontTelugu->set_force_autohinter(true); //just looks better..i think?
Ref<FontData> FontThai;
- FontThai.instance();
+ FontThai.instantiate();
FontThai->load_memory(_font_NotoSansThaiUI_Regular, _font_NotoSansThaiUI_Regular_size, "ttf", default_font_size);
FontThai->set_antialiased(font_antialiased);
FontThai->set_hinting(font_hinting);
FontThai->set_force_autohinter(true); //just looks better..i think?
Ref<FontData> FontHindi;
- FontHindi.instance();
+ FontHindi.instantiate();
FontHindi->load_memory(_font_NotoSansDevanagariUI_Regular, _font_NotoSansDevanagariUI_Regular_size, "ttf", default_font_size);
FontHindi->set_antialiased(font_antialiased);
FontHindi->set_hinting(font_hinting);
@@ -285,7 +285,7 @@ void editor_register_fonts(Ref<Theme> p_theme) {
/* Hack */
Ref<FontData> dfmono;
- dfmono.instance();
+ dfmono.instantiate();
dfmono->load_memory(_font_Hack_Regular, _font_Hack_Regular_size, "ttf", default_font_size);
dfmono->set_antialiased(font_antialiased);
dfmono->set_hinting(font_hinting);
diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp
index b93ffa9321..57ddc64e95 100644
--- a/editor/editor_help_search.cpp
+++ b/editor/editor_help_search.cpp
@@ -239,7 +239,7 @@ EditorHelpSearch::EditorHelpSearch() {
results_tree->set_column_title(0, TTR("Name"));
results_tree->set_column_title(1, TTR("Member Type"));
results_tree->set_column_expand(1, false);
- results_tree->set_column_min_width(1, 150 * EDSCALE);
+ results_tree->set_column_custom_minimum_width(1, 150 * EDSCALE);
results_tree->set_custom_minimum_size(Size2(0, 100) * EDSCALE);
results_tree->set_hide_root(true);
results_tree->set_select_mode(Tree::SELECT_ROW);
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index 69709315ff..cfce37ea1b 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -417,7 +417,7 @@ bool EditorPropertyRevert::may_node_be_in_instance(Node *p_node) {
return might_be; // or might not be
}
-bool EditorPropertyRevert::get_instanced_node_original_property(Node *p_node, const StringName &p_prop, Variant &value) {
+bool EditorPropertyRevert::get_instantiated_node_original_property(Node *p_node, const StringName &p_prop, Variant &value) {
Node *node = p_node;
Node *orig = node;
@@ -524,7 +524,7 @@ bool EditorPropertyRevert::can_property_revert(Object *p_object, const StringNam
if (node && EditorPropertyRevert::may_node_be_in_instance(node)) {
//check for difference including instantiation
Variant vorig;
- if (EditorPropertyRevert::get_instanced_node_original_property(node, p_property, vorig)) {
+ if (EditorPropertyRevert::get_instantiated_node_original_property(node, p_property, vorig)) {
Variant v = p_object->get(p_property);
if (EditorPropertyRevert::is_node_property_different(node, v, vorig)) {
@@ -764,7 +764,7 @@ void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) {
Variant vorig;
Node *node = Object::cast_to<Node>(object);
- if (node && EditorPropertyRevert::may_node_be_in_instance(node) && EditorPropertyRevert::get_instanced_node_original_property(node, property, vorig)) {
+ if (node && EditorPropertyRevert::may_node_be_in_instance(node) && EditorPropertyRevert::get_instantiated_node_original_property(node, property, vorig)) {
emit_changed(property, vorig.duplicate(true));
update_property();
return;
diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h
index e4bcab3e3f..f493290b09 100644
--- a/editor/editor_inspector.h
+++ b/editor/editor_inspector.h
@@ -40,7 +40,7 @@ class UndoRedo;
class EditorPropertyRevert {
public:
static bool may_node_be_in_instance(Node *p_node);
- static bool get_instanced_node_original_property(Node *p_node, const StringName &p_prop, Variant &value);
+ static bool get_instantiated_node_original_property(Node *p_node, const StringName &p_prop, Variant &value);
static bool is_node_property_different(Node *p_node, const Variant &p_current, const Variant &p_orig);
static bool can_property_revert(Object *p_object, const StringName &p_property);
@@ -83,7 +83,7 @@ private:
bool draw_top_bg;
bool _is_property_different(const Variant &p_current, const Variant &p_orig);
- bool _get_instanced_node_original_property(const StringName &p_prop, Variant &value);
+ bool _get_instantiated_node_original_property(const StringName &p_prop, Variant &value);
void _focusable_focused(int p_index);
bool selectable;
@@ -271,7 +271,7 @@ class EditorInspector : public ScrollContainer {
VBoxContainer *main_vbox;
- //map use to cache the instanced editors
+ //map use to cache the instantiated editors
Map<StringName, List<EditorProperty *>> editor_property_map;
List<EditorInspectorSection *> sections;
Set<StringName> pending;
diff --git a/editor/editor_layouts_dialog.cpp b/editor/editor_layouts_dialog.cpp
index 0bf1863459..437841ccc1 100644
--- a/editor/editor_layouts_dialog.cpp
+++ b/editor/editor_layouts_dialog.cpp
@@ -83,7 +83,7 @@ void EditorLayoutsDialog::_post_popup() {
layout_names->clear();
Ref<ConfigFile> config;
- config.instance();
+ config.instantiate();
Error err = config->load(EditorSettings::get_singleton()->get_editor_layouts_config());
if (err != OK) {
return;
diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp
index 35d8021394..b3e90236a6 100644
--- a/editor/editor_log.cpp
+++ b/editor/editor_log.cpp
@@ -103,7 +103,7 @@ void EditorLog::_start_state_save_timer() {
void EditorLog::_save_state() {
Ref<ConfigFile> config;
- config.instance();
+ config.instantiate();
// Load and amend existing config if it exists.
config->load(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("editor_layout.cfg"));
@@ -122,22 +122,21 @@ void EditorLog::_load_state() {
is_loading_state = true;
Ref<ConfigFile> config;
- config.instance();
- Error err = config->load(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("editor_layout.cfg"));
-
- if (err == OK) {
- const String section = "editor_log";
- for (Map<MessageType, LogFilter *>::Element *E = type_filter_map.front(); E; E = E->next()) {
- E->get()->set_active(config->get_value(section, "log_filter_" + itos(E->key()), false));
- }
+ config.instantiate();
+ config->load(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("editor_layout.cfg"));
- collapse = config->get_value(section, "collapse", false);
- collapse_button->set_pressed(collapse);
- bool show_search = config->get_value(section, "show_search", true);
- search_box->set_visible(show_search);
- show_search_button->set_pressed(show_search);
+ // Run the below code even if config->load returns an error, since we want the defaults to be set even if the file does not exist yet.
+ const String section = "editor_log";
+ for (Map<MessageType, LogFilter *>::Element *E = type_filter_map.front(); E; E = E->next()) {
+ E->get()->set_active(config->get_value(section, "log_filter_" + itos(E->key()), true));
}
+ collapse = config->get_value(section, "collapse", false);
+ collapse_button->set_pressed(collapse);
+ bool show_search = config->get_value(section, "show_search", true);
+ search_box->set_visible(show_search);
+ show_search_button->set_pressed(show_search);
+
is_loading_state = false;
}
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 73bb1f3856..b962ea6e3e 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -32,6 +32,7 @@
#include "core/config/project_settings.h"
#include "core/core_bind.h"
+#include "core/extension/native_extension_manager.h"
#include "core/input/input.h"
#include "core/io/config_file.h"
#include "core/io/file_access.h"
@@ -1243,7 +1244,7 @@ void EditorNode::_get_scene_metadata(const String &p_file) {
String path = EditorSettings::get_singleton()->get_project_settings_dir().plus_file(p_file.get_file() + "-editstate-" + p_file.md5_text() + ".cfg");
Ref<ConfigFile> cf;
- cf.instance();
+ cf.instantiate();
Error err = cf->load(path);
if (err != OK || !cf->has_section("editor_states")) {
@@ -1277,7 +1278,7 @@ void EditorNode::_set_scene_metadata(const String &p_file, int p_idx) {
String path = EditorSettings::get_singleton()->get_project_settings_dir().plus_file(p_file.get_file() + "-editstate-" + p_file.md5_text() + ".cfg");
Ref<ConfigFile> cf;
- cf.instance();
+ cf.instantiate();
Dictionary md;
@@ -1422,7 +1423,7 @@ void EditorNode::_save_scene_with_preview(String p_file, int p_idx) {
// We cannot fallback on the 2D editor, because it may not have been used yet,
// which would result in an invalid texture.
if (c3d == 0 && c2d == 0) {
- img.instance();
+ img.instantiate();
img->create(1, 1, false, Image::FORMAT_RGB8);
} else if (c3d < c2d) {
Ref<ViewportTexture> viewport_texture = scene_root->get_texture();
@@ -1607,16 +1608,16 @@ void EditorNode::_save_scene(String p_file, int idx) {
if (ResourceCache::has(p_file)) {
// something may be referencing this resource and we are good with that.
// we must update it, but also let the previous scene state go, as
- // old version still work for referencing changes in instanced or inherited scenes
+ // old version still work for referencing changes in instantiated or inherited scenes
sdata = Ref<PackedScene>(Object::cast_to<PackedScene>(ResourceCache::get(p_file)));
if (sdata.is_valid()) {
sdata->recreate_state();
} else {
- sdata.instance();
+ sdata.instantiate();
}
} else {
- sdata.instance();
+ sdata.instantiate();
}
Error err = sdata->pack(scene);
@@ -1625,15 +1626,6 @@ void EditorNode::_save_scene(String p_file, int idx) {
return;
}
- // force creation of node path cache
- // (hacky but needed for the tree to update properly)
- Node *dummy_scene = sdata->instance(PackedScene::GEN_EDIT_STATE_INSTANCE);
- if (!dummy_scene) {
- show_accept(TTR("Couldn't save scene. Likely dependencies (instances or inheritance) couldn't be satisfied."), TTR("OK"));
- return;
- }
- memdelete(dummy_scene);
-
int flg = 0;
if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources")) {
flg |= ResourceSaver::FLAG_COMPRESS;
@@ -1849,11 +1841,11 @@ void EditorNode::_dialog_action(String p_file) {
}
Ref<ConfigFile> config;
- config.instance();
+ config.instantiate();
Error err = config->load(EditorSettings::get_singleton()->get_editor_layouts_config());
if (err == ERR_FILE_CANT_OPEN || err == ERR_FILE_NOT_FOUND) {
- config.instance(); // new config
+ config.instantiate(); // new config
} else if (err != OK) {
show_warning(TTR("An error occurred while trying to save the editor layout.\nMake sure the editor's user data path is writable."));
return;
@@ -1877,7 +1869,7 @@ void EditorNode::_dialog_action(String p_file) {
}
Ref<ConfigFile> config;
- config.instance();
+ config.instantiate();
Error err = config->load(EditorSettings::get_singleton()->get_editor_layouts_config());
if (err != OK || !config->has_section(p_file)) {
@@ -2082,7 +2074,7 @@ void EditorNode::_edit_current() {
editable_warning = TTR("This resource belongs to a scene that was imported, so it's not editable.\nPlease read the documentation relevant to importing scenes to better understand this workflow.");
} else {
if ((!get_edited_scene() || get_edited_scene()->get_filename() != base_path) && ResourceLoader::get_resource_type(base_path) == "PackedScene") {
- editable_warning = TTR("This resource belongs to a scene that was instanced or inherited.\nChanges to it won't be kept when saving the current scene.");
+ editable_warning = TTR("This resource belongs to a scene that was instantiated or inherited.\nChanges to it won't be kept when saving the current scene.");
}
}
} else if (current_res->get_path().is_resource_file()) {
@@ -2408,11 +2400,13 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
}
} break;
- case FILE_CLOSE_ALL_AND_QUIT:
- case FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER:
case FILE_CLOSE: {
+ _scene_tab_closed(editor_data.get_edited_scene());
+ } break;
+ case FILE_CLOSE_ALL_AND_QUIT:
+ case FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER: {
if (!p_confirmed) {
- tab_closing = p_option == FILE_CLOSE ? editor_data.get_edited_scene() : _next_unsaved_scene(false);
+ tab_closing = _next_unsaved_scene(false);
_scene_tab_changed(tab_closing);
if (unsaved_cache || p_option == FILE_CLOSE_ALL_AND_QUIT || p_option == FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER) {
@@ -2425,8 +2419,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
break;
}
}
- } else if (p_option == FILE_CLOSE) {
- tab_closing = editor_data.get_edited_scene();
}
if (!editor_data.get_edited_scene_root(tab_closing)) {
// empty tab
@@ -3144,7 +3136,7 @@ void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled,
}
Ref<ConfigFile> cf;
- cf.instance();
+ cf.instantiate();
if (!DirAccess::exists(p_addon.get_base_dir())) {
_remove_plugin_from_enabled(p_addon);
WARN_PRINT("Addon '" + p_addon + "' failed to load. No directory found. Removing from enabled plugins.");
@@ -3525,7 +3517,7 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
sdata->set_path(lpath, true); //take over path
}
- Node *new_scene = sdata->instance(PackedScene::GEN_EDIT_STATE_MAIN);
+ Node *new_scene = sdata->instantiate(PackedScene::GEN_EDIT_STATE_MAIN);
if (!new_scene) {
sdata.unref();
@@ -3589,11 +3581,11 @@ void EditorNode::open_request(const String &p_path) {
}
void EditorNode::request_instance_scene(const String &p_path) {
- scene_tree_dock->instance(p_path);
+ scene_tree_dock->instantiate(p_path);
}
-void EditorNode::request_instance_scenes(const Vector<String> &p_files) {
- scene_tree_dock->instance_scenes(p_files);
+void EditorNode::request_instantiate_scenes(const Vector<String> &p_files) {
+ scene_tree_dock->instantiate_scenes(p_files);
}
ImportDock *EditorNode::get_import_dock() {
@@ -3617,8 +3609,8 @@ void EditorNode::_inherit_request(String p_file) {
_dialog_action(p_file);
}
-void EditorNode::_instance_request(const Vector<String> &p_files) {
- request_instance_scenes(p_files);
+void EditorNode::_instantiate_request(const Vector<String> &p_files) {
+ request_instantiate_scenes(p_files);
}
void EditorNode::_close_messages() {
@@ -3780,9 +3772,12 @@ void EditorNode::register_editor_types() {
ClassDB::register_class<EditorScenePostImport>();
//ClassDB::register_type<EditorImportExport>();
ClassDB::register_class<EditorDebuggerPlugin>();
+
+ NativeExtensionManager::get_singleton()->initialize_extensions(NativeExtension::INITIALIZATION_LEVEL_EDITOR);
}
void EditorNode::unregister_editor_types() {
+ NativeExtensionManager::get_singleton()->deinitialize_extensions(NativeExtension::INITIALIZATION_LEVEL_EDITOR);
_init_callbacks.clear();
if (EditorPaths::get_singleton()) {
EditorPaths::free();
@@ -4352,7 +4347,7 @@ void EditorNode::_save_docks() {
return; //scanning, do not touch docks
}
Ref<ConfigFile> config;
- config.instance();
+ config.instantiate();
// Load and amend existing config if it exists.
config->load(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("editor_layout.cfg"));
@@ -4417,7 +4412,7 @@ void EditorNode::_dock_split_dragged(int ofs) {
void EditorNode::_load_docks() {
Ref<ConfigFile> config;
- config.instance();
+ config.instantiate();
Error err = config->load(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("editor_layout.cfg"));
if (err != OK) {
//no config
@@ -4650,7 +4645,7 @@ bool EditorNode::has_scenes_in_session() {
return false;
}
Ref<ConfigFile> config;
- config.instance();
+ config.instantiate();
Error err = config->load(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("editor_layout.cfg"));
if (err != OK) {
return false;
@@ -4743,7 +4738,7 @@ void EditorNode::_update_layouts_menu() {
editor_layouts->add_shortcut(ED_SHORTCUT("layout/default", TTR("Default")), SETTINGS_LAYOUT_DEFAULT);
Ref<ConfigFile> config;
- config.instance();
+ config.instantiate();
Error err = config->load(EditorSettings::get_singleton()->get_editor_layouts_config());
if (err != OK) {
return; //no config
@@ -4786,7 +4781,7 @@ void EditorNode::_layout_menu_option(int p_id) {
} break;
default: {
Ref<ConfigFile> config;
- config.instance();
+ config.instantiate();
Error err = config->load(EditorSettings::get_singleton()->get_editor_layouts_config());
if (err != OK) {
return; //no config
@@ -5337,7 +5332,7 @@ void EditorNode::reload_scene(const String &p_path) {
if (scene_idx == -1) {
if (get_edited_scene()) {
- //scene is not open, so at it might be instanced. We'll refresh the whole scene later.
+ //scene is not open, so at it might be instantiated. We'll refresh the whole scene later.
editor_data.get_undo_redo().clear_history();
}
return;
@@ -5734,87 +5729,87 @@ EditorNode::EditorNode() {
{ //register importers at the beginning, so dialogs are created with the right extensions
Ref<ResourceImporterTexture> import_texture;
- import_texture.instance();
+ import_texture.instantiate();
ResourceFormatImporter::get_singleton()->add_importer(import_texture);
Ref<ResourceImporterLayeredTexture> import_cubemap;
- import_cubemap.instance();
+ import_cubemap.instantiate();
import_cubemap->set_mode(ResourceImporterLayeredTexture::MODE_CUBEMAP);
ResourceFormatImporter::get_singleton()->add_importer(import_cubemap);
Ref<ResourceImporterLayeredTexture> import_array;
- import_array.instance();
+ import_array.instantiate();
import_array->set_mode(ResourceImporterLayeredTexture::MODE_2D_ARRAY);
ResourceFormatImporter::get_singleton()->add_importer(import_array);
Ref<ResourceImporterLayeredTexture> import_cubemap_array;
- import_cubemap_array.instance();
+ import_cubemap_array.instantiate();
import_cubemap_array->set_mode(ResourceImporterLayeredTexture::MODE_CUBEMAP_ARRAY);
ResourceFormatImporter::get_singleton()->add_importer(import_cubemap_array);
Ref<ResourceImporterLayeredTexture> import_3d;
- import_3d.instance();
+ import_3d.instantiate();
import_3d->set_mode(ResourceImporterLayeredTexture::MODE_3D);
ResourceFormatImporter::get_singleton()->add_importer(import_3d);
Ref<ResourceImporterImage> import_image;
- import_image.instance();
+ import_image.instantiate();
ResourceFormatImporter::get_singleton()->add_importer(import_image);
Ref<ResourceImporterTextureAtlas> import_texture_atlas;
- import_texture_atlas.instance();
+ import_texture_atlas.instantiate();
ResourceFormatImporter::get_singleton()->add_importer(import_texture_atlas);
Ref<ResourceImporterCSVTranslation> import_csv_translation;
- import_csv_translation.instance();
+ import_csv_translation.instantiate();
ResourceFormatImporter::get_singleton()->add_importer(import_csv_translation);
Ref<ResourceImporterWAV> import_wav;
- import_wav.instance();
+ import_wav.instantiate();
ResourceFormatImporter::get_singleton()->add_importer(import_wav);
Ref<ResourceImporterOBJ> import_obj;
- import_obj.instance();
+ import_obj.instantiate();
ResourceFormatImporter::get_singleton()->add_importer(import_obj);
Ref<ResourceImporterShaderFile> import_shader_file;
- import_shader_file.instance();
+ import_shader_file.instantiate();
ResourceFormatImporter::get_singleton()->add_importer(import_shader_file);
Ref<ResourceImporterScene> import_scene;
- import_scene.instance();
+ import_scene.instantiate();
ResourceFormatImporter::get_singleton()->add_importer(import_scene);
{
Ref<EditorSceneImporterCollada> import_collada;
- import_collada.instance();
+ import_collada.instantiate();
import_scene->add_importer(import_collada);
Ref<EditorOBJImporter> import_obj2;
- import_obj2.instance();
+ import_obj2.instantiate();
import_scene->add_importer(import_obj2);
Ref<EditorSceneImporterESCN> import_escn;
- import_escn.instance();
+ import_escn.instantiate();
import_scene->add_importer(import_escn);
}
Ref<ResourceImporterBitMap> import_bitmap;
- import_bitmap.instance();
+ import_bitmap.instantiate();
ResourceFormatImporter::get_singleton()->add_importer(import_bitmap);
}
{
Ref<EditorInspectorDefaultPlugin> eidp;
- eidp.instance();
+ eidp.instantiate();
EditorInspector::add_inspector_plugin(eidp);
Ref<EditorInspectorRootMotionPlugin> rmp;
- rmp.instance();
+ rmp.instantiate();
EditorInspector::add_inspector_plugin(rmp);
Ref<EditorInspectorShaderModePlugin> smp;
- smp.instance();
+ smp.instantiate();
EditorInspector::add_inspector_plugin(smp);
}
@@ -6517,7 +6512,7 @@ EditorNode::EditorNode() {
filesystem_dock = memnew(FileSystemDock(this));
filesystem_dock->connect("inherit", callable_mp(this, &EditorNode::_inherit_request));
- filesystem_dock->connect("instance", callable_mp(this, &EditorNode::_instance_request));
+ filesystem_dock->connect("instance", callable_mp(this, &EditorNode::_instantiate_request));
filesystem_dock->connect("display_mode_changed", callable_mp(this, &EditorNode::_save_docks));
// Scene: Top left
@@ -6557,7 +6552,7 @@ EditorNode::EditorNode() {
const String docks_section = "docks";
overridden_default_layout = -1;
- default_layout.instance();
+ default_layout.instantiate();
// Dock numbers are based on DockSlot enum value + 1
default_layout->set_value(docks_section, "dock_3", "Scene,Import");
default_layout->set_value(docks_section, "dock_4", "FileSystem");
@@ -6838,31 +6833,31 @@ EditorNode::EditorNode() {
{
Ref<StandardMaterial3DConversionPlugin> spatial_mat_convert;
- spatial_mat_convert.instance();
+ spatial_mat_convert.instantiate();
resource_conversion_plugins.push_back(spatial_mat_convert);
Ref<CanvasItemMaterialConversionPlugin> canvas_item_mat_convert;
- canvas_item_mat_convert.instance();
+ canvas_item_mat_convert.instantiate();
resource_conversion_plugins.push_back(canvas_item_mat_convert);
Ref<ParticlesMaterialConversionPlugin> particles_mat_convert;
- particles_mat_convert.instance();
+ particles_mat_convert.instantiate();
resource_conversion_plugins.push_back(particles_mat_convert);
Ref<ProceduralSkyMaterialConversionPlugin> procedural_sky_mat_convert;
- procedural_sky_mat_convert.instance();
+ procedural_sky_mat_convert.instantiate();
resource_conversion_plugins.push_back(procedural_sky_mat_convert);
Ref<PanoramaSkyMaterialConversionPlugin> panorama_sky_mat_convert;
- panorama_sky_mat_convert.instance();
+ panorama_sky_mat_convert.instantiate();
resource_conversion_plugins.push_back(panorama_sky_mat_convert);
Ref<PhysicalSkyMaterialConversionPlugin> physical_sky_mat_convert;
- physical_sky_mat_convert.instance();
+ physical_sky_mat_convert.instantiate();
resource_conversion_plugins.push_back(physical_sky_mat_convert);
Ref<VisualShaderConversionPlugin> vshader_convert;
- vshader_convert.instance();
+ vshader_convert.instantiate();
resource_conversion_plugins.push_back(vshader_convert);
}
update_spinner_step_msec = OS::get_singleton()->get_ticks_msec();
@@ -6875,12 +6870,12 @@ EditorNode::EditorNode() {
editor_plugins_force_input_forwarding = memnew(EditorPluginList);
Ref<EditorExportTextSceneToBinaryPlugin> export_text_to_binary_plugin;
- export_text_to_binary_plugin.instance();
+ export_text_to_binary_plugin.instantiate();
EditorExport::get_singleton()->add_export_plugin(export_text_to_binary_plugin);
Ref<PackedSceneEditorTranslationParserPlugin> packed_scene_translation_parser_plugin;
- packed_scene_translation_parser_plugin.instance();
+ packed_scene_translation_parser_plugin.instantiate();
EditorTranslationParser::get_singleton()->add_parser(packed_scene_translation_parser_plugin, EditorTranslationParser::STANDARD);
_edit_current();
@@ -6901,7 +6896,7 @@ EditorNode::EditorNode() {
saved_version = 1;
unsaved_cache = true;
- _last_instanced_scene = nullptr;
+ _last_instantiated_scene = nullptr;
quick_open = memnew(EditorQuickOpen);
gui_base->add_child(quick_open);
diff --git a/editor/editor_node.h b/editor/editor_node.h
index 037ed263c5..9a135cfdd7 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -332,7 +332,7 @@ private:
EditorNativeShaderSourceVisualizer *native_shader_source_visualizer;
String defer_load_scene;
- Node *_last_instanced_scene;
+ Node *_last_instantiated_scene;
EditorLog *log;
CenterContainer *tabs_center;
@@ -491,7 +491,7 @@ private:
void _discard_changes(const String &p_str = String());
void _inherit_request(String p_file);
- void _instance_request(const Vector<String> &p_files);
+ void _instantiate_request(const Vector<String> &p_files);
void _display_top_editors(bool p_display);
void _set_top_editors(Vector<EditorPlugin *> p_editor_plugins_over);
@@ -770,7 +770,7 @@ public:
static VSplitContainer *get_top_split() { return singleton->top_split; }
void request_instance_scene(const String &p_path);
- void request_instance_scenes(const Vector<String> &p_files);
+ void request_instantiate_scenes(const Vector<String> &p_files);
FileSystemDock *get_filesystem_dock();
ImportDock *get_import_dock();
SceneTreeDock *get_scene_tree_dock();
diff --git a/editor/editor_plugin_settings.cpp b/editor/editor_plugin_settings.cpp
index 1db24bb908..62fbad7bcf 100644
--- a/editor/editor_plugin_settings.cpp
+++ b/editor/editor_plugin_settings.cpp
@@ -57,7 +57,7 @@ void EditorPluginSettings::update_plugins() {
for (int i = 0; i < plugins.size(); i++) {
Ref<ConfigFile> cf;
- cf.instance();
+ cf.instantiate();
const String path = plugins[i];
Error err2 = cf->load(path);
@@ -216,10 +216,10 @@ EditorPluginSettings::EditorPluginSettings() {
plugin_list->set_column_expand(2, false);
plugin_list->set_column_expand(3, false);
plugin_list->set_column_expand(4, false);
- plugin_list->set_column_min_width(1, 100 * EDSCALE);
- plugin_list->set_column_min_width(2, 250 * EDSCALE);
- plugin_list->set_column_min_width(3, 80 * EDSCALE);
- plugin_list->set_column_min_width(4, 40 * EDSCALE);
+ plugin_list->set_column_custom_minimum_width(1, 100 * EDSCALE);
+ plugin_list->set_column_custom_minimum_width(2, 250 * EDSCALE);
+ plugin_list->set_column_custom_minimum_width(3, 80 * EDSCALE);
+ plugin_list->set_column_custom_minimum_width(4, 40 * EDSCALE);
plugin_list->set_hide_root(true);
plugin_list->connect("item_edited", callable_mp(this, &EditorPluginSettings::_plugin_activity_changed));
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 3feeaec070..5ca596417b 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -491,6 +491,7 @@ void EditorPropertyEnum::update_property() {
}
void EditorPropertyEnum::setup(const Vector<String> &p_options) {
+ options->clear();
int64_t current_val = 0;
for (int i = 0; i < p_options.size(); i++) {
Vector<String> text_split = p_options[i].split(":");
@@ -2535,7 +2536,7 @@ void EditorPropertyResource::_viewport_selected(const NodePath &p_path) {
}
Ref<ViewportTexture> vt;
- vt.instance();
+ vt.instantiate();
vt->set_viewport_path_in_scene(get_tree()->get_edited_scene_root()->get_path_to(to_node));
vt->setup_local_to_scene();
@@ -2699,30 +2700,42 @@ void EditorInspectorDefaultPlugin::parse_begin(Object *p_object) {
}
bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage, bool p_wide) {
+ Control *editor = EditorInspectorDefaultPlugin::get_editor_for_property(p_object, p_type, p_path, p_hint, p_hint_text, p_usage, p_wide);
+ if (editor) {
+ add_property_editor(p_path, editor);
+ }
+ return false;
+}
+
+void EditorInspectorDefaultPlugin::parse_end() {
+ //do none
+}
+
+EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage, bool p_wide) {
double default_float_step = EDITOR_GET("interface/inspector/default_float_step");
switch (p_type) {
// atomic types
case Variant::NIL: {
EditorPropertyNil *editor = memnew(EditorPropertyNil);
- add_property_editor(p_path, editor);
+ return editor;
} break;
case Variant::BOOL: {
EditorPropertyCheck *editor = memnew(EditorPropertyCheck);
- add_property_editor(p_path, editor);
+ return editor;
} break;
case Variant::INT: {
if (p_hint == PROPERTY_HINT_ENUM) {
EditorPropertyEnum *editor = memnew(EditorPropertyEnum);
Vector<String> options = p_hint_text.split(",");
editor->setup(options);
- add_property_editor(p_path, editor);
+ return editor;
} else if (p_hint == PROPERTY_HINT_FLAGS) {
EditorPropertyFlags *editor = memnew(EditorPropertyFlags);
Vector<String> options = p_hint_text.split(",");
editor->setup(options);
- add_property_editor(p_path, editor);
+ return editor;
} else if (p_hint == PROPERTY_HINT_LAYERS_2D_PHYSICS ||
p_hint == PROPERTY_HINT_LAYERS_2D_RENDER ||
@@ -2755,11 +2768,11 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
}
EditorPropertyLayers *editor = memnew(EditorPropertyLayers);
editor->setup(lt);
- add_property_editor(p_path, editor);
+ return editor;
} else if (p_hint == PROPERTY_HINT_OBJECT_ID) {
EditorPropertyObjectID *editor = memnew(EditorPropertyObjectID);
editor->setup(p_hint_text);
- add_property_editor(p_path, editor);
+ return editor;
} else {
EditorPropertyInteger *editor = memnew(EditorPropertyInteger);
@@ -2789,7 +2802,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
editor->setup(min, max, step, greater, lesser);
- add_property_editor(p_path, editor);
+ return editor;
}
} break;
case Variant::FLOAT: {
@@ -2809,7 +2822,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
}
editor->setup(full, flip);
- add_property_editor(p_path, editor);
+ return editor;
} else {
EditorPropertyFloat *editor = memnew(EditorPropertyFloat);
@@ -2841,7 +2854,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
editor->setup(min, max, step, hide_slider, exp_range, greater, lesser);
- add_property_editor(p_path, editor);
+ return editor;
}
} break;
case Variant::STRING: {
@@ -2849,14 +2862,14 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
EditorPropertyTextEnum *editor = memnew(EditorPropertyTextEnum);
Vector<String> options = p_hint_text.split(",");
editor->setup(options);
- add_property_editor(p_path, editor);
+ return editor;
} else if (p_hint == PROPERTY_HINT_MULTILINE_TEXT) {
EditorPropertyMultilineText *editor = memnew(EditorPropertyMultilineText);
- add_property_editor(p_path, editor);
+ return editor;
} else if (p_hint == PROPERTY_HINT_TYPE_STRING) {
EditorPropertyClassName *editor = memnew(EditorPropertyClassName);
editor->setup("Object", p_hint_text);
- add_property_editor(p_path, editor);
+ return editor;
} else if (p_hint == PROPERTY_HINT_DIR || p_hint == PROPERTY_HINT_FILE || p_hint == PROPERTY_HINT_SAVE_FILE || p_hint == PROPERTY_HINT_GLOBAL_DIR || p_hint == PROPERTY_HINT_GLOBAL_FILE) {
Vector<String> extensions = p_hint_text.split(",");
bool global = p_hint == PROPERTY_HINT_GLOBAL_DIR || p_hint == PROPERTY_HINT_GLOBAL_FILE;
@@ -2867,7 +2880,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
if (save) {
editor->set_save_mode();
}
- add_property_editor(p_path, editor);
+ return editor;
} else if (p_hint == PROPERTY_HINT_METHOD_OF_VARIANT_TYPE ||
p_hint == PROPERTY_HINT_METHOD_OF_BASE_TYPE ||
p_hint == PROPERTY_HINT_METHOD_OF_INSTANCE ||
@@ -2905,14 +2918,14 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
}
}
editor->setup(type, p_hint_text);
- add_property_editor(p_path, editor);
+ return editor;
} else {
EditorPropertyText *editor = memnew(EditorPropertyText);
if (p_hint == PROPERTY_HINT_PLACEHOLDER_TEXT) {
editor->set_placeholder(p_hint_text);
}
- add_property_editor(p_path, editor);
+ return editor;
}
} break;
@@ -2933,7 +2946,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
}
editor->setup(min, max, step, hide_slider);
- add_property_editor(p_path, editor);
+ return editor;
} break;
case Variant::VECTOR2I: {
@@ -2948,7 +2961,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
}
editor->setup(min, max, hide_slider);
- add_property_editor(p_path, editor);
+ return editor;
} break;
case Variant::RECT2: {
@@ -2966,7 +2979,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
}
editor->setup(min, max, step, hide_slider);
- add_property_editor(p_path, editor);
+ return editor;
} break;
case Variant::RECT2I: {
EditorPropertyRect2i *editor = memnew(EditorPropertyRect2i(p_wide));
@@ -2980,7 +2993,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
}
editor->setup(min, max, hide_slider);
- add_property_editor(p_path, editor);
+ return editor;
} break;
case Variant::VECTOR3: {
EditorPropertyVector3 *editor = memnew(EditorPropertyVector3(p_wide));
@@ -2997,7 +3010,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
}
editor->setup(min, max, step, hide_slider);
- add_property_editor(p_path, editor);
+ return editor;
} break;
case Variant::VECTOR3I: {
@@ -3013,7 +3026,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
}
editor->setup(min, max, hide_slider);
- add_property_editor(p_path, editor);
+ return editor;
} break;
case Variant::TRANSFORM2D: {
@@ -3031,7 +3044,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
}
editor->setup(min, max, step, hide_slider);
- add_property_editor(p_path, editor);
+ return editor;
} break;
case Variant::PLANE: {
@@ -3049,7 +3062,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
}
editor->setup(min, max, step, hide_slider);
- add_property_editor(p_path, editor);
+ return editor;
} break;
case Variant::QUATERNION: {
EditorPropertyQuaternion *editor = memnew(EditorPropertyQuaternion);
@@ -3066,7 +3079,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
}
editor->setup(min, max, step, hide_slider);
- add_property_editor(p_path, editor);
+ return editor;
} break;
case Variant::AABB: {
EditorPropertyAABB *editor = memnew(EditorPropertyAABB);
@@ -3083,7 +3096,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
}
editor->setup(min, max, step, hide_slider);
- add_property_editor(p_path, editor);
+ return editor;
} break;
case Variant::BASIS: {
EditorPropertyBasis *editor = memnew(EditorPropertyBasis);
@@ -3100,7 +3113,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
}
editor->setup(min, max, step, hide_slider);
- add_property_editor(p_path, editor);
+ return editor;
} break;
case Variant::TRANSFORM3D: {
EditorPropertyTransform3D *editor = memnew(EditorPropertyTransform3D);
@@ -3117,7 +3130,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
}
editor->setup(min, max, step, hide_slider);
- add_property_editor(p_path, editor);
+ return editor;
} break;
@@ -3125,21 +3138,21 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
case Variant::COLOR: {
EditorPropertyColor *editor = memnew(EditorPropertyColor);
editor->setup(p_hint != PROPERTY_HINT_COLOR_NO_ALPHA);
- add_property_editor(p_path, editor);
+ return editor;
} break;
case Variant::STRING_NAME: {
if (p_hint == PROPERTY_HINT_ENUM) {
EditorPropertyTextEnum *editor = memnew(EditorPropertyTextEnum);
Vector<String> options = p_hint_text.split(",");
editor->setup(options, true);
- add_property_editor(p_path, editor);
+ return editor;
} else {
EditorPropertyText *editor = memnew(EditorPropertyText);
if (p_hint == PROPERTY_HINT_PLACEHOLDER_TEXT) {
editor->set_placeholder(p_hint_text);
}
editor->set_string_name(true);
- add_property_editor(p_path, editor);
+ return editor;
}
} break;
case Variant::NODE_PATH: {
@@ -3152,12 +3165,12 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
Vector<StringName> sn = Variant(types); //convert via variant
editor->setup(NodePath(), sn, (p_usage & PROPERTY_USAGE_NODE_PATH_FROM_SCENE_ROOT));
}
- add_property_editor(p_path, editor);
+ return editor;
} break;
case Variant::RID: {
EditorPropertyRID *editor = memnew(EditorPropertyRID);
- add_property_editor(p_path, editor);
+ return editor;
} break;
case Variant::OBJECT: {
EditorPropertyResource *editor = memnew(EditorPropertyResource);
@@ -3176,70 +3189,66 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
}
}
- add_property_editor(p_path, editor);
+ return editor;
} break;
case Variant::DICTIONARY: {
EditorPropertyDictionary *editor = memnew(EditorPropertyDictionary);
- add_property_editor(p_path, editor);
+ return editor;
} break;
case Variant::ARRAY: {
EditorPropertyArray *editor = memnew(EditorPropertyArray);
editor->setup(Variant::ARRAY, p_hint_text);
- add_property_editor(p_path, editor);
+ return editor;
} break;
case Variant::PACKED_BYTE_ARRAY: {
EditorPropertyArray *editor = memnew(EditorPropertyArray);
editor->setup(Variant::PACKED_BYTE_ARRAY);
- add_property_editor(p_path, editor);
+ return editor;
} break;
case Variant::PACKED_INT32_ARRAY: {
EditorPropertyArray *editor = memnew(EditorPropertyArray);
editor->setup(Variant::PACKED_INT32_ARRAY);
- add_property_editor(p_path, editor);
+ return editor;
} break;
case Variant::PACKED_INT64_ARRAY: {
EditorPropertyArray *editor = memnew(EditorPropertyArray);
editor->setup(Variant::PACKED_INT64_ARRAY);
- add_property_editor(p_path, editor);
+ return editor;
} break;
case Variant::PACKED_FLOAT32_ARRAY: {
EditorPropertyArray *editor = memnew(EditorPropertyArray);
editor->setup(Variant::PACKED_FLOAT32_ARRAY);
- add_property_editor(p_path, editor);
+ return editor;
} break;
case Variant::PACKED_FLOAT64_ARRAY: {
EditorPropertyArray *editor = memnew(EditorPropertyArray);
editor->setup(Variant::PACKED_FLOAT64_ARRAY);
- add_property_editor(p_path, editor);
+ return editor;
} break;
case Variant::PACKED_STRING_ARRAY: {
EditorPropertyArray *editor = memnew(EditorPropertyArray);
editor->setup(Variant::PACKED_STRING_ARRAY);
- add_property_editor(p_path, editor);
+ return editor;
} break;
case Variant::PACKED_VECTOR2_ARRAY: {
EditorPropertyArray *editor = memnew(EditorPropertyArray);
editor->setup(Variant::PACKED_VECTOR2_ARRAY);
- add_property_editor(p_path, editor);
+ return editor;
} break;
case Variant::PACKED_VECTOR3_ARRAY: {
EditorPropertyArray *editor = memnew(EditorPropertyArray);
editor->setup(Variant::PACKED_VECTOR3_ARRAY);
- add_property_editor(p_path, editor);
+ return editor;
} break;
case Variant::PACKED_COLOR_ARRAY: {
EditorPropertyArray *editor = memnew(EditorPropertyArray);
editor->setup(Variant::PACKED_COLOR_ARRAY);
- add_property_editor(p_path, editor);
+
} break;
default: {
}
}
- return false; //can be overridden, although it will most likely be last anyway
-}
-
-void EditorInspectorDefaultPlugin::parse_end() {
- //do none
+ return nullptr;
}
diff --git a/editor/editor_properties.h b/editor/editor_properties.h
index dcde7dda3d..522f4eebf6 100644
--- a/editor/editor_properties.h
+++ b/editor/editor_properties.h
@@ -649,6 +649,8 @@ public:
virtual void parse_begin(Object *p_object) override;
virtual bool parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage, bool p_wide = false) override;
virtual void parse_end() override;
+
+ static EditorProperty *get_editor_for_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage, bool p_wide = false);
};
#endif // EDITOR_PROPERTIES_H
diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp
index 66fabcd940..9987aaf3fe 100644
--- a/editor/editor_properties_array_dict.cpp
+++ b/editor/editor_properties_array_dict.cpp
@@ -550,6 +550,8 @@ void EditorPropertyArray::_length_changed(double p_page) {
void EditorPropertyArray::setup(Variant::Type p_array_type, const String &p_hint_string) {
array_type = p_array_type;
+ // The format of p_hint_string is:
+ // subType/subTypeHint:nextSubtype ... etc
if (array_type == Variant::ARRAY && !p_hint_string.is_empty()) {
int hint_subtype_separator = p_hint_string.find(":");
if (hint_subtype_separator >= 0) {
@@ -572,7 +574,7 @@ void EditorPropertyArray::_bind_methods() {
}
EditorPropertyArray::EditorPropertyArray() {
- object.instance();
+ object.instantiate();
page_len = int(EDITOR_GET("interface/inspector/max_array_dictionary_items_per_page"));
edit = memnew(Button);
edit->set_h_size_flags(SIZE_EXPAND_FILL);
@@ -971,7 +973,7 @@ void EditorPropertyDictionary::update_property() {
PanelContainer *pc = memnew(PanelContainer);
vbox->add_child(pc);
Ref<StyleBoxFlat> flat;
- flat.instance();
+ flat.instantiate();
for (int j = 0; j < 4; j++) {
flat->set_default_margin(Side(j), 2 * EDSCALE);
}
@@ -1066,7 +1068,7 @@ void EditorPropertyDictionary::_bind_methods() {
}
EditorPropertyDictionary::EditorPropertyDictionary() {
- object.instance();
+ object.instantiate();
page_len = int(EDITOR_GET("interface/inspector/max_array_dictionary_items_per_page"));
edit = memnew(Button);
edit->set_h_size_flags(SIZE_EXPAND_FILL);
diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp
index 1ea8c71f85..350fc5eccb 100644
--- a/editor/editor_resource_picker.cpp
+++ b/editor/editor_resource_picker.cpp
@@ -271,7 +271,7 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) {
}
String orig_type = edited_resource->get_class();
- Object *inst = ClassDB::instance(orig_type);
+ Object *inst = ClassDB::instantiate(orig_type);
Ref<Resource> unique_resource = Ref<Resource>(Object::cast_to<Resource>(inst));
ERR_FAIL_COND(unique_resource.is_null());
@@ -334,7 +334,7 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) {
Variant obj;
if (ScriptServer::is_global_class(intype)) {
- obj = ClassDB::instance(ScriptServer::get_global_class_native_base(intype));
+ obj = ClassDB::instantiate(ScriptServer::get_global_class_native_base(intype));
if (obj) {
Ref<Script> script = ResourceLoader::load(ScriptServer::get_global_class_path(intype));
if (script.is_valid()) {
@@ -342,7 +342,7 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) {
}
}
} else {
- obj = ClassDB::instance(intype);
+ obj = ClassDB::instantiate(intype);
}
if (!obj) {
@@ -395,7 +395,7 @@ void EditorResourcePicker::set_create_options(Object *p_menu_node) {
}
}
- if (!is_custom_resource && !(ScriptServer::is_global_class(t) || ClassDB::can_instance(t))) {
+ if (!is_custom_resource && !(ScriptServer::is_global_class(t) || ClassDB::can_instantiate(t))) {
continue;
}
@@ -644,7 +644,7 @@ void EditorResourcePicker::_bind_methods() {
ClassDB::add_virtual_method(get_class_static(), MethodInfo("_handle_menu_selected", PropertyInfo(Variant::INT, "id")));
ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_type"), "set_base_type", "get_base_type");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "edited_resource", PROPERTY_HINT_RESOURCE_TYPE, "Resource", 0), "set_edited_resource", "get_edited_resource");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "edited_resource", PROPERTY_HINT_RESOURCE_TYPE, "Resource", PROPERTY_USAGE_NONE), "set_edited_resource", "get_edited_resource");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editable"), "set_editable", "is_editable");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "toggle_mode"), "set_toggle_mode", "is_toggle_mode");
@@ -857,7 +857,7 @@ void EditorScriptPicker::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_script_owner", "owner_node"), &EditorScriptPicker::set_script_owner);
ClassDB::bind_method(D_METHOD("get_script_owner"), &EditorScriptPicker::get_script_owner);
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "script_owner", PROPERTY_HINT_RESOURCE_TYPE, "Node", 0), "set_script_owner", "get_script_owner");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "script_owner", PROPERTY_HINT_RESOURCE_TYPE, "Node", PROPERTY_USAGE_NONE), "set_script_owner", "get_script_owner");
}
EditorScriptPicker::EditorScriptPicker() {
diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp
index 0f1b70936a..f904ae80a7 100644
--- a/editor/editor_resource_preview.cpp
+++ b/editor/editor_resource_preview.cpp
@@ -177,7 +177,7 @@ void EditorResourcePreview::_generate_preview(Ref<ImageTexture> &r_texture, Ref<
Ref<Image> small_image = r_texture->get_image();
small_image = small_image->duplicate();
small_image->resize(small_thumbnail_size, small_thumbnail_size, Image::INTERPOLATE_CUBIC);
- r_small_texture.instance();
+ r_small_texture.instantiate();
r_small_texture->create_from_image(small_image);
}
@@ -293,21 +293,21 @@ void EditorResourcePreview::_thread() {
if (cache_valid) {
Ref<Image> img;
- img.instance();
+ img.instantiate();
Ref<Image> small_img;
- small_img.instance();
+ small_img.instantiate();
if (img->load(cache_base + ".png") != OK) {
cache_valid = false;
} else {
- texture.instance();
+ texture.instantiate();
texture->create_from_image(img);
if (has_small_texture) {
if (small_img->load(cache_base + "_small.png") != OK) {
cache_valid = false;
} else {
- small_texture.instance();
+ small_texture.instantiate();
small_texture->create_from_image(small_img);
}
}
diff --git a/editor/editor_run_native.cpp b/editor/editor_run_native.cpp
index 1ffa20d1ea..a604022391 100644
--- a/editor/editor_run_native.cpp
+++ b/editor/editor_run_native.cpp
@@ -49,7 +49,7 @@ void EditorRunNative::_notification(int p_what) {
if (!im->is_empty()) {
im->resize(16 * EDSCALE, 16 * EDSCALE);
Ref<ImageTexture> small_icon;
- small_icon.instance();
+ small_icon.instantiate();
small_icon->create_from_image(im);
MenuButton *mb = memnew(MenuButton);
mb->get_popup()->connect("id_pressed", callable_mp(this, &EditorRunNative::_run_native), varray(i));
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 3f66326b41..3f02b76ff6 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -79,7 +79,7 @@ bool EditorSettings::_set_only(const StringName &p_name, const Variant &p_value)
Ref<InputEvent> shortcut = arr[i + 1];
Ref<Shortcut> sc;
- sc.instance();
+ sc.instantiate();
sc->set_shortcut(shortcut);
add_shortcut(name, sc);
}
@@ -1476,7 +1476,7 @@ Ref<Shortcut> EditorSettings::get_shortcut(const String &p_name) const {
Ref<Shortcut> sc;
const Map<String, List<Ref<InputEvent>>>::Element *builtin_override = builtin_action_overrides.find(p_name);
if (builtin_override) {
- sc.instance();
+ sc.instantiate();
sc->set_shortcut(builtin_override->get().front()->get());
sc->set_name(InputMap::get_singleton()->get_builtin_display_name(p_name));
}
@@ -1485,7 +1485,7 @@ Ref<Shortcut> EditorSettings::get_shortcut(const String &p_name) const {
if (sc.is_null()) {
const OrderedHashMap<String, List<Ref<InputEvent>>>::ConstElement builtin_default = InputMap::get_singleton()->get_builtins().find(p_name);
if (builtin_default) {
- sc.instance();
+ sc.instantiate();
sc->set_shortcut(builtin_default.get().front()->get());
sc->set_name(InputMap::get_singleton()->get_builtin_display_name(p_name));
}
@@ -1528,7 +1528,7 @@ Ref<Shortcut> ED_SHORTCUT(const String &p_path, const String &p_name, uint32_t p
Ref<InputEventKey> ie;
if (p_keycode) {
- ie.instance();
+ ie.instantiate();
ie->set_unicode(p_keycode & KEY_CODE_MASK);
ie->set_keycode(p_keycode & KEY_CODE_MASK);
@@ -1540,7 +1540,7 @@ Ref<Shortcut> ED_SHORTCUT(const String &p_path, const String &p_name, uint32_t p
if (!EditorSettings::get_singleton()) {
Ref<Shortcut> sc;
- sc.instance();
+ sc.instantiate();
sc->set_name(p_name);
sc->set_shortcut(ie);
sc->set_meta("original", ie);
@@ -1554,7 +1554,7 @@ Ref<Shortcut> ED_SHORTCUT(const String &p_path, const String &p_name, uint32_t p
return sc;
}
- sc.instance();
+ sc.instantiate();
sc->set_name(p_name);
sc->set_shortcut(ie);
sc->set_meta("original", ie); //to compare against changes
@@ -1585,7 +1585,7 @@ void EditorSettings::set_builtin_action_override(const String &p_name, const Arr
// Check equality of each event.
for (List<Ref<InputEvent>>::Element *E = builtin_events.front(); E; E = E->next()) {
- if (!E->get()->shortcut_match(p_events[event_idx])) {
+ if (!E->get()->is_match(p_events[event_idx])) {
same_as_builtin = false;
break;
}
diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp
index 4f0d75ecce..d8c765911c 100644
--- a/editor/editor_spin_slider.cpp
+++ b/editor/editor_spin_slider.cpp
@@ -373,7 +373,7 @@ void EditorSpinSlider::_evaluate_input_text() {
const String text = TS->parse_number(value_input->get_text().replace(",", "."));
Ref<Expression> expr;
- expr.instance();
+ expr.instantiate();
Error err = expr->parse(text);
if (err != OK) {
return;
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp
index fa543b7455..131a77e52f 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -766,12 +766,12 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_stylebox("sub_inspector_bg" + itos(i), "Editor", sub_inspector_bg);
Ref<StyleBoxFlat> bg_color;
- bg_color.instance();
+ bg_color.instantiate();
bg_color->set_bg_color(si_base_color * Color(0.7, 0.7, 0.7, 0.8));
bg_color->set_border_width_all(0);
Ref<StyleBoxFlat> bg_color_selected;
- bg_color_selected.instance();
+ bg_color_selected.instantiate();
bg_color_selected->set_border_width_all(0);
bg_color_selected->set_bg_color(si_base_color * Color(0.8, 0.8, 0.8, 0.8));
diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp
index 76c6fcc3d3..dd4ce74406 100644
--- a/editor/export_template_manager.cpp
+++ b/editor/export_template_manager.cpp
@@ -242,10 +242,8 @@ void ExportTemplateManager::_refresh_mirrors_completed(int p_status, int p_code,
response_json.parse_utf8((const char *)r, p_data.size());
}
- Variant response;
- String errs;
- int errline;
- Error err = JSON::parse(response_json, response, errs, errline);
+ JSON json;
+ Error err = json.parse(response_json);
if (err != OK) {
EditorNode::get_singleton()->show_warning(TTR("Error parsing JSON with the list of mirrors. Please report this issue!"));
is_refreshing_mirrors = false;
@@ -260,7 +258,7 @@ void ExportTemplateManager::_refresh_mirrors_completed(int p_status, int p_code,
mirrors_available = false;
- Dictionary data = response;
+ Dictionary data = json.get_data();
if (data.has("mirrors")) {
Array mirrors = data["mirrors"];
diff --git a/editor/fileserver/editor_file_server.cpp b/editor/fileserver/editor_file_server.cpp
index 654915e3e5..8f019a95fd 100644
--- a/editor/fileserver/editor_file_server.cpp
+++ b/editor/fileserver/editor_file_server.cpp
@@ -312,7 +312,7 @@ void EditorFileServer::stop() {
}
EditorFileServer::EditorFileServer() {
- server.instance();
+ server.instantiate();
quit = false;
active = false;
cmd = CMD_NONE;
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index fe1fa9f9d6..cb89e5c7d0 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -945,7 +945,7 @@ void FileSystemDock::_select_file(const String &p_path, bool p_select_in_favorit
} else if (fpath != "Favorites") {
if (FileAccess::exists(fpath + ".import")) {
Ref<ConfigFile> config;
- config.instance();
+ config.instantiate();
Error err = config->load(fpath + ".import");
if (err == OK) {
if (config->has_section_key("remap", "importer")) {
@@ -2675,7 +2675,7 @@ void FileSystemDock::_update_import_dock() {
for (int i = 0; i < efiles.size(); i++) {
String fpath = efiles[i];
Ref<ConfigFile> cf;
- cf.instance();
+ cf.instantiate();
Error err = cf->load(fpath + ".import");
if (err != OK) {
imports.clear();
diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp
index c29b5d5906..cb8de09a9a 100644
--- a/editor/find_in_files.cpp
+++ b/editor/find_in_files.cpp
@@ -638,7 +638,7 @@ void FindInFilesPanel::set_with_replace(bool with_replace) {
// Results show checkboxes on their left so they can be opted out
_results_display->set_columns(2);
_results_display->set_column_expand(0, false);
- _results_display->set_column_min_width(0, 48 * EDSCALE);
+ _results_display->set_column_custom_minimum_width(0, 48 * EDSCALE);
} else {
// Results are single-cell items
diff --git a/editor/icons/CenterView.svg b/editor/icons/CenterView.svg
new file mode 100644
index 0000000000..c2a918fe81
--- /dev/null
+++ b/editor/icons/CenterView.svg
@@ -0,0 +1 @@
+<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><circle cx="4" cy="12" fill="none" r="2"/><g fill="#e0e0e0"><path d="m7.3333333 6c-.7386666 0-1.3333333.5946667-1.3333333 1.3333333v1.3333334c0 .7386663.5946667 1.3333333 1.3333333 1.3333333h1.3333334c.7386666 0 1.3333333-.594667 1.3333333-1.3333333v-1.3333334c0-.7386666-.5946667-1.3333333-1.3333333-1.3333333z" stroke-width=".666667"/><g stroke-width=".830398"><path d="m2.9918978 5.5000002c-.7478701.0001968-1.1170118.9026572-.5810669 1.4205652l.2441488.2424178h-2.15497967v1.6548989h2.15497967l-.2441488.242418c-.8159014.77992.3929613 1.9802119 1.178451 1.1700959l1.6667154-1.6548989c.3253369-.3231472.3253369-.8469488 0-1.170096l-1.6667154-1.6548989c-.1568986-.1601378-.3723426-.2504824-.5973507-.2504937z"/><path d="m13.008102 10.5c.74787-.000197 1.117012-.9026571.581067-1.4205651l-.244149-.242418h2.15498v-1.6548988h-2.15498l.244149-.2424179c.815901-.7799207-.392961-1.9802122-1.178451-1.1700961l-1.666715 1.6548987c-.325337.3231474-.325337.846949 0 1.1700961l1.666715 1.6548991c.156899.160138.372343.250482.597351.250494z"/><path d="m5.5000001 13.008102c.000197.74787.902657 1.117012 1.420565.581067l.242418-.244149v2.15498h1.654899v-2.15498l.242418.244149c.77992.815901 1.9802119-.392961 1.1700959-1.178451l-1.6548989-1.666715c-.323147-.325337-.846949-.325337-1.170096 0l-1.654899 1.666715c-.160138.156899-.250482.372343-.250494.597351z"/><path d="m10.5 2.9918983c-.000197-.7478701-.9026571-1.1170121-1.4205651-.581067l-.242418.244149v-2.1549801h-1.6548989v2.1549801l-.242418-.2441491c-.77992-.815901-1.9802121.3929611-1.170096 1.1784512l1.654899 1.6667148c.3231469.325337.8469489.325337 1.1700959 0l1.6548991-1.6667148c.160138-.156899.250482-.3723431.250494-.597351z"/></g></g></svg>
diff --git a/editor/icons/RectangleAddRemove.svg b/editor/icons/RectangleAddRemove.svg
deleted file mode 100644
index 87e2155a0d..0000000000
--- a/editor/icons/RectangleAddRemove.svg
+++ /dev/null
@@ -1 +0,0 @@
-<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m2 2c-.5522619.0000552-.9999448.4477381-1 1v10c.0000552.552262.4477381.999945 1 1h6v-2h-5v-8h10v1h2v-2c-.000055-.5522619-.447738-.9999448-1-1zm9.25 4v2.25h-2.25v1.5h2.25v2.25h1.5v-2.25h2.25v-1.5h-2.25v-2.25zm-2.25 7.5v1.5h6v-1.5z" fill="#e0e0e0"/></svg>
diff --git a/editor/icons/TileChecked.svg b/editor/icons/TileChecked.svg
new file mode 100644
index 0000000000..33b99a0e4c
--- /dev/null
+++ b/editor/icons/TileChecked.svg
@@ -0,0 +1 @@
+<svg height="16" viewBox="0 0 16 15.999999" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m3.3333333 1c-1.2887 0-2.3333333 1.0446683-2.3333333 2.3333333v9.3333337c0 1.2887 1.0446683 2.333333 2.3333333 2.333333h9.3333337c1.2887 0 2.333333-1.044668 2.333333-2.333333v-9.3333337c0-1.2887-1.044668-2.3333333-2.333333-2.3333333z" fill="#808080" stroke-width="1.16667"/><path d="m11.500773 3.7343508-5.6117507 5.6117502-1.7045017-1.6814543-1.4992276 1.4992276 3.2037293 3.1806817 7.1109777-7.1109775z" fill="#fff" stroke-width="1.06023"/></svg>
diff --git a/editor/icons/TileUnchecked.svg b/editor/icons/TileUnchecked.svg
new file mode 100644
index 0000000000..cd8db4ee19
--- /dev/null
+++ b/editor/icons/TileUnchecked.svg
@@ -0,0 +1 @@
+<svg height="16" viewBox="0 0 16 15.999999" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m3.3333333 1c-1.2887 0-2.3333333 1.0446683-2.3333333 2.3333333v9.3333337c0 1.2887 1.0446683 2.333333 2.3333333 2.333333h9.3333337c1.2887 0 2.333333-1.044668 2.333333-2.333333v-9.3333337c0-1.2887-1.044668-2.3333333-2.333333-2.3333333z" fill="#808080" stroke-width="1.16667"/></svg>
diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp
index dc1bd38a99..ddf89f077b 100644
--- a/editor/import/editor_import_collada.cpp
+++ b/editor/import/editor_import_collada.cpp
@@ -850,7 +850,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<EditorSceneImpor
}
Ref<SurfaceTool> surftool;
- surftool.instance();
+ surftool.instantiate();
surftool->begin(Mesh::PRIMITIVE_TRIANGLES);
for (int k = 0; k < vertex_array.size(); k++) {
@@ -1544,7 +1544,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
}
Vector3 s = xform.basis.get_scale();
- bool singular_matrix = Math::is_equal_approx(s.x, 0.0f) || Math::is_equal_approx(s.y, 0.0f) || Math::is_equal_approx(s.z, 0.0f);
+ bool singular_matrix = Math::is_zero_approx(s.x) || Math::is_zero_approx(s.y) || Math::is_zero_approx(s.z);
Quaternion q = singular_matrix ? Quaternion() : xform.basis.get_rotation_quaternion();
Vector3 l = xform.origin;
@@ -1595,7 +1595,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
xform = sk->get_bone_rest(nm.bone).affine_inverse() * xform;
Vector3 s = xform.basis.get_scale();
- bool singular_matrix = Math::is_equal_approx(s.x, 0.0f) || Math::is_equal_approx(s.y, 0.0f) || Math::is_equal_approx(s.z, 0.0f);
+ bool singular_matrix = Math::is_zero_approx(s.x) || Math::is_zero_approx(s.y) || Math::is_zero_approx(s.z);
Quaternion q = singular_matrix ? Quaternion() : xform.basis.get_rotation_quaternion();
Vector3 l = xform.origin;
diff --git a/editor/import/resource_importer_bitmask.cpp b/editor/import/resource_importer_bitmask.cpp
index ffef759c07..7fd9230284 100644
--- a/editor/import/resource_importer_bitmask.cpp
+++ b/editor/import/resource_importer_bitmask.cpp
@@ -78,7 +78,7 @@ Error ResourceImporterBitMap::import(const String &p_source_file, const String &
int create_from = p_options["create_from"];
float threshold = p_options["threshold"];
Ref<Image> image;
- image.instance();
+ image.instantiate();
Error err = ImageLoader::load_image(p_source_file, image);
if (err != OK) {
return err;
@@ -88,7 +88,7 @@ Error ResourceImporterBitMap::import(const String &p_source_file, const String &
int h = image->get_height();
Ref<BitMap> bitmap;
- bitmap.instance();
+ bitmap.instantiate();
bitmap->create(Size2(w, h));
for (int i = 0; i < h; i++) {
diff --git a/editor/import/resource_importer_csv_translation.cpp b/editor/import/resource_importer_csv_translation.cpp
index c9e446a1a2..07647d8b6a 100644
--- a/editor/import/resource_importer_csv_translation.cpp
+++ b/editor/import/resource_importer_csv_translation.cpp
@@ -104,7 +104,7 @@ Error ResourceImporterCSVTranslation::import(const String &p_source_file, const
locales.push_back(locale);
Ref<Translation> translation;
- translation.instance();
+ translation.instantiate();
translation->set_locale(locale);
translations.push_back(translation);
}
diff --git a/editor/import/resource_importer_layered_texture.cpp b/editor/import/resource_importer_layered_texture.cpp
index 6d2215c379..2ac8b8bd7d 100644
--- a/editor/import/resource_importer_layered_texture.cpp
+++ b/editor/import/resource_importer_layered_texture.cpp
@@ -186,7 +186,7 @@ void ResourceImporterLayeredTexture::_save_tex(Vector<Ref<Image>> p_images, cons
for (int i = 0; i < mm_d; i++) {
Ref<Image> mm;
- mm.instance();
+ mm.instantiate();
mm->create(mm_w, mm_h, false, p_images[0]->get_format());
Vector3 pos;
pos.z = float(i) * float(d) / float(mm_d) + 0.5;
@@ -328,7 +328,7 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const
}
Ref<Image> image;
- image.instance();
+ image.instantiate();
Error err = ImageLoader::load_image(p_source_file, image, nullptr, false, 1.0);
if (err != OK) {
return err;
diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp
index 3aa17ee581..01603c0a6a 100644
--- a/editor/import/resource_importer_obj.cpp
+++ b/editor/import/resource_importer_obj.cpp
@@ -57,7 +57,7 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Stand
//vertex
current_name = l.replace("newmtl", "").strip_edges();
- current.instance();
+ current.instantiate();
current->set_name(current_name);
material_map[current_name] = current;
} else if (l.begins_with("Ka ")) {
@@ -207,7 +207,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_
ERR_FAIL_COND_V_MSG(!f, ERR_CANT_OPEN, vformat("Couldn't open OBJ file '%s', it may not exist or not be readable.", p_path));
Ref<ArrayMesh> mesh;
- mesh.instance();
+ mesh.instantiate();
bool generate_tangents = p_generate_tangents;
Vector3 scale_mesh = p_scale_mesh;
@@ -378,7 +378,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_
if (!p_single_mesh) {
mesh->set_name(name);
r_meshes.push_back(mesh);
- mesh.instance();
+ mesh.instantiate();
current_group = "";
current_material = "";
}
@@ -440,7 +440,7 @@ Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, in
for (List<Ref<Mesh>>::Element *E = meshes.front(); E; E = E->next()) {
Ref<EditorSceneImporterMesh> mesh;
- mesh.instance();
+ mesh.instantiate();
Ref<Mesh> m = E->get();
for (int i = 0; i < m->get_surface_count(); i++) {
mesh->add_surface(m->surface_get_primitive_type(i), m->surface_get_arrays(i), Array(), Dictionary(), m->surface_get_material(i));
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index 08aa2fecbb..c14b948dae 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -1422,7 +1422,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
}
if (root_type != "Node3D") {
- Node *base_node = Object::cast_to<Node>(ClassDB::instance(root_type));
+ Node *base_node = Object::cast_to<Node>(ClassDB::instantiate(root_type));
if (base_node) {
scene->replace_by(base_node);
@@ -1557,7 +1557,7 @@ Node *EditorSceneImporterESCN::import_scene(const String &p_path, uint32_t p_fla
Ref<PackedScene> ps = ResourceFormatLoaderText::singleton->load(p_path, p_path, &error);
ERR_FAIL_COND_V_MSG(!ps.is_valid(), nullptr, "Cannot load scene as text resource from path '" + p_path + "'.");
- Node *scene = ps->instance();
+ Node *scene = ps->instantiate();
ERR_FAIL_COND_V(!scene, nullptr);
return scene;
diff --git a/editor/import/resource_importer_shader_file.cpp b/editor/import/resource_importer_shader_file.cpp
index 70119bfd1c..4d92490675 100644
--- a/editor/import/resource_importer_shader_file.cpp
+++ b/editor/import/resource_importer_shader_file.cpp
@@ -99,7 +99,7 @@ Error ResourceImporterShaderFile::import(const String &p_source_file, const Stri
String file_txt = file->get_as_utf8_string();
Ref<RDShaderFile> shader_file;
- shader_file.instance();
+ shader_file.instantiate();
String base_path = p_source_file.get_base_dir();
err = shader_file->parse_versions_from_text(file_txt, "", _include_function, &base_path);
diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp
index 72df65a787..daf7b15794 100644
--- a/editor/import/resource_importer_texture.cpp
+++ b/editor/import/resource_importer_texture.cpp
@@ -88,7 +88,7 @@ void ResourceImporterTexture::update_imports() {
for (Map<StringName, MakeInfo>::Element *E = make_flags.front(); E; E = E->next()) {
Ref<ConfigFile> cf;
- cf.instance();
+ cf.instantiate();
String src_path = String(E->key()) + ".import";
Error err = cf->load(src_path);
@@ -411,13 +411,13 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String
Image::RoughnessChannel roughness_channel = Image::ROUGHNESS_CHANNEL_R;
if (mipmaps && roughness > 1 && FileAccess::exists(normal_map)) {
- normal_image.instance();
+ normal_image.instantiate();
if (ImageLoader::load_image(normal_map, normal_image) == OK) {
roughness_channel = Image::RoughnessChannel(roughness - 2);
}
}
Ref<Image> image;
- image.instance();
+ image.instantiate();
Error err = ImageLoader::load_image(p_source_file, image, nullptr, hdr_as_srgb, scale);
if (err != OK) {
return err;
diff --git a/editor/import/resource_importer_texture_atlas.cpp b/editor/import/resource_importer_texture_atlas.cpp
index d5d1a14be3..dec1466da1 100644
--- a/editor/import/resource_importer_texture_atlas.cpp
+++ b/editor/import/resource_importer_texture_atlas.cpp
@@ -87,7 +87,7 @@ Error ResourceImporterTextureAtlas::import(const String &p_source_file, const St
//it's a simple hack
Ref<Image> broken = memnew(Image((const char **)atlas_import_failed_xpm));
Ref<ImageTexture> broken_texture;
- broken_texture.instance();
+ broken_texture.instantiate();
broken_texture->create_from_image(broken);
String target_file = p_save_path + ".tex";
@@ -201,7 +201,7 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file
const Map<StringName, Variant> &options = E->get();
Ref<Image> image;
- image.instance();
+ image.instantiate();
Error err = ImageLoader::load_image(source, image);
ERR_CONTINUE(err != OK);
@@ -240,7 +240,7 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file
pack_data.is_mesh = true;
Ref<BitMap> bit_map;
- bit_map.instance();
+ bit_map.instantiate();
bit_map->create_from_image_alpha(image);
Vector<Vector<Vector2>> polygons = bit_map->clip_opaque_to_polygons(Rect2(0, 0, image->get_width(), image->get_height()));
@@ -272,7 +272,7 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file
//blit the atlas
Ref<Image> new_atlas;
- new_atlas.instance();
+ new_atlas.instantiate();
new_atlas->create(atlas_width, atlas_height, false, Image::FORMAT_RGBA8);
for (int i = 0; i < pack_data_files.size(); i++) {
@@ -303,7 +303,7 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file
cache.reference_ptr(resptr);
} else {
Ref<ImageTexture> res_cache;
- res_cache.instance();
+ res_cache.instantiate();
res_cache->create_from_image(new_atlas);
res_cache->set_path(p_group_file);
cache = res_cache;
@@ -321,7 +321,7 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file
//region
Ref<AtlasTexture> atlas_texture;
- atlas_texture.instance();
+ atlas_texture.instantiate();
atlas_texture->set_atlas(cache);
atlas_texture->set_region(Rect2(offset, pack_data.region.size));
atlas_texture->set_margin(Rect2(pack_data.region.position, Size2(pack_data.image->get_width(), pack_data.image->get_height()) - pack_data.region.size));
@@ -329,7 +329,7 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file
texture = atlas_texture;
} else {
Ref<ArrayMesh> mesh;
- mesh.instance();
+ mesh.instantiate();
for (int i = 0; i < pack_data.chart_pieces.size(); i++) {
const EditorAtlasPacker::Chart &chart = charts[pack_data.chart_pieces[i]];
@@ -375,7 +375,7 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file
}
Ref<MeshTexture> mesh_texture;
- mesh_texture.instance();
+ mesh_texture.instantiate();
mesh_texture->set_base_texture(cache);
mesh_texture->set_image_size(pack_data.image->get_size());
mesh_texture->set_mesh(mesh);
diff --git a/editor/import/resource_importer_wav.cpp b/editor/import/resource_importer_wav.cpp
index e615212569..e845a90259 100644
--- a/editor/import/resource_importer_wav.cpp
+++ b/editor/import/resource_importer_wav.cpp
@@ -508,7 +508,7 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
}
Ref<AudioStreamSample> sample;
- sample.instance();
+ sample.instantiate();
sample->set_data(dst_data);
sample->set_format(dst_format);
sample->set_mix_rate(rate);
diff --git a/editor/import/scene_import_settings.cpp b/editor/import/scene_import_settings.cpp
index 600f3fe2f0..f9f47ec4f4 100644
--- a/editor/import/scene_import_settings.cpp
+++ b/editor/import/scene_import_settings.cpp
@@ -435,7 +435,7 @@ void SceneImportSettings::open_settings(const String &p_path) {
base_subresource_settings.clear();
Ref<ConfigFile> config;
- config.instance();
+ config.instantiate();
Error err = config->load(p_path + ".import");
if (err == OK) {
List<String> keys;
@@ -1105,12 +1105,12 @@ SceneImportSettings::SceneImportSettings() {
{
Ref<StandardMaterial3D> selection_mat;
- selection_mat.instance();
+ selection_mat.instantiate();
selection_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
selection_mat->set_albedo(Color(1, 0.8, 1.0));
Ref<SurfaceTool> st;
- st.instance();
+ st.instantiate();
st->begin(Mesh::PRIMITIVE_LINES);
AABB base_aabb;
@@ -1126,7 +1126,7 @@ SceneImportSettings::SceneImportSettings() {
st->add_vertex(b.lerp(a, 0.2));
}
- selection_mesh.instance();
+ selection_mesh.instantiate();
st->commit(selection_mesh);
selection_mesh->surface_set_material(0, selection_mat);
@@ -1141,7 +1141,7 @@ SceneImportSettings::SceneImportSettings() {
base_viewport->add_child(mesh_preview);
mesh_preview->hide();
- material_preview.instance();
+ material_preview.instantiate();
}
inspector = memnew(EditorInspector);
@@ -1163,13 +1163,13 @@ SceneImportSettings::SceneImportSettings() {
external_path_tree->set_columns(3);
external_path_tree->set_column_titles_visible(true);
external_path_tree->set_column_expand(0, true);
- external_path_tree->set_column_min_width(0, 100 * EDSCALE);
+ external_path_tree->set_column_custom_minimum_width(0, 100 * EDSCALE);
external_path_tree->set_column_title(0, TTR("Resource"));
external_path_tree->set_column_expand(1, true);
- external_path_tree->set_column_min_width(1, 100 * EDSCALE);
+ external_path_tree->set_column_custom_minimum_width(1, 100 * EDSCALE);
external_path_tree->set_column_title(1, TTR("Path"));
external_path_tree->set_column_expand(2, false);
- external_path_tree->set_column_min_width(2, 200 * EDSCALE);
+ external_path_tree->set_column_custom_minimum_width(2, 200 * EDSCALE);
external_path_tree->set_column_title(2, TTR("Status"));
save_path = memnew(EditorFileDialog);
save_path->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_DIR);
diff --git a/editor/import/scene_importer_mesh.cpp b/editor/import/scene_importer_mesh.cpp
index bf17ea7bca..ce78166d1e 100644
--- a/editor/import/scene_importer_mesh.cpp
+++ b/editor/import/scene_importer_mesh.cpp
@@ -215,6 +215,7 @@ void EditorSceneImporterMesh::generate_lods() {
int index_target = indices.size() * threshold;
float max_mesh_error_percentage = 1e0f;
float mesh_error = 0.0f;
+ float scale = SurfaceTool::simplify_scale_func((const float *)vertices_ptr, vertex_count, sizeof(Vector3));
while (index_target > min_indices) {
Vector<int> new_indices;
new_indices.resize(indices.size());
@@ -223,8 +224,8 @@ void EditorSceneImporterMesh::generate_lods() {
break;
}
Surface::LOD lod;
- lod.distance = mesh_error;
- if (Math::is_equal_approx(mesh_error, 0.0f)) {
+ lod.distance = mesh_error * scale;
+ if (Math::is_zero_approx(mesh_error)) {
break;
}
if (new_len <= 0) {
@@ -251,7 +252,7 @@ Ref<ArrayMesh> EditorSceneImporterMesh::get_mesh(const Ref<Mesh> &p_base) {
mesh = p_base;
}
if (mesh.is_null()) {
- mesh.instance();
+ mesh.instantiate();
}
mesh->set_name(get_name());
if (has_meta("import_id")) {
@@ -320,7 +321,7 @@ void EditorSceneImporterMesh::create_shadow_mesh() {
}
}
- shadow_mesh.instance();
+ shadow_mesh.instantiate();
for (int i = 0; i < surfaces.size(); i++) {
LocalVector<int> vertex_remap;
@@ -528,7 +529,7 @@ Vector<Ref<Shape3D>> EditorSceneImporterMesh::convex_decompose() const {
}
Ref<ConvexPolygonShape3D> shape;
- shape.instance();
+ shape.instantiate();
shape->set_points(convex_points);
ret.push_back(shape);
}
@@ -587,7 +588,7 @@ Ref<NavigationMesh> EditorSceneImporterMesh::create_navigation_mesh() {
}
Ref<NavigationMesh> nm;
- nm.instance();
+ nm.instantiate();
nm->set_vertices(vertices);
Vector<int> v3;
@@ -733,7 +734,7 @@ Error EditorSceneImporterMesh::lightmap_unwrap_cached(const Transform3D &p_base_
for (int i = 0; i < lightmap_surfaces.size(); i++) {
Ref<SurfaceTool> st;
- st.instance();
+ st.instantiate();
st->begin(Mesh::PRIMITIVE_TRIANGLES);
st->set_material(lightmap_surfaces[i].material);
st->set_meta("name", lightmap_surfaces[i].name);
diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp
index 17c51f0f85..6fa9864830 100644
--- a/editor/import_dock.cpp
+++ b/editor/import_dock.cpp
@@ -91,7 +91,7 @@ public:
void ImportDock::set_edit_path(const String &p_path) {
Ref<ConfigFile> config;
- config.instance();
+ config.instantiate();
Error err = config->load(p_path + ".import");
if (err != OK) {
clear();
@@ -182,7 +182,7 @@ void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) {
for (int i = 0; i < p_paths.size(); i++) {
Ref<ConfigFile> config;
- config.instance();
+ config.instantiate();
Error err = config->load(p_paths[i] + ".import");
ERR_CONTINUE(err != OK);
@@ -328,7 +328,7 @@ void ImportDock::_importer_selected(int i_idx) {
Ref<ConfigFile> config;
if (params->paths.size()) {
- config.instance();
+ config.instantiate();
Error err = config->load(params->paths[0] + ".import");
if (err != OK) {
config.unref();
@@ -440,7 +440,7 @@ void ImportDock::_reimport_attempt() {
}
for (int i = 0; i < params->paths.size(); i++) {
Ref<ConfigFile> config;
- config.instance();
+ config.instantiate();
Error err = config->load(params->paths[i] + ".import");
ERR_CONTINUE(err != OK);
@@ -477,7 +477,7 @@ void ImportDock::_advanced_options() {
void ImportDock::_reimport() {
for (int i = 0; i < params->paths.size(); i++) {
Ref<ConfigFile> config;
- config.instance();
+ config.instantiate();
Error err = config->load(params->paths[i] + ".import");
ERR_CONTINUE(err != OK);
diff --git a/editor/localization_editor.cpp b/editor/localization_editor.cpp
index 161f1dde0d..91a15f1131 100644
--- a/editor/localization_editor.cpp
+++ b/editor/localization_editor.cpp
@@ -729,7 +729,7 @@ LocalizationEditor::LocalizationEditor() {
translation_remap_options->set_column_titles_visible(true);
translation_remap_options->set_column_expand(0, true);
translation_remap_options->set_column_expand(1, false);
- translation_remap_options->set_column_min_width(1, 200);
+ translation_remap_options->set_column_custom_minimum_width(1, 200);
translation_remap_options->connect("item_edited", callable_mp(this, &LocalizationEditor::_translation_res_option_changed));
translation_remap_options->connect("button_pressed", callable_mp(this, &LocalizationEditor::_translation_res_option_delete));
tmc->add_child(translation_remap_options);
diff --git a/editor/node_3d_editor_gizmos.cpp b/editor/node_3d_editor_gizmos.cpp
index 19663e46e1..2a399f4b03 100644
--- a/editor/node_3d_editor_gizmos.cpp
+++ b/editor/node_3d_editor_gizmos.cpp
@@ -600,8 +600,6 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point,
r_normal = -p_camera->project_ray_normal(p_point);
return true;
}
-
- return false;
}
if (collision_segments.size()) {
@@ -652,8 +650,6 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point,
r_normal = -p_camera->project_ray_normal(p_point);
return true;
}
-
- return false;
}
if (collision_mesh.is_valid()) {
@@ -759,7 +755,7 @@ EditorNode3DGizmo::EditorNode3DGizmo() {
hidden = false;
base = nullptr;
selected = false;
- instanced = false;
+ instantiated = false;
spatial_node = nullptr;
gizmo_plugin = nullptr;
selectable_icon_size = -1.0f;
@@ -3427,7 +3423,7 @@ void LightmapGIGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
array[RS::ARRAY_COLOR] = colors;
Ref<ArrayMesh> mesh;
- mesh.instance();
+ mesh.instantiate();
mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, array, Array(), Dictionary(), 0); //no compression
mesh->surface_set_material(0, material_probes);
diff --git a/editor/plugins/animation_blend_space_1d_editor.cpp b/editor/plugins/animation_blend_space_1d_editor.cpp
index f7c0ebcfaf..b6dd9474d3 100644
--- a/editor/plugins/animation_blend_space_1d_editor.cpp
+++ b/editor/plugins/animation_blend_space_1d_editor.cpp
@@ -386,7 +386,7 @@ void AnimationNodeBlendSpace1DEditor::_add_menu_type(int p_index) {
} else {
String type = menu->get_item_metadata(p_index);
- Object *obj = ClassDB::instance(type);
+ Object *obj = ClassDB::instantiate(type);
ERR_FAIL_COND(!obj);
AnimationNode *an = Object::cast_to<AnimationNode>(obj);
ERR_FAIL_COND(!an);
@@ -413,7 +413,7 @@ void AnimationNodeBlendSpace1DEditor::_add_menu_type(int p_index) {
void AnimationNodeBlendSpace1DEditor::_add_animation_type(int p_index) {
Ref<AnimationNodeAnimation> anim;
- anim.instance();
+ anim.instantiate();
anim->set_animation(animations_to_add[p_index]);
@@ -594,7 +594,7 @@ AnimationNodeBlendSpace1DEditor::AnimationNodeBlendSpace1DEditor() {
add_child(top_hb);
Ref<ButtonGroup> bg;
- bg.instance();
+ bg.instantiate();
tool_blend = memnew(Button);
tool_blend->set_flat(true);
diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp
index e719df53d5..359df95bce 100644
--- a/editor/plugins/animation_blend_space_2d_editor.cpp
+++ b/editor/plugins/animation_blend_space_2d_editor.cpp
@@ -308,7 +308,7 @@ void AnimationNodeBlendSpace2DEditor::_add_menu_type(int p_index) {
} else {
String type = menu->get_item_metadata(p_index);
- Object *obj = ClassDB::instance(type);
+ Object *obj = ClassDB::instantiate(type);
ERR_FAIL_COND(!obj);
AnimationNode *an = Object::cast_to<AnimationNode>(obj);
ERR_FAIL_COND(!an);
@@ -335,7 +335,7 @@ void AnimationNodeBlendSpace2DEditor::_add_menu_type(int p_index) {
void AnimationNodeBlendSpace2DEditor::_add_animation_type(int p_index) {
Ref<AnimationNodeAnimation> anim;
- anim.instance();
+ anim.instantiate();
anim->set_animation(animations_to_add[p_index]);
@@ -818,7 +818,7 @@ AnimationNodeBlendSpace2DEditor::AnimationNodeBlendSpace2DEditor() {
add_child(top_hb);
Ref<ButtonGroup> bg;
- bg.instance();
+ bg.instantiate();
tool_blend = memnew(Button);
tool_blend->set_flat(true);
diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp
index 867c701733..dcde89f177 100644
--- a/editor/plugins/animation_blend_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp
@@ -288,14 +288,14 @@ void AnimationNodeBlendTreeEditor::_add_node(int p_idx) {
ERR_FAIL_COND(!anode.is_valid());
base_name = anode->get_class();
} else if (add_options[p_idx].type != String()) {
- AnimationNode *an = Object::cast_to<AnimationNode>(ClassDB::instance(add_options[p_idx].type));
+ AnimationNode *an = Object::cast_to<AnimationNode>(ClassDB::instantiate(add_options[p_idx].type));
ERR_FAIL_COND(!an);
anode = Ref<AnimationNode>(an);
base_name = add_options[p_idx].name;
} else {
ERR_FAIL_COND(add_options[p_idx].script.is_null());
String base_type = add_options[p_idx].script->get_instance_base_type();
- AnimationNode *an = Object::cast_to<AnimationNode>(ClassDB::instance(base_type));
+ AnimationNode *an = Object::cast_to<AnimationNode>(ClassDB::instantiate(base_type));
ERR_FAIL_COND(!an);
anode = Ref<AnimationNode>(an);
anode->set_script(add_options[p_idx].script);
diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp
index 4a3f3212fa..48d7cfdee2 100644
--- a/editor/plugins/animation_player_editor_plugin.cpp
+++ b/editor/plugins/animation_player_editor_plugin.cpp
@@ -121,11 +121,11 @@ void AnimationPlayerEditor::_notification(int p_what) {
Ref<Image> reset_img = reset_icon->get_image();
Ref<Image> autoplay_reset_img;
Size2 icon_size = Size2(autoplay_img->get_width(), autoplay_img->get_height());
- autoplay_reset_img.instance();
+ autoplay_reset_img.instantiate();
autoplay_reset_img->create(icon_size.x * 2, icon_size.y, false, autoplay_img->get_format());
autoplay_reset_img->blit_rect(autoplay_img, Rect2(Point2(), icon_size), Point2());
autoplay_reset_img->blit_rect(reset_img, Rect2(Point2(), icon_size), Point2(icon_size.x, 0));
- autoplay_reset_icon.instance();
+ autoplay_reset_icon.instantiate();
autoplay_reset_icon->create_from_image(autoplay_reset_img);
}
stop->set_icon(get_theme_icon("Stop", "EditorIcons"));
@@ -569,8 +569,8 @@ void AnimationPlayerEditor::_animation_blend() {
blend_editor.dialog->popup_centered(Size2(400, 400) * EDSCALE);
blend_editor.tree->set_hide_root(true);
- blend_editor.tree->set_column_min_width(0, 10);
- blend_editor.tree->set_column_min_width(1, 3);
+ blend_editor.tree->set_column_custom_minimum_width(0, 10);
+ blend_editor.tree->set_column_custom_minimum_width(1, 3);
List<StringName> anims;
player->get_animation_list(&anims);
diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp
index fe5a0cab4d..94e526922d 100644
--- a/editor/plugins/animation_state_machine_editor.cpp
+++ b/editor/plugins/animation_state_machine_editor.cpp
@@ -257,7 +257,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
} else {
Ref<AnimationNodeStateMachineTransition> tr;
- tr.instance();
+ tr.instantiate();
tr->set_switch_mode(AnimationNodeStateMachineTransition::SwitchMode(transition_mode->get_selected()));
updating = true;
@@ -423,7 +423,7 @@ void AnimationNodeStateMachineEditor::_add_menu_type(int p_index) {
} else {
String type = menu->get_item_metadata(p_index);
- Object *obj = ClassDB::instance(type);
+ Object *obj = ClassDB::instantiate(type);
ERR_FAIL_COND(!obj);
AnimationNode *an = Object::cast_to<AnimationNode>(obj);
ERR_FAIL_COND(!an);
@@ -462,7 +462,7 @@ void AnimationNodeStateMachineEditor::_add_menu_type(int p_index) {
void AnimationNodeStateMachineEditor::_add_animation_type(int p_index) {
Ref<AnimationNodeAnimation> anim;
- anim.instance();
+ anim.instantiate();
anim->set_animation(animations_to_add[p_index]);
@@ -1213,7 +1213,7 @@ AnimationNodeStateMachineEditor::AnimationNodeStateMachineEditor() {
add_child(top_hb);
Ref<ButtonGroup> bg;
- bg.instance();
+ bg.instantiate();
tool_select = memnew(Button);
tool_select->set_flat(true);
diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp
index c33b06ff32..e90665f84d 100644
--- a/editor/plugins/animation_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_tree_editor_plugin.cpp
@@ -76,7 +76,7 @@ void AnimationTreeEditor::_update_path() {
}
Ref<ButtonGroup> group;
- group.instance();
+ group.instantiate();
Button *b = memnew(Button);
b->set_text("Root");
diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp
index 93bb170128..cd61ebd418 100644
--- a/editor/plugins/asset_library_editor_plugin.cpp
+++ b/editor/plugins/asset_library_editor_plugin.cpp
@@ -86,7 +86,7 @@ void EditorAssetLibraryItem::_bind_methods() {
EditorAssetLibraryItem::EditorAssetLibraryItem() {
Ref<StyleBoxEmpty> border;
- border.instance();
+ border.instantiate();
border->set_default_margin(SIDE_LEFT, 5 * EDSCALE);
border->set_default_margin(SIDE_RIGHT, 5 * EDSCALE);
border->set_default_margin(SIDE_BOTTOM, 5 * EDSCALE);
@@ -155,7 +155,7 @@ void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const
thumbnail->blend_rect(overlay, overlay->get_used_rect(), overlay_pos);
Ref<ImageTexture> tex;
- tex.instance();
+ tex.instantiate();
tex->create_from_image(thumbnail);
preview_images[i].button->set_icon(tex);
@@ -761,7 +761,7 @@ void EditorAssetLibrary::_image_update(bool use_cache, bool final, const PackedB
}
Ref<ImageTexture> tex;
- tex.instance();
+ tex.instantiate();
tex->create_from_image(image);
obj->call("set_image", image_queue[p_queue_id].image_type, image_queue[p_queue_id].image_index, tex);
@@ -1098,11 +1098,9 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
Dictionary d;
{
- Variant js;
- String errs;
- int errl;
- JSON::parse(str, js, errs, errl);
- d = js;
+ JSON json;
+ json.parse(str);
+ d = json.get_data();
}
RequestType requested = requesting;
@@ -1437,7 +1435,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
library_scroll_bg->add_child(library_scroll);
Ref<StyleBoxEmpty> border2;
- border2.instance();
+ border2.instantiate();
border2->set_default_margin(SIDE_LEFT, 15 * EDSCALE);
border2->set_default_margin(SIDE_RIGHT, 35 * EDSCALE);
border2->set_default_margin(SIDE_BOTTOM, 15 * EDSCALE);
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index e648ffff29..033a3e4fab 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -5478,7 +5478,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
p = view_menu->get_popup();
p->set_hide_on_checkable_item_selection(false);
- p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_grid", TTR("Always Show Grid"), KEY_MASK_CTRL | KEY_G), SHOW_GRID);
+ p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_grid", TTR("Always Show Grid"), KEY_MASK_CMD | KEY_G), SHOW_GRID);
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_helpers", TTR("Show Helpers"), KEY_H), SHOW_HELPERS);
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_rulers", TTR("Show Rulers")), SHOW_RULERS);
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_guides", TTR("Show Guides"), KEY_Y), SHOW_GUIDES);
@@ -5698,7 +5698,7 @@ void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) cons
label_desc->show();
} else {
if (scene.is_valid()) {
- Node *instance = scene->instance();
+ Node *instance = scene->instantiate();
if (instance) {
preview_node->add_child(instance);
}
@@ -5811,26 +5811,26 @@ bool CanvasItemEditorViewport::_create_instance(Node *parent, String &path, cons
return false;
}
- Node *instanced_scene = sdata->instance(PackedScene::GEN_EDIT_STATE_INSTANCE);
- if (!instanced_scene) { // error on instancing
+ Node *instantiated_scene = sdata->instantiate(PackedScene::GEN_EDIT_STATE_INSTANCE);
+ if (!instantiated_scene) { // error on instancing
return false;
}
if (editor->get_edited_scene()->get_filename() != "") { // cyclical instancing
- if (_cyclical_dependency_exists(editor->get_edited_scene()->get_filename(), instanced_scene)) {
- memdelete(instanced_scene);
+ if (_cyclical_dependency_exists(editor->get_edited_scene()->get_filename(), instantiated_scene)) {
+ memdelete(instantiated_scene);
return false;
}
}
- instanced_scene->set_filename(ProjectSettings::get_singleton()->localize_path(path));
+ instantiated_scene->set_filename(ProjectSettings::get_singleton()->localize_path(path));
- editor_data->get_undo_redo().add_do_method(parent, "add_child", instanced_scene);
- editor_data->get_undo_redo().add_do_method(instanced_scene, "set_owner", editor->get_edited_scene());
- editor_data->get_undo_redo().add_do_reference(instanced_scene);
- editor_data->get_undo_redo().add_undo_method(parent, "remove_child", instanced_scene);
+ editor_data->get_undo_redo().add_do_method(parent, "add_child", instantiated_scene);
+ editor_data->get_undo_redo().add_do_method(instantiated_scene, "set_owner", editor->get_edited_scene());
+ editor_data->get_undo_redo().add_do_reference(instantiated_scene);
+ editor_data->get_undo_redo().add_undo_method(parent, "remove_child", instantiated_scene);
- String new_name = parent->validate_child_name(instanced_scene);
+ String new_name = parent->validate_child_name(instantiated_scene);
EditorDebuggerNode *ed = EditorDebuggerNode::get_singleton();
editor_data->get_undo_redo().add_do_method(ed, "live_debug_instance_node", editor->get_edited_scene()->get_path_to(parent), path, new_name);
editor_data->get_undo_redo().add_undo_method(ed, "live_debug_remove_node", NodePath(String(editor->get_edited_scene()->get_path_to(parent)) + "/" + new_name));
@@ -5841,11 +5841,11 @@ bool CanvasItemEditorViewport::_create_instance(Node *parent, String &path, cons
target_pos = canvas_item_editor->snap_point(target_pos);
target_pos = parent_ci->get_global_transform_with_canvas().affine_inverse().xform(target_pos);
// Preserve instance position of the original scene.
- CanvasItem *instance_ci = Object::cast_to<CanvasItem>(instanced_scene);
+ CanvasItem *instance_ci = Object::cast_to<CanvasItem>(instantiated_scene);
if (instance_ci) {
target_pos += instance_ci->_edit_get_position();
}
- editor_data->get_undo_redo().add_do_method(instanced_scene, "set_position", target_pos);
+ editor_data->get_undo_redo().add_do_method(instantiated_scene, "set_position", target_pos);
}
return true;
@@ -5928,7 +5928,7 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian
if (d.has("type")) {
if (String(d["type"]) == "files") {
Vector<String> files = d["files"];
- bool can_instance = false;
+ bool can_instantiate = false;
for (int i = 0; i < files.size(); i++) { // check if dragged files contain resource or scene can be created at least once
RES res = ResourceLoader::load(files[i]);
if (res.is_null()) {
@@ -5937,11 +5937,11 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian
String type = res->get_class();
if (type == "PackedScene") {
Ref<PackedScene> sdata = Ref<PackedScene>(Object::cast_to<PackedScene>(*res));
- Node *instanced_scene = sdata->instance(PackedScene::GEN_EDIT_STATE_INSTANCE);
- if (!instanced_scene) {
+ Node *instantiated_scene = sdata->instantiate(PackedScene::GEN_EDIT_STATE_INSTANCE);
+ if (!instantiated_scene) {
continue;
}
- memdelete(instanced_scene);
+ memdelete(instantiated_scene);
} else if (type == "Texture2D" ||
type == "ImageTexture" ||
type == "ViewportTexture" ||
@@ -5956,10 +5956,10 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian
} else {
continue;
}
- can_instance = true;
+ can_instantiate = true;
break;
}
- if (can_instance) {
+ if (can_instantiate) {
if (!preview_node->get_parent()) { // create preview only once
_create_preview(files);
}
@@ -5967,7 +5967,7 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian
preview_node->set_position((p_point - trans.get_origin()) / trans.get_scale().x);
label->set_text(vformat(TTR("Adding %s..."), default_type));
}
- return can_instance;
+ return can_instantiate;
}
}
label->hide();
@@ -6092,7 +6092,7 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte
vbc->add_child(btn_group);
btn_group->set_h_size_flags(0);
- button_group.instance();
+ button_group.instantiate();
for (int i = 0; i < types.size(); i++) {
CheckBox *check = memnew(CheckBox);
btn_group->add_child(check);
diff --git a/editor/plugins/collision_polygon_3d_editor_plugin.cpp b/editor/plugins/collision_polygon_3d_editor_plugin.cpp
index a0df7e289e..7873c1b136 100644
--- a/editor/plugins/collision_polygon_3d_editor_plugin.cpp
+++ b/editor/plugins/collision_polygon_3d_editor_plugin.cpp
@@ -537,7 +537,7 @@ CollisionPolygon3DEditor::CollisionPolygon3DEditor(EditorNode *p_editor) {
pointsm = memnew(MeshInstance3D);
imgeom->add_child(pointsm);
- m.instance();
+ m.instantiate();
pointsm->set_mesh(m);
pointsm->set_transform(Transform3D(Basis(), Vector3(0, 0, 0.00001)));
diff --git a/editor/plugins/cpu_particles_2d_editor_plugin.cpp b/editor/plugins/cpu_particles_2d_editor_plugin.cpp
index 3403aeceba..6a56cd31d1 100644
--- a/editor/plugins/cpu_particles_2d_editor_plugin.cpp
+++ b/editor/plugins/cpu_particles_2d_editor_plugin.cpp
@@ -74,7 +74,7 @@ void CPUParticles2DEditorPlugin::_menu_callback(int p_idx) {
void CPUParticles2DEditorPlugin::_generate_emission_mask() {
Ref<Image> img;
- img.instance();
+ img.instantiate();
Error err = ImageLoader::load_image(source_emission_file, img);
ERR_FAIL_COND_MSG(err != OK, "Error loading image '" + source_emission_file + "'.");
diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp
index 7a38fd2bd5..706243fe25 100644
--- a/editor/plugins/curve_editor_plugin.cpp
+++ b/editor/plugins/curve_editor_plugin.cpp
@@ -127,6 +127,8 @@ void CurveEditor::on_gui_input(const Ref<InputEvent> &p_event) {
case MOUSE_BUTTON_LEFT:
_dragging = true;
break;
+ default:
+ break;
}
}
@@ -776,7 +778,7 @@ void EditorInspectorPluginCurve::parse_begin(Object *p_object) {
CurveEditorPlugin::CurveEditorPlugin(EditorNode *p_node) {
Ref<EditorInspectorPluginCurve> curve_plugin;
- curve_plugin.instance();
+ curve_plugin.instantiate();
EditorInspector::add_inspector_plugin(curve_plugin);
get_editor_interface()->get_resource_previewer()->add_preview_generator(memnew(CurvePreviewGenerator));
@@ -798,7 +800,7 @@ Ref<Texture2D> CurvePreviewGenerator::generate(const Ref<Resource> &p_from, cons
int thumbnail_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size");
thumbnail_size *= EDSCALE;
Ref<Image> img_ref;
- img_ref.instance();
+ img_ref.instantiate();
Image &im = **img_ref;
im.create(thumbnail_size, thumbnail_size / 2, false, Image::FORMAT_RGBA8);
diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp
index 235ccb18cb..a233d66d82 100644
--- a/editor/plugins/editor_preview_plugins.cpp
+++ b/editor/plugins/editor_preview_plugins.cpp
@@ -174,7 +174,7 @@ Ref<Texture2D> EditorImagePreviewPlugin::generate(const RES &p_from, const Size2
post_process_preview(img);
Ref<ImageTexture> ptex;
- ptex.instance();
+ ptex.instantiate();
ptex->create_from_image(img);
return ptex;
@@ -219,7 +219,7 @@ Ref<Texture2D> EditorBitmapPreviewPlugin::generate(const RES &p_from, const Size
}
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create(bm->get_size().width, bm->get_size().height, false, Image::FORMAT_L8, data);
if (img->is_compressed()) {
@@ -278,7 +278,7 @@ Ref<Texture2D> EditorPackedScenePreviewPlugin::generate_from_path(const String &
}
Ref<Image> img;
- img.instance();
+ img.instantiate();
Error err = img->load(path);
if (err == OK) {
Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture));
@@ -501,7 +501,7 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size
int line = 0;
int col = 0;
Ref<Image> img;
- img.instance();
+ img.instantiate();
int thumbnail_size = MAX(p_size.x, p_size.y);
img->create(thumbnail_size, thumbnail_size, false, Image::FORMAT_RGBA8);
@@ -688,7 +688,7 @@ Ref<Texture2D> EditorAudioStreamPreviewPlugin::generate(const RES &p_from, const
Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture));
Ref<Image> image;
- image.instance();
+ image.instantiate();
image->create(w, h, false, Image::FORMAT_RGB8, img);
ptex->create_from_image(image);
return ptex;
@@ -881,7 +881,7 @@ Ref<Texture2D> EditorFontPreviewPlugin::generate_from_path(const String &p_path,
if (res->is_class("Font")) {
sampled_font = res->duplicate();
} else if (res->is_class("FontData")) {
- sampled_font.instance();
+ sampled_font.instantiate();
sampled_font->add_data(res->duplicate());
}
diff --git a/editor/plugins/font_editor_plugin.cpp b/editor/plugins/font_editor_plugin.cpp
index 8de7dc2447..9b0af37abb 100644
--- a/editor/plugins/font_editor_plugin.cpp
+++ b/editor/plugins/font_editor_plugin.cpp
@@ -119,7 +119,7 @@ void FontDataPreview::set_data(const Ref<FontData> &p_data) {
}
FontDataPreview::FontDataPreview() {
- line.instance();
+ line.instantiate();
}
/*************************************************************************/
@@ -326,6 +326,6 @@ bool EditorInspectorPluginFont::parse_property(Object *p_object, Variant::Type p
FontEditorPlugin::FontEditorPlugin(EditorNode *p_node) {
Ref<EditorInspectorPluginFont> fd_plugin;
- fd_plugin.instance();
+ fd_plugin.instantiate();
EditorInspector::add_inspector_plugin(fd_plugin);
}
diff --git a/editor/plugins/gpu_particles_2d_editor_plugin.cpp b/editor/plugins/gpu_particles_2d_editor_plugin.cpp
index b447304a3f..37f900280b 100644
--- a/editor/plugins/gpu_particles_2d_editor_plugin.cpp
+++ b/editor/plugins/gpu_particles_2d_editor_plugin.cpp
@@ -146,7 +146,7 @@ void GPUParticles2DEditorPlugin::_generate_emission_mask() {
}
Ref<Image> img;
- img.instance();
+ img.instantiate();
Error err = ImageLoader::load_image(source_emission_file, img);
ERR_FAIL_COND_MSG(err != OK, "Error loading image '" + source_emission_file + "'.");
@@ -270,11 +270,11 @@ void GPUParticles2DEditorPlugin::_generate_emission_mask() {
}
}
- img.instance();
+ img.instantiate();
img->create(w, h, false, Image::FORMAT_RGF, texdata);
Ref<ImageTexture> imgt;
- imgt.instance();
+ imgt.instantiate();
imgt->create_from_image(img);
pm->set_emission_point_texture(imgt);
@@ -291,10 +291,10 @@ void GPUParticles2DEditorPlugin::_generate_emission_mask() {
}
}
- img.instance();
+ img.instantiate();
img->create(w, h, false, Image::FORMAT_RGBA8, colordata);
- imgt.instance();
+ imgt.instantiate();
imgt->create_from_image(img);
pm->set_emission_color_texture(imgt);
}
@@ -314,10 +314,10 @@ void GPUParticles2DEditorPlugin::_generate_emission_mask() {
}
}
- img.instance();
+ img.instantiate();
img->create(w, h, false, Image::FORMAT_RGF, normdata);
- imgt.instance();
+ imgt.instantiate();
imgt->create_from_image(img);
pm->set_emission_normal_texture(imgt);
diff --git a/editor/plugins/gpu_particles_3d_editor_plugin.cpp b/editor/plugins/gpu_particles_3d_editor_plugin.cpp
index 17c7397729..571bcf9c4a 100644
--- a/editor/plugins/gpu_particles_3d_editor_plugin.cpp
+++ b/editor/plugins/gpu_particles_3d_editor_plugin.cpp
@@ -359,7 +359,7 @@ void GPUParticles3DEditor::_generate_emission_points() {
Ref<Image> image = memnew(Image(w, h, false, Image::FORMAT_RGBF, point_img));
Ref<ImageTexture> tex;
- tex.instance();
+ tex.instantiate();
Ref<ParticlesMaterial> material = node->get_process_material();
ERR_FAIL_COND(material.is_null());
@@ -387,7 +387,7 @@ void GPUParticles3DEditor::_generate_emission_points() {
Ref<Image> image2 = memnew(Image(w, h, false, Image::FORMAT_RGBF, point_img2));
Ref<ImageTexture> tex2;
- tex2.instance();
+ tex2.instantiate();
material->set_emission_normal_texture(tex2);
} else {
diff --git a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp
index 8c4928b7cb..a2dee4a1dc 100644
--- a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp
+++ b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp
@@ -137,7 +137,7 @@ void GPUParticlesCollisionSDFEditorPlugin::_sdf_save_path_and_bake(const String
Ref<ConfigFile> config;
- config.instance();
+ config.instantiate();
if (FileAccess::exists(p_path + ".import")) {
config->load(p_path + ".import");
}
diff --git a/editor/plugins/gradient_editor_plugin.cpp b/editor/plugins/gradient_editor_plugin.cpp
index 46fa00f730..355bdb69d8 100644
--- a/editor/plugins/gradient_editor_plugin.cpp
+++ b/editor/plugins/gradient_editor_plugin.cpp
@@ -92,6 +92,6 @@ void EditorInspectorPluginGradient::parse_begin(Object *p_object) {
GradientEditorPlugin::GradientEditorPlugin(EditorNode *p_node) {
Ref<EditorInspectorPluginGradient> plugin;
- plugin.instance();
+ plugin.instantiate();
add_inspector_plugin(plugin);
}
diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp
index 81f0ecacf2..17a634ee14 100644
--- a/editor/plugins/material_editor_plugin.cpp
+++ b/editor/plugins/material_editor_plugin.cpp
@@ -111,7 +111,7 @@ MaterialEditor::MaterialEditor() {
vc->set_anchors_and_offsets_preset(PRESET_WIDE);
viewport = memnew(SubViewport);
Ref<World3D> world_3d;
- world_3d.instance();
+ world_3d.instantiate();
viewport->set_world_3d(world_3d); //use own world
vc->add_child(viewport);
viewport->set_disable_input(true);
@@ -146,9 +146,9 @@ MaterialEditor::MaterialEditor() {
box_xform.origin.y = 0.2;
box_instance->set_transform(box_xform);
- sphere_mesh.instance();
+ sphere_mesh.instantiate();
sphere_instance->set_mesh(sphere_mesh);
- box_mesh.instance();
+ box_mesh.instantiate();
box_instance->set_mesh(box_mesh);
set_custom_minimum_size(Size2(1, 150) * EDSCALE);
@@ -223,7 +223,7 @@ void EditorInspectorPluginMaterial::parse_begin(Object *p_object) {
}
EditorInspectorPluginMaterial::EditorInspectorPluginMaterial() {
- env.instance();
+ env.instantiate();
Ref<Sky> sky = memnew(Sky());
env->set_sky(sky);
env->set_background(Environment::BG_COLOR);
@@ -233,7 +233,7 @@ EditorInspectorPluginMaterial::EditorInspectorPluginMaterial() {
MaterialEditorPlugin::MaterialEditorPlugin(EditorNode *p_node) {
Ref<EditorInspectorPluginMaterial> plugin;
- plugin.instance();
+ plugin.instantiate();
add_inspector_plugin(plugin);
}
@@ -251,10 +251,10 @@ Ref<Resource> StandardMaterial3DConversionPlugin::convert(const Ref<Resource> &p
ERR_FAIL_COND_V(!mat.is_valid(), Ref<Resource>());
Ref<ShaderMaterial> smat;
- smat.instance();
+ smat.instantiate();
Ref<Shader> shader;
- shader.instance();
+ shader.instantiate();
String code = RS::get_singleton()->shader_get_code(mat->get_shader_rid());
@@ -295,10 +295,10 @@ Ref<Resource> ParticlesMaterialConversionPlugin::convert(const Ref<Resource> &p_
ERR_FAIL_COND_V(!mat.is_valid(), Ref<Resource>());
Ref<ShaderMaterial> smat;
- smat.instance();
+ smat.instantiate();
Ref<Shader> shader;
- shader.instance();
+ shader.instantiate();
String code = RS::get_singleton()->shader_get_code(mat->get_shader_rid());
@@ -332,10 +332,10 @@ Ref<Resource> CanvasItemMaterialConversionPlugin::convert(const Ref<Resource> &p
ERR_FAIL_COND_V(!mat.is_valid(), Ref<Resource>());
Ref<ShaderMaterial> smat;
- smat.instance();
+ smat.instantiate();
Ref<Shader> shader;
- shader.instance();
+ shader.instantiate();
String code = RS::get_singleton()->shader_get_code(mat->get_shader_rid());
@@ -369,10 +369,10 @@ Ref<Resource> ProceduralSkyMaterialConversionPlugin::convert(const Ref<Resource>
ERR_FAIL_COND_V(!mat.is_valid(), Ref<Resource>());
Ref<ShaderMaterial> smat;
- smat.instance();
+ smat.instantiate();
Ref<Shader> shader;
- shader.instance();
+ shader.instantiate();
String code = RS::get_singleton()->shader_get_code(mat->get_shader_rid());
@@ -406,10 +406,10 @@ Ref<Resource> PanoramaSkyMaterialConversionPlugin::convert(const Ref<Resource> &
ERR_FAIL_COND_V(!mat.is_valid(), Ref<Resource>());
Ref<ShaderMaterial> smat;
- smat.instance();
+ smat.instantiate();
Ref<Shader> shader;
- shader.instance();
+ shader.instantiate();
String code = RS::get_singleton()->shader_get_code(mat->get_shader_rid());
@@ -443,10 +443,10 @@ Ref<Resource> PhysicalSkyMaterialConversionPlugin::convert(const Ref<Resource> &
ERR_FAIL_COND_V(!mat.is_valid(), Ref<Resource>());
Ref<ShaderMaterial> smat;
- smat.instance();
+ smat.instantiate();
Ref<Shader> shader;
- shader.instance();
+ shader.instantiate();
String code = RS::get_singleton()->shader_get_code(mat->get_shader_rid());
diff --git a/editor/plugins/mesh_editor_plugin.cpp b/editor/plugins/mesh_editor_plugin.cpp
index 8d488dce20..fcc6b84efb 100644
--- a/editor/plugins/mesh_editor_plugin.cpp
+++ b/editor/plugins/mesh_editor_plugin.cpp
@@ -110,7 +110,7 @@ void MeshEditor::_bind_methods() {
MeshEditor::MeshEditor() {
viewport = memnew(SubViewport);
Ref<World3D> world_3d;
- world_3d.instance();
+ world_3d.instantiate();
viewport->set_world_3d(world_3d); //use own world
add_child(viewport);
viewport->set_disable_input(true);
@@ -182,6 +182,6 @@ void EditorInspectorPluginMesh::parse_begin(Object *p_object) {
MeshEditorPlugin::MeshEditorPlugin(EditorNode *p_node) {
Ref<EditorInspectorPluginMesh> plugin;
- plugin.instance();
+ plugin.instantiate();
add_inspector_plugin(plugin);
}
diff --git a/editor/plugins/mesh_library_editor_plugin.cpp b/editor/plugins/mesh_library_editor_plugin.cpp
index e64992759d..5d1d29cbc8 100644
--- a/editor/plugins/mesh_library_editor_plugin.cpp
+++ b/editor/plugins/mesh_library_editor_plugin.cpp
@@ -193,7 +193,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
void MeshLibraryEditor::_import_scene_cbk(const String &p_str) {
Ref<PackedScene> ps = ResourceLoader::load(p_str, "PackedScene");
ERR_FAIL_COND(ps.is_null());
- Node *scene = ps->instance();
+ Node *scene = ps->instantiate();
ERR_FAIL_COND_MSG(!scene, "Cannot create an instance from PackedScene '" + p_str + "'.");
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index 911c5147bf..59c0d81ae7 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -33,6 +33,7 @@
#include "core/config/project_settings.h"
#include "core/input/input.h"
#include "core/math/camera_matrix.h"
+#include "core/math/math_funcs.h"
#include "core/os/keyboard.h"
#include "core/string/print_string.h"
#include "core/templates/sort_array.h"
@@ -1397,6 +1398,8 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
}
} break;
+ default:
+ break;
}
}
@@ -3713,7 +3716,7 @@ void Node3DEditorViewport::_create_preview(const Vector<String> &files) const {
preview_node->add_child(mesh_instance);
} else {
if (scene.is_valid()) {
- Node *instance = scene->instance();
+ Node *instance = scene->instantiate();
if (instance) {
preview_node->add_child(instance);
}
@@ -3758,49 +3761,49 @@ bool Node3DEditorViewport::_create_instance(Node *parent, String &path, const Po
Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res));
Ref<Mesh> mesh = Ref<Mesh>(Object::cast_to<Mesh>(*res));
- Node *instanced_scene = nullptr;
+ Node *instantiated_scene = nullptr;
if (mesh != nullptr || scene != nullptr) {
if (mesh != nullptr) {
MeshInstance3D *mesh_instance = memnew(MeshInstance3D);
mesh_instance->set_mesh(mesh);
mesh_instance->set_name(path.get_file().get_basename());
- instanced_scene = mesh_instance;
+ instantiated_scene = mesh_instance;
} else {
if (!scene.is_valid()) { // invalid scene
return false;
} else {
- instanced_scene = scene->instance(PackedScene::GEN_EDIT_STATE_INSTANCE);
+ instantiated_scene = scene->instantiate(PackedScene::GEN_EDIT_STATE_INSTANCE);
}
}
}
- if (instanced_scene == nullptr) {
+ if (instantiated_scene == nullptr) {
return false;
}
if (editor->get_edited_scene()->get_filename() != "") { // cyclical instancing
- if (_cyclical_dependency_exists(editor->get_edited_scene()->get_filename(), instanced_scene)) {
- memdelete(instanced_scene);
+ if (_cyclical_dependency_exists(editor->get_edited_scene()->get_filename(), instantiated_scene)) {
+ memdelete(instantiated_scene);
return false;
}
}
if (scene != nullptr) {
- instanced_scene->set_filename(ProjectSettings::get_singleton()->localize_path(path));
+ instantiated_scene->set_filename(ProjectSettings::get_singleton()->localize_path(path));
}
- editor_data->get_undo_redo().add_do_method(parent, "add_child", instanced_scene);
- editor_data->get_undo_redo().add_do_method(instanced_scene, "set_owner", editor->get_edited_scene());
- editor_data->get_undo_redo().add_do_reference(instanced_scene);
- editor_data->get_undo_redo().add_undo_method(parent, "remove_child", instanced_scene);
+ editor_data->get_undo_redo().add_do_method(parent, "add_child", instantiated_scene);
+ editor_data->get_undo_redo().add_do_method(instantiated_scene, "set_owner", editor->get_edited_scene());
+ editor_data->get_undo_redo().add_do_reference(instantiated_scene);
+ editor_data->get_undo_redo().add_undo_method(parent, "remove_child", instantiated_scene);
- String new_name = parent->validate_child_name(instanced_scene);
+ String new_name = parent->validate_child_name(instantiated_scene);
EditorDebuggerNode *ed = EditorDebuggerNode::get_singleton();
editor_data->get_undo_redo().add_do_method(ed, "live_debug_instance_node", editor->get_edited_scene()->get_path_to(parent), path, new_name);
editor_data->get_undo_redo().add_undo_method(ed, "live_debug_remove_node", NodePath(String(editor->get_edited_scene()->get_path_to(parent)) + "/" + new_name));
- Node3D *node3d = Object::cast_to<Node3D>(instanced_scene);
+ Node3D *node3d = Object::cast_to<Node3D>(instantiated_scene);
if (node3d) {
Transform3D global_transform;
Node3D *parent_node3d = Object::cast_to<Node3D>(parent);
@@ -3811,7 +3814,7 @@ bool Node3DEditorViewport::_create_instance(Node *parent, String &path, const Po
global_transform.origin = spatial_editor->snap_point(_get_instance_position(p_point));
global_transform.basis *= node3d->get_transform().basis;
- editor_data->get_undo_redo().add_do_method(instanced_scene, "set_global_transform", global_transform);
+ editor_data->get_undo_redo().add_do_method(instantiated_scene, "set_global_transform", global_transform);
}
return true;
@@ -3854,7 +3857,7 @@ void Node3DEditorViewport::_perform_drop_data() {
}
bool Node3DEditorViewport::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
- bool can_instance = false;
+ bool can_instantiate = false;
if (!preview_node->is_inside_tree()) {
Dictionary d = p_data;
@@ -3876,11 +3879,11 @@ bool Node3DEditorViewport::can_drop_data_fw(const Point2 &p_point, const Variant
String type = res->get_class();
if (type == "PackedScene") {
Ref<PackedScene> sdata = ResourceLoader::load(files[i]);
- Node *instanced_scene = sdata->instance(PackedScene::GEN_EDIT_STATE_INSTANCE);
- if (!instanced_scene) {
+ Node *instantiated_scene = sdata->instantiate(PackedScene::GEN_EDIT_STATE_INSTANCE);
+ if (!instantiated_scene) {
continue;
}
- memdelete(instanced_scene);
+ memdelete(instantiated_scene);
} else if (type == "Mesh" || type == "ArrayMesh" || type == "PrimitiveMesh") {
Ref<Mesh> mesh = ResourceLoader::load(files[i]);
if (!mesh.is_valid()) {
@@ -3889,24 +3892,24 @@ bool Node3DEditorViewport::can_drop_data_fw(const Point2 &p_point, const Variant
} else {
continue;
}
- can_instance = true;
+ can_instantiate = true;
break;
}
}
- if (can_instance) {
+ if (can_instantiate) {
_create_preview(files);
}
}
} else {
- can_instance = true;
+ can_instantiate = true;
}
- if (can_instance) {
+ if (can_instantiate) {
Transform3D global_transform = Transform3D(Basis(), _get_instance_position(p_point));
preview_node->set_global_transform(global_transform);
}
- return can_instance;
+ return can_instantiate;
}
void Node3DEditorViewport::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
@@ -5316,7 +5319,7 @@ void Node3DEditor::_init_indicators() {
origin_enabled = true;
grid_enabled = true;
- indicator_mat.instance();
+ indicator_mat.instantiate();
indicator_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
indicator_mat->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
indicator_mat->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true);
@@ -5396,7 +5399,7 @@ void Node3DEditor::_init_indicators() {
"}");
for (int i = 0; i < 3; i++) {
- grid_mat[i].instance();
+ grid_mat[i].instantiate();
grid_mat[i]->set_shader(grid_shader);
}
@@ -6547,9 +6550,11 @@ void Node3DEditor::clear() {
void Node3DEditor::_sun_direction_draw() {
sun_direction->draw_rect(Rect2(Vector2(), sun_direction->get_size()), Color(1, 1, 1, 1));
- sun_direction_material->set_shader_param("sun_direction", -preview_sun->get_transform().basis.get_axis(Vector3::AXIS_Z));
- float nrg = sun_energy->get_value();
- sun_direction_material->set_shader_param("sun_color", Vector3(sun_color->get_pick_color().r * nrg, sun_color->get_pick_color().g * nrg, sun_color->get_pick_color().b * nrg));
+ Vector3 z_axis = preview_sun->get_transform().basis.get_axis(Vector3::AXIS_Z);
+ z_axis = get_editor_viewport(0)->camera->get_camera_transform().basis.xform_inv(z_axis);
+ sun_direction_material->set_shader_param("sun_direction", Vector3(z_axis.x, -z_axis.y, z_axis.z));
+ Color color = sun_color->get_pick_color() * sun_energy->get_value();
+ sun_direction_material->set_shader_param("sun_color", Vector3(color.r, color.g, color.b));
}
void Node3DEditor::_preview_settings_changed() {
@@ -6559,7 +6564,7 @@ void Node3DEditor::_preview_settings_changed() {
{ // preview sun
Transform3D t;
- t.basis = sun_rotation;
+ t.basis = Basis(Vector3(sun_rotation.x, sun_rotation.y, 0));
preview_sun->set_transform(t);
sun_direction->update();
preview_sun->set_param(Light3D::PARAM_ENERGY, sun_energy->get_value());
@@ -6581,11 +6586,20 @@ void Node3DEditor::_preview_settings_changed() {
environment->set_tonemapper(environ_tonemap_button->is_pressed() ? Environment::TONE_MAPPER_FILMIC : Environment::TONE_MAPPER_LINEAR);
}
}
+
void Node3DEditor::_load_default_preview_settings() {
sun_environ_updating = true;
- sun_rotation = Basis(Vector3(0, 1, 0), Math_PI * 3.0 / 4) * Basis(Vector3(1, 0, 0), -Math_PI / 4);
+ // These default rotations place the preview sun at an angular altitude
+ // of 60 degrees (must be negative) and an azimuth of 30 degrees clockwise
+ // from north (or 150 CCW from south), from north east, facing south west.
+ // On any not-tidally-locked planet, a sun would have an angular altitude
+ // of 60 degrees as the average of all points on the sphere at noon.
+ // The azimuth choice is arbitrary, but ideally shouldn't be on an axis.
+ sun_rotation = Vector2(-Math::deg2rad(60.0), Math::deg2rad(150.0));
+ sun_angle_altitude->set_value(-Math::rad2deg(sun_rotation.x));
+ sun_angle_azimuth->set_value(180.0 - Math::rad2deg(sun_rotation.y));
sun_direction->update();
environ_sky_color->set_pick_color(Color::hex(0x91b2ceff));
environ_ground_color->set_pick_color(Color::hex(0x1f1f21ff));
@@ -6628,6 +6642,9 @@ void Node3DEditor::_update_preview_environment() {
}
}
+ sun_angle_altitude->set_value(-Math::rad2deg(sun_rotation.x));
+ sun_angle_azimuth->set_value(180.0 - Math::rad2deg(sun_rotation.y));
+
bool disable_env = world_env_count > 0 || environ_button->is_pressed();
environ_button->set_disabled(world_env_count > 0);
@@ -6656,17 +6673,21 @@ void Node3DEditor::_update_preview_environment() {
void Node3DEditor::_sun_direction_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid() && mm->get_button_mask() & MOUSE_BUTTON_MASK_LEFT) {
- float x = -mm->get_relative().y * 0.02 * EDSCALE;
- float y = mm->get_relative().x * 0.02 * EDSCALE;
-
- Basis rot = Basis(Vector3(0, 1, 0), y) * Basis(Vector3(1, 0, 0), x);
-
- sun_rotation = rot * sun_rotation;
- sun_rotation.orthonormalize();
+ sun_rotation.x += mm->get_relative().y * (0.02 * EDSCALE);
+ sun_rotation.y -= mm->get_relative().x * (0.02 * EDSCALE);
+ sun_rotation.x = CLAMP(sun_rotation.x, -Math_TAU / 4, Math_TAU / 4);
+ sun_angle_altitude->set_value(-Math::rad2deg(sun_rotation.x));
+ sun_angle_azimuth->set_value(180.0 - Math::rad2deg(sun_rotation.y));
_preview_settings_changed();
}
}
+void Node3DEditor::_sun_direction_angle_set() {
+ sun_rotation.x = Math::deg2rad(-sun_angle_altitude->get_value());
+ sun_rotation.y = Math::deg2rad(180.0 - sun_angle_azimuth->get_value());
+ _preview_settings_changed();
+}
+
Node3DEditor::Node3DEditor(EditorNode *p_editor) {
gizmo.visible = true;
gizmo.scale = 1.0;
@@ -6896,7 +6917,7 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) {
p->add_separator();
p->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_origin", TTR("View Origin")), MENU_VIEW_ORIGIN);
- p->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_grid", TTR("View Grid")), MENU_VIEW_GRID);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_grid", TTR("View Grid"), KEY_MASK_CMD + KEY_G), MENU_VIEW_GRID);
p->add_separator();
p->add_shortcut(ED_SHORTCUT("spatial_editor/settings", TTR("Settings...")), MENU_VIEW_CAMERA_SETTINGS);
@@ -7096,14 +7117,43 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) {
sun_direction->set_default_cursor_shape(CURSOR_MOVE);
String sun_dir_shader_code = "shader_type canvas_item; uniform vec3 sun_direction; uniform vec3 sun_color; void fragment() { vec3 n; n.xy = UV * 2.0 - 1.0; n.z = sqrt(max(0.0, 1.0 - dot(n.xy, n.xy))); COLOR.rgb = dot(n,sun_direction) * sun_color; COLOR.a = 1.0 - smoothstep(0.99,1.0,length(n.xy)); }";
- sun_direction_shader.instance();
+ sun_direction_shader.instantiate();
sun_direction_shader->set_code(sun_dir_shader_code);
- sun_direction_material.instance();
+ sun_direction_material.instantiate();
sun_direction_material->set_shader(sun_direction_shader);
sun_direction_material->set_shader_param("sun_direction", Vector3(0, 0, 1));
sun_direction_material->set_shader_param("sun_color", Vector3(1, 1, 1));
sun_direction->set_material(sun_direction_material);
+ HBoxContainer *sun_angle_hbox = memnew(HBoxContainer);
+ VBoxContainer *sun_angle_altitude_vbox = memnew(VBoxContainer);
+ Label *sun_angle_altitude_label = memnew(Label);
+ sun_angle_altitude_label->set_text(TTR("Angular Altitude"));
+ sun_angle_altitude_vbox->add_child(sun_angle_altitude_label);
+ sun_angle_altitude = memnew(EditorSpinSlider);
+ sun_angle_altitude->set_max(90);
+ sun_angle_altitude->set_min(-90);
+ sun_angle_altitude->set_step(0.1);
+ sun_angle_altitude->connect("value_changed", callable_mp(this, &Node3DEditor::_sun_direction_angle_set).unbind(1));
+ sun_angle_altitude_vbox->add_child(sun_angle_altitude);
+ sun_angle_hbox->add_child(sun_angle_altitude_vbox);
+ VBoxContainer *sun_angle_azimuth_vbox = memnew(VBoxContainer);
+ sun_angle_azimuth_vbox->set_custom_minimum_size(Vector2(100, 0));
+ Label *sun_angle_azimuth_label = memnew(Label);
+ sun_angle_azimuth_label->set_text(TTR("Azimuth"));
+ sun_angle_azimuth_vbox->add_child(sun_angle_azimuth_label);
+ sun_angle_azimuth = memnew(EditorSpinSlider);
+ sun_angle_azimuth->set_max(180);
+ sun_angle_azimuth->set_min(-180);
+ sun_angle_azimuth->set_step(0.1);
+ sun_angle_azimuth->set_allow_greater(true);
+ sun_angle_azimuth->set_allow_lesser(true);
+ sun_angle_azimuth->connect("value_changed", callable_mp(this, &Node3DEditor::_sun_direction_angle_set).unbind(1));
+ sun_angle_azimuth_vbox->add_child(sun_angle_azimuth);
+ sun_angle_hbox->add_child(sun_angle_azimuth_vbox);
+ sun_angle_hbox->add_theme_constant_override("separation", 10);
+ sun_vb->add_child(sun_angle_hbox);
+
sun_color = memnew(ColorPickerButton);
sun_color->set_edit_alpha(false);
sun_vb->add_margin_child(TTR("Sun Color"), sun_color);
@@ -7200,11 +7250,11 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) {
preview_sun->set_shadow(true);
preview_sun->set_shadow_mode(DirectionalLight3D::SHADOW_PARALLEL_4_SPLITS);
preview_environment = memnew(WorldEnvironment);
- environment.instance();
+ environment.instantiate();
preview_environment->set_environment(environment);
Ref<Sky> sky;
- sky.instance();
- sky_material.instance();
+ sky.instantiate();
+ sky_material.instantiate();
sky->set_material(sky_material);
environment->set_sky(sky);
environment->set_background(Environment::BG_SKY);
@@ -7335,17 +7385,17 @@ Node3DEditorPlugin::~Node3DEditorPlugin() {
}
void EditorNode3DGizmoPlugin::create_material(const String &p_name, const Color &p_color, bool p_billboard, bool p_on_top, bool p_use_vertex_color) {
- Color instanced_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/instanced", Color(0.7, 0.7, 0.7, 0.6));
+ Color instantiated_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/instantiated", Color(0.7, 0.7, 0.7, 0.6));
Vector<Ref<StandardMaterial3D>> mats;
for (int i = 0; i < 4; i++) {
bool selected = i % 2 == 1;
- bool instanced = i < 2;
+ bool instantiated = i < 2;
Ref<StandardMaterial3D> material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
- Color color = instanced ? instanced_color : p_color;
+ Color color = instantiated ? instantiated_color : p_color;
if (!selected) {
color.a *= 0.3;
@@ -7377,17 +7427,17 @@ void EditorNode3DGizmoPlugin::create_material(const String &p_name, const Color
}
void EditorNode3DGizmoPlugin::create_icon_material(const String &p_name, const Ref<Texture2D> &p_texture, bool p_on_top, const Color &p_albedo) {
- Color instanced_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/instanced", Color(0.7, 0.7, 0.7, 0.6));
+ Color instantiated_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/instantiated", Color(0.7, 0.7, 0.7, 0.6));
Vector<Ref<StandardMaterial3D>> icons;
for (int i = 0; i < 4; i++) {
bool selected = i % 2 == 1;
- bool instanced = i < 2;
+ bool instantiated = i < 2;
Ref<StandardMaterial3D> icon = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
- Color color = instanced ? instanced_color : p_albedo;
+ Color color = instantiated ? instantiated_color : p_albedo;
if (!selected) {
color.a *= 0.85;
@@ -7546,7 +7596,7 @@ Ref<EditorNode3DGizmo> EditorNode3DGizmoPlugin::create_gizmo(Node3D *p_spatial)
Ref<EditorNode3DGizmo> ref;
if (has_gizmo(p_spatial)) {
- ref.instance();
+ ref.instantiate();
}
return ref;
}
diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h
index 20a0c501df..fa432a5868 100644
--- a/editor/plugins/node_3d_editor_plugin.h
+++ b/editor/plugins/node_3d_editor_plugin.h
@@ -52,7 +52,7 @@ class EditorNode3DGizmo : public Node3DGizmo {
GDCLASS(EditorNode3DGizmo, Node3DGizmo);
bool selected;
- bool instanced;
+ bool instantiated;
public:
void set_selected(bool p_selected) { selected = p_selected; }
@@ -764,6 +764,8 @@ private:
VBoxContainer *sun_vb;
Popup *sun_environ_popup;
Control *sun_direction;
+ EditorSpinSlider *sun_angle_altitude;
+ EditorSpinSlider *sun_angle_azimuth;
ColorPickerButton *sun_color;
EditorSpinSlider *sun_energy;
EditorSpinSlider *sun_max_distance;
@@ -771,8 +773,9 @@ private:
void _sun_direction_draw();
void _sun_direction_input(const Ref<InputEvent> &p_event);
+ void _sun_direction_angle_set();
- Basis sun_rotation;
+ Vector2 sun_rotation;
Ref<Shader> sun_direction_shader;
Ref<ShaderMaterial> sun_direction_material;
diff --git a/editor/plugins/occluder_instance_3d_editor_plugin.cpp b/editor/plugins/occluder_instance_3d_editor_plugin.cpp
index 0821f140b3..b0cafd83be 100644
--- a/editor/plugins/occluder_instance_3d_editor_plugin.cpp
+++ b/editor/plugins/occluder_instance_3d_editor_plugin.cpp
@@ -56,7 +56,7 @@ void OccluderInstance3DEditorPlugin::_bake_select_file(const String &p_file) {
} break;
case OccluderInstance3D::BAKE_ERROR_NO_MESHES: {
- EditorNode::get_singleton()->show_warning(TTR("No meshes to bake."));
+ EditorNode::get_singleton()->show_warning(TTR("No meshes to bake.\nMake sure there is at least one MeshInstance3D node in the scene whose visual layers are part of the OccluderInstance3D's Bake Mask property."));
break;
}
default: {
diff --git a/editor/plugins/ot_features_plugin.cpp b/editor/plugins/ot_features_plugin.cpp
index ebfdf2c7cd..baab9bc438 100644
--- a/editor/plugins/ot_features_plugin.cpp
+++ b/editor/plugins/ot_features_plugin.cpp
@@ -208,6 +208,6 @@ bool EditorInspectorPluginOpenTypeFeatures::parse_property(Object *p_object, Var
OpenTypeFeaturesEditorPlugin::OpenTypeFeaturesEditorPlugin(EditorNode *p_node) {
Ref<EditorInspectorPluginOpenTypeFeatures> ftr_plugin;
- ftr_plugin.instance();
+ ftr_plugin.instantiate();
EditorInspector::add_inspector_plugin(ftr_plugin);
}
diff --git a/editor/plugins/path_3d_editor_plugin.cpp b/editor/plugins/path_3d_editor_plugin.cpp
index b0eb13c3c6..82b51f8a06 100644
--- a/editor/plugins/path_3d_editor_plugin.cpp
+++ b/editor/plugins/path_3d_editor_plugin.cpp
@@ -554,7 +554,7 @@ Path3DEditorPlugin::Path3DEditorPlugin(EditorNode *p_node) {
mirror_handle_length = true;
Ref<Path3DGizmoPlugin> gizmo_plugin;
- gizmo_plugin.instance();
+ gizmo_plugin.instantiate();
Node3DEditor::get_singleton()->add_gizmo_plugin(gizmo_plugin);
sep = memnew(VSeparator);
diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp
index 8a14db0cfd..1a13a028c8 100644
--- a/editor/plugins/polygon_2d_editor_plugin.cpp
+++ b/editor/plugins/polygon_2d_editor_plugin.cpp
@@ -162,7 +162,7 @@ void Polygon2DEditor::_update_bone_list() {
}
Ref<ButtonGroup> bg;
- bg.instance();
+ bg.instantiate();
for (int i = 0; i < node->get_bone_count(); i++) {
CheckBox *cb = memnew(CheckBox);
NodePath np = node->get_bone_path(i);
@@ -1231,7 +1231,7 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) :
uv_edit->add_child(uv_main_vb);
HBoxContainer *uv_mode_hb = memnew(HBoxContainer);
- uv_edit_group.instance();
+ uv_edit_group.instantiate();
uv_edit_mode[0] = memnew(Button);
uv_mode_hb->add_child(uv_edit_mode[0]);
diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp
index b8b2c6d343..a7c11f8521 100644
--- a/editor/plugins/resource_preloader_editor_plugin.cpp
+++ b/editor/plugins/resource_preloader_editor_plugin.cpp
@@ -367,8 +367,8 @@ ResourcePreloaderEditor::ResourcePreloaderEditor() {
tree = memnew(Tree);
tree->connect("button_pressed", callable_mp(this, &ResourcePreloaderEditor::_cell_button_pressed));
tree->set_columns(2);
- tree->set_column_min_width(0, 2);
- tree->set_column_min_width(1, 3);
+ tree->set_column_custom_minimum_width(0, 2);
+ tree->set_column_custom_minimum_width(1, 3);
tree->set_column_expand(0, true);
tree->set_column_expand(1, true);
tree->set_v_size_flags(SIZE_EXPAND_FILL);
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 0410ab3a45..498d5b0711 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -71,7 +71,7 @@ Array EditorSyntaxHighlighter::_get_supported_languages() const {
Ref<EditorSyntaxHighlighter> EditorSyntaxHighlighter::_create() const {
Ref<EditorSyntaxHighlighter> syntax_highlighter;
- syntax_highlighter.instance();
+ syntax_highlighter.instantiate();
if (get_script_instance()) {
syntax_highlighter->set_script(get_script_instance()->get_script());
}
@@ -201,7 +201,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() {
Ref<EditorSyntaxHighlighter> EditorStandardSyntaxHighlighter::_create() const {
Ref<EditorStandardSyntaxHighlighter> syntax_highlighter;
- syntax_highlighter.instance();
+ syntax_highlighter.instantiate();
return syntax_highlighter;
}
@@ -209,7 +209,7 @@ Ref<EditorSyntaxHighlighter> EditorStandardSyntaxHighlighter::_create() const {
Ref<EditorSyntaxHighlighter> EditorPlainTextSyntaxHighlighter::_create() const {
Ref<EditorPlainTextSyntaxHighlighter> syntax_highlighter;
- syntax_highlighter.instance();
+ syntax_highlighter.instantiate();
return syntax_highlighter;
}
@@ -760,6 +760,7 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) {
_update_members_overview_visibility();
_update_help_overview_visibility();
_save_layout();
+ _update_find_replace_bar();
}
void ScriptEditor::_close_current_tab(bool p_save) {
@@ -829,6 +830,7 @@ void ScriptEditor::_close_all_tabs() {
_close_current_tab(false);
}
+ _update_find_replace_bar();
}
void ScriptEditor::_ask_close_current_unsaved_tab(ScriptEditorBase *current) {
@@ -1629,7 +1631,7 @@ void ScriptEditor::_help_overview_selected(int p_idx) {
}
void ScriptEditor::_script_selected(int p_idx) {
- grab_focus_block = !Input::get_singleton()->is_mouse_button_pressed(1); //amazing hack, simply amazing
+ grab_focus_block = !Input::get_singleton()->is_mouse_button_pressed(MOUSE_BUTTON_LEFT); //amazing hack, simply amazing
_go_to_tab(script_list->get_item_metadata(p_idx));
grab_focus_block = false;
@@ -1640,15 +1642,13 @@ void ScriptEditor::ensure_select_current() {
ScriptEditorBase *se = _get_current_editor();
if (se) {
se->enable_editor();
- se->set_find_replace_bar(find_replace_bar);
if (!grab_focus_block && is_visible_in_tree()) {
se->ensure_focus();
}
- } else {
- find_replace_bar->hide();
}
}
+ _update_find_replace_bar();
_update_selected_editor_menu();
}
@@ -2520,6 +2520,16 @@ void ScriptEditor::_file_removed(const String &p_removed_file) {
}
}
+void ScriptEditor::_update_find_replace_bar() {
+ ScriptEditorBase *se = _get_current_editor();
+ if (se) {
+ se->set_find_replace_bar(find_replace_bar);
+ } else {
+ find_replace_bar->set_text_edit(nullptr);
+ find_replace_bar->hide();
+ }
+}
+
void ScriptEditor::_autosave_scripts() {
save_all_scripts();
}
@@ -2771,6 +2781,8 @@ void ScriptEditor::_script_list_gui_input(const Ref<InputEvent> &ev) {
case MOUSE_BUTTON_RIGHT: {
_make_script_list_context_menu();
} break;
+ default:
+ break;
}
}
}
diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h
index 1d379059d4..72a649ffbf 100644
--- a/editor/plugins/script_editor_plugin.h
+++ b/editor/plugins/script_editor_plugin.h
@@ -80,7 +80,7 @@ public:
virtual Ref<EditorSyntaxHighlighter> _create() const override;
- EditorStandardSyntaxHighlighter() { highlighter.instance(); }
+ EditorStandardSyntaxHighlighter() { highlighter.instantiate(); }
};
class EditorPlainTextSyntaxHighlighter : public EditorSyntaxHighlighter {
@@ -328,6 +328,7 @@ class ScriptEditor : public PanelContainer {
void _show_error_dialog(String p_path);
void _close_tab(int p_idx, bool p_save = true, bool p_history_back = true);
+ void _update_find_replace_bar();
void _close_current_tab(bool p_save = true);
void _close_discard_current_tab(const String &p_str);
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 3ec20ae68e..5fc1f74089 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -109,13 +109,11 @@ ConnectionInfoDialog::ConnectionInfoDialog() {
////////////////////////////////////////////////////////////////////////////////
Vector<String> ScriptTextEditor::get_functions() {
- String errortxt;
- int line = -1, col;
CodeEdit *te = code_editor->get_text_editor();
String text = te->get_text();
List<String> fnc;
- if (script->get_language()->validate(text, line, col, errortxt, script->get_path(), &fnc)) {
+ if (script->get_language()->validate(text, script->get_path(), &fnc)) {
//if valid rewrite functions to latest
functions.clear();
for (List<String>::Element *E = fnc.front(); E; E = E->next()) {
@@ -168,7 +166,6 @@ void ScriptTextEditor::enable_editor() {
void ScriptTextEditor::_load_theme_settings() {
CodeEdit *text_edit = code_editor->get_text_editor();
- text_edit->clear_keywords();
Color updated_marked_line_color = EDITOR_GET("text_editor/highlighting/mark_color");
Color updated_safe_line_number_color = EDITOR_GET("text_editor/highlighting/safe_line_number_color");
@@ -222,47 +219,10 @@ void ScriptTextEditor::_set_theme_for_script() {
String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String();
text_edit->add_comment_delimiter(beg, end, end == "");
}
+}
- /* add keywords for auto completion */
- // singleton autoloads (as types, just as engine singletons are)
- Map<StringName, ProjectSettings::AutoloadInfo> autoloads = ProjectSettings::get_singleton()->get_autoload_list();
- for (Map<StringName, ProjectSettings::AutoloadInfo>::Element *E = autoloads.front(); E; E = E->next()) {
- const ProjectSettings::AutoloadInfo &info = E->value();
- if (info.is_singleton) {
- text_edit->add_keyword(info.name);
- }
- }
-
- // engine types
- List<StringName> types;
- ClassDB::get_class_list(&types);
- for (List<StringName>::Element *E = types.front(); E; E = E->next()) {
- String n = E->get();
- if (n.begins_with("_")) {
- n = n.substr(1, n.length());
- }
- text_edit->add_keyword(n);
- }
-
- // user types
- List<StringName> global_classes;
- ScriptServer::get_global_class_list(&global_classes);
- for (List<StringName>::Element *E = global_classes.front(); E; E = E->next()) {
- text_edit->add_keyword(E->get());
- }
-
- List<String> keywords;
- script->get_language()->get_reserved_words(&keywords);
- for (List<String>::Element *E = keywords.front(); E; E = E->next()) {
- text_edit->add_keyword(E->get());
- }
-
- // core types
- List<String> core_types;
- script->get_language()->get_core_type_words(&core_types);
- for (List<String>::Element *E = core_types.front(); E; E = E->next()) {
- text_edit->add_keyword(E->get());
- }
+void ScriptTextEditor::_show_errors_panel(bool p_show) {
+ errors_panel->set_visible(p_show);
}
void ScriptTextEditor::_show_warnings_panel(bool p_show) {
@@ -279,6 +239,12 @@ void ScriptTextEditor::_warning_clicked(Variant p_line) {
}
}
+void ScriptTextEditor::_error_clicked(Variant p_line) {
+ if (p_line.get_type() == Variant::INT) {
+ code_editor->get_text_editor()->cursor_set_line(p_line.operator int64_t());
+ }
+}
+
void ScriptTextEditor::reload_text() {
ERR_FAIL_COND(script.is_null());
@@ -429,23 +395,21 @@ Ref<Texture2D> ScriptTextEditor::get_theme_icon() {
}
void ScriptTextEditor::_validate_script() {
- String errortxt;
- int line = -1, col;
CodeEdit *te = code_editor->get_text_editor();
String text = te->get_text();
List<String> fnc;
Set<int> safe_lines;
List<ScriptLanguage::Warning> warnings;
+ List<ScriptLanguage::ScriptError> errors;
- if (!script->get_language()->validate(text, line, col, errortxt, script->get_path(), &fnc, &warnings, &safe_lines)) {
- String error_text = "error(" + itos(line) + "," + itos(col) + "): " + errortxt;
+ if (!script->get_language()->validate(text, script->get_path(), &fnc, &errors, &warnings, &safe_lines)) {
+ String error_text = TTR("Error at ") + "(" + itos(errors[0].line) + "," + itos(errors[0].column) + "): " + errors[0].message;
code_editor->set_error(error_text);
- code_editor->set_error_pos(line - 1, col - 1);
+ code_editor->set_error_pos(errors[0].line - 1, errors[0].column - 1);
script_is_valid = false;
} else {
code_editor->set_error("");
- line = -1;
if (!script->is_tool()) {
script->set_source_code(text);
script->update_exports();
@@ -487,7 +451,8 @@ void ScriptTextEditor::_validate_script() {
}
}
- code_editor->set_warning_nb(warning_nb);
+ code_editor->set_error_count(errors.size());
+ code_editor->set_warning_count(warning_nb);
// Add script warnings.
warnings_panel->push_table(3);
@@ -521,23 +486,52 @@ void ScriptTextEditor::_validate_script() {
}
warnings_panel->pop(); // Table.
- line--;
+ errors_panel->clear();
+ errors_panel->push_table(2);
+ for (List<ScriptLanguage::ScriptError>::Element *E = errors.front(); E; E = E->next()) {
+ ScriptLanguage::ScriptError err = E->get();
+
+ errors_panel->push_cell();
+ errors_panel->push_meta(err.line - 1);
+ errors_panel->push_color(warnings_panel->get_theme_color("error_color", "Editor"));
+ errors_panel->add_text(TTR("Line") + " " + itos(err.line) + ":");
+ errors_panel->pop(); // Color.
+ errors_panel->pop(); // Meta goto.
+ errors_panel->pop(); // Cell.
+
+ errors_panel->push_cell();
+ errors_panel->add_text(err.message);
+ errors_panel->pop(); // Cell.
+ }
+ errors_panel->pop(); // Table
+
bool highlight_safe = EDITOR_DEF("text_editor/highlighting/highlight_type_safe_lines", true);
bool last_is_safe = false;
for (int i = 0; i < te->get_line_count(); i++) {
- te->set_line_background_color(i, (line == i) ? marked_line_color : Color(0, 0, 0, 0));
+ if (errors.is_empty()) {
+ te->set_line_background_color(i, Color(0, 0, 0, 0));
+ } else {
+ for (List<ScriptLanguage::ScriptError>::Element *E = errors.front(); E; E = E->next()) {
+ bool error_line = i == E->get().line - 1;
+ te->set_line_background_color(i, error_line ? marked_line_color : Color(0, 0, 0, 0));
+ if (error_line) {
+ break;
+ }
+ }
+ }
+
if (highlight_safe) {
if (safe_lines.has(i + 1)) {
te->set_line_gutter_item_color(i, line_number_gutter, safe_line_number_color);
last_is_safe = true;
- } else if (last_is_safe && (te->is_line_comment(i) || te->get_line(i).strip_edges().is_empty())) {
+ } else if (last_is_safe && (te->is_in_comment(i) != -1 || te->get_line(i).strip_edges().is_empty())) {
te->set_line_gutter_item_color(i, line_number_gutter, safe_line_number_color);
} else {
te->set_line_gutter_item_color(i, line_number_gutter, default_line_number_color);
last_is_safe = false;
}
} else {
- te->set_line_gutter_item_color(line, 1, default_line_number_color);
+ te->set_line_gutter_item_color(i, 1, default_line_number_color);
}
}
@@ -1044,7 +1038,7 @@ void ScriptTextEditor::_edit_option(int p_op) {
return;
}
- tx->indent_selected_lines_left();
+ tx->unindent_lines();
} break;
case EDIT_INDENT_RIGHT: {
Ref<Script> scr = script;
@@ -1052,7 +1046,7 @@ void ScriptTextEditor::_edit_option(int p_op) {
return;
}
- tx->indent_selected_lines_right();
+ tx->indent_lines();
} break;
case EDIT_DELETE_LINE: {
code_editor->delete_lines();
@@ -1675,6 +1669,7 @@ void ScriptTextEditor::_enable_code_editor() {
editor_box->set_v_size_flags(SIZE_EXPAND_FILL);
editor_box->add_child(code_editor);
+ code_editor->connect("show_errors_panel", callable_mp(this, &ScriptTextEditor::_show_errors_panel));
code_editor->connect("show_warnings_panel", callable_mp(this, &ScriptTextEditor::_show_warnings_panel));
code_editor->connect("validate_script", callable_mp(this, &ScriptTextEditor::_validate_script));
code_editor->connect("load_theme_settings", callable_mp(this, &ScriptTextEditor::_load_theme_settings));
@@ -1695,6 +1690,13 @@ void ScriptTextEditor::_enable_code_editor() {
"normal_font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("main_size", "EditorFonts"));
warnings_panel->connect("meta_clicked", callable_mp(this, &ScriptTextEditor::_warning_clicked));
+ editor_box->add_child(errors_panel);
+ errors_panel->add_theme_font_override(
+ "normal_font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("main", "EditorFonts"));
+ errors_panel->add_theme_font_size_override(
+ "normal_font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("main_size", "EditorFonts"));
+ errors_panel->connect("meta_clicked", callable_mp(this, &ScriptTextEditor::_error_clicked));
+
add_child(context_menu);
context_menu->connect("id_pressed", callable_mp(this, &ScriptTextEditor::_edit_option));
@@ -1826,6 +1828,14 @@ ScriptTextEditor::ScriptTextEditor() {
warnings_panel->set_focus_mode(FOCUS_CLICK);
warnings_panel->hide();
+ errors_panel = memnew(RichTextLabel);
+ errors_panel->set_custom_minimum_size(Size2(0, 100 * EDSCALE));
+ errors_panel->set_h_size_flags(SIZE_EXPAND_FILL);
+ errors_panel->set_meta_underline(true);
+ errors_panel->set_selection_enabled(true);
+ errors_panel->set_focus_mode(FOCUS_CLICK);
+ errors_panel->hide();
+
update_settings();
code_editor->get_text_editor()->set_code_hint_draw_below(EditorSettings::get_singleton()->get("text_editor/completion/put_callhint_tooltip_below_current_line"));
@@ -1851,11 +1861,11 @@ ScriptTextEditor::ScriptTextEditor() {
highlighter_menu->set_name("highlighter_menu");
Ref<EditorPlainTextSyntaxHighlighter> plain_highlighter;
- plain_highlighter.instance();
+ plain_highlighter.instantiate();
add_syntax_highlighter(plain_highlighter);
Ref<EditorStandardSyntaxHighlighter> highlighter;
- highlighter.instance();
+ highlighter.instantiate();
add_syntax_highlighter(highlighter);
set_syntax_highlighter(highlighter);
@@ -1886,6 +1896,7 @@ ScriptTextEditor::~ScriptTextEditor() {
if (!editor_enabled) {
memdelete(code_editor);
memdelete(warnings_panel);
+ memdelete(errors_panel);
memdelete(context_menu);
memdelete(color_panel);
memdelete(edit_hb);
diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h
index 7bb961bf19..8a8e9aa737 100644
--- a/editor/plugins/script_text_editor.h
+++ b/editor/plugins/script_text_editor.h
@@ -55,6 +55,7 @@ class ScriptTextEditor : public ScriptEditorBase {
CodeTextEditor *code_editor = nullptr;
RichTextLabel *warnings_panel = nullptr;
+ RichTextLabel *errors_panel = nullptr;
Ref<Script> script;
bool script_is_valid = false;
@@ -161,7 +162,9 @@ protected:
void _load_theme_settings();
void _set_theme_for_script();
+ void _show_errors_panel(bool p_show);
void _show_warnings_panel(bool p_show);
+ void _error_clicked(Variant p_line);
void _warning_clicked(Variant p_line);
void _notification(int p_what);
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index e4a5a3796e..173f1dd7fb 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -240,7 +240,7 @@ void ShaderTextEditor::_validate_script() {
warnings.sort_custom<WarningsComparator>();
_update_warning_panel();
} else {
- set_warning_nb(0);
+ set_warning_count(0);
}
emit_signal("script_changed");
}
@@ -280,14 +280,14 @@ void ShaderTextEditor::_update_warning_panel() {
}
warnings_panel->pop(); // Table.
- set_warning_nb(warning_count);
+ set_warning_count(warning_count);
}
void ShaderTextEditor::_bind_methods() {
}
ShaderTextEditor::ShaderTextEditor() {
- syntax_highlighter.instance();
+ syntax_highlighter.instantiate();
get_text_editor()->set_syntax_highlighter(syntax_highlighter);
}
@@ -323,19 +323,13 @@ void ShaderEditor::_menu_option(int p_option) {
if (shader.is_null()) {
return;
}
-
- CodeEdit *tx = shader_editor->get_text_editor();
- tx->indent_selected_lines_left();
-
+ shader_editor->get_text_editor()->unindent_lines();
} break;
case EDIT_INDENT_RIGHT: {
if (shader.is_null()) {
return;
}
-
- CodeEdit *tx = shader_editor->get_text_editor();
- tx->indent_selected_lines_right();
-
+ shader_editor->get_text_editor()->indent_lines();
} break;
case EDIT_DELETE_LINE: {
shader_editor->delete_lines();
diff --git a/editor/plugins/shader_file_editor_plugin.cpp b/editor/plugins/shader_file_editor_plugin.cpp
index 47d7f8204b..85ccc5b798 100644
--- a/editor/plugins/shader_file_editor_plugin.cpp
+++ b/editor/plugins/shader_file_editor_plugin.cpp
@@ -272,7 +272,7 @@ ShaderFileEditor::ShaderFileEditor(EditorNode *p_node) {
main_vb->add_child(stage_hb);
Ref<ButtonGroup> bg;
- bg.instance();
+ bg.instantiate();
for (int i = 0; i < RD::SHADER_STAGE_MAX; i++) {
Button *button = memnew(Button(stage_str[i]));
button->set_toggle_mode(true);
diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp
index a97584ebce..0b04c2e50e 100644
--- a/editor/plugins/skeleton_3d_editor_plugin.cpp
+++ b/editor/plugins/skeleton_3d_editor_plugin.cpp
@@ -700,7 +700,7 @@ Skeleton3DEditorPlugin::Skeleton3DEditorPlugin(EditorNode *p_node) {
editor = p_node;
Ref<EditorInspectorPluginSkeleton> skeleton_plugin;
- skeleton_plugin.instance();
+ skeleton_plugin.instantiate();
skeleton_plugin->editor = editor;
EditorInspector::add_inspector_plugin(skeleton_plugin);
diff --git a/editor/plugins/sprite_2d_editor_plugin.cpp b/editor/plugins/sprite_2d_editor_plugin.cpp
index 4a7f6c0f7e..ef328bcfe2 100644
--- a/editor/plugins/sprite_2d_editor_plugin.cpp
+++ b/editor/plugins/sprite_2d_editor_plugin.cpp
@@ -186,7 +186,7 @@ void Sprite2DEditor::_update_mesh_data() {
}
Ref<BitMap> bm;
- bm.instance();
+ bm.instantiate();
bm->create_from_image_alpha(image);
int shrink = shrink_pixels->get_value();
@@ -322,7 +322,7 @@ void Sprite2DEditor::_convert_to_mesh_2d_node() {
}
Ref<ArrayMesh> mesh;
- mesh.instance();
+ mesh.instantiate();
Array a;
a.resize(Mesh::ARRAY_MAX);
@@ -435,7 +435,7 @@ void Sprite2DEditor::_create_light_occluder_2d_node() {
Vector<Vector2> outline = computed_outline_lines[i];
Ref<OccluderPolygon2D> polygon;
- polygon.instance();
+ polygon.instantiate();
PackedVector2Array a;
a.resize(outline.size());
diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp
index a5a3d624ec..70c7b3072b 100644
--- a/editor/plugins/sprite_frames_editor_plugin.cpp
+++ b/editor/plugins/sprite_frames_editor_plugin.cpp
@@ -103,17 +103,16 @@ void SpriteFramesEditor::_sheet_preview_draw() {
}
void SpriteFramesEditor::_sheet_preview_input(const Ref<InputEvent> &p_event) {
- Ref<InputEventMouseButton> mb = p_event;
-
+ const Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) {
- Size2i size = split_sheet_preview->get_size();
- int h = split_sheet_h->get_value();
- int v = split_sheet_v->get_value();
+ const Size2i size = split_sheet_preview->get_size();
+ const int h = split_sheet_h->get_value();
+ const int v = split_sheet_v->get_value();
- int x = CLAMP(int(mb->get_position().x) * h / size.width, 0, h - 1);
- int y = CLAMP(int(mb->get_position().y) * v / size.height, 0, v - 1);
+ const int x = CLAMP(int(mb->get_position().x) * h / size.width, 0, h - 1);
+ const int y = CLAMP(int(mb->get_position().y) * v / size.height, 0, v - 1);
- int idx = h * y + x;
+ const int idx = h * y + x;
if (mb->is_shift_pressed() && last_frame_selected >= 0) {
//select multiple
@@ -124,6 +123,9 @@ void SpriteFramesEditor::_sheet_preview_input(const Ref<InputEvent> &p_event) {
}
for (int i = from; i <= to; i++) {
+ // Prevent double-toggling the same frame when moving the mouse when the mouse button is still held.
+ frames_toggled_by_mouse_hover.insert(idx);
+
if (mb->is_ctrl_pressed()) {
frames_selected.erase(i);
} else {
@@ -131,6 +133,9 @@ void SpriteFramesEditor::_sheet_preview_input(const Ref<InputEvent> &p_event) {
}
}
} else {
+ // Prevent double-toggling the same frame when moving the mouse when the mouse button is still held.
+ frames_toggled_by_mouse_hover.insert(idx);
+
if (frames_selected.has(idx)) {
frames_selected.erase(idx);
} else {
@@ -141,6 +146,39 @@ void SpriteFramesEditor::_sheet_preview_input(const Ref<InputEvent> &p_event) {
last_frame_selected = idx;
split_sheet_preview->update();
}
+
+ if (mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) {
+ frames_toggled_by_mouse_hover.clear();
+ }
+
+ const Ref<InputEventMouseMotion> mm = p_event;
+ if (mm.is_valid() && mm->get_button_mask() & MOUSE_BUTTON_MASK_LEFT) {
+ // Select by holding down the mouse button on frames.
+ const Size2i size = split_sheet_preview->get_size();
+ const int h = split_sheet_h->get_value();
+ const int v = split_sheet_v->get_value();
+
+ const int x = CLAMP(int(mm->get_position().x) * h / size.width, 0, h - 1);
+ const int y = CLAMP(int(mm->get_position().y) * v / size.height, 0, v - 1);
+
+ const int idx = h * y + x;
+
+ if (!frames_toggled_by_mouse_hover.has(idx)) {
+ // Only allow toggling each tile once per mouse hold.
+ // Otherwise, the selection would constantly "flicker" in and out when moving the mouse cursor.
+ // The mouse button must be released before it can be toggled again.
+ frames_toggled_by_mouse_hover.insert(idx);
+
+ if (frames_selected.has(idx)) {
+ frames_selected.erase(idx);
+ } else {
+ frames_selected.insert(idx);
+ }
+
+ last_frame_selected = idx;
+ split_sheet_preview->update();
+ }
+ }
}
void SpriteFramesEditor::_sheet_scroll_input(const Ref<InputEvent> &p_event) {
@@ -189,7 +227,7 @@ void SpriteFramesEditor::_sheet_add_frames() {
int y = (yp * height) + region_rect.position.y;
Ref<AtlasTexture> at;
- at.instance();
+ at.instantiate();
at->set_atlas(split_sheet_preview->get_texture());
at->set_region(Rect2(x, y, width, height));
diff --git a/editor/plugins/sprite_frames_editor_plugin.h b/editor/plugins/sprite_frames_editor_plugin.h
index 77cdbb4af6..e6c59e3533 100644
--- a/editor/plugins/sprite_frames_editor_plugin.h
+++ b/editor/plugins/sprite_frames_editor_plugin.h
@@ -87,6 +87,7 @@ class SpriteFramesEditor : public HSplitContainer {
Button *split_sheet_zoom_in;
EditorFileDialog *file_split_sheet;
Set<int> frames_selected;
+ Set<int> frames_toggled_by_mouse_hover;
int last_frame_selected;
float scale_ratio;
diff --git a/editor/plugins/style_box_editor_plugin.cpp b/editor/plugins/style_box_editor_plugin.cpp
index 64df982d5d..6954cacac6 100644
--- a/editor/plugins/style_box_editor_plugin.cpp
+++ b/editor/plugins/style_box_editor_plugin.cpp
@@ -93,6 +93,6 @@ StyleBoxPreview::StyleBoxPreview() {
StyleBoxEditorPlugin::StyleBoxEditorPlugin(EditorNode *p_node) {
Ref<EditorInspectorPluginStyleBox> inspector_plugin;
- inspector_plugin.instance();
+ inspector_plugin.instantiate();
add_inspector_plugin(inspector_plugin);
}
diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp
index 621f843e6f..d62be993af 100644
--- a/editor/plugins/text_editor.cpp
+++ b/editor/plugins/text_editor.cpp
@@ -320,10 +320,10 @@ void TextEditor::_edit_option(int p_op) {
code_editor->move_lines_down();
} break;
case EDIT_INDENT_LEFT: {
- tx->indent_selected_lines_left();
+ tx->unindent_lines();
} break;
case EDIT_INDENT_RIGHT: {
- tx->indent_selected_lines_right();
+ tx->indent_lines();
} break;
case EDIT_DELETE_LINE: {
code_editor->delete_lines();
@@ -581,11 +581,11 @@ TextEditor::TextEditor() {
highlighter_menu->connect("id_pressed", callable_mp(this, &TextEditor::_change_syntax_highlighter));
Ref<EditorPlainTextSyntaxHighlighter> plain_highlighter;
- plain_highlighter.instance();
+ plain_highlighter.instantiate();
add_syntax_highlighter(plain_highlighter);
Ref<EditorStandardSyntaxHighlighter> highlighter;
- highlighter.instance();
+ highlighter.instantiate();
add_syntax_highlighter(highlighter);
set_syntax_highlighter(plain_highlighter);
diff --git a/editor/plugins/texture_3d_editor_plugin.cpp b/editor/plugins/texture_3d_editor_plugin.cpp
index 36297c8a4a..696aa88e23 100644
--- a/editor/plugins/texture_3d_editor_plugin.cpp
+++ b/editor/plugins/texture_3d_editor_plugin.cpp
@@ -85,9 +85,9 @@ void Texture3DEditor::_make_shaders() {
" COLOR = textureLod(tex,vec3(UV,layer),0.0);\n"
"}";
- shader.instance();
+ shader.instantiate();
shader->set_code(shader_3d);
- material.instance();
+ material.instantiate();
material->set_shader(shader);
}
@@ -207,6 +207,6 @@ void EditorInspectorPlugin3DTexture::parse_begin(Object *p_object) {
Texture3DEditorPlugin::Texture3DEditorPlugin(EditorNode *p_node) {
Ref<EditorInspectorPlugin3DTexture> plugin;
- plugin.instance();
+ plugin.instantiate();
add_inspector_plugin(plugin);
}
diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp
index ecf7370834..10b942d9ee 100644
--- a/editor/plugins/texture_editor_plugin.cpp
+++ b/editor/plugins/texture_editor_plugin.cpp
@@ -160,6 +160,6 @@ void EditorInspectorPluginTexture::parse_begin(Object *p_object) {
TextureEditorPlugin::TextureEditorPlugin(EditorNode *p_node) {
Ref<EditorInspectorPluginTexture> plugin;
- plugin.instance();
+ plugin.instantiate();
add_inspector_plugin(plugin);
}
diff --git a/editor/plugins/texture_layered_editor_plugin.cpp b/editor/plugins/texture_layered_editor_plugin.cpp
index 89ed98d53e..3f46cd64a2 100644
--- a/editor/plugins/texture_layered_editor_plugin.cpp
+++ b/editor/plugins/texture_layered_editor_plugin.cpp
@@ -112,7 +112,7 @@ void TextureLayeredEditor::_make_shaders() {
" COLOR = textureLod(tex,vec3(UV,layer),0.0);\n"
"}";
- shaders[0].instance();
+ shaders[0].instantiate();
shaders[0]->set_code(shader_2d_array);
String shader_cube = ""
@@ -125,7 +125,7 @@ void TextureLayeredEditor::_make_shaders() {
" COLOR = textureLod(tex,n,0.0);\n"
"}";
- shaders[1].instance();
+ shaders[1].instantiate();
shaders[1]->set_code(shader_cube);
String shader_cube_array = ""
@@ -139,11 +139,11 @@ void TextureLayeredEditor::_make_shaders() {
" COLOR = textureLod(tex,vec4(n,layer),0.0);\n"
"}";
- shaders[2].instance();
+ shaders[2].instantiate();
shaders[2]->set_code(shader_cube_array);
for (int i = 0; i < 3; i++) {
- materials[i].instance();
+ materials[i].instantiate();
materials[i]->set_shader(shaders[i]);
}
}
@@ -271,6 +271,6 @@ void EditorInspectorPluginLayeredTexture::parse_begin(Object *p_object) {
TextureLayeredEditorPlugin::TextureLayeredEditorPlugin(EditorNode *p_node) {
Ref<EditorInspectorPluginLayeredTexture> plugin;
- plugin.instance();
+ plugin.instantiate();
add_inspector_plugin(plugin);
}
diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp
index 22b39c59f5..99d7267eac 100644
--- a/editor/plugins/theme_editor_plugin.cpp
+++ b/editor/plugins/theme_editor_plugin.cpp
@@ -932,9 +932,9 @@ ThemeItemImportTree::ThemeItemImportTree() {
import_items_tree->set_column_expand(0, true);
import_items_tree->set_column_expand(IMPORT_ITEM, false);
import_items_tree->set_column_expand(IMPORT_ITEM_DATA, false);
- import_items_tree->set_column_min_width(0, 160 * EDSCALE);
- import_items_tree->set_column_min_width(IMPORT_ITEM, 80 * EDSCALE);
- import_items_tree->set_column_min_width(IMPORT_ITEM_DATA, 80 * EDSCALE);
+ import_items_tree->set_column_custom_minimum_width(0, 160 * EDSCALE);
+ import_items_tree->set_column_custom_minimum_width(IMPORT_ITEM, 80 * EDSCALE);
+ import_items_tree->set_column_custom_minimum_width(IMPORT_ITEM_DATA, 80 * EDSCALE);
ScrollContainer *import_bulk_sc = memnew(ScrollContainer);
import_bulk_sc->set_custom_minimum_size(Size2(260.0, 0.0) * EDSCALE);
@@ -2263,7 +2263,7 @@ void ThemeTypeEditor::_update_type_items() {
} else {
item_editor->set_edited_resource(RES());
}
- item_editor->connect("resource_selected", callable_mp(this, &ThemeTypeEditor::_edit_resource_item), varray(item_control));
+ item_editor->connect("resource_selected", callable_mp(this, &ThemeTypeEditor::_edit_resource_item));
item_editor->connect("resource_changed", callable_mp(this, &ThemeTypeEditor::_font_item_changed), varray(E.key()));
} else {
if (Theme::get_default()->has_font(E.key(), edited_type)) {
@@ -2334,7 +2334,7 @@ void ThemeTypeEditor::_update_type_items() {
} else {
item_editor->set_edited_resource(RES());
}
- item_editor->connect("resource_selected", callable_mp(this, &ThemeTypeEditor::_edit_resource_item), varray(item_control));
+ item_editor->connect("resource_selected", callable_mp(this, &ThemeTypeEditor::_edit_resource_item));
item_editor->connect("resource_changed", callable_mp(this, &ThemeTypeEditor::_icon_item_changed), varray(E.key()));
} else {
if (Theme::get_default()->has_icon(E.key(), edited_type)) {
@@ -2381,7 +2381,7 @@ void ThemeTypeEditor::_update_type_items() {
} else {
item_editor->set_edited_resource(RES());
}
- item_editor->connect("resource_selected", callable_mp(this, &ThemeTypeEditor::_edit_resource_item), varray(item_control));
+ item_editor->connect("resource_selected", callable_mp(this, &ThemeTypeEditor::_edit_resource_item));
item_editor->connect("resource_changed", callable_mp(this, &ThemeTypeEditor::_stylebox_item_changed), varray(leading_stylebox.item_name));
stylebox_items_list->add_child(item_control);
@@ -2408,7 +2408,7 @@ void ThemeTypeEditor::_update_type_items() {
} else {
item_editor->set_edited_resource(RES());
}
- item_editor->connect("resource_selected", callable_mp(this, &ThemeTypeEditor::_edit_resource_item), varray(item_control));
+ item_editor->connect("resource_selected", callable_mp(this, &ThemeTypeEditor::_edit_resource_item));
item_editor->connect("resource_changed", callable_mp(this, &ThemeTypeEditor::_stylebox_item_changed), varray(E.key()));
Button *pin_leader_button = memnew(Button);
@@ -2417,7 +2417,7 @@ void ThemeTypeEditor::_update_type_items() {
pin_leader_button->set_icon(get_theme_icon("Pin", "EditorIcons"));
pin_leader_button->set_tooltip(TTR("Pin this StyleBox as a main style. Editing its properties will update the same properties in all other StyleBoxes of this type."));
item_control->add_child(pin_leader_button);
- pin_leader_button->connect("pressed", callable_mp(this, &ThemeTypeEditor::_pin_leading_stylebox), varray(stylebox_value, E.key()));
+ pin_leader_button->connect("pressed", callable_mp(this, &ThemeTypeEditor::_pin_leading_stylebox), varray(item_editor, E.key()));
} else {
if (Theme::get_default()->has_stylebox(E.key(), edited_type)) {
item_editor->set_edited_resource(Theme::get_default()->get_stylebox(E.key(), edited_type));
@@ -2612,6 +2612,10 @@ void ThemeTypeEditor::_item_remove_cbk(int p_data_type, String p_item_name) {
} break;
case Theme::DATA_TYPE_STYLEBOX: {
edited_theme->clear_stylebox(p_item_name, edited_type);
+
+ if (leading_stylebox.pinned && leading_stylebox.item_name == p_item_name) {
+ _unpin_leading_stylebox();
+ }
} break;
}
}
@@ -2661,6 +2665,10 @@ void ThemeTypeEditor::_item_rename_confirmed(int p_data_type, String p_item_name
} break;
case Theme::DATA_TYPE_STYLEBOX: {
edited_theme->rename_stylebox(p_item_name, new_name, edited_type);
+
+ if (leading_stylebox.pinned && leading_stylebox.item_name == p_item_name) {
+ leading_stylebox.item_name = new_name;
+ }
} break;
}
}
@@ -2695,7 +2703,7 @@ void ThemeTypeEditor::_font_size_item_changed(float p_value, String p_item_name)
edited_theme->set_font_size(p_item_name, edited_type, int(p_value));
}
-void ThemeTypeEditor::_edit_resource_item(RES p_resource, Control *p_editor) {
+void ThemeTypeEditor::_edit_resource_item(RES p_resource) {
EditorNode::get_singleton()->edit_resource(p_resource);
}
@@ -2723,16 +2731,21 @@ void ThemeTypeEditor::_stylebox_item_changed(Ref<StyleBox> p_value, String p_ite
}
}
-void ThemeTypeEditor::_pin_leading_stylebox(Ref<StyleBox> p_stylebox, String p_item_name) {
+void ThemeTypeEditor::_pin_leading_stylebox(Control *p_editor, String p_item_name) {
if (leading_stylebox.stylebox.is_valid()) {
leading_stylebox.stylebox->disconnect("changed", callable_mp(this, &ThemeTypeEditor::_update_stylebox_from_leading));
}
+ Ref<StyleBox> stylebox;
+ if (Object::cast_to<EditorResourcePicker>(p_editor)) {
+ stylebox = Object::cast_to<EditorResourcePicker>(p_editor)->get_edited_resource();
+ }
+
LeadingStylebox leader;
leader.pinned = true;
leader.item_name = p_item_name;
- leader.stylebox = p_stylebox;
- leader.ref_stylebox = (p_stylebox.is_valid() ? p_stylebox->duplicate() : RES());
+ leader.stylebox = stylebox;
+ leader.ref_stylebox = (stylebox.is_valid() ? stylebox->duplicate() : RES());
leading_stylebox = leader;
if (leading_stylebox.stylebox.is_valid()) {
diff --git a/editor/plugins/theme_editor_plugin.h b/editor/plugins/theme_editor_plugin.h
index 77baf46395..cdedbbec8d 100644
--- a/editor/plugins/theme_editor_plugin.h
+++ b/editor/plugins/theme_editor_plugin.h
@@ -329,11 +329,11 @@ class ThemeTypeEditor : public MarginContainer {
void _color_item_changed(Color p_value, String p_item_name);
void _constant_item_changed(float p_value, String p_item_name);
void _font_size_item_changed(float p_value, String p_item_name);
- void _edit_resource_item(RES p_resource, Control *p_editor);
+ void _edit_resource_item(RES p_resource);
void _font_item_changed(Ref<Font> p_value, String p_item_name);
void _icon_item_changed(Ref<Texture2D> p_value, String p_item_name);
void _stylebox_item_changed(Ref<StyleBox> p_value, String p_item_name);
- void _pin_leading_stylebox(Ref<StyleBox> p_stylebox, String p_item_name);
+ void _pin_leading_stylebox(Control *p_editor, String p_item_name);
void _unpin_leading_stylebox();
void _update_stylebox_from_leading();
diff --git a/editor/plugins/theme_editor_preview.cpp b/editor/plugins/theme_editor_preview.cpp
index cb7b5949d1..0b02150444 100644
--- a/editor/plugins/theme_editor_preview.cpp
+++ b/editor/plugins/theme_editor_preview.cpp
@@ -403,7 +403,7 @@ void SceneThemeEditorPreview::_reload_scene() {
preview_content->remove_child(node);
}
- Node *instance = loaded_scene->instance();
+ Node *instance = loaded_scene->instantiate();
if (!instance || !Object::cast_to<Control>(instance)) {
EditorNode::get_singleton()->show_warning(TTR("Invalid PackedScene resource, must have a Control node at its root."));
emit_signal("scene_invalidated");
@@ -435,7 +435,7 @@ bool SceneThemeEditorPreview::set_preview_scene(const String &p_path) {
return false;
}
- Node *instance = loaded_scene->instance();
+ Node *instance = loaded_scene->instantiate();
if (!instance || !Object::cast_to<Control>(instance)) {
EditorNode::get_singleton()->show_warning(TTR("Invalid PackedScene resource, must have a Control node at its root."));
return false;
diff --git a/editor/plugins/tiles/tile_atlas_view.cpp b/editor/plugins/tiles/tile_atlas_view.cpp
index 78f181e321..374a255df3 100644
--- a/editor/plugins/tiles/tile_atlas_view.cpp
+++ b/editor/plugins/tiles/tile_atlas_view.cpp
@@ -33,7 +33,6 @@
#include "core/input/input.h"
#include "core/os/keyboard.h"
#include "scene/gui/box_container.h"
-#include "scene/gui/center_container.h"
#include "scene/gui/label.h"
#include "scene/gui/panel.h"
#include "scene/gui/texture_rect.h"
@@ -44,21 +43,41 @@
void TileAtlasView::_gui_input(const Ref<InputEvent> &p_event) {
bool ctrl = Input::get_singleton()->is_key_pressed(KEY_CTRL);
- Ref<InputEventMouseButton> b = p_event;
- if (b.is_valid()) {
- if (ctrl && b->is_pressed() && b->get_button_index() == MOUSE_BUTTON_WHEEL_DOWN) {
+ Ref<InputEventMouseButton> mb = p_event;
+ if (mb.is_valid()) {
+ drag_type = DRAG_TYPE_NONE;
+ if (ctrl && mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_WHEEL_DOWN) {
// Zoom out
zoom_widget->set_zoom_by_increments(-2);
- emit_signal("transform_changed", zoom_widget->get_zoom(), Vector2(scroll_container->get_h_scroll(), scroll_container->get_v_scroll()));
- _update_zoom(zoom_widget->get_zoom(), true);
+ emit_signal("transform_changed", zoom_widget->get_zoom(), panning);
+ _update_zoom_and_panning(true);
accept_event();
}
- if (ctrl && b->is_pressed() && b->get_button_index() == MOUSE_BUTTON_WHEEL_UP) {
+ if (ctrl && mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_WHEEL_UP) {
// Zoom in
zoom_widget->set_zoom_by_increments(2);
- emit_signal("transform_changed", zoom_widget->get_zoom(), Vector2(scroll_container->get_h_scroll(), scroll_container->get_v_scroll()));
- _update_zoom(zoom_widget->get_zoom(), true);
+ emit_signal("transform_changed", zoom_widget->get_zoom(), panning);
+ _update_zoom_and_panning(true);
+ accept_event();
+ }
+
+ if (mb->get_button_index() == MOUSE_BUTTON_MIDDLE || mb->get_button_index() == MOUSE_BUTTON_RIGHT) {
+ if (mb->is_pressed()) {
+ drag_type = DRAG_TYPE_PAN;
+ } else {
+ drag_type = DRAG_TYPE_NONE;
+ }
+ accept_event();
+ }
+ }
+
+ Ref<InputEventMouseMotion> mm = p_event;
+ if (mm.is_valid()) {
+ if (drag_type == DRAG_TYPE_PAN) {
+ panning += mm->get_relative();
+ _update_zoom_and_panning();
+ emit_signal("transform_changed", zoom_widget->get_zoom(), panning);
accept_event();
}
}
@@ -103,25 +122,27 @@ Size2i TileAtlasView::_compute_alternative_tiles_control_size() {
return size;
}
-void TileAtlasView::_update_zoom(float p_zoom, bool p_zoom_on_mouse_pos, Vector2i p_scroll) {
+void TileAtlasView::_update_zoom_and_panning(bool p_zoom_on_mouse_pos) {
+ float zoom = zoom_widget->get_zoom();
+
// Compute the minimum sizes.
Size2i base_tiles_control_size = _compute_base_tiles_control_size();
- base_tiles_root_control->set_custom_minimum_size(Vector2(base_tiles_control_size) * p_zoom);
+ base_tiles_root_control->set_custom_minimum_size(Vector2(base_tiles_control_size) * zoom);
Size2i alternative_tiles_control_size = _compute_alternative_tiles_control_size();
- alternative_tiles_root_control->set_custom_minimum_size(Vector2(alternative_tiles_control_size) * p_zoom);
+ alternative_tiles_root_control->set_custom_minimum_size(Vector2(alternative_tiles_control_size) * zoom);
// Set the texture for the base tiles.
Ref<Texture2D> texture = tile_set_atlas_source->get_texture();
// Set the scales.
if (base_tiles_control_size.x > 0 && base_tiles_control_size.y > 0) {
- base_tiles_drawing_root->set_scale(Vector2(p_zoom, p_zoom));
+ base_tiles_drawing_root->set_scale(Vector2(zoom, zoom));
} else {
base_tiles_drawing_root->set_scale(Vector2(1, 1));
}
if (alternative_tiles_control_size.x > 0 && alternative_tiles_control_size.y > 0) {
- alternative_tiles_drawing_root->set_scale(Vector2(p_zoom, p_zoom));
+ alternative_tiles_drawing_root->set_scale(Vector2(zoom, zoom));
} else {
alternative_tiles_drawing_root->set_scale(Vector2(1, 1));
}
@@ -129,64 +150,40 @@ void TileAtlasView::_update_zoom(float p_zoom, bool p_zoom_on_mouse_pos, Vector2
// Update the margin container's margins.
const char *constants[] = { "margin_left", "margin_top", "margin_right", "margin_bottom" };
for (int i = 0; i < 4; i++) {
- margin_container->add_theme_constant_override(constants[i], margin_container_paddings[i] * p_zoom);
+ margin_container->add_theme_constant_override(constants[i], margin_container_paddings[i] * zoom);
}
// Update the backgrounds.
background_left->update();
background_right->update();
- if (p_scroll != Vector2i(-1, -1)) {
- scroll_container->set_h_scroll(p_scroll.x);
- scroll_container->set_v_scroll(p_scroll.y);
- }
-
// Zoom on the position.
- if (previous_zoom != p_zoom) {
- // TODO: solve this.
- // There is however an issue with scrollcainter preventing this, as it seems
- // that the scrollbars are not updated right aways after its children update.
-
- // Compute point on previous area.
- /*Vector2 max = Vector2(scroll_container->get_h_scrollbar()->get_max(), scroll_container->get_v_scrollbar()->get_max());
- Vector2 min = Vector2(scroll_container->get_h_scrollbar()->get_min(), scroll_container->get_v_scrollbar()->get_min());
- Vector2 value = Vector2(scroll_container->get_h_scrollbar()->get_value(), scroll_container->get_v_scrollbar()->get_value());
-
- Vector2 old_max = max * previous_zoom / p_zoom;
-
- Vector2 max_pixel_change = max - old_max;
- Vector2 ratio = ((value + scroll_container->get_local_mouse_position()) / old_max).max(Vector2()).min(Vector2(1,1));
- Vector2 offset = max_pixel_change * ratio;
-
- print_line("--- ZOOMED ---");
- print_line(vformat("max: %s", max));
- print_line(vformat("min: %s", min));
- print_line(vformat("value: %s", value));
- print_line(vformat("size: %s", scroll_container->get_size()));
- print_line(vformat("mouse_pos: %s", scroll_container->get_local_mouse_position()));
-
- print_line(vformat("ratio: %s", ratio));
- print_line(vformat("max_pixel_change: %s", max_pixel_change));
- print_line(vformat("offset: %s", offset));
-
+ if (p_zoom_on_mouse_pos) {
+ // Offset the panning relative to the center of panel.
+ Vector2 relative_mpos = get_local_mouse_position() - get_size() / 2;
+ panning = (panning - relative_mpos) * zoom / previous_zoom + relative_mpos;
+ } else {
+ // Center of panel.
+ panning = panning * zoom / previous_zoom;
+ }
+ button_center_view->set_disabled(panning.is_equal_approx(Vector2()));
- print_line(vformat("value before: %s", Vector2(scroll_container->get_h_scroll(), scroll_container->get_v_scroll())));
- scroll_container->set_h_scroll(10000);//scroll_container->get_h_scroll()+offset.x);
- scroll_container->set_v_scroll(10000);//scroll_container->get_v_scroll()+offset.y);
- print_line(vformat("value after: %s", Vector2(scroll_container->get_h_scroll(), scroll_container->get_v_scroll())));
- */
+ previous_zoom = zoom;
- previous_zoom = p_zoom;
- }
+ center_container->set_begin(panning - center_container->get_minimum_size() / 2);
+ center_container->set_size(center_container->get_minimum_size());
}
-void TileAtlasView::_scroll_changed() {
- emit_signal("transform_changed", zoom_widget->get_zoom(), Vector2(scroll_container->get_h_scroll(), scroll_container->get_v_scroll()));
+void TileAtlasView::_zoom_widget_changed() {
+ _update_zoom_and_panning();
+ emit_signal("transform_changed", zoom_widget->get_zoom(), panning);
}
-void TileAtlasView::_zoom_widget_changed() {
- _update_zoom(zoom_widget->get_zoom());
- emit_signal("transform_changed", zoom_widget->get_zoom(), Vector2(scroll_container->get_h_scroll(), scroll_container->get_v_scroll()));
+void TileAtlasView::_center_view() {
+ panning = Vector2();
+ button_center_view->set_disabled(true);
+ _update_zoom_and_panning();
+ emit_signal("transform_changed", zoom_widget->get_zoom(), panning);
}
void TileAtlasView::_base_tiles_root_control_gui_input(const Ref<InputEvent> &p_event) {
@@ -415,7 +412,7 @@ void TileAtlasView::set_atlas_source(TileSet *p_tile_set, TileSetAtlasSource *p_
_update_alternative_tiles_rect_cache();
// Update everything.
- _update_zoom(zoom_widget->get_zoom());
+ _update_zoom_and_panning();
// Change children control size.
Size2i base_tiles_control_size = _compute_base_tiles_control_size();
@@ -448,9 +445,10 @@ float TileAtlasView::get_zoom() const {
return zoom_widget->get_zoom();
};
-void TileAtlasView::set_transform(float p_zoom, Vector2i p_scroll) {
+void TileAtlasView::set_transform(float p_zoom, Vector2i p_panning) {
zoom_widget->set_zoom(p_zoom);
- _update_zoom(zoom_widget->get_zoom(), false, p_scroll);
+ panning = p_panning;
+ _update_zoom_and_panning();
};
void TileAtlasView::set_padding(Side p_side, int p_padding) {
@@ -525,7 +523,7 @@ Rect2i TileAtlasView::get_alternative_tile_rect(const Vector2i p_coords, int p_a
}
void TileAtlasView::update() {
- scroll_container->update();
+ base_tiles_draw->update();
base_tiles_texture_grid->update();
base_tiles_shape_grid->update();
base_tiles_dark->update();
@@ -534,124 +532,149 @@ void TileAtlasView::update() {
background_right->update();
}
+void TileAtlasView::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_READY:
+ button_center_view->set_icon(get_theme_icon("CenterView", "EditorIcons"));
+ break;
+ }
+}
+
void TileAtlasView::_bind_methods() {
+ ClassDB::bind_method("_gui_input", &TileAtlasView::_gui_input);
+
ADD_SIGNAL(MethodInfo("transform_changed", PropertyInfo(Variant::FLOAT, "zoom"), PropertyInfo(Variant::VECTOR2, "scroll")));
}
TileAtlasView::TileAtlasView() {
- Panel *panel_container = memnew(Panel);
- panel_container->set_h_size_flags(SIZE_EXPAND_FILL);
- panel_container->set_v_size_flags(SIZE_EXPAND_FILL);
- panel_container->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
- add_child(panel_container);
-
- //Scrolling
- scroll_container = memnew(ScrollContainer);
- scroll_container->get_h_scrollbar()->connect("value_changed", callable_mp(this, &TileAtlasView::_scroll_changed).unbind(1));
- scroll_container->get_v_scrollbar()->connect("value_changed", callable_mp(this, &TileAtlasView::_scroll_changed).unbind(1));
- panel_container->add_child(scroll_container);
- scroll_container->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
+ set_texture_filter(CanvasItem::TEXTURE_FILTER_NEAREST);
+
+ Panel *panel = memnew(Panel);
+ panel->set_clip_contents(true);
+ panel->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
+ panel->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
+ panel->set_h_size_flags(SIZE_EXPAND_FILL);
+ panel->set_v_size_flags(SIZE_EXPAND_FILL);
+ add_child(panel);
+ // Scrollingsc
zoom_widget = memnew(EditorZoomWidget);
add_child(zoom_widget);
zoom_widget->set_anchors_and_offsets_preset(Control::PRESET_TOP_LEFT, Control::PRESET_MODE_MINSIZE, 2 * EDSCALE);
zoom_widget->connect("zoom_changed", callable_mp(this, &TileAtlasView::_zoom_widget_changed).unbind(1));
- CenterContainer *center_container = memnew(CenterContainer);
- center_container->set_h_size_flags(SIZE_EXPAND_FILL);
- center_container->set_v_size_flags(SIZE_EXPAND_FILL);
+ button_center_view = memnew(Button);
+ button_center_view->set_icon(get_theme_icon("CenterView", "EditorIcons"));
+ button_center_view->set_anchors_and_offsets_preset(Control::PRESET_TOP_RIGHT, Control::PRESET_MODE_MINSIZE, 5);
+ button_center_view->connect("pressed", callable_mp(this, &TileAtlasView::_center_view));
+ button_center_view->set_flat(true);
+ button_center_view->set_disabled(true);
+ add_child(button_center_view);
+
+ center_container = memnew(CenterContainer);
+ center_container->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
+ center_container->set_anchors_preset(Control::PRESET_CENTER);
center_container->connect("gui_input", callable_mp(this, &TileAtlasView::_gui_input));
- scroll_container->add_child(center_container);
+ panel->add_child(center_container);
missing_source_label = memnew(Label);
missing_source_label->set_text(TTR("No atlas source with a valid texture selected."));
center_container->add_child(missing_source_label);
margin_container = memnew(MarginContainer);
+ margin_container->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
center_container->add_child(margin_container);
hbox = memnew(HBoxContainer);
+ hbox->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
hbox->add_theme_constant_override("separation", 10);
hbox->hide();
margin_container->add_child(hbox);
VBoxContainer *left_vbox = memnew(VBoxContainer);
+ left_vbox->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
hbox->add_child(left_vbox);
VBoxContainer *right_vbox = memnew(VBoxContainer);
+ right_vbox->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
hbox->add_child(right_vbox);
// Base tiles.
Label *base_tile_label = memnew(Label);
+ base_tile_label->set_mouse_filter(Control::MOUSE_FILTER_PASS);
base_tile_label->set_text(TTR("Base Tiles"));
base_tile_label->set_align(Label::ALIGN_CENTER);
left_vbox->add_child(base_tile_label);
base_tiles_root_control = memnew(Control);
+ base_tiles_root_control->set_mouse_filter(Control::MOUSE_FILTER_PASS);
base_tiles_root_control->set_v_size_flags(Control::SIZE_EXPAND_FILL);
base_tiles_root_control->connect("gui_input", callable_mp(this, &TileAtlasView::_base_tiles_root_control_gui_input));
left_vbox->add_child(base_tiles_root_control);
background_left = memnew(Control);
+ background_left->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
background_left->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
background_left->set_texture_repeat(TextureRepeat::TEXTURE_REPEAT_ENABLED);
- background_left->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
background_left->connect("draw", callable_mp(this, &TileAtlasView::_draw_background_left));
base_tiles_root_control->add_child(background_left);
base_tiles_drawing_root = memnew(Control);
+ base_tiles_drawing_root->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
base_tiles_drawing_root->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
base_tiles_drawing_root->set_texture_filter(TEXTURE_FILTER_NEAREST);
- base_tiles_drawing_root->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
base_tiles_root_control->add_child(base_tiles_drawing_root);
base_tiles_draw = memnew(Control);
+ base_tiles_draw->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
base_tiles_draw->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
base_tiles_draw->connect("draw", callable_mp(this, &TileAtlasView::_draw_base_tiles));
- base_tiles_draw->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
base_tiles_drawing_root->add_child(base_tiles_draw);
base_tiles_texture_grid = memnew(Control);
+ base_tiles_texture_grid->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
base_tiles_texture_grid->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
base_tiles_texture_grid->connect("draw", callable_mp(this, &TileAtlasView::_draw_base_tiles_texture_grid));
- base_tiles_texture_grid->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
base_tiles_drawing_root->add_child(base_tiles_texture_grid);
base_tiles_shape_grid = memnew(Control);
+ base_tiles_shape_grid->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
base_tiles_shape_grid->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
base_tiles_shape_grid->connect("draw", callable_mp(this, &TileAtlasView::_draw_base_tiles_shape_grid));
- base_tiles_shape_grid->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
base_tiles_drawing_root->add_child(base_tiles_shape_grid);
base_tiles_dark = memnew(Control);
+ base_tiles_dark->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
base_tiles_dark->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
base_tiles_dark->connect("draw", callable_mp(this, &TileAtlasView::_draw_base_tiles_dark));
- base_tiles_dark->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
base_tiles_drawing_root->add_child(base_tiles_dark);
// Alternative tiles.
Label *alternative_tiles_label = memnew(Label);
+ alternative_tiles_label->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
alternative_tiles_label->set_text(TTR("Alternative Tiles"));
alternative_tiles_label->set_align(Label::ALIGN_CENTER);
right_vbox->add_child(alternative_tiles_label);
alternative_tiles_root_control = memnew(Control);
+ alternative_tiles_root_control->set_mouse_filter(Control::MOUSE_FILTER_PASS);
alternative_tiles_root_control->connect("gui_input", callable_mp(this, &TileAtlasView::_alternative_tiles_root_control_gui_input));
right_vbox->add_child(alternative_tiles_root_control);
background_right = memnew(Control);
+ background_right->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
background_right->set_texture_repeat(TextureRepeat::TEXTURE_REPEAT_ENABLED);
background_right->connect("draw", callable_mp(this, &TileAtlasView::_draw_background_right));
- background_right->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
+
alternative_tiles_root_control->add_child(background_right);
alternative_tiles_drawing_root = memnew(Control);
- alternative_tiles_drawing_root->set_texture_filter(TEXTURE_FILTER_NEAREST);
alternative_tiles_drawing_root->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
+ alternative_tiles_drawing_root->set_texture_filter(TEXTURE_FILTER_NEAREST);
alternative_tiles_root_control->add_child(alternative_tiles_drawing_root);
alternatives_draw = memnew(Control);
- alternatives_draw->connect("draw", callable_mp(this, &TileAtlasView::_draw_alternatives));
alternatives_draw->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
+ alternatives_draw->connect("draw", callable_mp(this, &TileAtlasView::_draw_alternatives));
alternative_tiles_drawing_root->add_child(alternatives_draw);
}
diff --git a/editor/plugins/tiles/tile_atlas_view.h b/editor/plugins/tiles/tile_atlas_view.h
index 28fd3ed1e0..bafc2b3985 100644
--- a/editor/plugins/tiles/tile_atlas_view.h
+++ b/editor/plugins/tiles/tile_atlas_view.h
@@ -34,6 +34,7 @@
#include "editor/editor_zoom_widget.h"
#include "scene/gui/box_container.h"
#include "scene/gui/button.h"
+#include "scene/gui/center_container.h"
#include "scene/gui/label.h"
#include "scene/gui/margin_container.h"
#include "scene/gui/scroll_container.h"
@@ -48,17 +49,24 @@ private:
TileSetAtlasSource *tile_set_atlas_source;
int source_id = -1;
+ enum DragType {
+ DRAG_TYPE_NONE,
+ DRAG_TYPE_PAN,
+ };
+ DragType drag_type = DRAG_TYPE_NONE;
float previous_zoom = 1.0;
EditorZoomWidget *zoom_widget;
+ Button *button_center_view;
+ CenterContainer *center_container;
+ Vector2 panning;
+ void _update_zoom_and_panning(bool p_zoom_on_mouse_pos = false);
void _zoom_widget_changed();
- void _scroll_changed();
- void _update_zoom(float p_zoom, bool p_zoom_on_mouse_pos = false, Vector2i p_scroll = Vector2i(-1, -1));
+ void _center_view();
void _gui_input(const Ref<InputEvent> &p_event);
Map<Vector2, Map<int, Rect2i>> alternative_tiles_rect_cache;
void _update_alternative_tiles_rect_cache();
- ScrollContainer *scroll_container;
MarginContainer *margin_container;
int margin_container_paddings[4] = { 0, 0, 0, 0 };
HBoxContainer *hbox;
@@ -102,16 +110,15 @@ private:
Size2i _compute_alternative_tiles_control_size();
protected:
+ void _notification(int p_what);
static void _bind_methods();
public:
// Global.
void set_atlas_source(TileSet *p_tile_set, TileSetAtlasSource *p_tile_set_atlas_source, int p_source_id);
- ScrollContainer *get_scroll_container() { return scroll_container; };
-
float get_zoom() const;
- void set_transform(float p_zoom, Vector2i p_scroll);
+ void set_transform(float p_zoom, Vector2i p_panning);
void set_padding(Side p_side, int p_padding);
diff --git a/editor/plugins/tiles/tile_data_editors.cpp b/editor/plugins/tiles/tile_data_editors.cpp
index 61457e3e59..d9d0e48fb3 100644
--- a/editor/plugins/tiles/tile_data_editors.cpp
+++ b/editor/plugins/tiles/tile_data_editors.cpp
@@ -32,202 +32,2436 @@
#include "tile_set_editor.h"
-TileData *TileDataEditor::_get_tile_data(TileSet *p_tile_set, int p_atlas_source_id, Vector2i p_atlas_coords, int p_alternative_tile) {
- ERR_FAIL_COND_V(!p_tile_set, nullptr);
- ERR_FAIL_COND_V(!p_tile_set->has_source(p_atlas_source_id), nullptr);
+#include "core/math/geometry_2d.h"
+#include "core/os/keyboard.h"
+
+#include "editor/editor_properties.h"
+#include "editor/editor_scale.h"
+
+void TileDataEditor::_call_tile_set_changed() {
+ _tile_set_changed();
+}
+
+TileData *TileDataEditor::_get_tile_data(TileMapCell p_cell) {
+ ERR_FAIL_COND_V(!tile_set.is_valid(), nullptr);
+ ERR_FAIL_COND_V(!tile_set->has_source(p_cell.source_id), nullptr);
TileData *td = nullptr;
- TileSetSource *source = *p_tile_set->get_source(p_atlas_source_id);
+ TileSetSource *source = *tile_set->get_source(p_cell.source_id);
TileSetAtlasSource *atlas_source = Object::cast_to<TileSetAtlasSource>(source);
if (atlas_source) {
- ERR_FAIL_COND_V(!atlas_source->has_tile(p_atlas_coords), nullptr);
- ERR_FAIL_COND_V(!atlas_source->has_alternative_tile(p_atlas_coords, p_alternative_tile), nullptr);
- td = Object::cast_to<TileData>(atlas_source->get_tile_data(p_atlas_coords, p_alternative_tile));
+ ERR_FAIL_COND_V(!atlas_source->has_tile(p_cell.get_atlas_coords()), nullptr);
+ ERR_FAIL_COND_V(!atlas_source->has_alternative_tile(p_cell.get_atlas_coords(), p_cell.alternative_tile), nullptr);
+ td = Object::cast_to<TileData>(atlas_source->get_tile_data(p_cell.get_atlas_coords(), p_cell.alternative_tile));
}
return td;
}
-void TileDataEditor::edit(TileSet *p_tile_set, int p_atlas_source_id, Vector2i p_atlas_coords, int p_alternative_tile, String p_property) {
+void TileDataEditor::_bind_methods() {
+ ADD_SIGNAL(MethodInfo("needs_redraw"));
}
-void TileDataTextureOffsetEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileSet *p_tile_set, int p_atlas_source_id, Vector2i p_atlas_coords, int p_alternative_tile, String p_property) {
- TileData *tile_data = _get_tile_data(p_tile_set, p_atlas_source_id, p_atlas_coords, p_alternative_tile);
- ERR_FAIL_COND(!tile_data);
+void TileDataEditor::set_tile_set(Ref<TileSet> p_tile_set) {
+ if (tile_set.is_valid()) {
+ tile_set->disconnect("changed", callable_mp(this, &TileDataEditor::_call_tile_set_changed));
+ }
+ tile_set = p_tile_set;
+ if (tile_set.is_valid()) {
+ tile_set->connect("changed", callable_mp(this, &TileDataEditor::_call_tile_set_changed));
+ }
+ _call_tile_set_changed();
+}
- bool valid;
- Variant value = tile_data->get(p_property, &valid);
- if (!valid) {
- return;
+bool DummyObject::_set(const StringName &p_name, const Variant &p_value) {
+ if (properties.has(p_name)) {
+ properties[p_name] = p_value;
+ return true;
}
- ERR_FAIL_COND(value.get_type() != Variant::VECTOR2I);
+ return false;
+}
- Vector2i tile_set_tile_size = p_tile_set->get_tile_size();
- Rect2i rect = Rect2i(-tile_set_tile_size / 2, tile_set_tile_size);
- p_tile_set->draw_tile_shape(p_canvas_item, p_transform.xform(rect), Color(1.0, 0.0, 0.0));
+bool DummyObject::_get(const StringName &p_name, Variant &r_ret) const {
+ if (properties.has(p_name)) {
+ r_ret = properties[p_name];
+ return true;
+ }
+ return false;
+}
+
+bool DummyObject::has_dummy_property(StringName p_name) {
+ return properties.has(p_name);
+}
+
+void DummyObject::add_dummy_property(StringName p_name) {
+ ERR_FAIL_COND(properties.has(p_name));
+ properties[p_name] = Variant();
+}
+
+void DummyObject::remove_dummy_property(StringName p_name) {
+ ERR_FAIL_COND(!properties.has(p_name));
+ properties.erase(p_name);
+}
+
+void DummyObject::clear_dummy_properties() {
+ properties.clear();
+}
+
+void GenericTilePolygonEditor::_base_control_draw() {
+ ERR_FAIL_COND(!tile_set.is_valid());
+
+ real_t grab_threshold = EDITOR_GET("editors/poly_editor/point_grab_radius");
+
+ Color grid_color = EditorSettings::get_singleton()->get("editors/tiles_editor/grid_color");
+ const Ref<Texture2D> handle = get_theme_icon("EditorPathSharpHandle", "EditorIcons");
+ const Ref<Texture2D> add_handle = get_theme_icon("EditorHandleAdd", "EditorIcons");
+
+ Size2 tile_size = tile_set->get_tile_size();
+
+ Transform2D xform;
+ xform.set_origin(base_control->get_size() / 2 + panning);
+ xform.set_scale(Vector2(editor_zoom_widget->get_zoom(), editor_zoom_widget->get_zoom()));
+ base_control->draw_set_transform_matrix(xform);
+
+ // Draw the tile shape filled.
+ tile_set->draw_tile_shape(base_control, Rect2(-tile_size / 2, tile_size), Color(1.0, 1.0, 1.0, 0.3), true);
+
+ // Draw the background.
+ if (background_texture.is_valid()) {
+ base_control->draw_texture_rect_region(background_texture, Rect2(-background_region.size / 2 - background_offset, background_region.size), background_region, background_modulate, background_transpose);
+ }
+
+ // Draw the polygons.
+ for (unsigned int i = 0; i < polygons.size(); i++) {
+ const Vector<Vector2> &polygon = polygons[i];
+ Color color = polygon_color;
+ if (!in_creation_polygon.is_empty()) {
+ color = color.darkened(0.3);
+ }
+ color.a = 0.5;
+ Vector<Color> v_color;
+ v_color.push_back(color);
+ base_control->draw_polygon(polygon, v_color);
+
+ color.a = 0.7;
+ for (int j = 0; j < polygon.size(); j++) {
+ base_control->draw_line(polygon[j], polygon[(j + 1) % polygon.size()], color);
+ }
+ }
+
+ // Draw the polygon in creation.
+ if (!in_creation_polygon.is_empty()) {
+ for (int i = 0; i < in_creation_polygon.size() - 1; i++) {
+ base_control->draw_line(in_creation_polygon[i], in_creation_polygon[i + 1], Color(1.0, 1.0, 1.0));
+ }
+ }
+
+ 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);
+ }
+
+ 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));
+ }
+
+ // Draw the handles.
+ int tinted_polygon_index = -1;
+ int tinted_point_index = -1;
+ if (drag_type == DRAG_TYPE_DRAG_POINT) {
+ tinted_polygon_index = drag_polygon_index;
+ tinted_point_index = drag_point_index;
+ } else if (hovered_point_index >= 0) {
+ tinted_polygon_index = hovered_polygon_index;
+ tinted_point_index = hovered_point_index;
+ }
+
+ base_control->draw_set_transform_matrix(Transform2D());
+ if (!in_creation_polygon.is_empty()) {
+ for (int i = 0; i < in_creation_polygon.size(); i++) {
+ base_control->draw_texture(handle, xform.xform(in_creation_polygon[i]) - handle->get_size() / 2);
+ }
+ } else {
+ for (int i = 0; i < (int)polygons.size(); i++) {
+ const Vector<Vector2> &polygon = polygons[i];
+ for (int j = 0; j < polygon.size(); j++) {
+ const Color modulate = (tinted_polygon_index == i && tinted_point_index == j) ? Color(0.5, 1, 2) : Color(1, 1, 1);
+ base_control->draw_texture(handle, xform.xform(polygon[j]) - handle->get_size() / 2, modulate);
+ }
+ }
+ }
+
+ // Draw the text on top of the selected point.
+ if (tinted_polygon_index >= 0) {
+ Ref<Font> font = get_theme_font("font", "Label");
+ int font_size = get_theme_font_size("font_size", "Label");
+ String text = multiple_polygon_mode ? vformat("%d:%d", tinted_polygon_index, tinted_point_index) : vformat("%d", tinted_point_index);
+ Size2 text_size = font->get_string_size(text, font_size);
+ base_control->draw_string(font, xform.xform(polygons[tinted_polygon_index][tinted_point_index]) - text_size * 0.5, text, HALIGN_LEFT, -1, font_size, Color(1.0, 1.0, 1.0, 0.5));
+ }
+
+ if (drag_type == DRAG_TYPE_CREATE_POINT) {
+ base_control->draw_texture(handle, xform.xform(in_creation_point) - handle->get_size() / 2, Color(0.5, 1, 2));
+ }
+
+ // Draw the point creation preview in edit mode.
+ if (hovered_segment_index >= 0) {
+ base_control->draw_texture(add_handle, xform.xform(hovered_segment_point) - add_handle->get_size() / 2);
+ }
+
+ // Draw the tile shape line.
+ base_control->draw_set_transform_matrix(xform);
+ tile_set->draw_tile_shape(base_control, Rect2(-tile_size / 2, tile_size), grid_color, false);
+ base_control->draw_set_transform_matrix(Transform2D());
+}
+
+void GenericTilePolygonEditor::_center_view() {
+ panning = Vector2();
+ base_control->update();
+ button_center_view->set_disabled(true);
+}
+
+void GenericTilePolygonEditor::_zoom_changed() {
+ base_control->update();
+}
+
+void GenericTilePolygonEditor::_advanced_menu_item_pressed(int p_item_pressed) {
+ switch (p_item_pressed) {
+ case RESET_TO_DEFAULT_TILE:
+ undo_redo->create_action(TTR("Edit Polygons"));
+ undo_redo->add_do_method(this, "clear_polygons");
+ undo_redo->add_do_method(this, "add_polygon", tile_set->get_tile_shape_polygon());
+ undo_redo->add_do_method(base_control, "update");
+ undo_redo->add_do_method(this, "emit_signal", "polygons_changed");
+ undo_redo->add_undo_method(this, "clear_polygons");
+ for (unsigned int i = 0; i < polygons.size(); i++) {
+ undo_redo->add_undo_method(this, "add_polygon", polygons[i]);
+ }
+ undo_redo->add_undo_method(base_control, "update");
+ undo_redo->add_undo_method(this, "emit_signal", "polygons_changed");
+ undo_redo->commit_action(true);
+ break;
+ case CLEAR_TILE:
+ undo_redo->create_action(TTR("Edit Polygons"));
+ undo_redo->add_do_method(this, "clear_polygons");
+ undo_redo->add_do_method(base_control, "update");
+ undo_redo->add_do_method(this, "emit_signal", "polygons_changed");
+ undo_redo->add_undo_method(this, "clear_polygons");
+ for (unsigned int i = 0; i < polygons.size(); i++) {
+ undo_redo->add_undo_method(this, "add_polygon", polygons[i]);
+ }
+ undo_redo->add_undo_method(base_control, "update");
+ undo_redo->add_undo_method(this, "emit_signal", "polygons_changed");
+ undo_redo->commit_action(true);
+ break;
+ default:
+ break;
+ }
+}
+
+void GenericTilePolygonEditor::_grab_polygon_point(Vector2 p_pos, const Transform2D &p_polygon_xform, int &r_polygon_index, int &r_point_index) {
+ const real_t grab_threshold = EDITOR_GET("editors/poly_editor/point_grab_radius");
+ r_polygon_index = -1;
+ r_point_index = -1;
+ float closest_distance = grab_threshold + 1.0;
+ for (unsigned int i = 0; i < polygons.size(); i++) {
+ const Vector<Vector2> &polygon = polygons[i];
+ for (int j = 0; j < polygon.size(); j++) {
+ float distance = p_pos.distance_to(p_polygon_xform.xform(polygon[j]));
+ if (distance < grab_threshold && distance < closest_distance) {
+ r_polygon_index = i;
+ r_point_index = j;
+ closest_distance = distance;
+ }
+ }
+ }
+}
+
+void GenericTilePolygonEditor::_grab_polygon_segment_point(Vector2 p_pos, const Transform2D &p_polygon_xform, int &r_polygon_index, int &r_segment_index, Vector2 &r_point) {
+ const real_t grab_threshold = EDITOR_GET("editors/poly_editor/point_grab_radius");
+
+ Point2 point = p_polygon_xform.affine_inverse().xform(p_pos);
+ r_polygon_index = -1;
+ r_segment_index = -1;
+ float closest_distance = grab_threshold * 2.0;
+ for (unsigned int i = 0; i < polygons.size(); i++) {
+ const Vector<Vector2> &polygon = polygons[i];
+ for (int j = 0; j < polygon.size(); j++) {
+ Vector2 segment[2] = { polygon[j], polygon[(j + 1) % polygon.size()] };
+ Vector2 closest_point = Geometry2D::get_closest_point_to_segment(point, segment);
+ float distance = closest_point.distance_to(point);
+ if (distance < grab_threshold / editor_zoom_widget->get_zoom() && distance < closest_distance) {
+ r_polygon_index = i;
+ r_segment_index = j;
+ r_point = closest_point;
+ closest_distance = distance;
+ }
+ }
+ }
+}
+
+void GenericTilePolygonEditor::_snap_to_tile_shape(Point2 &r_point, float &r_current_snapped_dist, float p_snap_dist) {
+ ERR_FAIL_COND(!tile_set.is_valid());
+
+ Vector<Point2> polygon = tile_set->get_tile_shape_polygon();
+ Point2 snapped_point = r_point;
+
+ // Snap to polygon vertices.
+ bool snapped = false;
+ for (int i = 0; i < polygon.size(); i++) {
+ float distance = r_point.distance_to(polygon[i]);
+ if (distance < p_snap_dist && distance < r_current_snapped_dist) {
+ snapped_point = polygon[i];
+ r_current_snapped_dist = distance;
+ snapped = true;
+ }
+ }
+
+ // Snap to edges if we did not snap to vertices.
+ if (!snapped) {
+ for (int i = 0; i < polygon.size(); i++) {
+ Point2 segment[2] = { polygon[i], polygon[(i + 1) % polygon.size()] };
+ Point2 point = Geometry2D::get_closest_point_to_segment(r_point, segment);
+ float distance = r_point.distance_to(point);
+ if (distance < p_snap_dist && distance < r_current_snapped_dist) {
+ snapped_point = point;
+ r_current_snapped_dist = distance;
+ }
+ }
+ }
+
+ r_point = snapped_point;
+}
+
+void GenericTilePolygonEditor::_snap_to_half_pixel(Point2 &r_point) {
+ r_point = (r_point * 2).round() / 2.0;
+}
+
+void GenericTilePolygonEditor::_base_control_gui_input(Ref<InputEvent> p_event) {
+ real_t grab_threshold = EDITOR_GET("editors/poly_editor/point_grab_radius");
+
+ hovered_polygon_index = -1;
+ hovered_point_index = -1;
+ hovered_segment_index = -1;
+ hovered_segment_point = Vector2();
+
+ Transform2D xform;
+ xform.set_origin(base_control->get_size() / 2 + panning);
+ xform.set_scale(Vector2(editor_zoom_widget->get_zoom(), editor_zoom_widget->get_zoom()));
+
+ Ref<InputEventMouseMotion> mm = p_event;
+ if (mm.is_valid()) {
+ if (drag_type == DRAG_TYPE_DRAG_POINT) {
+ ERR_FAIL_INDEX(drag_polygon_index, (int)polygons.size());
+ ERR_FAIL_INDEX(drag_point_index, polygons[drag_polygon_index].size());
+ 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);
+ }
+ polygons[drag_polygon_index].write[drag_point_index] = point;
+ } else if (drag_type == DRAG_TYPE_PAN) {
+ panning += mm->get_position() - drag_last_pos;
+ drag_last_pos = mm->get_position();
+ button_center_view->set_disabled(panning.is_equal_approx(Vector2()));
+ } else {
+ // Update hovered point.
+ _grab_polygon_point(mm->get_position(), xform, hovered_polygon_index, hovered_point_index);
+
+ // If we have no hovered point, check if we hover a segment.
+ if (hovered_point_index == -1) {
+ _grab_polygon_segment_point(mm->get_position(), xform, hovered_polygon_index, hovered_segment_index, hovered_segment_point);
+ }
+ }
+ }
+
+ Ref<InputEventMouseButton> mb = p_event;
+ if (mb.is_valid()) {
+ if (mb->get_button_index() == MOUSE_BUTTON_WHEEL_UP && mb->is_ctrl_pressed()) {
+ editor_zoom_widget->set_zoom_by_increments(1);
+ _zoom_changed();
+ accept_event();
+ } else if (mb->get_button_index() == MOUSE_BUTTON_WHEEL_DOWN && mb->is_ctrl_pressed()) {
+ editor_zoom_widget->set_zoom_by_increments(-1);
+ _zoom_changed();
+ accept_event();
+ } else if (mb->get_button_index() == MOUSE_BUTTON_LEFT) {
+ if (mb->is_pressed()) {
+ if (tools_button_group->get_pressed_button() != button_create) {
+ in_creation_polygon.clear();
+ }
+ if (tools_button_group->get_pressed_button() == button_create) {
+ // Create points.
+ if (in_creation_polygon.size() >= 3 && mb->get_position().distance_to(xform.xform(in_creation_polygon[0])) < grab_threshold) {
+ // Closes and create polygon.
+ if (!multiple_polygon_mode) {
+ clear_polygons();
+ }
+ int added = add_polygon(in_creation_polygon);
+
+ in_creation_polygon.clear();
+ button_edit->set_pressed(true);
+ undo_redo->create_action(TTR("Edit Polygons"));
+ if (!multiple_polygon_mode) {
+ undo_redo->add_do_method(this, "clear_polygons");
+ }
+ undo_redo->add_do_method(this, "add_polygon", in_creation_polygon);
+ undo_redo->add_do_method(base_control, "update");
+ undo_redo->add_undo_method(this, "remove_polygon", added);
+ undo_redo->add_undo_method(base_control, "update");
+ undo_redo->commit_action(false);
+ emit_signal("polygons_changed");
+ } else {
+ // Create a new point.
+ drag_type = DRAG_TYPE_CREATE_POINT;
+ }
+ } else if (tools_button_group->get_pressed_button() == button_edit) {
+ // Edit points.
+ int closest_polygon;
+ int closest_point;
+ _grab_polygon_point(mb->get_position(), xform, closest_polygon, closest_point);
+ if (closest_polygon >= 0) {
+ drag_type = DRAG_TYPE_DRAG_POINT;
+ drag_polygon_index = closest_polygon;
+ drag_point_index = closest_point;
+ drag_old_polygon = polygons[drag_polygon_index];
+ } else {
+ // Create a point.
+ Vector2 point_to_create;
+ _grab_polygon_segment_point(mb->get_position(), xform, closest_polygon, closest_point, point_to_create);
+ if (closest_polygon >= 0) {
+ polygons[closest_polygon].insert(closest_point + 1, point_to_create);
+ drag_type = DRAG_TYPE_DRAG_POINT;
+ drag_polygon_index = closest_polygon;
+ drag_point_index = closest_point + 1;
+ drag_old_polygon = polygons[closest_polygon];
+ }
+ }
+ } else if (tools_button_group->get_pressed_button() == button_delete) {
+ // Remove point.
+ int closest_polygon;
+ int closest_point;
+ _grab_polygon_point(mb->get_position(), xform, closest_polygon, closest_point);
+ if (closest_polygon >= 0) {
+ PackedVector2Array old_polygon = polygons[closest_polygon];
+ polygons[closest_polygon].remove(closest_point);
+ undo_redo->create_action(TTR("Edit Polygons"));
+ if (polygons[closest_polygon].size() < 3) {
+ remove_polygon(closest_polygon);
+ undo_redo->add_do_method(this, "remove_polygon", closest_polygon);
+ undo_redo->add_undo_method(this, "add_polygon", old_polygon, closest_polygon);
+ } else {
+ undo_redo->add_do_method(this, "set_polygon", closest_polygon, polygons[closest_polygon]);
+ undo_redo->add_undo_method(this, "set_polygon", closest_polygon, old_polygon);
+ }
+ undo_redo->add_do_method(base_control, "update");
+ undo_redo->add_undo_method(base_control, "update");
+ undo_redo->commit_action(false);
+ emit_signal("polygons_changed");
+ }
+ }
+ } else {
+ if (drag_type == DRAG_TYPE_DRAG_POINT) {
+ undo_redo->create_action(TTR("Edit Polygons"));
+ undo_redo->add_do_method(this, "set_polygon", drag_polygon_index, polygons[drag_polygon_index]);
+ undo_redo->add_do_method(base_control, "update");
+ undo_redo->add_undo_method(this, "set_polygon", drag_polygon_index, drag_old_polygon);
+ undo_redo->add_undo_method(base_control, "update");
+ undo_redo->commit_action(false);
+ emit_signal("polygons_changed");
+ } else if (drag_type == DRAG_TYPE_CREATE_POINT) {
+ 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);
+ }
+ in_creation_polygon.push_back(point);
+ }
+ drag_type = DRAG_TYPE_NONE;
+ drag_point_index = -1;
+ }
+
+ } else if (mb->get_button_index() == MOUSE_BUTTON_RIGHT) {
+ if (mb->is_pressed()) {
+ if (tools_button_group->get_pressed_button() == button_edit) {
+ // Remove point or pan.
+ int closest_polygon;
+ int closest_point;
+ _grab_polygon_point(mb->get_position(), xform, closest_polygon, closest_point);
+ if (closest_polygon >= 0) {
+ PackedVector2Array old_polygon = polygons[closest_polygon];
+ polygons[closest_polygon].remove(closest_point);
+ undo_redo->create_action(TTR("Edit Polygons"));
+ if (polygons[closest_polygon].size() < 3) {
+ remove_polygon(closest_polygon);
+ undo_redo->add_do_method(this, "remove_polygon", closest_polygon);
+ undo_redo->add_undo_method(this, "add_polygon", old_polygon, closest_polygon);
+ } else {
+ undo_redo->add_do_method(this, "set_polygon", closest_polygon, polygons[closest_polygon]);
+ undo_redo->add_undo_method(this, "set_polygon", closest_polygon, old_polygon);
+ }
+ undo_redo->add_do_method(base_control, "update");
+ undo_redo->add_undo_method(base_control, "update");
+ undo_redo->commit_action(false);
+ emit_signal("polygons_changed");
+ } else {
+ drag_type = DRAG_TYPE_PAN;
+ drag_last_pos = mb->get_position();
+ }
+ } else {
+ drag_type = DRAG_TYPE_PAN;
+ drag_last_pos = mb->get_position();
+ }
+ } else {
+ drag_type = DRAG_TYPE_NONE;
+ }
+ } else if (mb->get_button_index() == MOUSE_BUTTON_MIDDLE) {
+ if (mb->is_pressed()) {
+ drag_type = DRAG_TYPE_PAN;
+ drag_last_pos = mb->get_position();
+ } else {
+ drag_type = DRAG_TYPE_NONE;
+ }
+ }
+ }
+
+ base_control->update();
+}
+
+void GenericTilePolygonEditor::set_tile_set(Ref<TileSet> p_tile_set) {
+ if (tile_set != p_tile_set) {
+ // Set the default tile shape
+ clear_polygons();
+ if (p_tile_set.is_valid()) {
+ add_polygon(p_tile_set->get_tile_shape_polygon());
+ }
+ }
+ tile_set = p_tile_set;
+}
+
+void GenericTilePolygonEditor::set_background(Ref<Texture2D> p_texture, Rect2 p_region, Vector2 p_offset, bool p_flip_h, bool p_flip_v, bool p_transpose, Color p_modulate) {
+ background_texture = p_texture;
+ background_region = p_region;
+ background_offset = p_offset;
+ background_h_flip = p_flip_h;
+ background_v_flip = p_flip_v;
+ background_transpose = p_transpose;
+ background_modulate = p_modulate;
+ base_control->update();
+}
+
+int GenericTilePolygonEditor::get_polygon_count() {
+ return polygons.size();
+}
+
+int GenericTilePolygonEditor::add_polygon(Vector<Point2> p_polygon, int p_index) {
+ ERR_FAIL_COND_V(p_polygon.size() < 3, -1);
+ ERR_FAIL_COND_V(!multiple_polygon_mode && polygons.size() >= 1, -1);
+
+ if (p_index < 0) {
+ polygons.push_back(p_polygon);
+ base_control->update();
+ button_edit->set_pressed(true);
+ return polygons.size() - 1;
+ } else {
+ polygons.insert(p_index, p_polygon);
+ button_edit->set_pressed(true);
+ base_control->update();
+ return p_index;
+ }
+}
+
+void GenericTilePolygonEditor::remove_polygon(int p_index) {
+ ERR_FAIL_INDEX(p_index, (int)polygons.size());
+ polygons.remove(p_index);
+
+ if (polygons.size() == 0) {
+ button_create->set_pressed(true);
+ }
+ base_control->update();
+}
+
+void GenericTilePolygonEditor::clear_polygons() {
+ polygons.clear();
+ base_control->update();
+}
+
+void GenericTilePolygonEditor::set_polygon(int p_polygon_index, Vector<Point2> p_polygon) {
+ ERR_FAIL_INDEX(p_polygon_index, (int)polygons.size());
+ ERR_FAIL_COND(p_polygon.size() < 3);
+ polygons[p_polygon_index] = p_polygon;
+ button_edit->set_pressed(true);
+ base_control->update();
}
-void TileDataIntegerEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileSet *p_tile_set, int p_atlas_source_id, Vector2i p_atlas_coords, int p_alternative_tile, String p_property) {
- TileData *tile_data = _get_tile_data(p_tile_set, p_atlas_source_id, p_atlas_coords, p_alternative_tile);
+Vector<Point2> GenericTilePolygonEditor::get_polygon(int p_polygon_index) {
+ ERR_FAIL_INDEX_V(p_polygon_index, (int)polygons.size(), Vector<Point2>());
+ return polygons[p_polygon_index];
+}
+
+void GenericTilePolygonEditor::set_polygons_color(Color p_color) {
+ polygon_color = p_color;
+ base_control->update();
+}
+
+void GenericTilePolygonEditor::set_multiple_polygon_mode(bool p_multiple_polygon_mode) {
+ multiple_polygon_mode = p_multiple_polygon_mode;
+}
+
+void GenericTilePolygonEditor::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_READY:
+ button_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveCreate", "EditorIcons"));
+ button_edit->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveEdit", "EditorIcons"));
+ button_delete->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveDelete", "EditorIcons"));
+ button_center_view->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CenterView", "EditorIcons"));
+ button_pixel_snap->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Snap", "EditorIcons"));
+ button_advanced_menu->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("GuiTabMenu", "EditorIcons"));
+ break;
+ }
+}
+
+void GenericTilePolygonEditor::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("get_polygon_count"), &GenericTilePolygonEditor::get_polygon_count);
+ ClassDB::bind_method(D_METHOD("add_polygon", "polygon", "index"), &GenericTilePolygonEditor::add_polygon, DEFVAL(-1));
+ ClassDB::bind_method(D_METHOD("remove_polygon", "index"), &GenericTilePolygonEditor::remove_polygon);
+ ClassDB::bind_method(D_METHOD("clear_polygons"), &GenericTilePolygonEditor::clear_polygons);
+ ClassDB::bind_method(D_METHOD("set_polygon", "index", "polygon"), &GenericTilePolygonEditor::set_polygon);
+ ClassDB::bind_method(D_METHOD("get_polygon", "index"), &GenericTilePolygonEditor::set_polygon);
+
+ ADD_SIGNAL(MethodInfo("polygons_changed"));
+}
+
+GenericTilePolygonEditor::GenericTilePolygonEditor() {
+ toolbar = memnew(HBoxContainer);
+ add_child(toolbar);
+
+ tools_button_group.instantiate();
+
+ button_create = memnew(Button);
+ button_create->set_flat(true);
+ button_create->set_toggle_mode(true);
+ button_create->set_button_group(tools_button_group);
+ button_create->set_pressed(true);
+ toolbar->add_child(button_create);
+
+ button_edit = memnew(Button);
+ button_edit->set_flat(true);
+ button_edit->set_toggle_mode(true);
+ button_edit->set_button_group(tools_button_group);
+ toolbar->add_child(button_edit);
+
+ button_delete = memnew(Button);
+ button_delete->set_flat(true);
+ button_delete->set_toggle_mode(true);
+ button_delete->set_button_group(tools_button_group);
+ toolbar->add_child(button_delete);
+
+ button_advanced_menu = memnew(MenuButton);
+ button_advanced_menu->set_flat(true);
+ button_advanced_menu->set_toggle_mode(true);
+ button_advanced_menu->get_popup()->add_item(TTR("Reset to default tile shape"), RESET_TO_DEFAULT_TILE);
+ button_advanced_menu->get_popup()->add_item(TTR("Clear"), CLEAR_TILE);
+ button_advanced_menu->get_popup()->connect("id_pressed", callable_mp(this, &GenericTilePolygonEditor::_advanced_menu_item_pressed));
+ toolbar->add_child(button_advanced_menu);
+
+ 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);
+ toolbar->add_child(button_pixel_snap);
+
+ Control *root = memnew(Control);
+ root->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ root->set_custom_minimum_size(Size2(0, 200 * EDSCALE));
+ root->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
+ add_child(root);
+
+ panel = memnew(Panel);
+ panel->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
+ panel->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
+ root->add_child(panel);
+
+ base_control = memnew(Control);
+ base_control->set_texture_filter(CanvasItem::TEXTURE_FILTER_NEAREST);
+ base_control->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
+ base_control->connect("draw", callable_mp(this, &GenericTilePolygonEditor::_base_control_draw));
+ base_control->connect("gui_input", callable_mp(this, &GenericTilePolygonEditor::_base_control_gui_input));
+ base_control->set_clip_contents(true);
+ root->add_child(base_control);
+
+ editor_zoom_widget = memnew(EditorZoomWidget);
+ editor_zoom_widget->set_position(Vector2(5, 5));
+ editor_zoom_widget->connect("zoom_changed", callable_mp(this, &GenericTilePolygonEditor::_zoom_changed).unbind(1));
+ root->add_child(editor_zoom_widget);
+
+ button_center_view = memnew(Button);
+ button_center_view->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CenterView", "EditorIcons"));
+ button_center_view->set_anchors_and_offsets_preset(Control::PRESET_TOP_RIGHT, Control::PRESET_MODE_MINSIZE, 5);
+ button_center_view->connect("pressed", callable_mp(this, &GenericTilePolygonEditor::_center_view));
+ button_center_view->set_flat(true);
+ button_center_view->set_disabled(true);
+ root->add_child(button_center_view);
+}
+
+void TileDataDefaultEditor::_property_value_changed(StringName p_property, Variant p_value, StringName p_field) {
+ ERR_FAIL_COND(!dummy_object);
+ dummy_object->set(p_property, p_value);
+}
+
+Variant TileDataDefaultEditor::_get_painted_value() {
+ ERR_FAIL_COND_V(!dummy_object, Variant());
+ return dummy_object->get(property);
+}
+
+void TileDataDefaultEditor::_set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) {
+ TileData *tile_data = Object::cast_to<TileData>(p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile));
ERR_FAIL_COND(!tile_data);
+ Variant value = tile_data->get(property);
+ dummy_object->set(property, value);
+ if (property_editor) {
+ property_editor->update_property();
+ }
+}
- bool valid;
- Variant value = tile_data->get(p_property, &valid);
- if (!valid) {
- return;
+void TileDataDefaultEditor::_set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value) {
+ TileData *tile_data = Object::cast_to<TileData>(p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile));
+ ERR_FAIL_COND(!tile_data);
+ tile_data->set(property, p_value);
+}
+
+Variant TileDataDefaultEditor::_get_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) {
+ TileData *tile_data = Object::cast_to<TileData>(p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile));
+ ERR_FAIL_COND_V(!tile_data, Variant());
+ return tile_data->get(property);
+}
+
+void TileDataDefaultEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map<TileMapCell, Variant> p_previous_values, Variant p_new_value) {
+ for (Map<TileMapCell, Variant>::Element *E = p_previous_values.front(); E; E = E->next()) {
+ Vector2i coords = E->key().get_atlas_coords();
+ undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/%s", coords.x, coords.y, E->key().alternative_tile, property), E->get());
+ undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/%s", coords.x, coords.y, E->key().alternative_tile, property), p_new_value);
}
- ERR_FAIL_COND(value.get_type() != Variant::INT);
+}
- Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font("bold", "EditorFonts");
- int height = font->get_height();
- int width = 200;
- p_canvas_item->draw_string(font, p_transform.get_origin() + Vector2i(-width / 2, height / 2), vformat("%d", value), HALIGN_CENTER, width, -1, Color(1, 1, 1), 1, Color(0, 0, 0, 1));
+void TileDataDefaultEditor::forward_draw_over_atlas(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) {
+ if (drag_type == DRAG_TYPE_PAINT_RECT) {
+ Color grid_color = EditorSettings::get_singleton()->get("editors/tiles_editor/grid_color");
+ Color selection_color = Color().from_hsv(Math::fposmod(grid_color.get_h() + 0.5, 1.0), grid_color.get_s(), grid_color.get_v(), 1.0);
+
+ p_canvas_item->draw_set_transform_matrix(p_transform);
+
+ Rect2i rect;
+ rect.set_position(p_tile_atlas_view->get_atlas_tile_coords_at_pos(drag_start_pos));
+ rect.set_end(p_tile_atlas_view->get_atlas_tile_coords_at_pos(p_transform.affine_inverse().xform(p_canvas_item->get_local_mouse_position())));
+ rect = rect.abs();
+
+ Set<TileMapCell> edited;
+ for (int x = rect.get_position().x; x <= rect.get_end().x; x++) {
+ for (int y = rect.get_position().y; y <= rect.get_end().y; y++) {
+ Vector2i coords = Vector2i(x, y);
+ coords = p_tile_set_atlas_source->get_tile_at_coords(coords);
+ if (coords != TileSetSource::INVALID_ATLAS_COORDS) {
+ TileMapCell cell;
+ cell.source_id = 0;
+ cell.set_atlas_coords(coords);
+ cell.alternative_tile = 0;
+ edited.insert(cell);
+ }
+ }
+ }
+
+ for (Set<TileMapCell>::Element *E = edited.front(); E; E = E->next()) {
+ Vector2i coords = E->get().get_atlas_coords();
+ p_canvas_item->draw_rect(p_tile_set_atlas_source->get_tile_texture_region(coords), selection_color, false);
+ }
+ p_canvas_item->draw_set_transform_matrix(Transform2D());
+ }
+};
+
+void TileDataDefaultEditor::forward_draw_over_alternatives(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform){
+
+};
+
+void TileDataDefaultEditor::forward_painting_atlas_gui_input(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, const Ref<InputEvent> &p_event) {
+ Ref<InputEventMouseMotion> mm = p_event;
+ if (mm.is_valid()) {
+ if (drag_type == DRAG_TYPE_PAINT) {
+ Vector<Vector2i> line = Geometry2D::bresenham_line(p_tile_atlas_view->get_atlas_tile_coords_at_pos(drag_last_pos), p_tile_atlas_view->get_atlas_tile_coords_at_pos(mm->get_position()));
+ for (int i = 0; i < line.size(); i++) {
+ Vector2i coords = p_tile_set_atlas_source->get_tile_at_coords(line[i]);
+ if (coords != TileSetSource::INVALID_ATLAS_COORDS) {
+ TileMapCell cell;
+ cell.source_id = 0;
+ cell.set_atlas_coords(coords);
+ cell.alternative_tile = 0;
+ if (!drag_modified.has(cell)) {
+ drag_modified[cell] = _get_value(p_tile_set_atlas_source, coords, 0);
+ }
+ _set_value(p_tile_set_atlas_source, coords, 0, drag_painted_value);
+ }
+ }
+ drag_last_pos = mm->get_position();
+ }
+ }
+
+ Ref<InputEventMouseButton> mb = p_event;
+ if (mb.is_valid()) {
+ if (mb->get_button_index() == MOUSE_BUTTON_LEFT) {
+ if (mb->is_pressed()) {
+ if (picker_button->is_pressed()) {
+ Vector2i coords = p_tile_atlas_view->get_atlas_tile_coords_at_pos(mb->get_position());
+ coords = p_tile_set_atlas_source->get_tile_at_coords(coords);
+ if (coords != TileSetSource::INVALID_ATLAS_COORDS) {
+ _set_painted_value(p_tile_set_atlas_source, coords, 0);
+ picker_button->set_pressed(false);
+ }
+ } else if (mb->is_ctrl_pressed()) {
+ drag_type = DRAG_TYPE_PAINT_RECT;
+ drag_modified.clear();
+ drag_painted_value = _get_painted_value();
+ drag_start_pos = mb->get_position();
+ } else {
+ drag_type = DRAG_TYPE_PAINT;
+ drag_modified.clear();
+ drag_painted_value = _get_painted_value();
+ Vector2i coords = p_tile_atlas_view->get_atlas_tile_coords_at_pos(mb->get_position());
+ coords = p_tile_set_atlas_source->get_tile_at_coords(coords);
+ if (coords != TileSetSource::INVALID_ATLAS_COORDS) {
+ TileMapCell cell;
+ cell.source_id = 0;
+ cell.set_atlas_coords(coords);
+ cell.alternative_tile = 0;
+ drag_modified[cell] = _get_value(p_tile_set_atlas_source, coords, 0);
+ _set_value(p_tile_set_atlas_source, coords, 0, drag_painted_value);
+ }
+ drag_last_pos = mb->get_position();
+ }
+ } else {
+ if (drag_type == DRAG_TYPE_PAINT_RECT) {
+ Rect2i rect;
+ rect.set_position(p_tile_atlas_view->get_atlas_tile_coords_at_pos(drag_start_pos));
+ rect.set_end(p_tile_atlas_view->get_atlas_tile_coords_at_pos(mb->get_position()));
+ rect = rect.abs();
+
+ drag_modified.clear();
+ for (int x = rect.get_position().x; x <= rect.get_end().x; x++) {
+ for (int y = rect.get_position().y; y <= rect.get_end().y; y++) {
+ Vector2i coords = Vector2i(x, y);
+ coords = p_tile_set_atlas_source->get_tile_at_coords(coords);
+ if (coords != TileSetSource::INVALID_ATLAS_COORDS) {
+ TileMapCell cell;
+ cell.source_id = 0;
+ cell.set_atlas_coords(coords);
+ cell.alternative_tile = 0;
+ drag_modified[cell] = _get_value(p_tile_set_atlas_source, coords, 0);
+ }
+ }
+ }
+ undo_redo->create_action(TTR("Painting Tiles Property"));
+ _setup_undo_redo_action(p_tile_set_atlas_source, drag_modified, drag_painted_value);
+ undo_redo->commit_action(true);
+ drag_type = DRAG_TYPE_NONE;
+ } else if (drag_type == DRAG_TYPE_PAINT) {
+ undo_redo->create_action(TTR("Painting Tiles Property"));
+ _setup_undo_redo_action(p_tile_set_atlas_source, drag_modified, drag_painted_value);
+ undo_redo->commit_action(false);
+ drag_type = DRAG_TYPE_NONE;
+ }
+ }
+ }
+ }
}
-void TileDataFloatEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileSet *p_tile_set, int p_atlas_source_id, Vector2i p_atlas_coords, int p_alternative_tile, String p_property) {
- TileData *tile_data = _get_tile_data(p_tile_set, p_atlas_source_id, p_atlas_coords, p_alternative_tile);
+void TileDataDefaultEditor::forward_painting_alternatives_gui_input(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, const Ref<InputEvent> &p_event) {
+ Ref<InputEventMouseMotion> mm = p_event;
+ if (mm.is_valid()) {
+ if (drag_type == DRAG_TYPE_PAINT) {
+ Vector3i tile = p_tile_atlas_view->get_alternative_tile_at_pos(mm->get_position());
+ Vector2i coords = Vector2i(tile.x, tile.y);
+ int alternative_tile = tile.z;
+
+ if (coords != TileSetSource::INVALID_ATLAS_COORDS) {
+ TileMapCell cell;
+ cell.source_id = 0;
+ cell.set_atlas_coords(coords);
+ cell.alternative_tile = alternative_tile;
+ if (!drag_modified.has(cell)) {
+ drag_modified[cell] = _get_value(p_tile_set_atlas_source, coords, alternative_tile);
+ }
+ _set_value(p_tile_set_atlas_source, coords, alternative_tile, drag_painted_value);
+ }
+
+ drag_last_pos = mm->get_position();
+ }
+ }
+
+ Ref<InputEventMouseButton> mb = p_event;
+ if (mb.is_valid()) {
+ if (mb->get_button_index() == MOUSE_BUTTON_LEFT) {
+ if (mb->is_pressed()) {
+ if (picker_button->is_pressed()) {
+ Vector3i tile = p_tile_atlas_view->get_alternative_tile_at_pos(mb->get_position());
+ Vector2i coords = Vector2i(tile.x, tile.y);
+ int alternative_tile = tile.z;
+ if (coords != TileSetSource::INVALID_ATLAS_COORDS) {
+ _set_painted_value(p_tile_set_atlas_source, coords, alternative_tile);
+ picker_button->set_pressed(false);
+ }
+ } else {
+ drag_type = DRAG_TYPE_PAINT;
+ drag_modified.clear();
+ drag_painted_value = _get_painted_value();
+
+ Vector3i tile = p_tile_atlas_view->get_alternative_tile_at_pos(mb->get_position());
+ Vector2i coords = Vector2i(tile.x, tile.y);
+ int alternative_tile = tile.z;
+
+ if (coords != TileSetSource::INVALID_ATLAS_COORDS) {
+ TileMapCell cell;
+ cell.source_id = 0;
+ cell.set_atlas_coords(coords);
+ cell.alternative_tile = alternative_tile;
+ drag_modified[cell] = _get_value(p_tile_set_atlas_source, coords, alternative_tile);
+ _set_value(p_tile_set_atlas_source, coords, alternative_tile, drag_painted_value);
+ }
+ drag_last_pos = mb->get_position();
+ }
+ } else {
+ undo_redo->create_action(TTR("Painting Tiles Property"));
+ _setup_undo_redo_action(p_tile_set_atlas_source, drag_modified, drag_painted_value);
+ undo_redo->commit_action(false);
+ drag_type = DRAG_TYPE_NONE;
+ }
+ }
+ }
+}
+
+void TileDataDefaultEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected) {
+ TileData *tile_data = _get_tile_data(p_cell);
ERR_FAIL_COND(!tile_data);
bool valid;
- Variant value = tile_data->get(p_property, &valid);
+ Variant value = tile_data->get(property, &valid);
if (!valid) {
return;
}
- ERR_FAIL_COND(value.get_type() != Variant::FLOAT);
- Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font("bold", "EditorFonts");
- int height = font->get_height();
- int width = 200;
- p_canvas_item->draw_string(font, p_transform.get_origin() + Vector2i(-width / 2, height / 2), vformat("%.2f", value), HALIGN_CENTER, width, -1, Color(1, 1, 1), 1, Color(0, 0, 0, 1));
+ if (value.get_type() == Variant::BOOL) {
+ Ref<Texture2D> texture = (bool)value ? tile_bool_checked : tile_bool_unchecked;
+ int size = MIN(tile_set->get_tile_size().x, tile_set->get_tile_size().y) / 3;
+ Rect2 rect = p_transform.xform(Rect2(Vector2(-size / 2, -size / 2), Vector2(size, size)));
+ p_canvas_item->draw_texture_rect(texture, rect);
+ } else if (value.get_type() == Variant::COLOR) {
+ int size = MIN(tile_set->get_tile_size().x, tile_set->get_tile_size().y) / 3;
+ Rect2 rect = p_transform.xform(Rect2(Vector2(-size / 2, -size / 2), Vector2(size, size)));
+ p_canvas_item->draw_rect(rect, value);
+ } else {
+ Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font("bold", "EditorFonts");
+ String text;
+ switch (value.get_type()) {
+ case Variant::INT:
+ text = vformat("%d", value);
+ break;
+ case Variant::FLOAT:
+ text = vformat("%.2f", value);
+ break;
+ case Variant::STRING:
+ case Variant::STRING_NAME:
+ text = value;
+ break;
+ default:
+ return;
+ break;
+ }
+
+ Color color = Color(1, 1, 1);
+ if (p_selected) {
+ Color grid_color = EditorSettings::get_singleton()->get("editors/tiles_editor/grid_color");
+ Color selection_color = Color().from_hsv(Math::fposmod(grid_color.get_h() + 0.5, 1.0), grid_color.get_s(), grid_color.get_v(), 1.0);
+ selection_color.set_v(0.9);
+ color = selection_color;
+ } else if (is_visible_in_tree()) {
+ Variant painted_value = _get_painted_value();
+ bool equal = (painted_value.get_type() == Variant::FLOAT && value.get_type() == Variant::FLOAT) ? Math::is_equal_approx(float(painted_value), float(value)) : painted_value == value;
+ if (equal) {
+ color = Color(0.7, 0.7, 0.7);
+ }
+ }
+
+ Vector2 string_size = font->get_string_size(text);
+ p_canvas_item->draw_string(font, p_transform.get_origin() + Vector2i(-string_size.x / 2, string_size.y / 2), text, HALIGN_CENTER, string_size.x, -1, color, 1, Color(0, 0, 0, 1));
+ }
}
-void TileDataPositionEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileSet *p_tile_set, int p_atlas_source_id, Vector2i p_atlas_coords, int p_alternative_tile, String p_property) {
- TileData *tile_data = _get_tile_data(p_tile_set, p_atlas_source_id, p_atlas_coords, p_alternative_tile);
+void TileDataDefaultEditor::setup_property_editor(Variant::Type p_type, String p_property, String p_label, Variant p_default_value) {
+ ERR_FAIL_COND_MSG(!property.is_empty(), "Cannot setup TileDataDefaultEditor twice");
+ property = p_property;
+
+ // Update everything.
+ if (property_editor) {
+ property_editor->queue_delete();
+ }
+
+ // Update the dummy object.
+ dummy_object->add_dummy_property(p_property);
+
+ // Get the default value for the type.
+ if (p_default_value == Variant()) {
+ Callable::CallError error;
+ Variant painted_value;
+ Variant::construct(p_type, painted_value, nullptr, 0, error);
+ dummy_object->set(p_property, painted_value);
+ } else {
+ dummy_object->set(p_property, p_default_value);
+ }
+
+ // Create and setup the property editor.
+ property_editor = EditorInspectorDefaultPlugin::get_editor_for_property(dummy_object, p_type, p_property, PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT);
+ property_editor->set_object_and_property(dummy_object, p_property);
+ if (p_label.is_empty()) {
+ property_editor->set_label(p_property);
+ } else {
+ property_editor->set_label(p_label);
+ }
+ property_editor->connect("property_changed", callable_mp(this, &TileDataDefaultEditor::_property_value_changed).unbind(1));
+ property_editor->update_property();
+ add_child(property_editor);
+}
+
+void TileDataDefaultEditor::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED:
+ picker_button->set_icon(get_theme_icon("ColorPick", "EditorIcons"));
+ tile_bool_checked = get_theme_icon("TileChecked", "EditorIcons");
+ tile_bool_unchecked = get_theme_icon("TileUnchecked", "EditorIcons");
+ break;
+ default:
+ break;
+ }
+}
+
+TileDataDefaultEditor::TileDataDefaultEditor() {
+ label = memnew(Label);
+ label->set_text("Painting:");
+ add_child(label);
+
+ toolbar->add_child(memnew(VSeparator));
+
+ picker_button = memnew(Button);
+ picker_button->set_flat(true);
+ picker_button->set_toggle_mode(true);
+ picker_button->set_shortcut(ED_SHORTCUT("tiles_editor/picker", "Picker", KEY_P));
+ toolbar->add_child(picker_button);
+}
+
+TileDataDefaultEditor::~TileDataDefaultEditor() {
+ toolbar->queue_delete();
+ memdelete(dummy_object);
+}
+
+void TileDataTextureOffsetEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected) {
+ TileData *tile_data = _get_tile_data(p_cell);
+ ERR_FAIL_COND(!tile_data);
+
+ Vector2i tile_set_tile_size = tile_set->get_tile_size();
+ Rect2i rect = Rect2i(-tile_set_tile_size / 2, tile_set_tile_size);
+ Color color = Color(1.0, 0.0, 0.0);
+ if (p_selected) {
+ Color grid_color = EditorSettings::get_singleton()->get("editors/tiles_editor/grid_color");
+ Color selection_color = Color().from_hsv(Math::fposmod(grid_color.get_h() + 0.5, 1.0), grid_color.get_s(), grid_color.get_v(), 1.0);
+ color = selection_color;
+ }
+ tile_set->draw_tile_shape(p_canvas_item, p_transform.xform(rect), color);
+}
+
+void TileDataPositionEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected) {
+ TileData *tile_data = _get_tile_data(p_cell);
ERR_FAIL_COND(!tile_data);
bool valid;
- Variant value = tile_data->get(p_property, &valid);
+ Variant value = tile_data->get(property, &valid);
if (!valid) {
return;
}
ERR_FAIL_COND(value.get_type() != Variant::VECTOR2I && value.get_type() != Variant::VECTOR2);
+ Color color = Color(1.0, 1.0, 1.0);
+ if (p_selected) {
+ Color grid_color = EditorSettings::get_singleton()->get("editors/tiles_editor/grid_color");
+ Color selection_color = Color().from_hsv(Math::fposmod(grid_color.get_h() + 0.5, 1.0), grid_color.get_s(), grid_color.get_v(), 1.0);
+ color = selection_color;
+ }
Ref<Texture2D> position_icon = TileSetEditor::get_singleton()->get_theme_icon("EditorPosition", "EditorIcons");
- p_canvas_item->draw_texture(position_icon, p_transform.xform(Vector2(value)) - position_icon->get_size() / 2);
+ p_canvas_item->draw_texture(position_icon, p_transform.xform(Vector2(value)) - position_icon->get_size() / 2, color);
}
-void TileDataYSortEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileSet *p_tile_set, int p_atlas_source_id, Vector2i p_atlas_coords, int p_alternative_tile, String p_property) {
- TileData *tile_data = _get_tile_data(p_tile_set, p_atlas_source_id, p_atlas_coords, p_alternative_tile);
+void TileDataYSortEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected) {
+ TileData *tile_data = _get_tile_data(p_cell);
ERR_FAIL_COND(!tile_data);
- bool valid;
- Variant value = tile_data->get(p_property, &valid);
- if (!valid) {
- return;
+ Color color = Color(1.0, 1.0, 1.0);
+ if (p_selected) {
+ Color grid_color = EditorSettings::get_singleton()->get("editors/tiles_editor/grid_color");
+ Color selection_color = Color().from_hsv(Math::fposmod(grid_color.get_h() + 0.5, 1.0), grid_color.get_s(), grid_color.get_v(), 1.0);
+ color = selection_color;
}
- ERR_FAIL_COND(value.get_type() != Variant::INT);
-
Ref<Texture2D> position_icon = TileSetEditor::get_singleton()->get_theme_icon("EditorPosition", "EditorIcons");
- p_canvas_item->draw_texture(position_icon, p_transform.xform(Vector2(0, value)) - position_icon->get_size() / 2);
+ p_canvas_item->draw_texture(position_icon, p_transform.xform(Vector2(0, tile_data->get_y_sort_origin())) - position_icon->get_size() / 2, color);
}
-void TileDataOcclusionShapeEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileSet *p_tile_set, int p_atlas_source_id, Vector2i p_atlas_coords, int p_alternative_tile, String p_property) {
- TileData *tile_data = _get_tile_data(p_tile_set, p_atlas_source_id, p_atlas_coords, p_alternative_tile);
+void TileDataOcclusionShapeEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected) {
+ TileData *tile_data = _get_tile_data(p_cell);
ERR_FAIL_COND(!tile_data);
- Vector<String> components = String(p_property).split("/", true);
- if (components[0].begins_with("occlusion_layer_") && components[0].trim_prefix("occlusion_layer_").is_valid_integer()) {
- int occlusion_layer = components[0].trim_prefix("occlusion_layer_").to_int();
- if (occlusion_layer >= 0 && occlusion_layer < p_tile_set->get_occlusion_layers_count()) {
- // Draw all shapes.
- Vector<Color> debug_occlusion_color;
- debug_occlusion_color.push_back(Color(0.5, 0, 0, 0.6));
+ Color grid_color = EditorSettings::get_singleton()->get("editors/tiles_editor/grid_color");
+ Color selection_color = Color().from_hsv(Math::fposmod(grid_color.get_h() + 0.5, 1.0), grid_color.get_s(), grid_color.get_v(), 1.0);
+ Color color = grid_color.darkened(0.2);
+ if (p_selected) {
+ color = selection_color.darkened(0.2);
+ }
+ color.a *= 0.5;
- RenderingServer::get_singleton()->canvas_item_add_set_transform(p_canvas_item->get_canvas_item(), p_transform);
- Ref<OccluderPolygon2D> occluder = tile_data->get_occluder(occlusion_layer);
- if (occluder.is_valid() && occluder->get_polygon().size() >= 3) {
- p_canvas_item->draw_polygon(Variant(occluder->get_polygon()), debug_occlusion_color);
- }
- RenderingServer::get_singleton()->canvas_item_add_set_transform(p_canvas_item->get_canvas_item(), Transform2D());
+ Vector<Color> debug_occlusion_color;
+ debug_occlusion_color.push_back(color);
+
+ RenderingServer::get_singleton()->canvas_item_add_set_transform(p_canvas_item->get_canvas_item(), p_transform);
+ Ref<OccluderPolygon2D> occluder = tile_data->get_occluder(occlusion_layer);
+ if (occluder.is_valid() && occluder->get_polygon().size() >= 3) {
+ p_canvas_item->draw_polygon(Variant(occluder->get_polygon()), debug_occlusion_color);
+ }
+ RenderingServer::get_singleton()->canvas_item_add_set_transform(p_canvas_item->get_canvas_item(), Transform2D());
+}
+
+Variant TileDataOcclusionShapeEditor::_get_painted_value() {
+ Ref<OccluderPolygon2D> occluder_polygon;
+ occluder_polygon.instantiate();
+ if (polygon_editor->get_polygon_count() >= 1) {
+ occluder_polygon->set_polygon(polygon_editor->get_polygon(0));
+ }
+ return occluder_polygon;
+}
+
+void TileDataOcclusionShapeEditor::_set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) {
+ TileData *tile_data = Object::cast_to<TileData>(p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile));
+ ERR_FAIL_COND(!tile_data);
+
+ Ref<OccluderPolygon2D> occluder_polygon = tile_data->get_occluder(occlusion_layer);
+ polygon_editor->clear_polygons();
+ if (occluder_polygon.is_valid()) {
+ polygon_editor->add_polygon(occluder_polygon->get_polygon());
+ }
+ polygon_editor->set_background(p_tile_set_atlas_source->get_texture(), p_tile_set_atlas_source->get_tile_texture_region(p_coords), p_tile_set_atlas_source->get_tile_effective_texture_offset(p_coords, p_alternative_tile), tile_data->get_flip_h(), tile_data->get_flip_v(), tile_data->get_transpose(), tile_data->get_modulate());
+}
+
+void TileDataOcclusionShapeEditor::_set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value) {
+ TileData *tile_data = Object::cast_to<TileData>(p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile));
+ ERR_FAIL_COND(!tile_data);
+ Ref<OccluderPolygon2D> occluder_polygon = p_value;
+ tile_data->set_occluder(occlusion_layer, occluder_polygon);
+
+ polygon_editor->set_background(p_tile_set_atlas_source->get_texture(), p_tile_set_atlas_source->get_tile_texture_region(p_coords), p_tile_set_atlas_source->get_tile_effective_texture_offset(p_coords, p_alternative_tile), tile_data->get_flip_h(), tile_data->get_flip_v(), tile_data->get_transpose(), tile_data->get_modulate());
+}
+
+Variant TileDataOcclusionShapeEditor::_get_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) {
+ TileData *tile_data = Object::cast_to<TileData>(p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile));
+ ERR_FAIL_COND_V(!tile_data, Variant());
+ return tile_data->get_occluder(occlusion_layer);
+}
+
+void TileDataOcclusionShapeEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map<TileMapCell, Variant> p_previous_values, Variant p_new_value) {
+ for (Map<TileMapCell, Variant>::Element *E = p_previous_values.front(); E; E = E->next()) {
+ Vector2i coords = E->key().get_atlas_coords();
+ undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/occlusion_layer_%d/polygon", coords.x, coords.y, E->key().alternative_tile, occlusion_layer), E->get());
+ undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/occlusion_layer_%d/polygon", coords.x, coords.y, E->key().alternative_tile, occlusion_layer), p_new_value);
+ }
+}
+
+void TileDataOcclusionShapeEditor::_tile_set_changed() {
+ polygon_editor->set_tile_set(tile_set);
+}
+
+void TileDataOcclusionShapeEditor::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ polygon_editor->set_polygons_color(get_tree()->get_debug_collisions_color());
+ break;
+ default:
+ break;
+ }
+}
+
+TileDataOcclusionShapeEditor::TileDataOcclusionShapeEditor() {
+ polygon_editor = memnew(GenericTilePolygonEditor);
+ add_child(polygon_editor);
+}
+
+void TileDataCollisionEditor::_property_value_changed(StringName p_property, Variant p_value, StringName p_field) {
+ dummy_object->set(p_property, p_value);
+}
+
+void TileDataCollisionEditor::_polygons_changed() {
+ // Update the dummy object properties and their editors.
+ for (int i = 0; i < polygon_editor->get_polygon_count(); i++) {
+ StringName one_way_property = vformat("polygon_%d_one_way", i);
+ StringName one_way_margin_property = vformat("polygon_%d_one_way_margin", i);
+
+ if (!dummy_object->has_dummy_property(one_way_property)) {
+ dummy_object->add_dummy_property(one_way_property);
+ dummy_object->set(one_way_property, false);
}
+
+ if (!dummy_object->has_dummy_property(one_way_margin_property)) {
+ dummy_object->add_dummy_property(one_way_margin_property);
+ dummy_object->set(one_way_margin_property, 1.0);
+ }
+
+ if (!property_editors.has(one_way_property)) {
+ EditorProperty *one_way_property_editor = EditorInspectorDefaultPlugin::get_editor_for_property(dummy_object, Variant::BOOL, one_way_property, PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT);
+ one_way_property_editor->set_object_and_property(dummy_object, one_way_property);
+ one_way_property_editor->set_label(one_way_property);
+ one_way_property_editor->connect("property_changed", callable_mp(this, &TileDataCollisionEditor::_property_value_changed).unbind(1));
+ one_way_property_editor->update_property();
+ add_child(one_way_property_editor);
+ property_editors[one_way_property] = one_way_property_editor;
+ }
+
+ if (!property_editors.has(one_way_margin_property)) {
+ EditorProperty *one_way_margin_property_editor = EditorInspectorDefaultPlugin::get_editor_for_property(dummy_object, Variant::FLOAT, one_way_margin_property, PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT);
+ one_way_margin_property_editor->set_object_and_property(dummy_object, one_way_margin_property);
+ one_way_margin_property_editor->set_label(one_way_margin_property);
+ one_way_margin_property_editor->connect("property_changed", callable_mp(this, &TileDataCollisionEditor::_property_value_changed).unbind(1));
+ one_way_margin_property_editor->update_property();
+ add_child(one_way_margin_property_editor);
+ property_editors[one_way_margin_property] = one_way_margin_property_editor;
+ }
+ }
+
+ // Remove uneeded properties and their editors.
+ for (int i = polygon_editor->get_polygon_count(); dummy_object->has_dummy_property(vformat("polygon_%d_one_way", i)); i++) {
+ dummy_object->remove_dummy_property(vformat("polygon_%d_one_way", i));
+ }
+ for (int i = polygon_editor->get_polygon_count(); dummy_object->has_dummy_property(vformat("polygon_%d_one_way_margin", i)); i++) {
+ dummy_object->remove_dummy_property(vformat("polygon_%d_one_way_margin", i));
+ }
+ for (int i = polygon_editor->get_polygon_count(); property_editors.has(vformat("polygon_%d_one_way", i)); i++) {
+ property_editors[vformat("polygon_%d_one_way", i)]->queue_delete();
+ property_editors.erase(vformat("polygon_%d_one_way", i));
}
+ for (int i = polygon_editor->get_polygon_count(); property_editors.has(vformat("polygon_%d_one_way_margin", i)); i++) {
+ property_editors[vformat("polygon_%d_one_way_margin", i)]->queue_delete();
+ property_editors.erase(vformat("polygon_%d_one_way_margin", i));
+ }
+}
+
+Variant TileDataCollisionEditor::_get_painted_value() {
+ Array array;
+ for (int i = 0; i < polygon_editor->get_polygon_count(); i++) {
+ ERR_FAIL_COND_V(polygon_editor->get_polygon(i).size() < 3, Variant());
+ Dictionary dict;
+ dict["points"] = polygon_editor->get_polygon(i);
+ dict["one_way"] = dummy_object->get(vformat("polygon_%d_one_way", i));
+ dict["one_way_margin"] = dummy_object->get(vformat("polygon_%d_one_way_margin", i));
+ array.push_back(dict);
+ }
+
+ return array;
}
-void TileDataCollisionShapeEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileSet *p_tile_set, int p_atlas_source_id, Vector2i p_atlas_coords, int p_alternative_tile, String p_property) {
- TileData *tile_data = _get_tile_data(p_tile_set, p_atlas_source_id, p_atlas_coords, p_alternative_tile);
+void TileDataCollisionEditor::_set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) {
+ TileData *tile_data = Object::cast_to<TileData>(p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile));
ERR_FAIL_COND(!tile_data);
- Vector<String> components = String(p_property).split("/", true);
- if (components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_integer()) {
- int physics_layer = components[0].trim_prefix("physics_layer_").to_int();
- if (physics_layer >= 0 && physics_layer < p_tile_set->get_physics_layers_count()) {
- // Draw all shapes.
- Color debug_collision_color = p_canvas_item->get_tree()->get_debug_collisions_color();
- RenderingServer::get_singleton()->canvas_item_add_set_transform(p_canvas_item->get_canvas_item(), p_transform);
- for (int i = 0; i < tile_data->get_collision_shapes_count(physics_layer); i++) {
- Ref<Shape2D> shape = tile_data->get_collision_shape_shape(physics_layer, i);
- if (shape.is_valid()) {
- shape->draw(p_canvas_item->get_canvas_item(), debug_collision_color);
- }
- }
- RenderingServer::get_singleton()->canvas_item_add_set_transform(p_canvas_item->get_canvas_item(), Transform2D());
+ polygon_editor->clear_polygons();
+ for (int i = 0; i < tile_data->get_collision_polygons_count(physics_layer); i++) {
+ Vector<Vector2> polygon = tile_data->get_collision_polygon_points(physics_layer, i);
+ if (polygon.size() >= 3) {
+ polygon_editor->add_polygon(polygon);
}
}
+
+ _polygons_changed();
+ for (int i = 0; i < tile_data->get_collision_polygons_count(physics_layer); i++) {
+ dummy_object->set(vformat("polygon_%d_one_way", i), tile_data->is_collision_polygon_one_way(physics_layer, i));
+ dummy_object->set(vformat("polygon_%d_one_way_margin", i), tile_data->get_collision_polygon_one_way_margin(physics_layer, i));
+ }
+ for (Map<StringName, EditorProperty *>::Element *E = property_editors.front(); E; E = E->next()) {
+ E->get()->update_property();
+ }
+
+ polygon_editor->set_background(p_tile_set_atlas_source->get_texture(), p_tile_set_atlas_source->get_tile_texture_region(p_coords), p_tile_set_atlas_source->get_tile_effective_texture_offset(p_coords, p_alternative_tile), tile_data->get_flip_h(), tile_data->get_flip_v(), tile_data->get_transpose(), tile_data->get_modulate());
}
-void TileDataTerrainsEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileSet *p_tile_set, int p_atlas_source_id, Vector2i p_atlas_coords, int p_alternative_tile, String p_property) {
- TileData *tile_data = _get_tile_data(p_tile_set, p_atlas_source_id, p_atlas_coords, p_alternative_tile);
+void TileDataCollisionEditor::_set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value) {
+ TileData *tile_data = Object::cast_to<TileData>(p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile));
ERR_FAIL_COND(!tile_data);
- Vector<String> components = String(p_property).split("/", true);
- if (components[0] == "terrain_mode" || components[0] == "terrain" || components[0] == "terrains_peering_bit") {
- TileSetPluginAtlasTerrain::draw_terrains(p_canvas_item, p_transform, p_tile_set, tile_data);
+ Array array = p_value;
+ tile_data->set_collision_polygons_count(physics_layer, array.size());
+ for (int i = 0; i < array.size(); i++) {
+ Dictionary dict = array[i];
+ tile_data->set_collision_polygon_points(physics_layer, i, dict["points"]);
+ tile_data->set_collision_polygon_one_way(physics_layer, i, dict["one_way"]);
+ tile_data->set_collision_polygon_one_way_margin(physics_layer, i, dict["one_way_margin"]);
+ }
+
+ polygon_editor->set_background(p_tile_set_atlas_source->get_texture(), p_tile_set_atlas_source->get_tile_texture_region(p_coords), p_tile_set_atlas_source->get_tile_effective_texture_offset(p_coords, p_alternative_tile), tile_data->get_flip_h(), tile_data->get_flip_v(), tile_data->get_transpose(), tile_data->get_modulate());
+}
+
+Variant TileDataCollisionEditor::_get_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) {
+ TileData *tile_data = Object::cast_to<TileData>(p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile));
+ ERR_FAIL_COND_V(!tile_data, Variant());
+
+ Array array;
+ for (int i = 0; i < tile_data->get_collision_polygons_count(physics_layer); i++) {
+ Dictionary dict;
+ dict["points"] = tile_data->get_collision_polygon_points(physics_layer, i);
+ dict["one_way"] = tile_data->is_collision_polygon_one_way(physics_layer, i);
+ dict["one_way_margin"] = tile_data->get_collision_polygon_one_way_margin(physics_layer, i);
+ array.push_back(dict);
+ }
+ return array;
+}
+
+void TileDataCollisionEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map<TileMapCell, Variant> p_previous_values, Variant p_new_value) {
+ Array new_array = p_new_value;
+ for (Map<TileMapCell, Variant>::Element *E = p_previous_values.front(); E; E = E->next()) {
+ Array old_array = E->get();
+
+ Vector2i coords = E->key().get_atlas_coords();
+ undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/physics_layer_%d/polygons_count", coords.x, coords.y, E->key().alternative_tile, physics_layer), old_array.size());
+ for (int i = 0; i < old_array.size(); i++) {
+ Dictionary dict = old_array[i];
+ undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/physics_layer_%d/polygon_%d/points", coords.x, coords.y, E->key().alternative_tile, physics_layer, i), dict["points"]);
+ undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/physics_layer_%d/polygon_%d/one_way", coords.x, coords.y, E->key().alternative_tile, physics_layer, i), dict["one_way"]);
+ undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/physics_layer_%d/polygon_%d/one_way_margin", coords.x, coords.y, E->key().alternative_tile, physics_layer, i), dict["one_way_margin"]);
+ }
+
+ undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/physics_layer_%d/polygons_count", coords.x, coords.y, E->key().alternative_tile, physics_layer), new_array.size());
+ for (int i = 0; i < new_array.size(); i++) {
+ Dictionary dict = new_array[i];
+ undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/physics_layer_%d/polygon_%d/points", coords.x, coords.y, E->key().alternative_tile, physics_layer, i), dict["points"]);
+ undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/physics_layer_%d/polygon_%d/one_way", coords.x, coords.y, E->key().alternative_tile, physics_layer, i), dict["one_way"]);
+ undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/physics_layer_%d/polygon_%d/one_way_margin", coords.x, coords.y, E->key().alternative_tile, physics_layer, i), dict["one_way_margin"]);
+ }
+ }
+}
+
+void TileDataCollisionEditor::_tile_set_changed() {
+ polygon_editor->set_tile_set(tile_set);
+ _polygons_changed();
+}
+
+void TileDataCollisionEditor::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ polygon_editor->set_polygons_color(get_tree()->get_debug_collisions_color());
+ break;
+ default:
+ break;
}
}
-void TileDataNavigationPolygonEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileSet *p_tile_set, int p_atlas_source_id, Vector2i p_atlas_coords, int p_alternative_tile, String p_property) {
- TileData *tile_data = _get_tile_data(p_tile_set, p_atlas_source_id, p_atlas_coords, p_alternative_tile);
+TileDataCollisionEditor::TileDataCollisionEditor() {
+ polygon_editor = memnew(GenericTilePolygonEditor);
+ polygon_editor->set_multiple_polygon_mode(true);
+ polygon_editor->connect("polygons_changed", callable_mp(this, &TileDataCollisionEditor::_polygons_changed));
+ add_child(polygon_editor);
+
+ _polygons_changed();
+}
+
+TileDataCollisionEditor::~TileDataCollisionEditor() {
+ memdelete(dummy_object);
+}
+
+void TileDataCollisionEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected) {
+ TileData *tile_data = _get_tile_data(p_cell);
ERR_FAIL_COND(!tile_data);
- Vector<String> components = String(p_property).split("/", true);
- if (components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_integer()) {
- int navigation_layer = components[0].trim_prefix("navigation_layer_").to_int();
- if (navigation_layer >= 0 && navigation_layer < p_tile_set->get_navigation_layers_count()) {
- // Draw all shapes.
- RenderingServer::get_singleton()->canvas_item_add_set_transform(p_canvas_item->get_canvas_item(), p_transform);
+ // Draw all shapes.
+ Vector<Color> color;
+ if (p_selected) {
+ Color grid_color = EditorSettings::get_singleton()->get("editors/tiles_editor/grid_color");
+ Color selection_color = Color().from_hsv(Math::fposmod(grid_color.get_h() + 0.5, 1.0), grid_color.get_s(), grid_color.get_v(), 1.0);
+ selection_color.a = 0.7;
+ color.push_back(selection_color);
+ } else {
+ Color debug_collision_color = p_canvas_item->get_tree()->get_debug_collisions_color();
+ color.push_back(debug_collision_color);
+ }
+
+ RenderingServer::get_singleton()->canvas_item_add_set_transform(p_canvas_item->get_canvas_item(), p_transform);
+ for (int i = 0; i < tile_data->get_collision_polygons_count(physics_layer); i++) {
+ Vector<Vector2> polygon = tile_data->get_collision_polygon_points(physics_layer, i);
+ if (polygon.size() >= 3) {
+ p_canvas_item->draw_polygon(polygon, color);
+ }
+ }
+ RenderingServer::get_singleton()->canvas_item_add_set_transform(p_canvas_item->get_canvas_item(), Transform2D());
+}
+
+void TileDataTerrainsEditor::_update_terrain_selector() {
+ ERR_FAIL_COND(!tile_set.is_valid());
+
+ // Update the terrain set selector.
+ Vector<String> options;
+ options.push_back(String(TTR("No terrains")) + String(":-1"));
+ for (int i = 0; i < tile_set->get_terrain_sets_count(); i++) {
+ options.push_back(vformat("Terrain Set %d", i));
+ }
+ terrain_set_property_editor->setup(options);
+ terrain_set_property_editor->update_property();
+
+ // Update the terrain selector.
+ int terrain_set = int(dummy_object->get("terrain_set"));
+ if (terrain_set == -1) {
+ terrain_property_editor->hide();
+ } else {
+ options.clear();
+ Vector<Vector<Ref<Texture2D>>> icons = tile_set->generate_terrains_icons(Size2(16, 16) * EDSCALE);
+ options.push_back(String(TTR("No terrain")) + String(":-1"));
+ for (int i = 0; i < tile_set->get_terrains_count(terrain_set); i++) {
+ String name = tile_set->get_terrain_name(terrain_set, i);
+ if (name.is_empty()) {
+ options.push_back(vformat("Terrain %d", i));
+ } else {
+ options.push_back(name);
+ }
+ }
+ terrain_property_editor->setup(options);
+ terrain_property_editor->update_property();
+
+ // Kind of a hack to set icons.
+ // We could provide a way to modify that in the EditorProperty.
+ OptionButton *option_button = Object::cast_to<OptionButton>(terrain_property_editor->get_child(0));
+ for (int terrain = 0; terrain < tile_set->get_terrains_count(terrain_set); terrain++) {
+ option_button->set_item_icon(terrain + 1, icons[terrain_set][terrain]);
+ }
+ terrain_property_editor->show();
+ }
+}
+
+void TileDataTerrainsEditor::_property_value_changed(StringName p_property, Variant p_value, StringName p_field) {
+ Variant old_value = dummy_object->get(p_property);
+ dummy_object->set(p_property, p_value);
+ if (p_property == "terrain_set") {
+ if (p_value != old_value) {
+ dummy_object->set("terrain", -1);
+ }
+ _update_terrain_selector();
+ }
+ emit_signal("needs_redraw");
+}
+
+void TileDataTerrainsEditor::_tile_set_changed() {
+ ERR_FAIL_COND(!tile_set.is_valid());
+
+ // Fix if wrong values are selected.
+ if (int(dummy_object->get("terrain_set")) > tile_set->get_terrain_sets_count()) {
+ dummy_object->set("terrain_set", -1);
+ }
+ int terrain_set = int(dummy_object->get("terrain"));
+ if (terrain_set >= 0) {
+ if (int(dummy_object->get("terrain")) > tile_set->get_terrains_count(terrain_set)) {
+ dummy_object->set("terrain", -1);
+ }
+ }
+
+ _update_terrain_selector();
+}
+
+void TileDataTerrainsEditor::forward_draw_over_atlas(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) {
+ ERR_FAIL_COND(!tile_set.is_valid());
- Ref<NavigationPolygon> navigation_polygon = tile_data->get_navigation_polygon(navigation_layer);
- if (navigation_polygon.is_valid()) {
- Vector<Vector2> verts = navigation_polygon->get_vertices();
- if (verts.size() < 3) {
- return;
+ // Draw the hovered terrain bit, or the whole tile if it has the wrong terrain set.
+ Vector2i hovered_coords = TileSetSource::INVALID_ATLAS_COORDS;
+ if (drag_type == DRAG_TYPE_NONE) {
+ Vector2i mouse_pos = p_transform.affine_inverse().xform(p_canvas_item->get_local_mouse_position());
+ hovered_coords = p_tile_atlas_view->get_atlas_tile_coords_at_pos(mouse_pos);
+ hovered_coords = p_tile_set_atlas_source->get_tile_at_coords(hovered_coords);
+ if (hovered_coords != TileSetSource::INVALID_ATLAS_COORDS) {
+ TileData *tile_data = Object::cast_to<TileData>(p_tile_set_atlas_source->get_tile_data(hovered_coords, 0));
+ int terrain_set = tile_data->get_terrain_set();
+ Rect2i texture_region = p_tile_set_atlas_source->get_tile_texture_region(hovered_coords);
+ Vector2i position = (texture_region.position + texture_region.get_end()) / 2 + p_tile_set_atlas_source->get_tile_effective_texture_offset(hovered_coords, 0);
+
+ if (terrain_set >= 0 && terrain_set == int(dummy_object->get("terrain_set"))) {
+ // Draw hovered bit.
+ Transform2D xform;
+ xform.set_origin(position);
+
+ Vector<Color> color;
+ color.push_back(Color(1.0, 1.0, 1.0, 0.5));
+
+ for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) {
+ TileSet::CellNeighbor bit = TileSet::CellNeighbor(i);
+ if (tile_set->is_valid_peering_bit_terrain(terrain_set, bit)) {
+ Vector<Vector2> polygon = tile_set->get_terrain_bit_polygon(terrain_set, bit);
+ if (Geometry2D::is_point_in_polygon(xform.affine_inverse().xform(mouse_pos), polygon)) {
+ p_canvas_item->draw_set_transform_matrix(p_transform * xform);
+ p_canvas_item->draw_polygon(polygon, color);
+ }
+ }
}
+ } else {
+ // Draw hovered tile.
+ Vector2i tile_size = tile_set->get_tile_size();
+ Rect2i rect = p_transform.xform(Rect2i(position - tile_size / 2, tile_size));
+ tile_set->draw_tile_shape(p_canvas_item, rect, Color(1.0, 1.0, 1.0, 0.5), true);
+ }
+ }
+ }
+
+ // Dim terrains with wrong terrain set.
+ Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font("bold", "EditorFonts");
+ for (int i = 0; i < p_tile_set_atlas_source->get_tiles_count(); i++) {
+ Vector2i coords = p_tile_set_atlas_source->get_tile_id(i);
+ if (coords != hovered_coords) {
+ TileData *tile_data = Object::cast_to<TileData>(p_tile_set_atlas_source->get_tile_data(coords, 0));
+ if (tile_data->get_terrain_set() != int(dummy_object->get("terrain_set"))) {
+ // Dimming
+ p_canvas_item->draw_set_transform_matrix(p_transform);
+ Rect2i rect = p_tile_set_atlas_source->get_tile_texture_region(coords);
+ p_canvas_item->draw_rect(rect, Color(0.0, 0.0, 0.0, 0.3));
+
+ // Text
+ p_canvas_item->draw_set_transform_matrix(Transform2D());
+ Rect2i texture_region = p_tile_set_atlas_source->get_tile_texture_region(coords);
+ Vector2i position = (texture_region.position + texture_region.get_end()) / 2 + p_tile_set_atlas_source->get_tile_effective_texture_offset(coords, 0);
+
+ Color color = Color(1, 1, 1);
+ String text;
+ if (tile_data->get_terrain_set() >= 0) {
+ text = vformat("%d", tile_data->get_terrain_set());
+ } else {
+ text = "-";
+ }
+ Vector2 string_size = font->get_string_size(text);
+ p_canvas_item->draw_string(font, p_transform.xform(position) + Vector2i(-string_size.x / 2, string_size.y / 2), text, HALIGN_CENTER, string_size.x, -1, color, 1, Color(0, 0, 0, 1));
+ }
+ }
+ }
+ p_canvas_item->draw_set_transform_matrix(Transform2D());
+
+ if (drag_type == DRAG_TYPE_PAINT_TERRAIN_SET_RECT) {
+ // Draw selection rectangle.
+ Color grid_color = EditorSettings::get_singleton()->get("editors/tiles_editor/grid_color");
+ Color selection_color = Color().from_hsv(Math::fposmod(grid_color.get_h() + 0.5, 1.0), grid_color.get_s(), grid_color.get_v(), 1.0);
+
+ p_canvas_item->draw_set_transform_matrix(p_transform);
- Color color = p_canvas_item->get_tree()->get_debug_navigation_color();
+ Rect2i rect;
+ rect.set_position(p_tile_atlas_view->get_atlas_tile_coords_at_pos(drag_start_pos));
+ rect.set_end(p_tile_atlas_view->get_atlas_tile_coords_at_pos(p_transform.affine_inverse().xform(p_canvas_item->get_local_mouse_position())));
+ rect = rect.abs();
- RandomPCG rand;
- for (int i = 0; i < navigation_polygon->get_polygon_count(); i++) {
- // An array of vertices for this polygon.
- Vector<int> polygon = navigation_polygon->get_polygon(i);
- Vector<Vector2> vertices;
- vertices.resize(polygon.size());
+ Set<TileMapCell> edited;
+ for (int x = rect.get_position().x; x <= rect.get_end().x; x++) {
+ for (int y = rect.get_position().y; y <= rect.get_end().y; y++) {
+ Vector2i coords = Vector2i(x, y);
+ coords = p_tile_set_atlas_source->get_tile_at_coords(coords);
+ if (coords != TileSetSource::INVALID_ATLAS_COORDS) {
+ TileMapCell cell;
+ cell.source_id = 0;
+ cell.set_atlas_coords(coords);
+ cell.alternative_tile = 0;
+ edited.insert(cell);
+ }
+ }
+ }
+
+ for (Set<TileMapCell>::Element *E = edited.front(); E; E = E->next()) {
+ Vector2i coords = E->get().get_atlas_coords();
+ p_canvas_item->draw_rect(p_tile_set_atlas_source->get_tile_texture_region(coords), selection_color, false);
+ }
+ p_canvas_item->draw_set_transform_matrix(Transform2D());
+ } else if (drag_type == DRAG_TYPE_PAINT_TERRAIN_BITS_RECT) {
+ // Highlight selected peering bits.
+ Dictionary painted = Dictionary(drag_painted_value);
+ int terrain_set = int(painted["terrain_set"]);
+
+ Rect2i rect;
+ rect.set_position(p_tile_atlas_view->get_atlas_tile_coords_at_pos(drag_start_pos));
+ rect.set_end(p_tile_atlas_view->get_atlas_tile_coords_at_pos(p_transform.affine_inverse().xform(p_canvas_item->get_local_mouse_position())));
+ rect = rect.abs();
+
+ Set<TileMapCell> edited;
+ for (int x = rect.get_position().x; x <= rect.get_end().x; x++) {
+ for (int y = rect.get_position().y; y <= rect.get_end().y; y++) {
+ Vector2i coords = Vector2i(x, y);
+ coords = p_tile_set_atlas_source->get_tile_at_coords(coords);
+ if (coords != TileSetSource::INVALID_ATLAS_COORDS) {
+ TileData *tile_data = Object::cast_to<TileData>(p_tile_set_atlas_source->get_tile_data(coords, 0));
+ if (tile_data->get_terrain_set() == terrain_set) {
+ TileMapCell cell;
+ cell.source_id = 0;
+ cell.set_atlas_coords(coords);
+ cell.alternative_tile = 0;
+ edited.insert(cell);
+ }
+ }
+ }
+ }
+
+ Vector2 end = p_transform.affine_inverse().xform(p_canvas_item->get_local_mouse_position());
+ Vector<Point2> mouse_pos_rect_polygon;
+ mouse_pos_rect_polygon.push_back(drag_start_pos);
+ mouse_pos_rect_polygon.push_back(Vector2(end.x, drag_start_pos.y));
+ mouse_pos_rect_polygon.push_back(end);
+ mouse_pos_rect_polygon.push_back(Vector2(drag_start_pos.x, end.y));
+
+ Vector<Color> color;
+ color.push_back(Color(1.0, 1.0, 1.0, 0.5));
+
+ p_canvas_item->draw_set_transform_matrix(p_transform);
+
+ for (Set<TileMapCell>::Element *E = edited.front(); E; E = E->next()) {
+ Vector2i coords = E->get().get_atlas_coords();
+
+ Rect2i texture_region = p_tile_set_atlas_source->get_tile_texture_region(coords);
+ Vector2i position = (texture_region.position + texture_region.get_end()) / 2 + p_tile_set_atlas_source->get_tile_effective_texture_offset(coords, 0);
+
+ for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) {
+ TileSet::CellNeighbor bit = TileSet::CellNeighbor(i);
+ if (tile_set->is_valid_peering_bit_terrain(terrain_set, bit)) {
+ Vector<Vector2> polygon = tile_set->get_terrain_bit_polygon(terrain_set, bit);
for (int j = 0; j < polygon.size(); j++) {
- ERR_FAIL_INDEX(polygon[j], verts.size());
- vertices.write[j] = verts[polygon[j]];
+ polygon.write[j] += position;
+ }
+ if (!Geometry2D::intersect_polygons(polygon, mouse_pos_rect_polygon).is_empty()) {
+ // Draw bit.
+ p_canvas_item->draw_polygon(polygon, color);
+ }
+ }
+ }
+ }
+
+ p_canvas_item->draw_set_transform_matrix(Transform2D());
+ }
+}
+
+void TileDataTerrainsEditor::forward_draw_over_alternatives(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) {
+ ERR_FAIL_COND(!tile_set.is_valid());
+
+ // Draw the hovered terrain bit, or the whole tile if it has the wrong terrain set.
+ Vector2i hovered_coords = TileSetSource::INVALID_ATLAS_COORDS;
+ int hovered_alternative = TileSetSource::INVALID_TILE_ALTERNATIVE;
+ if (drag_type == DRAG_TYPE_NONE) {
+ Vector2i mouse_pos = p_transform.affine_inverse().xform(p_canvas_item->get_local_mouse_position());
+ Vector3i hovered = p_tile_atlas_view->get_alternative_tile_at_pos(mouse_pos);
+ hovered_coords = Vector2i(hovered.x, hovered.y);
+ hovered_alternative = hovered.z;
+ if (hovered_coords != TileSetSource::INVALID_ATLAS_COORDS) {
+ TileData *tile_data = Object::cast_to<TileData>(p_tile_set_atlas_source->get_tile_data(hovered_coords, hovered_alternative));
+ int terrain_set = tile_data->get_terrain_set();
+ Rect2i texture_region = p_tile_atlas_view->get_alternative_tile_rect(hovered_coords, hovered_alternative);
+ Vector2i position = (texture_region.position + texture_region.get_end()) / 2 + p_tile_set_atlas_source->get_tile_effective_texture_offset(hovered_coords, hovered_alternative);
+
+ if (terrain_set == int(dummy_object->get("terrain_set"))) {
+ // Draw hovered bit.
+ Transform2D xform;
+ xform.set_origin(position);
+
+ Vector<Color> color;
+ color.push_back(Color(1.0, 1.0, 1.0, 0.5));
+
+ for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) {
+ TileSet::CellNeighbor bit = TileSet::CellNeighbor(i);
+ if (tile_set->is_valid_peering_bit_terrain(terrain_set, bit)) {
+ Vector<Vector2> polygon = tile_set->get_terrain_bit_polygon(terrain_set, bit);
+ if (Geometry2D::is_point_in_polygon(xform.affine_inverse().xform(mouse_pos), polygon)) {
+ p_canvas_item->draw_set_transform_matrix(p_transform * xform);
+ p_canvas_item->draw_polygon(polygon, color);
+ }
+ }
+ }
+ } else {
+ // Draw hovered tile.
+ Vector2i tile_size = tile_set->get_tile_size();
+ Rect2i rect = p_transform.xform(Rect2i(position - tile_size / 2, tile_size));
+ tile_set->draw_tile_shape(p_canvas_item, rect, Color(1.0, 1.0, 1.0, 0.5), true);
+ }
+ }
+ }
+
+ // Dim terrains with wrong terrain set.
+ Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font("bold", "EditorFonts");
+ for (int i = 0; i < p_tile_set_atlas_source->get_tiles_count(); i++) {
+ Vector2i coords = p_tile_set_atlas_source->get_tile_id(i);
+ for (int j = 1; j < p_tile_set_atlas_source->get_alternative_tiles_count(coords); j++) {
+ int alternative_tile = p_tile_set_atlas_source->get_alternative_tile_id(coords, j);
+ if (coords != hovered_coords || alternative_tile != hovered_alternative) {
+ TileData *tile_data = Object::cast_to<TileData>(p_tile_set_atlas_source->get_tile_data(coords, alternative_tile));
+ if (tile_data->get_terrain_set() != int(dummy_object->get("terrain_set"))) {
+ // Dimming
+ p_canvas_item->draw_set_transform_matrix(p_transform);
+ Rect2i rect = p_tile_atlas_view->get_alternative_tile_rect(coords, alternative_tile);
+ p_canvas_item->draw_rect(rect, Color(0.0, 0.0, 0.0, 0.3));
+
+ // Text
+ p_canvas_item->draw_set_transform_matrix(Transform2D());
+ Rect2i texture_region = p_tile_atlas_view->get_alternative_tile_rect(coords, alternative_tile);
+ Vector2i position = (texture_region.position + texture_region.get_end()) / 2 + p_tile_set_atlas_source->get_tile_effective_texture_offset(coords, 0);
+
+ Color color = Color(1, 1, 1);
+ String text;
+ if (tile_data->get_terrain_set() >= 0) {
+ text = vformat("%d", tile_data->get_terrain_set());
+ } else {
+ text = "-";
+ }
+ Vector2 string_size = font->get_string_size(text);
+ p_canvas_item->draw_string(font, p_transform.xform(position) + Vector2i(-string_size.x / 2, string_size.y / 2), text, HALIGN_CENTER, string_size.x, -1, color, 1, Color(0, 0, 0, 1));
+ }
+ }
+ }
+ }
+
+ p_canvas_item->draw_set_transform_matrix(Transform2D());
+}
+
+void TileDataTerrainsEditor::forward_painting_atlas_gui_input(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, const Ref<InputEvent> &p_event) {
+ Ref<InputEventMouseMotion> mm = p_event;
+ if (mm.is_valid()) {
+ if (drag_type == DRAG_TYPE_PAINT_TERRAIN_SET) {
+ Vector<Vector2i> line = Geometry2D::bresenham_line(p_tile_atlas_view->get_atlas_tile_coords_at_pos(drag_last_pos), p_tile_atlas_view->get_atlas_tile_coords_at_pos(mm->get_position()));
+ for (int i = 0; i < line.size(); i++) {
+ Vector2i coords = p_tile_set_atlas_source->get_tile_at_coords(line[i]);
+ if (coords != TileSetSource::INVALID_ATLAS_COORDS) {
+ int terrain_set = drag_painted_value;
+ TileMapCell cell;
+ cell.source_id = 0;
+ cell.set_atlas_coords(coords);
+ cell.alternative_tile = 0;
+
+ // Save the old terrain_set and terrains bits.
+ TileData *tile_data = Object::cast_to<TileData>(p_tile_set_atlas_source->get_tile_data(coords, 0));
+ if (!drag_modified.has(cell)) {
+ Dictionary dict;
+ dict["terrain_set"] = tile_data->get_terrain_set();
+ Array array;
+ for (int j = 0; j < TileSet::CELL_NEIGHBOR_MAX; j++) {
+ TileSet::CellNeighbor bit = TileSet::CellNeighbor(j);
+ array.push_back(tile_data->is_valid_peering_bit_terrain(bit) ? tile_data->get_peering_bit_terrain(bit) : -1);
+ }
+ dict["terrain_peering_bits"] = array;
+ drag_modified[cell] = dict;
+ }
+
+ // Set the terrain_set.
+ tile_data->set_terrain_set(terrain_set);
+ }
+ }
+ drag_last_pos = mm->get_position();
+ } else if (drag_type == DRAG_TYPE_PAINT_TERRAIN_BITS) {
+ int terrain_set = Dictionary(drag_painted_value)["terrain_set"];
+ int terrain = Dictionary(drag_painted_value)["terrain"];
+ Vector<Vector2i> line = Geometry2D::bresenham_line(p_tile_atlas_view->get_atlas_tile_coords_at_pos(drag_last_pos), p_tile_atlas_view->get_atlas_tile_coords_at_pos(mm->get_position()));
+ for (int i = 0; i < line.size(); i++) {
+ Vector2i coords = p_tile_set_atlas_source->get_tile_at_coords(line[i]);
+ if (coords != TileSetSource::INVALID_ATLAS_COORDS) {
+ TileMapCell cell;
+ cell.source_id = 0;
+ cell.set_atlas_coords(coords);
+ cell.alternative_tile = 0;
+
+ TileData *tile_data = Object::cast_to<TileData>(p_tile_set_atlas_source->get_tile_data(coords, 0));
+ if (tile_data->get_terrain_set() == terrain_set) {
+ // Save the old terrain_set and terrains bits.
+ if (!drag_modified.has(cell)) {
+ Dictionary dict;
+ dict["terrain_set"] = tile_data->get_terrain_set();
+ Array array;
+ for (int j = 0; j < TileSet::CELL_NEIGHBOR_MAX; j++) {
+ TileSet::CellNeighbor bit = TileSet::CellNeighbor(j);
+ array.push_back(tile_data->is_valid_peering_bit_terrain(bit) ? tile_data->get_peering_bit_terrain(bit) : -1);
+ }
+ dict["terrain_peering_bits"] = array;
+ drag_modified[cell] = dict;
+ }
+
+ // Set the terrains bits.
+ Rect2i texture_region = p_tile_set_atlas_source->get_tile_texture_region(coords);
+ Vector2i position = (texture_region.position + texture_region.get_end()) / 2 + p_tile_set_atlas_source->get_tile_effective_texture_offset(coords, 0);
+ for (int j = 0; j < TileSet::CELL_NEIGHBOR_MAX; j++) {
+ TileSet::CellNeighbor bit = TileSet::CellNeighbor(j);
+ if (tile_data->is_valid_peering_bit_terrain(bit)) {
+ Vector<Vector2> polygon = tile_set->get_terrain_bit_polygon(tile_data->get_terrain_set(), bit);
+ if (Geometry2D::is_segment_intersecting_polygon(mm->get_position() - position, drag_last_pos - position, polygon)) {
+ tile_data->set_peering_bit_terrain(bit, terrain);
+ }
+ }
+ }
+ }
+ }
+ }
+ drag_last_pos = mm->get_position();
+ }
+ }
+
+ Ref<InputEventMouseButton> mb = p_event;
+ if (mb.is_valid()) {
+ if (mb->get_button_index() == MOUSE_BUTTON_LEFT) {
+ if (mb->is_pressed()) {
+ if (picker_button->is_pressed()) {
+ Vector2i coords = p_tile_atlas_view->get_atlas_tile_coords_at_pos(mb->get_position());
+ coords = p_tile_set_atlas_source->get_tile_at_coords(coords);
+ if (coords != TileSetSource::INVALID_ATLAS_COORDS) {
+ TileData *tile_data = Object::cast_to<TileData>(p_tile_set_atlas_source->get_tile_data(coords, 0));
+ int terrain_set = tile_data->get_terrain_set();
+ Rect2i texture_region = p_tile_set_atlas_source->get_tile_texture_region(coords);
+ Vector2i position = (texture_region.position + texture_region.get_end()) / 2 + p_tile_set_atlas_source->get_tile_effective_texture_offset(coords, 0);
+ dummy_object->set("terrain_set", terrain_set);
+ dummy_object->set("terrain", -1);
+ for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) {
+ TileSet::CellNeighbor bit = TileSet::CellNeighbor(i);
+ if (tile_set->is_valid_peering_bit_terrain(terrain_set, bit)) {
+ Vector<Vector2> polygon = tile_set->get_terrain_bit_polygon(terrain_set, bit);
+ if (Geometry2D::is_point_in_polygon(mb->get_position() - position, polygon)) {
+ dummy_object->set("terrain", tile_data->get_peering_bit_terrain(bit));
+ }
+ }
+ }
+ terrain_set_property_editor->update_property();
+ _update_terrain_selector();
+ picker_button->set_pressed(false);
+ }
+ } else {
+ Vector2i coords = p_tile_atlas_view->get_atlas_tile_coords_at_pos(mb->get_position());
+ coords = p_tile_set_atlas_source->get_tile_at_coords(coords);
+ TileData *tile_data = nullptr;
+ if (coords != TileSetAtlasSource::INVALID_ATLAS_COORDS) {
+ tile_data = Object::cast_to<TileData>(p_tile_set_atlas_source->get_tile_data(coords, 0));
+ }
+ int terrain_set = int(dummy_object->get("terrain_set"));
+ int terrain = int(dummy_object->get("terrain"));
+ if (terrain_set == -1 || !tile_data || tile_data->get_terrain_set() != terrain_set) {
+ if (mb->is_ctrl_pressed()) {
+ // Paint terrain set with rect.
+ drag_type = DRAG_TYPE_PAINT_TERRAIN_SET_RECT;
+ drag_modified.clear();
+ drag_painted_value = terrain_set;
+ drag_start_pos = mb->get_position();
+ } else {
+ // Paint terrain set.
+ drag_type = DRAG_TYPE_PAINT_TERRAIN_SET;
+ drag_modified.clear();
+ drag_painted_value = terrain_set;
+
+ if (coords != TileSetSource::INVALID_ATLAS_COORDS) {
+ TileMapCell cell;
+ cell.source_id = 0;
+ cell.set_atlas_coords(coords);
+ cell.alternative_tile = 0;
+
+ // Save the old terrain_set and terrains bits.
+ Dictionary dict;
+ dict["terrain_set"] = tile_data->get_terrain_set();
+ Array array;
+ for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) {
+ TileSet::CellNeighbor bit = TileSet::CellNeighbor(i);
+ array.push_back(tile_data->is_valid_peering_bit_terrain(bit) ? tile_data->get_peering_bit_terrain(bit) : -1);
+ }
+ dict["terrain_peering_bits"] = array;
+ drag_modified[cell] = dict;
+
+ // Set the terrain_set.
+ tile_data->set_terrain_set(terrain_set);
+ }
+ drag_last_pos = mb->get_position();
+ }
+ } else if (tile_data && tile_data->get_terrain_set() == terrain_set) {
+ if (mb->is_ctrl_pressed()) {
+ // Paint terrain set with rect.
+ drag_type = DRAG_TYPE_PAINT_TERRAIN_BITS_RECT;
+ drag_modified.clear();
+ Dictionary painted_dict;
+ painted_dict["terrain_set"] = terrain_set;
+ painted_dict["terrain"] = terrain;
+ drag_painted_value = painted_dict;
+ drag_start_pos = mb->get_position();
+ } else {
+ // Paint terrain bits.
+ drag_type = DRAG_TYPE_PAINT_TERRAIN_BITS;
+ drag_modified.clear();
+ Dictionary painted_dict;
+ painted_dict["terrain_set"] = terrain_set;
+ painted_dict["terrain"] = terrain;
+ drag_painted_value = painted_dict;
+
+ if (coords != TileSetSource::INVALID_ATLAS_COORDS) {
+ TileMapCell cell;
+ cell.source_id = 0;
+ cell.set_atlas_coords(coords);
+ cell.alternative_tile = 0;
+
+ // Save the old terrain_set and terrains bits.
+ Dictionary dict;
+ dict["terrain_set"] = tile_data->get_terrain_set();
+ Array array;
+ for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) {
+ TileSet::CellNeighbor bit = TileSet::CellNeighbor(i);
+ array.push_back(tile_data->is_valid_peering_bit_terrain(bit) ? tile_data->get_peering_bit_terrain(bit) : -1);
+ }
+ dict["terrain_peering_bits"] = array;
+ drag_modified[cell] = dict;
+
+ // Set the terrain bit.
+ Rect2i texture_region = p_tile_set_atlas_source->get_tile_texture_region(coords);
+ Vector2i position = (texture_region.position + texture_region.get_end()) / 2 + p_tile_set_atlas_source->get_tile_effective_texture_offset(coords, 0);
+
+ for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) {
+ TileSet::CellNeighbor bit = TileSet::CellNeighbor(i);
+ if (tile_set->is_valid_peering_bit_terrain(terrain_set, bit)) {
+ Vector<Vector2> polygon = tile_set->get_terrain_bit_polygon(terrain_set, bit);
+ if (Geometry2D::is_point_in_polygon(mb->get_position() - position, polygon)) {
+ tile_data->set_peering_bit_terrain(bit, terrain);
+ }
+ }
+ }
+ }
+ drag_last_pos = mb->get_position();
+ }
+ }
+ }
+ } else {
+ if (drag_type == DRAG_TYPE_PAINT_TERRAIN_SET_RECT) {
+ Rect2i rect;
+ rect.set_position(p_tile_atlas_view->get_atlas_tile_coords_at_pos(drag_start_pos));
+ rect.set_end(p_tile_atlas_view->get_atlas_tile_coords_at_pos(mb->get_position()));
+ rect = rect.abs();
+
+ Set<TileMapCell> edited;
+ for (int x = rect.get_position().x; x <= rect.get_end().x; x++) {
+ for (int y = rect.get_position().y; y <= rect.get_end().y; y++) {
+ Vector2i coords = Vector2i(x, y);
+ coords = p_tile_set_atlas_source->get_tile_at_coords(coords);
+ if (coords != TileSetSource::INVALID_ATLAS_COORDS) {
+ TileMapCell cell;
+ cell.source_id = 0;
+ cell.set_atlas_coords(coords);
+ cell.alternative_tile = 0;
+ edited.insert(cell);
+ }
+ }
+ }
+ undo_redo->create_action(TTR("Painting Terrain Set"));
+ for (Set<TileMapCell>::Element *E = edited.front(); E; E = E->next()) {
+ Vector2i coords = E->get().get_atlas_coords();
+ TileData *tile_data = Object::cast_to<TileData>(p_tile_set_atlas_source->get_tile_data(coords, 0));
+ undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrain_set", coords.x, coords.y, E->get().alternative_tile), tile_data->get_terrain_set());
+ undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrain_set", coords.x, coords.y, E->get().alternative_tile), drag_painted_value);
+ for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) {
+ TileSet::CellNeighbor bit = TileSet::CellNeighbor(i);
+ if (tile_data->is_valid_peering_bit_terrain(bit)) {
+ undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]), coords.x, coords.y, E->get().alternative_tile), tile_data->get_peering_bit_terrain(bit));
+ }
+ }
+ }
+ undo_redo->commit_action(true);
+ drag_type = DRAG_TYPE_NONE;
+ } else if (drag_type == DRAG_TYPE_PAINT_TERRAIN_SET) {
+ undo_redo->create_action(TTR("Painting Terrain Set"));
+ for (Map<TileMapCell, Variant>::Element *E = drag_modified.front(); E; E = E->next()) {
+ Dictionary dict = E->get();
+ Vector2i coords = E->key().get_atlas_coords();
+ undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrain_set", coords.x, coords.y, E->key().alternative_tile), drag_painted_value);
+ undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrain_set", coords.x, coords.y, E->key().alternative_tile), dict["terrain_set"]);
+ Array array = dict["terrain_peering_bits"];
+ for (int i = 0; i < array.size(); i++) {
+ TileSet::CellNeighbor bit = TileSet::CellNeighbor(i);
+ if (tile_set->is_valid_peering_bit_terrain(dict["terrain_set"], bit)) {
+ undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]), coords.x, coords.y, E->key().alternative_tile), array[i]);
+ }
+ }
+ }
+ undo_redo->commit_action(false);
+ drag_type = DRAG_TYPE_NONE;
+ } else if (drag_type == DRAG_TYPE_PAINT_TERRAIN_BITS) {
+ Dictionary painted = Dictionary(drag_painted_value);
+ int terrain_set = int(painted["terrain_set"]);
+ int terrain = int(painted["terrain"]);
+ undo_redo->create_action(TTR("Painting Terrain"));
+ for (Map<TileMapCell, Variant>::Element *E = drag_modified.front(); E; E = E->next()) {
+ Dictionary dict = E->get();
+ Vector2i coords = E->key().get_atlas_coords();
+ Array array = dict["terrain_peering_bits"];
+ for (int i = 0; i < array.size(); i++) {
+ TileSet::CellNeighbor bit = TileSet::CellNeighbor(i);
+ if (tile_set->is_valid_peering_bit_terrain(terrain_set, bit)) {
+ undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]), coords.x, coords.y, E->key().alternative_tile), terrain);
+ }
+ if (tile_set->is_valid_peering_bit_terrain(dict["terrain_set"], bit)) {
+ undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]), coords.x, coords.y, E->key().alternative_tile), array[i]);
+ }
+ }
+ }
+ undo_redo->commit_action(false);
+ drag_type = DRAG_TYPE_NONE;
+ } else if (drag_type == DRAG_TYPE_PAINT_TERRAIN_BITS_RECT) {
+ Dictionary painted = Dictionary(drag_painted_value);
+ int terrain_set = int(painted["terrain_set"]);
+ int terrain = int(painted["terrain"]);
+
+ Rect2i rect;
+ rect.set_position(p_tile_atlas_view->get_atlas_tile_coords_at_pos(drag_start_pos));
+ rect.set_end(p_tile_atlas_view->get_atlas_tile_coords_at_pos(mb->get_position()));
+ rect = rect.abs();
+
+ Set<TileMapCell> edited;
+ for (int x = rect.get_position().x; x <= rect.get_end().x; x++) {
+ for (int y = rect.get_position().y; y <= rect.get_end().y; y++) {
+ Vector2i coords = Vector2i(x, y);
+ coords = p_tile_set_atlas_source->get_tile_at_coords(coords);
+ if (coords != TileSetSource::INVALID_ATLAS_COORDS) {
+ TileData *tile_data = Object::cast_to<TileData>(p_tile_set_atlas_source->get_tile_data(coords, 0));
+ if (tile_data->get_terrain_set() == terrain_set) {
+ TileMapCell cell;
+ cell.source_id = 0;
+ cell.set_atlas_coords(coords);
+ cell.alternative_tile = 0;
+ edited.insert(cell);
+ }
+ }
+ }
+ }
+
+ Vector<Point2> mouse_pos_rect_polygon;
+ mouse_pos_rect_polygon.push_back(drag_start_pos);
+ mouse_pos_rect_polygon.push_back(Vector2(mb->get_position().x, drag_start_pos.y));
+ mouse_pos_rect_polygon.push_back(mb->get_position());
+ mouse_pos_rect_polygon.push_back(Vector2(drag_start_pos.x, mb->get_position().y));
+
+ undo_redo->create_action(TTR("Painting Terrain"));
+ for (Set<TileMapCell>::Element *E = edited.front(); E; E = E->next()) {
+ Vector2i coords = E->get().get_atlas_coords();
+ TileData *tile_data = Object::cast_to<TileData>(p_tile_set_atlas_source->get_tile_data(coords, 0));
+
+ for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) {
+ TileSet::CellNeighbor bit = TileSet::CellNeighbor(i);
+ if (tile_set->is_valid_peering_bit_terrain(terrain_set, bit)) {
+ Rect2i texture_region = p_tile_set_atlas_source->get_tile_texture_region(coords);
+ Vector2i position = (texture_region.position + texture_region.get_end()) / 2 + p_tile_set_atlas_source->get_tile_effective_texture_offset(coords, 0);
+
+ Vector<Vector2> polygon = tile_set->get_terrain_bit_polygon(terrain_set, bit);
+ for (int j = 0; j < polygon.size(); j++) {
+ polygon.write[j] += position;
+ }
+ if (!Geometry2D::intersect_polygons(polygon, mouse_pos_rect_polygon).is_empty()) {
+ // Draw bit.
+ undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]), coords.x, coords.y, E->get().alternative_tile), terrain);
+ undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]), coords.x, coords.y, E->get().alternative_tile), tile_data->get_peering_bit_terrain(bit));
+ }
+ }
+ }
+ }
+ undo_redo->commit_action(true);
+ drag_type = DRAG_TYPE_NONE;
+ }
+ }
+ }
+ }
+}
+
+void TileDataTerrainsEditor::forward_painting_alternatives_gui_input(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, const Ref<InputEvent> &p_event) {
+ Ref<InputEventMouseMotion> mm = p_event;
+ if (mm.is_valid()) {
+ if (drag_type == DRAG_TYPE_PAINT_TERRAIN_SET) {
+ Vector3i tile = p_tile_atlas_view->get_alternative_tile_at_pos(mm->get_position());
+ Vector2i coords = Vector2i(tile.x, tile.y);
+ int alternative_tile = tile.z;
+
+ if (coords != TileSetSource::INVALID_ATLAS_COORDS) {
+ TileMapCell cell;
+ cell.source_id = 0;
+ cell.set_atlas_coords(coords);
+ cell.alternative_tile = alternative_tile;
+ TileData *tile_data = Object::cast_to<TileData>(p_tile_set_atlas_source->get_tile_data(coords, alternative_tile));
+ if (!drag_modified.has(cell)) {
+ Dictionary dict;
+ dict["terrain_set"] = tile_data->get_terrain_set();
+ Array array;
+ for (int j = 0; j < TileSet::CELL_NEIGHBOR_MAX; j++) {
+ TileSet::CellNeighbor bit = TileSet::CellNeighbor(j);
+ array.push_back(tile_data->is_valid_peering_bit_terrain(bit) ? tile_data->get_peering_bit_terrain(bit) : -1);
+ }
+ dict["terrain_peering_bits"] = array;
+ drag_modified[cell] = dict;
+ }
+ tile_data->set_terrain_set(drag_painted_value);
+ }
+
+ drag_last_pos = mm->get_position();
+ } else if (drag_type == DRAG_TYPE_PAINT_TERRAIN_BITS) {
+ Dictionary painted = Dictionary(drag_painted_value);
+ int terrain_set = int(painted["terrain_set"]);
+ int terrain = int(painted["terrain"]);
+
+ Vector3i tile = p_tile_atlas_view->get_alternative_tile_at_pos(mm->get_position());
+ Vector2i coords = Vector2i(tile.x, tile.y);
+ int alternative_tile = tile.z;
+
+ if (coords != TileSetSource::INVALID_ATLAS_COORDS) {
+ TileMapCell cell;
+ cell.source_id = 0;
+ cell.set_atlas_coords(coords);
+ cell.alternative_tile = alternative_tile;
+
+ // Save the old terrain_set and terrains bits.
+ TileData *tile_data = Object::cast_to<TileData>(p_tile_set_atlas_source->get_tile_data(coords, alternative_tile));
+ if (tile_data->get_terrain_set() == terrain_set) {
+ if (!drag_modified.has(cell)) {
+ Dictionary dict;
+ dict["terrain_set"] = tile_data->get_terrain_set();
+ Array array;
+ for (int j = 0; j < TileSet::CELL_NEIGHBOR_MAX; j++) {
+ TileSet::CellNeighbor bit = TileSet::CellNeighbor(j);
+ array.push_back(tile_data->is_valid_peering_bit_terrain(bit) ? tile_data->get_peering_bit_terrain(bit) : -1);
+ }
+ dict["terrain_peering_bits"] = array;
+ drag_modified[cell] = dict;
+ }
+
+ // Set the terrains bits.
+ Rect2i texture_region = p_tile_atlas_view->get_alternative_tile_rect(coords, alternative_tile);
+ Vector2i position = (texture_region.position + texture_region.get_end()) / 2 + p_tile_set_atlas_source->get_tile_effective_texture_offset(coords, alternative_tile);
+ for (int j = 0; j < TileSet::CELL_NEIGHBOR_MAX; j++) {
+ TileSet::CellNeighbor bit = TileSet::CellNeighbor(j);
+ if (tile_data->is_valid_peering_bit_terrain(bit)) {
+ Vector<Vector2> polygon = tile_set->get_terrain_bit_polygon(tile_data->get_terrain_set(), bit);
+ if (Geometry2D::is_segment_intersecting_polygon(mm->get_position() - position, drag_last_pos - position, polygon)) {
+ tile_data->set_peering_bit_terrain(bit, terrain);
+ }
+ }
+ }
+ }
+ }
+ drag_last_pos = mm->get_position();
+ }
+ }
+
+ Ref<InputEventMouseButton> mb = p_event;
+ if (mb.is_valid()) {
+ if (mb->get_button_index() == MOUSE_BUTTON_LEFT) {
+ if (mb->is_pressed()) {
+ if (picker_button->is_pressed()) {
+ Vector3i tile = p_tile_atlas_view->get_alternative_tile_at_pos(mb->get_position());
+ Vector2i coords = Vector2i(tile.x, tile.y);
+ int alternative_tile = tile.z;
+
+ if (coords != TileSetSource::INVALID_ATLAS_COORDS) {
+ TileData *tile_data = Object::cast_to<TileData>(p_tile_set_atlas_source->get_tile_data(coords, alternative_tile));
+ int terrain_set = tile_data->get_terrain_set();
+ Rect2i texture_region = p_tile_atlas_view->get_alternative_tile_rect(coords, alternative_tile);
+ Vector2i position = (texture_region.position + texture_region.get_end()) / 2 + p_tile_set_atlas_source->get_tile_effective_texture_offset(coords, alternative_tile);
+ dummy_object->set("terrain_set", terrain_set);
+ dummy_object->set("terrain", -1);
+ for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) {
+ TileSet::CellNeighbor bit = TileSet::CellNeighbor(i);
+ if (tile_set->is_valid_peering_bit_terrain(terrain_set, bit)) {
+ Vector<Vector2> polygon = tile_set->get_terrain_bit_polygon(terrain_set, bit);
+ if (Geometry2D::is_point_in_polygon(mb->get_position() - position, polygon)) {
+ dummy_object->set("terrain", tile_data->get_peering_bit_terrain(bit));
+ }
+ }
+ }
+ terrain_set_property_editor->update_property();
+ _update_terrain_selector();
+ picker_button->set_pressed(false);
}
+ } else {
+ int terrain_set = int(dummy_object->get("terrain_set"));
+ int terrain = int(dummy_object->get("terrain"));
+
+ Vector3i tile = p_tile_atlas_view->get_alternative_tile_at_pos(mb->get_position());
+ Vector2i coords = Vector2i(tile.x, tile.y);
+ int alternative_tile = tile.z;
- // Generate the polygon color, slightly randomly modified from the settings one.
- Color random_variation_color;
- random_variation_color.set_hsv(color.get_h() + rand.random(-1.0, 1.0) * 0.05, color.get_s(), color.get_v() + rand.random(-1.0, 1.0) * 0.1);
- random_variation_color.a = color.a;
- Vector<Color> colors;
- colors.push_back(random_variation_color);
+ TileData *tile_data = Object::cast_to<TileData>(p_tile_set_atlas_source->get_tile_data(coords, alternative_tile));
- RenderingServer::get_singleton()->canvas_item_add_polygon(p_canvas_item->get_canvas_item(), vertices, colors);
+ if (terrain_set == -1 || !tile_data || tile_data->get_terrain_set() != terrain_set) {
+ drag_type = DRAG_TYPE_PAINT_TERRAIN_SET;
+ drag_modified.clear();
+ drag_painted_value = int(dummy_object->get("terrain_set"));
+ if (coords != TileSetSource::INVALID_ATLAS_COORDS) {
+ TileMapCell cell;
+ cell.source_id = 0;
+ cell.set_atlas_coords(coords);
+ cell.alternative_tile = alternative_tile;
+ Dictionary dict;
+ dict["terrain_set"] = tile_data->get_terrain_set();
+ Array array;
+ for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) {
+ TileSet::CellNeighbor bit = TileSet::CellNeighbor(i);
+ array.push_back(tile_data->is_valid_peering_bit_terrain(bit) ? tile_data->get_peering_bit_terrain(bit) : -1);
+ }
+ dict["terrain_peering_bits"] = array;
+ drag_modified[cell] = dict;
+ tile_data->set_terrain_set(drag_painted_value);
+ }
+ drag_last_pos = mb->get_position();
+ } else if (tile_data && tile_data->get_terrain_set() == terrain_set) {
+ // Paint terrain bits.
+ drag_type = DRAG_TYPE_PAINT_TERRAIN_BITS;
+ drag_modified.clear();
+ Dictionary painted_dict;
+ painted_dict["terrain_set"] = terrain_set;
+ painted_dict["terrain"] = terrain;
+ drag_painted_value = painted_dict;
+
+ if (coords != TileSetSource::INVALID_ATLAS_COORDS) {
+ TileMapCell cell;
+ cell.source_id = 0;
+ cell.set_atlas_coords(coords);
+ cell.alternative_tile = alternative_tile;
+
+ // Save the old terrain_set and terrains bits.
+ Dictionary dict;
+ dict["terrain_set"] = tile_data->get_terrain_set();
+ Array array;
+ for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) {
+ TileSet::CellNeighbor bit = TileSet::CellNeighbor(i);
+ array.push_back(tile_data->is_valid_peering_bit_terrain(bit) ? tile_data->get_peering_bit_terrain(bit) : -1);
+ }
+ dict["terrain_peering_bits"] = array;
+ drag_modified[cell] = dict;
+
+ // Set the terrain bit.
+ Rect2i texture_region = p_tile_atlas_view->get_alternative_tile_rect(coords, alternative_tile);
+ Vector2i position = (texture_region.position + texture_region.get_end()) / 2 + p_tile_set_atlas_source->get_tile_effective_texture_offset(coords, alternative_tile);
+ for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) {
+ TileSet::CellNeighbor bit = TileSet::CellNeighbor(i);
+ if (tile_set->is_valid_peering_bit_terrain(terrain_set, bit)) {
+ Vector<Vector2> polygon = tile_set->get_terrain_bit_polygon(terrain_set, bit);
+ if (Geometry2D::is_point_in_polygon(mb->get_position() - position, polygon)) {
+ tile_data->set_peering_bit_terrain(bit, terrain);
+ }
+ }
+ }
+ }
+ drag_last_pos = mb->get_position();
+ }
+ }
+ } else {
+ if (drag_type == DRAG_TYPE_PAINT_TERRAIN_SET) {
+ undo_redo->create_action(TTR("Painting Tiles Property"));
+ for (Map<TileMapCell, Variant>::Element *E = drag_modified.front(); E; E = E->next()) {
+ Dictionary dict = E->get();
+ Vector2i coords = E->key().get_atlas_coords();
+ undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrain_set", coords.x, coords.y, E->key().alternative_tile), dict["terrain_set"]);
+ undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrain_set", coords.x, coords.y, E->key().alternative_tile), drag_painted_value);
+ Array array = dict["terrain_peering_bits"];
+ for (int i = 0; i < array.size(); i++) {
+ undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]), coords.x, coords.y, E->key().alternative_tile), array[i]);
+ }
+ }
+ undo_redo->commit_action(false);
+ drag_type = DRAG_TYPE_NONE;
+ } else if (drag_type == DRAG_TYPE_PAINT_TERRAIN_BITS) {
+ Dictionary painted = Dictionary(drag_painted_value);
+ int terrain_set = int(painted["terrain_set"]);
+ int terrain = int(painted["terrain"]);
+ undo_redo->create_action(TTR("Painting Terrain"));
+ for (Map<TileMapCell, Variant>::Element *E = drag_modified.front(); E; E = E->next()) {
+ Dictionary dict = E->get();
+ Vector2i coords = E->key().get_atlas_coords();
+ Array array = dict["terrain_peering_bits"];
+ for (int i = 0; i < array.size(); i++) {
+ TileSet::CellNeighbor bit = TileSet::CellNeighbor(i);
+ if (tile_set->is_valid_peering_bit_terrain(terrain_set, bit)) {
+ undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]), coords.x, coords.y, E->key().alternative_tile), terrain);
+ }
+ if (tile_set->is_valid_peering_bit_terrain(dict["terrain_set"], bit)) {
+ undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]), coords.x, coords.y, E->key().alternative_tile), array[i]);
+ }
+ }
+ }
+ undo_redo->commit_action(false);
+ drag_type = DRAG_TYPE_NONE;
}
}
+ }
+ }
+}
+
+void TileDataTerrainsEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected) {
+ TileData *tile_data = _get_tile_data(p_cell);
+ ERR_FAIL_COND(!tile_data);
- RenderingServer::get_singleton()->canvas_item_add_set_transform(p_canvas_item->get_canvas_item(), Transform2D());
+ tile_set->draw_terrains(p_canvas_item, p_transform, tile_data);
+}
+
+void TileDataTerrainsEditor::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED:
+ picker_button->set_icon(get_theme_icon("ColorPick", "EditorIcons"));
+ break;
+ default:
+ break;
+ }
+}
+
+TileDataTerrainsEditor::TileDataTerrainsEditor() {
+ label = memnew(Label);
+ label->set_text("Painting:");
+ add_child(label);
+
+ // Toolbar
+ toolbar->add_child(memnew(VSeparator));
+
+ picker_button = memnew(Button);
+ picker_button->set_flat(true);
+ picker_button->set_toggle_mode(true);
+ picker_button->set_shortcut(ED_SHORTCUT("tiles_editor/picker", "Picker", KEY_P));
+ toolbar->add_child(picker_button);
+
+ // Setup
+ dummy_object->add_dummy_property("terrain_set");
+ dummy_object->set("terrain_set", -1);
+ dummy_object->add_dummy_property("terrain");
+ dummy_object->set("terrain", -1);
+
+ // Get the default value for the type.
+ terrain_set_property_editor = memnew(EditorPropertyEnum);
+ terrain_set_property_editor->set_object_and_property(dummy_object, "terrain_set");
+ terrain_set_property_editor->set_label("Terrain Set");
+ terrain_set_property_editor->connect("property_changed", callable_mp(this, &TileDataTerrainsEditor::_property_value_changed).unbind(1));
+ add_child(terrain_set_property_editor);
+
+ terrain_property_editor = memnew(EditorPropertyEnum);
+ terrain_property_editor->set_object_and_property(dummy_object, "terrain");
+ terrain_property_editor->set_label("Terrain");
+ terrain_property_editor->connect("property_changed", callable_mp(this, &TileDataTerrainsEditor::_property_value_changed).unbind(1));
+ add_child(terrain_property_editor);
+}
+
+TileDataTerrainsEditor::~TileDataTerrainsEditor() {
+ toolbar->queue_delete();
+ memdelete(dummy_object);
+}
+
+Variant TileDataNavigationEditor::_get_painted_value() {
+ Ref<NavigationPolygon> navigation_polygon;
+ navigation_polygon.instantiate();
+
+ for (int i = 0; i < polygon_editor->get_polygon_count(); i++) {
+ Vector<Vector2> polygon = polygon_editor->get_polygon(i);
+ navigation_polygon->add_outline(polygon);
+ }
+
+ navigation_polygon->make_polygons_from_outlines();
+ return navigation_polygon;
+}
+
+void TileDataNavigationEditor::_set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) {
+ TileData *tile_data = Object::cast_to<TileData>(p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile));
+ ERR_FAIL_COND(!tile_data);
+
+ Ref<NavigationPolygon> navigation_polygon = tile_data->get_navigation_polygon(navigation_layer);
+ polygon_editor->clear_polygons();
+ if (navigation_polygon.is_valid()) {
+ for (int i = 0; i < navigation_polygon->get_outline_count(); i++) {
+ polygon_editor->add_polygon(navigation_polygon->get_outline(i));
+ }
+ }
+ polygon_editor->set_background(p_tile_set_atlas_source->get_texture(), p_tile_set_atlas_source->get_tile_texture_region(p_coords), p_tile_set_atlas_source->get_tile_effective_texture_offset(p_coords, p_alternative_tile), tile_data->get_flip_h(), tile_data->get_flip_v(), tile_data->get_transpose(), tile_data->get_modulate());
+}
+
+void TileDataNavigationEditor::_set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value) {
+ TileData *tile_data = Object::cast_to<TileData>(p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile));
+ ERR_FAIL_COND(!tile_data);
+ Ref<NavigationPolygon> navigation_polygon = p_value;
+ tile_data->set_navigation_polygon(navigation_layer, navigation_polygon);
+
+ polygon_editor->set_background(p_tile_set_atlas_source->get_texture(), p_tile_set_atlas_source->get_tile_texture_region(p_coords), p_tile_set_atlas_source->get_tile_effective_texture_offset(p_coords, p_alternative_tile), tile_data->get_flip_h(), tile_data->get_flip_v(), tile_data->get_transpose(), tile_data->get_modulate());
+}
+
+Variant TileDataNavigationEditor::_get_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) {
+ TileData *tile_data = Object::cast_to<TileData>(p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile));
+ ERR_FAIL_COND_V(!tile_data, Variant());
+ return tile_data->get_navigation_polygon(navigation_layer);
+}
+
+void TileDataNavigationEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map<TileMapCell, Variant> p_previous_values, Variant p_new_value) {
+ for (Map<TileMapCell, Variant>::Element *E = p_previous_values.front(); E; E = E->next()) {
+ Vector2i coords = E->key().get_atlas_coords();
+ undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/navigation_layer_%d/polygon", coords.x, coords.y, E->key().alternative_tile, navigation_layer), E->get());
+ undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/navigation_layer_%d/polygon", coords.x, coords.y, E->key().alternative_tile, navigation_layer), p_new_value);
+ }
+}
+
+void TileDataNavigationEditor::_tile_set_changed() {
+ polygon_editor->set_tile_set(tile_set);
+}
+
+void TileDataNavigationEditor::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ polygon_editor->set_polygons_color(get_tree()->get_debug_navigation_color());
+ break;
+ default:
+ break;
+ }
+}
+
+TileDataNavigationEditor::TileDataNavigationEditor() {
+ polygon_editor = memnew(GenericTilePolygonEditor);
+ polygon_editor->set_multiple_polygon_mode(true);
+ add_child(polygon_editor);
+}
+
+void TileDataNavigationEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected) {
+ TileData *tile_data = _get_tile_data(p_cell);
+ ERR_FAIL_COND(!tile_data);
+
+ // Draw all shapes.
+ RenderingServer::get_singleton()->canvas_item_add_set_transform(p_canvas_item->get_canvas_item(), p_transform);
+
+ Ref<NavigationPolygon> navigation_polygon = tile_data->get_navigation_polygon(navigation_layer);
+ if (navigation_polygon.is_valid()) {
+ Vector<Vector2> verts = navigation_polygon->get_vertices();
+ if (verts.size() < 3) {
+ return;
+ }
+
+ Color color = p_canvas_item->get_tree()->get_debug_navigation_color();
+ if (p_selected) {
+ Color grid_color = EditorSettings::get_singleton()->get("editors/tiles_editor/grid_color");
+ Color selection_color = Color().from_hsv(Math::fposmod(grid_color.get_h() + 0.5, 1.0), grid_color.get_s(), grid_color.get_v(), 1.0);
+ selection_color.a = 0.7;
+ color = selection_color;
+ }
+
+ RandomPCG rand;
+ for (int i = 0; i < navigation_polygon->get_polygon_count(); i++) {
+ // An array of vertices for this polygon.
+ Vector<int> polygon = navigation_polygon->get_polygon(i);
+ Vector<Vector2> vertices;
+ vertices.resize(polygon.size());
+ for (int j = 0; j < polygon.size(); j++) {
+ ERR_FAIL_INDEX(polygon[j], verts.size());
+ vertices.write[j] = verts[polygon[j]];
+ }
+
+ // Generate the polygon color, slightly randomly modified from the settings one.
+ Color random_variation_color;
+ random_variation_color.set_hsv(color.get_h() + rand.random(-1.0, 1.0) * 0.05, color.get_s(), color.get_v() + rand.random(-1.0, 1.0) * 0.1);
+ random_variation_color.a = color.a;
+ Vector<Color> colors;
+ colors.push_back(random_variation_color);
+
+ RenderingServer::get_singleton()->canvas_item_add_polygon(p_canvas_item->get_canvas_item(), vertices, colors);
}
}
+
+ RenderingServer::get_singleton()->canvas_item_add_set_transform(p_canvas_item->get_canvas_item(), Transform2D());
}
diff --git a/editor/plugins/tiles/tile_data_editors.h b/editor/plugins/tiles/tile_data_editors.h
index b82189e1ee..781f26cc02 100644
--- a/editor/plugins/tiles/tile_data_editors.h
+++ b/editor/plugins/tiles/tile_data_editors.h
@@ -31,87 +31,378 @@
#ifndef TILE_DATA_EDITORS_H
#define TILE_DATA_EDITORS_H
+#include "tile_atlas_view.h"
+
+#include "editor/editor_node.h"
+#include "editor/editor_properties.h"
+
+#include "scene/gui/box_container.h"
#include "scene/gui/control.h"
+#include "scene/gui/label.h"
#include "scene/resources/tile_set.h"
-class TileDataEditor : public Control {
- GDCLASS(TileDataEditor, Control);
+class TileDataEditor : public VBoxContainer {
+ GDCLASS(TileDataEditor, VBoxContainer);
+
+private:
+ void _call_tile_set_changed();
protected:
- TileData *tile_data;
- String property;
+ Ref<TileSet> tile_set;
+ TileData *_get_tile_data(TileMapCell p_cell);
+ virtual void _tile_set_changed(){};
- TileData *_get_tile_data(TileSet *p_tile_set, int p_atlas_source_id, Vector2i p_atlas_coords, int p_alternative_tile);
+ static void _bind_methods();
public:
- // Edits a TileData property.
- void edit(TileSet *p_tile_set, int p_atlas_source_id, Vector2i p_atlas_coords, int p_alternative_tile, String p_property);
+ void set_tile_set(Ref<TileSet> p_tile_set);
+
+ // Input to handle painting.
+ virtual Control *get_toolbar() { return nullptr; };
+ virtual void forward_draw_over_atlas(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform){};
+ virtual void forward_draw_over_alternatives(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform){};
+ virtual void forward_painting_atlas_gui_input(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &p_event){};
+ virtual void forward_painting_alternatives_gui_input(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &p_event){};
- // Used to draw the value over a tile.
- virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileSet *p_tile_set, int p_atlas_source_id, Vector2i p_atlas_coords, int p_alternative_tile, String p_property){};
+ // Used to draw the tile data property value over a tile.
+ virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected = false){};
};
-class TileDataTextureOffsetEditor : public TileDataEditor {
- GDCLASS(TileDataTextureOffsetEditor, TileDataEditor);
+class DummyObject : public Object {
+ GDCLASS(DummyObject, Object)
+private:
+ Map<String, Variant> properties;
+
+protected:
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
public:
- virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileSet *p_tile_set, int p_atlas_source_id, Vector2i p_atlas_coords, int p_alternative_tile, String p_property) override;
+ bool has_dummy_property(StringName p_name);
+ void add_dummy_property(StringName p_name);
+ void remove_dummy_property(StringName p_name);
+ void clear_dummy_properties();
};
-class TileDataIntegerEditor : public TileDataEditor {
- GDCLASS(TileDataIntegerEditor, TileDataEditor);
+class GenericTilePolygonEditor : public VBoxContainer {
+ GDCLASS(GenericTilePolygonEditor, VBoxContainer);
+
+private:
+ Ref<TileSet> tile_set;
+ LocalVector<Vector<Point2>> polygons;
+ bool multiple_polygon_mode = false;
+
+ UndoRedo *undo_redo = EditorNode::get_undo_redo();
+
+ // UI
+ int hovered_polygon_index = -1;
+ int hovered_point_index = -1;
+ int hovered_segment_index = -1;
+ Vector2 hovered_segment_point;
+
+ enum DragType {
+ DRAG_TYPE_NONE,
+ DRAG_TYPE_DRAG_POINT,
+ DRAG_TYPE_CREATE_POINT,
+ DRAG_TYPE_PAN,
+ };
+ DragType drag_type;
+ int drag_polygon_index;
+ int drag_point_index;
+ Vector2 drag_last_pos;
+ PackedVector2Array drag_old_polygon;
+
+ HBoxContainer *toolbar;
+ Ref<ButtonGroup> tools_button_group;
+ Button *button_create;
+ Button *button_edit;
+ Button *button_delete;
+ Button *button_pixel_snap;
+ MenuButton *button_advanced_menu;
+
+ Vector<Point2> in_creation_polygon;
+
+ Panel *panel;
+ Control *base_control;
+ EditorZoomWidget *editor_zoom_widget;
+ Button *button_center_view;
+ Vector2 panning;
+
+ Ref<Texture2D> background_texture;
+ Rect2 background_region;
+ Vector2 background_offset;
+ bool background_h_flip;
+ bool background_v_flip;
+ bool background_transpose;
+ Color background_modulate;
+
+ Color polygon_color = Color(1.0, 0.0, 0.0);
+
+ enum AdvancedMenuOption {
+ RESET_TO_DEFAULT_TILE,
+ CLEAR_TILE,
+ };
+
+ void _base_control_draw();
+ void _zoom_changed();
+ void _advanced_menu_item_pressed(int p_item_pressed);
+ void _center_view();
+ void _base_control_gui_input(Ref<InputEvent> p_event);
+
+ 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 _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);
+
+protected:
+ void _notification(int p_what);
+ static void _bind_methods();
public:
- virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileSet *p_tile_set, int p_atlas_source_id, Vector2i p_atlas_coords, int p_alternative_tile, String p_property) override;
+ void set_tile_set(Ref<TileSet> p_tile_set);
+ void set_background(Ref<Texture2D> p_texture, Rect2 p_region = Rect2(), Vector2 p_offset = Vector2(), bool p_flip_h = false, bool p_flip_v = false, bool p_transpose = false, Color p_modulate = Color(1.0, 1.0, 1.0, 0.0));
+
+ int get_polygon_count();
+ int add_polygon(Vector<Point2> p_polygon, int p_index = -1);
+ void remove_polygon(int p_index);
+ void clear_polygons();
+ void set_polygon(int p_polygon_index, Vector<Point2> p_polygon);
+ Vector<Point2> get_polygon(int p_polygon_index);
+
+ void set_polygons_color(Color p_color);
+ void set_multiple_polygon_mode(bool p_multiple_polygon_mode);
+
+ GenericTilePolygonEditor();
};
-class TileDataFloatEditor : public TileDataEditor {
- GDCLASS(TileDataFloatEditor, TileDataEditor);
+class TileDataDefaultEditor : public TileDataEditor {
+ GDCLASS(TileDataDefaultEditor, TileDataEditor);
+
+private:
+ // Toolbar
+ HBoxContainer *toolbar = memnew(HBoxContainer);
+ Button *picker_button;
+
+ // UI
+ Ref<Texture2D> tile_bool_checked;
+ Ref<Texture2D> tile_bool_unchecked;
+ Label *label;
+
+ EditorProperty *property_editor = nullptr;
+
+ // Painting state.
+ enum DragType {
+ DRAG_TYPE_NONE = 0,
+ DRAG_TYPE_PAINT,
+ DRAG_TYPE_PAINT_RECT,
+ };
+ DragType drag_type = DRAG_TYPE_NONE;
+ Vector2 drag_start_pos;
+ Vector2 drag_last_pos;
+ Map<TileMapCell, Variant> drag_modified;
+ Variant drag_painted_value;
+
+ void _property_value_changed(StringName p_property, Variant p_value, StringName p_field);
+
+protected:
+ DummyObject *dummy_object = memnew(DummyObject);
+
+ UndoRedo *undo_redo = EditorNode::get_undo_redo();
+
+ StringName type;
+ String property;
+ void _notification(int p_what);
+
+ virtual Variant _get_painted_value();
+ virtual void _set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile);
+ virtual void _set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value);
+ virtual Variant _get_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile);
+ virtual void _setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map<TileMapCell, Variant> p_previous_values, Variant p_new_value);
public:
- virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileSet *p_tile_set, int p_atlas_source_id, Vector2i p_atlas_coords, int p_alternative_tile, String p_property) override;
+ virtual Control *get_toolbar() override { return toolbar; };
+ virtual void forward_draw_over_atlas(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) override;
+ virtual void forward_draw_over_alternatives(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) override;
+ virtual void forward_painting_atlas_gui_input(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &p_event) override;
+ virtual void forward_painting_alternatives_gui_input(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &p_event) override;
+ virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected = false) override;
+
+ void setup_property_editor(Variant::Type p_type, String p_property, String p_label = "", Variant p_default_value = Variant());
+
+ TileDataDefaultEditor();
+ ~TileDataDefaultEditor();
};
-class TileDataPositionEditor : public TileDataEditor {
- GDCLASS(TileDataPositionEditor, TileDataEditor);
+class TileDataTextureOffsetEditor : public TileDataDefaultEditor {
+ GDCLASS(TileDataTextureOffsetEditor, TileDataDefaultEditor);
public:
- virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileSet *p_tile_set, int p_atlas_source_id, Vector2i p_atlas_coords, int p_alternative_tile, String p_property) override;
+ virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected = false) override;
};
-class TileDataYSortEditor : public TileDataEditor {
- GDCLASS(TileDataYSortEditor, TileDataEditor);
+class TileDataPositionEditor : public TileDataDefaultEditor {
+ GDCLASS(TileDataPositionEditor, TileDataDefaultEditor);
public:
- virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileSet *p_tile_set, int p_atlas_source_id, Vector2i p_atlas_coords, int p_alternative_tile, String p_property) override;
+ virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected = false) override;
};
-class TileDataOcclusionShapeEditor : public TileDataEditor {
- GDCLASS(TileDataOcclusionShapeEditor, TileDataEditor);
+class TileDataYSortEditor : public TileDataDefaultEditor {
+ GDCLASS(TileDataYSortEditor, TileDataDefaultEditor);
public:
- virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileSet *p_tile_set, int p_atlas_source_id, Vector2i p_atlas_coords, int p_alternative_tile, String p_property) override;
+ virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected = false) override;
};
-class TileDataCollisionShapeEditor : public TileDataEditor {
- GDCLASS(TileDataCollisionShapeEditor, TileDataEditor);
+class TileDataOcclusionShapeEditor : public TileDataDefaultEditor {
+ GDCLASS(TileDataOcclusionShapeEditor, TileDataDefaultEditor);
+
+private:
+ int occlusion_layer = -1;
+
+ // UI
+ GenericTilePolygonEditor *polygon_editor;
+
+ void _polygon_changed(PackedVector2Array p_polygon);
+
+ virtual Variant _get_painted_value() override;
+ virtual void _set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override;
+ virtual void _set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value) override;
+ virtual Variant _get_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override;
+ virtual void _setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map<TileMapCell, Variant> p_previous_values, Variant p_new_value) override;
+
+protected:
+ UndoRedo *undo_redo = EditorNode::get_undo_redo();
+
+ virtual void _tile_set_changed() override;
+
+ void _notification(int p_what);
+
+public:
+ virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected = false) override;
+
+ void set_occlusion_layer(int p_occlusion_layer) { occlusion_layer = p_occlusion_layer; }
+
+ TileDataOcclusionShapeEditor();
+};
+
+class TileDataCollisionEditor : public TileDataDefaultEditor {
+ GDCLASS(TileDataCollisionEditor, TileDataDefaultEditor);
+
+ int physics_layer = -1;
+
+ // UI
+ GenericTilePolygonEditor *polygon_editor;
+ DummyObject *dummy_object = memnew(DummyObject);
+ Map<StringName, EditorProperty *> property_editors;
+
+ void _property_value_changed(StringName p_property, Variant p_value, StringName p_field);
+ void _polygons_changed();
+
+ virtual Variant _get_painted_value() override;
+ virtual void _set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override;
+ virtual void _set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value) override;
+ virtual Variant _get_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override;
+ virtual void _setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map<TileMapCell, Variant> p_previous_values, Variant p_new_value) override;
+
+protected:
+ UndoRedo *undo_redo = EditorNode::get_undo_redo();
+
+ virtual void _tile_set_changed() override;
+
+ void _notification(int p_what);
public:
- virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileSet *p_tile_set, int p_atlas_source_id, Vector2i p_atlas_coords, int p_alternative_tile, String p_property) override;
+ virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected = false) override;
+
+ void set_physics_layer(int p_physics_layer) { physics_layer = p_physics_layer; }
+
+ TileDataCollisionEditor();
+ ~TileDataCollisionEditor();
};
class TileDataTerrainsEditor : public TileDataEditor {
GDCLASS(TileDataTerrainsEditor, TileDataEditor);
+private:
+ // Toolbar
+ HBoxContainer *toolbar = memnew(HBoxContainer);
+ Button *picker_button;
+
+ // Painting state.
+ enum DragType {
+ DRAG_TYPE_NONE = 0,
+ DRAG_TYPE_PAINT_TERRAIN_SET,
+ DRAG_TYPE_PAINT_TERRAIN_SET_RECT,
+ DRAG_TYPE_PAINT_TERRAIN_BITS,
+ DRAG_TYPE_PAINT_TERRAIN_BITS_RECT,
+ };
+ DragType drag_type = DRAG_TYPE_NONE;
+ Vector2 drag_start_pos;
+ Vector2 drag_last_pos;
+ Map<TileMapCell, Variant> drag_modified;
+ Variant drag_painted_value;
+
+ // UI
+ Label *label;
+ DummyObject *dummy_object = memnew(DummyObject);
+ EditorPropertyEnum *terrain_set_property_editor = nullptr;
+ EditorPropertyEnum *terrain_property_editor = nullptr;
+
+ void _property_value_changed(StringName p_property, Variant p_value, StringName p_field);
+
+ void _update_terrain_selector();
+
+protected:
+ virtual void _tile_set_changed() override;
+
+ void _notification(int p_what);
+
+ UndoRedo *undo_redo = EditorNode::get_undo_redo();
+
public:
- virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileSet *p_tile_set, int p_atlas_source_id, Vector2i p_atlas_coords, int p_alternative_tile, String p_property) override;
+ virtual Control *get_toolbar() override { return toolbar; };
+ virtual void forward_draw_over_atlas(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) override;
+ virtual void forward_draw_over_alternatives(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) override;
+ virtual void forward_painting_atlas_gui_input(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &p_event) override;
+ virtual void forward_painting_alternatives_gui_input(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &p_event) override;
+ virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected = false) override;
+
+ TileDataTerrainsEditor();
+ ~TileDataTerrainsEditor();
};
-class TileDataNavigationPolygonEditor : public TileDataEditor {
- GDCLASS(TileDataNavigationPolygonEditor, TileDataEditor);
+class TileDataNavigationEditor : public TileDataDefaultEditor {
+ GDCLASS(TileDataNavigationEditor, TileDataDefaultEditor);
+
+private:
+ int navigation_layer = -1;
+ PackedVector2Array navigation_polygon;
+
+ // UI
+ GenericTilePolygonEditor *polygon_editor;
+
+ void _polygon_changed(PackedVector2Array p_polygon);
+
+ virtual Variant _get_painted_value() override;
+ virtual void _set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override;
+ virtual void _set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value) override;
+ virtual Variant _get_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override;
+ virtual void _setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map<TileMapCell, Variant> p_previous_values, Variant p_new_value) override;
+
+protected:
+ UndoRedo *undo_redo = EditorNode::get_undo_redo();
+
+ virtual void _tile_set_changed() override;
+
+ void _notification(int p_what);
public:
- virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileSet *p_tile_set, int p_atlas_source_id, Vector2i p_atlas_coords, int p_alternative_tile, String p_property) override;
+ virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected = false) override;
+
+ void set_navigation_layer(int p_navigation_layer) { navigation_layer = p_navigation_layer; }
+
+ TileDataNavigationEditor();
};
#endif // TILE_DATA_EDITORS_H
diff --git a/editor/plugins/tiles/tile_map_editor.cpp b/editor/plugins/tiles/tile_map_editor.cpp
index ef13d8ea12..86bd115ac2 100644
--- a/editor/plugins/tiles/tile_map_editor.cpp
+++ b/editor/plugins/tiles/tile_map_editor.cpp
@@ -1756,7 +1756,7 @@ TileMapEditorTilesPlugin::TileMapEditorTilesPlugin() {
HBoxContainer *tilemap_tiles_tools_buttons = memnew(HBoxContainer);
- tool_buttons_group.instance();
+ tool_buttons_group.instantiate();
select_tool_button = memnew(Button);
select_tool_button->set_flat(true);
@@ -2989,6 +2989,7 @@ void TileMapEditorTerrainsPlugin::_update_terrains_tree() {
}
// Fill in the terrain list.
+ Vector<Vector<Ref<Texture2D>>> icons = tile_set->generate_terrains_icons(Size2(16, 16) * EDSCALE);
for (int terrain_set_index = 0; terrain_set_index < tile_set->get_terrain_sets_count(); terrain_set_index++) {
// Add an item for the terrain set.
TreeItem *terrain_set_tree_item = terrains_tree->create_item();
@@ -3007,58 +3008,12 @@ void TileMapEditorTerrainsPlugin::_update_terrains_tree() {
terrain_set_tree_item->set_selectable(0, false);
for (int terrain_index = 0; terrain_index < tile_set->get_terrains_count(terrain_set_index); terrain_index++) {
- // Compute the terrains_tile_pattern used for terrain preview (whenever possible).
- TerrainsTilePattern terrains_tile_pattern;
- int max_bit_count = -1;
- for (Set<TerrainsTilePattern>::Element *E = per_terrain_terrains_tile_patterns[terrain_set_index][terrain_index].front(); E; E = E->next()) {
- int count = 0;
- for (int i = 0; i < E->get().size(); i++) {
- if (int(E->get()[i]) == terrain_index) {
- count++;
- }
- }
- if (count > max_bit_count) {
- terrains_tile_pattern = E->get();
- max_bit_count = count;
- }
- }
-
- // Get the preview.
- Ref<Texture2D> icon;
- Rect2 region;
- if (max_bit_count >= 0) {
- double max_probability = -1.0;
- for (Set<TileMapCell>::Element *E = per_terrain_terrains_tile_patterns_tiles[terrain_set_index][terrains_tile_pattern].front(); E; E = E->next()) {
- Ref<TileSetSource> source = tile_set->get_source(E->get().source_id);
-
- Ref<TileSetAtlasSource> atlas_source = source;
- if (atlas_source.is_valid()) {
- TileData *tile_data = Object::cast_to<TileData>(atlas_source->get_tile_data(E->get().get_atlas_coords(), E->get().alternative_tile));
- if (tile_data->get_probability() > max_probability) {
- icon = atlas_source->get_texture();
- region = atlas_source->get_tile_texture_region(E->get().get_atlas_coords());
- max_probability = tile_data->get_probability();
- }
- }
- }
- } else {
- Ref<Image> image;
- image.instance();
- image->create(1, 1, false, Image::FORMAT_RGBA8);
- image->set_pixel(0, 0, tile_set->get_terrain_color(terrain_set_index, terrain_index));
- Ref<ImageTexture> image_texture;
- image_texture.instance();
- image_texture->create_from_image(image);
- image_texture->set_size_override(Size2(32, 32) * EDSCALE);
- icon = image_texture;
- }
-
// Add the item to the terrain list.
TreeItem *terrain_tree_item = terrains_tree->create_item(terrain_set_tree_item);
terrain_tree_item->set_text(0, tile_set->get_terrain_name(terrain_set_index, terrain_index));
terrain_tree_item->set_icon_max_width(0, 32 * EDSCALE);
- terrain_tree_item->set_icon(0, icon);
- terrain_tree_item->set_icon_region(0, region);
+ terrain_tree_item->set_icon(0, icons[terrain_set_index][terrain_index]);
+
Dictionary metadata_dict;
metadata_dict["terrain_set"] = terrain_set_index;
metadata_dict["terrain_id"] = terrain_index;
@@ -3188,7 +3143,7 @@ TileMapEditorTerrainsPlugin::TileMapEditorTerrainsPlugin() {
HBoxContainer *tilemap_tiles_tools_buttons = memnew(HBoxContainer);
- tool_buttons_group.instance();
+ tool_buttons_group.instantiate();
paint_tool_button = memnew(Button);
paint_tool_button->set_flat(true);
diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
index 8e7d613027..9d849a0df5 100644
--- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
+++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
@@ -357,6 +357,7 @@ void TileSetAtlasSourceEditor::AtlasTileProxyObject::_bind_methods() {
void TileSetAtlasSourceEditor::_inspector_property_selected(String p_property) {
selected_property = p_property;
_update_atlas_view();
+ _update_current_tile_data_editor();
}
void TileSetAtlasSourceEditor::_update_tile_id_label() {
@@ -398,17 +399,315 @@ void TileSetAtlasSourceEditor::_update_fix_selected_and_hovered_tiles() {
}
}
+void TileSetAtlasSourceEditor::_update_atlas_source_inspector() {
+ // Update visibility.
+ bool visible = tools_button_group->get_pressed_button() == tool_setup_atlas_source_button;
+ atlas_source_inspector_label->set_visible(visible);
+ atlas_source_inspector->set_visible(visible);
+}
+
void TileSetAtlasSourceEditor::_update_tile_inspector() {
- bool has_atlas_tile_selected = (tools_button_group->get_pressed_button() == tool_select_button) && !selection.is_empty();
+ // Update visibility.
+ if (tools_button_group->get_pressed_button() == tool_select_button) {
+ if (!selection.is_empty()) {
+ tile_proxy_object->edit(tile_set_atlas_source, selection);
+ }
+ tile_inspector_label->show();
+ tile_inspector->set_visible(!selection.is_empty());
+ tile_inspector_no_tile_selected_label->set_visible(selection.is_empty());
+ } else {
+ tile_inspector_label->hide();
+ tile_inspector->hide();
+ tile_inspector_no_tile_selected_label->hide();
+ }
+}
- // Update the proxy object.
- if (has_atlas_tile_selected) {
- tile_proxy_object->edit(tile_set_atlas_source, selection);
+void TileSetAtlasSourceEditor::_update_tile_data_editors() {
+ String previously_selected;
+ if (tile_data_editors_tree && tile_data_editors_tree->get_selected()) {
+ previously_selected = tile_data_editors_tree->get_selected()->get_metadata(0);
+ }
+
+ tile_data_editors_tree->clear();
+
+ TreeItem *root = tile_data_editors_tree->create_item();
+
+ TreeItem *group;
+#define ADD_TILE_DATA_EDITOR_GROUP(text) \
+ group = tile_data_editors_tree->create_item(root); \
+ group->set_custom_bg_color(0, group_color); \
+ group->set_selectable(0, false); \
+ group->set_disable_folding(true); \
+ group->set_text(0, text);
+
+ TreeItem *item;
+#define ADD_TILE_DATA_EDITOR(parent, text, property) \
+ item = tile_data_editors_tree->create_item(parent); \
+ item->set_text(0, text); \
+ item->set_metadata(0, property); \
+ if (property == previously_selected) { \
+ item->select(0); \
+ }
+
+ // Theming.
+ tile_data_editors_tree->add_theme_constant_override("vseparation", 1);
+ tile_data_editors_tree->add_theme_constant_override("hseparation", 3);
+
+ Color group_color = get_theme_color("prop_category", "Editor");
+
+ // List of editors.
+ // --- Rendering ---
+ ADD_TILE_DATA_EDITOR_GROUP("Rendering");
+
+ ADD_TILE_DATA_EDITOR(group, "Texture Offset", "texture_offset");
+ if (!tile_data_editors.has("texture_offset")) {
+ TileDataTextureOffsetEditor *tile_data_texture_offset_editor = memnew(TileDataTextureOffsetEditor);
+ tile_data_texture_offset_editor->hide();
+ tile_data_texture_offset_editor->setup_property_editor(Variant::VECTOR2, "texture_offset");
+ tile_data_texture_offset_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update));
+ tile_data_texture_offset_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update));
+ tile_data_editors["texture_offset"] = tile_data_texture_offset_editor;
+ }
+
+ ADD_TILE_DATA_EDITOR(group, "Modulate", "modulate");
+ if (!tile_data_editors.has("modulate")) {
+ TileDataDefaultEditor *tile_data_modulate_editor = memnew(TileDataDefaultEditor());
+ tile_data_modulate_editor->hide();
+ tile_data_modulate_editor->setup_property_editor(Variant::COLOR, "modulate", "", Color(1.0, 1.0, 1.0, 1.0));
+ tile_data_modulate_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update));
+ tile_data_modulate_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update));
+ tile_data_editors["modulate"] = tile_data_modulate_editor;
+ }
+
+ ADD_TILE_DATA_EDITOR(group, "Z Index", "z_index");
+ if (!tile_data_editors.has("z_index")) {
+ TileDataDefaultEditor *tile_data_z_index_editor = memnew(TileDataDefaultEditor());
+ tile_data_z_index_editor->hide();
+ tile_data_z_index_editor->setup_property_editor(Variant::INT, "z_index");
+ tile_data_z_index_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update));
+ tile_data_z_index_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update));
+ tile_data_editors["z_index"] = tile_data_z_index_editor;
+ }
+
+ ADD_TILE_DATA_EDITOR(group, "Y Sort Origin", "y_sort_origin");
+ if (!tile_data_editors.has("y_sort_origin")) {
+ TileDataYSortEditor *tile_data_y_sort_editor = memnew(TileDataYSortEditor);
+ tile_data_y_sort_editor->hide();
+ tile_data_y_sort_editor->setup_property_editor(Variant::INT, "y_sort_origin");
+ tile_data_y_sort_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update));
+ tile_data_y_sort_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update));
+ tile_data_editors["y_sort_origin"] = tile_data_y_sort_editor;
+ }
+
+ for (int i = 0; i < tile_set->get_occlusion_layers_count(); i++) {
+ ADD_TILE_DATA_EDITOR(group, vformat("Occlusion Layer %d", i), vformat("occlusion_layer_%d", i));
+ if (!tile_data_editors.has(vformat("occlusion_layer_%d", i))) {
+ TileDataOcclusionShapeEditor *tile_data_occlusion_shape_editor = memnew(TileDataOcclusionShapeEditor());
+ tile_data_occlusion_shape_editor->hide();
+ tile_data_occlusion_shape_editor->set_occlusion_layer(i);
+ tile_data_occlusion_shape_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update));
+ tile_data_occlusion_shape_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update));
+ tile_data_editors[vformat("occlusion_layer_%d", i)] = tile_data_occlusion_shape_editor;
+ }
+ }
+ for (int i = tile_set->get_occlusion_layers_count(); tile_data_editors.has(vformat("occlusion_layer_%d", i)); i++) {
+ tile_data_editors[vformat("occlusion_layer_%d", i)]->queue_delete();
+ tile_data_editors.erase(vformat("occlusion_layer_%d", i));
+ }
+
+ // --- Rendering ---
+ ADD_TILE_DATA_EDITOR(root, "Terrains", "terrain_set");
+ if (!tile_data_editors.has("terrain_set")) {
+ TileDataTerrainsEditor *tile_data_terrains_editor = memnew(TileDataTerrainsEditor);
+ tile_data_terrains_editor->hide();
+ tile_data_terrains_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update));
+ tile_data_terrains_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update));
+ tile_data_editors["terrain_set"] = tile_data_terrains_editor;
+ }
+
+ // --- Miscellaneous ---
+ ADD_TILE_DATA_EDITOR(root, "Probability", "probability");
+ if (!tile_data_editors.has("probability")) {
+ TileDataDefaultEditor *tile_data_probability_editor = memnew(TileDataDefaultEditor());
+ tile_data_probability_editor->hide();
+ tile_data_probability_editor->setup_property_editor(Variant::FLOAT, "probability", "", 1.0);
+ tile_data_probability_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update));
+ tile_data_probability_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update));
+ tile_data_editors["probability"] = tile_data_probability_editor;
+ }
+
+ // --- Physics ---
+ ADD_TILE_DATA_EDITOR_GROUP("Physics");
+ for (int i = 0; i < tile_set->get_physics_layers_count(); i++) {
+ ADD_TILE_DATA_EDITOR(group, vformat("Physics Layer %d", i), vformat("physics_layer_%d", i));
+ if (!tile_data_editors.has(vformat("physics_layer_%d", i))) {
+ TileDataCollisionEditor *tile_data_collision_editor = memnew(TileDataCollisionEditor());
+ tile_data_collision_editor->hide();
+ tile_data_collision_editor->set_physics_layer(i);
+ tile_data_collision_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update));
+ tile_data_collision_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update));
+ tile_data_editors[vformat("physics_layer_%d", i)] = tile_data_collision_editor;
+ }
+ }
+ for (int i = tile_set->get_physics_layers_count(); tile_data_editors.has(vformat("physics_layer_%d", i)); i++) {
+ tile_data_editors[vformat("physics_layer_%d", i)]->queue_delete();
+ tile_data_editors.erase(vformat("physics_layer_%d", i));
+ }
+
+ // --- Navigation ---
+ ADD_TILE_DATA_EDITOR_GROUP("Navigation");
+ for (int i = 0; i < tile_set->get_navigation_layers_count(); i++) {
+ ADD_TILE_DATA_EDITOR(group, vformat("Navigation Layer %d", i), vformat("navigation_layer_%d", i));
+ if (!tile_data_editors.has(vformat("navigation_layer_%d", i))) {
+ TileDataNavigationEditor *tile_data_navigation_editor = memnew(TileDataNavigationEditor());
+ tile_data_navigation_editor->hide();
+ tile_data_navigation_editor->set_navigation_layer(i);
+ tile_data_navigation_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update));
+ tile_data_navigation_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update));
+ tile_data_editors[vformat("navigation_layer_%d", i)] = tile_data_navigation_editor;
+ }
+ }
+ for (int i = tile_set->get_navigation_layers_count(); tile_data_editors.has(vformat("navigation_layer_%d", i)); i++) {
+ tile_data_editors[vformat("navigation_layer_%d", i)]->queue_delete();
+ tile_data_editors.erase(vformat("navigation_layer_%d", i));
+ }
+
+ // --- Custom Data ---
+ ADD_TILE_DATA_EDITOR_GROUP("Custom Data");
+ for (int i = 0; i < tile_set->get_custom_data_layers_count(); i++) {
+ if (tile_set->get_custom_data_name(i).is_empty()) {
+ ADD_TILE_DATA_EDITOR(group, vformat("Custom Data %d", i), vformat("custom_data_%d", i));
+ } else {
+ ADD_TILE_DATA_EDITOR(group, tile_set->get_custom_data_name(i), vformat("custom_data_%d", i));
+ }
+ if (!tile_data_editors.has(vformat("custom_data_%d", i))) {
+ TileDataDefaultEditor *tile_data_custom_data_editor = memnew(TileDataDefaultEditor());
+ tile_data_custom_data_editor->hide();
+ tile_data_custom_data_editor->setup_property_editor(tile_set->get_custom_data_type(i), vformat("custom_data_%d", i), tile_set->get_custom_data_name(i));
+ tile_data_custom_data_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update));
+ tile_data_custom_data_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update));
+ tile_data_editors[vformat("custom_data_%d", i)] = tile_data_custom_data_editor;
+ }
+ }
+ for (int i = tile_set->get_custom_data_layers_count(); tile_data_editors.has(vformat("custom_data_%d", i)); i++) {
+ tile_data_editors[vformat("custom_data_%d", i)]->queue_delete();
+ tile_data_editors.erase(vformat("custom_data_%d", i));
+ }
+
+#undef ADD_TILE_DATA_EDITOR_GROUP
+#undef ADD_TILE_DATA_EDITOR
+
+ // Add tile data editors as children.
+ for (Map<String, TileDataEditor *>::Element *E = tile_data_editors.front(); E; E = E->next()) {
+ // Tile Data Editor.
+ TileDataEditor *tile_data_editor = E->get();
+ if (!tile_data_editor->is_inside_tree()) {
+ tile_data_painting_editor_container->add_child(tile_data_editor);
+ }
+ tile_data_editor->set_tile_set(tile_set);
+
+ // Toolbar.
+ Control *toolbar = tile_data_editor->get_toolbar();
+ if (!toolbar->is_inside_tree()) {
+ tool_settings_tile_data_toolbar_container->add_child(toolbar);
+ }
+ toolbar->hide();
}
// Update visibility.
- tile_inspector_label->set_visible(has_atlas_tile_selected);
- tile_inspector->set_visible(has_atlas_tile_selected);
+ bool is_visible = tools_button_group->get_pressed_button() == tool_paint_button;
+ tile_data_editor_dropdown_button->set_visible(is_visible);
+ tile_data_editor_dropdown_button->set_text(TTR("Select a property editor"));
+ tile_data_editors_label->set_visible(is_visible);
+}
+
+void TileSetAtlasSourceEditor::_update_current_tile_data_editor() {
+ // Find the property to use.
+ String property;
+ if (tools_button_group->get_pressed_button() == tool_select_button && tile_inspector->is_visible() && !tile_inspector->get_selected_path().is_empty()) {
+ Vector<String> components = tile_inspector->get_selected_path().split("/");
+ if (components.size() >= 1) {
+ property = components[0];
+
+ // Workaround for terrains as they don't have a common first component.
+ if (property.begins_with("terrains_")) {
+ property = "terrain_set";
+ }
+ }
+ } else if (tools_button_group->get_pressed_button() == tool_paint_button && tile_data_editors_tree->get_selected()) {
+ property = tile_data_editors_tree->get_selected()->get_metadata(0);
+ tile_data_editor_dropdown_button->set_text(tile_data_editors_tree->get_selected()->get_text(0));
+ }
+
+ // Hide all editors but the current one.
+ for (Map<String, TileDataEditor *>::Element *E = tile_data_editors.front(); E; E = E->next()) {
+ E->get()->hide();
+ E->get()->get_toolbar()->hide();
+ }
+ if (tile_data_editors.has(property)) {
+ current_tile_data_editor = tile_data_editors[property];
+ } else {
+ current_tile_data_editor = nullptr;
+ }
+
+ // Get the correct editor for the TileData's property.
+ if (current_tile_data_editor) {
+ current_tile_data_editor_toolbar = current_tile_data_editor->get_toolbar();
+ current_property = property;
+ current_tile_data_editor->set_visible(tools_button_group->get_pressed_button() == tool_paint_button);
+ current_tile_data_editor_toolbar->set_visible(tools_button_group->get_pressed_button() == tool_paint_button);
+ }
+}
+
+void TileSetAtlasSourceEditor::_tile_data_editor_dropdown_button_draw() {
+ if (!has_theme_icon("arrow", "OptionButton")) {
+ return;
+ }
+
+ RID ci = tile_data_editor_dropdown_button->get_canvas_item();
+ Ref<Texture2D> arrow = Control::get_theme_icon("arrow", "OptionButton");
+ Color clr = Color(1, 1, 1);
+ if (get_theme_constant("modulate_arrow")) {
+ switch (tile_data_editor_dropdown_button->get_draw_mode()) {
+ case BaseButton::DRAW_PRESSED:
+ clr = get_theme_color("font_pressed_color");
+ break;
+ case BaseButton::DRAW_HOVER:
+ clr = get_theme_color("font_hover_color");
+ break;
+ case BaseButton::DRAW_DISABLED:
+ clr = get_theme_color("font_disabled_color");
+ break;
+ default:
+ clr = get_theme_color("font_color");
+ }
+ }
+
+ Size2 size = tile_data_editor_dropdown_button->get_size();
+
+ Point2 ofs;
+ if (is_layout_rtl()) {
+ ofs = Point2(get_theme_constant("arrow_margin", "OptionButton"), int(Math::abs((size.height - arrow->get_height()) / 2)));
+ } else {
+ ofs = Point2(size.width - arrow->get_width() - get_theme_constant("arrow_margin", "OptionButton"), int(Math::abs((size.height - arrow->get_height()) / 2)));
+ }
+ arrow->draw(ci, ofs, clr);
+}
+
+void TileSetAtlasSourceEditor::_tile_data_editor_dropdown_button_pressed() {
+ Size2 size = tile_data_editor_dropdown_button->get_size();
+ tile_data_editors_popup->set_position(tile_data_editor_dropdown_button->get_screen_position() + Size2(0, size.height * get_global_transform().get_scale().y));
+ tile_data_editors_popup->set_size(Size2(size.width, 0));
+ tile_data_editors_popup->popup();
+}
+
+void TileSetAtlasSourceEditor::_tile_data_editors_tree_selected() {
+ tile_data_editors_popup->call_deferred("hide");
+ _update_current_tile_data_editor();
+ tile_atlas_control->update();
+ tile_atlas_control_unscaled->update();
+ alternative_tiles_control->update();
+ alternative_tiles_control_unscaled->update();
}
void TileSetAtlasSourceEditor::_update_atlas_view() {
@@ -467,19 +766,28 @@ void TileSetAtlasSourceEditor::_update_atlas_view() {
}
void TileSetAtlasSourceEditor::_update_toolbar() {
- // Hide all settings.
- for (int i = 0; i < tool_settings->get_child_count(); i++) {
- Object::cast_to<CanvasItem>(tool_settings->get_child(i))->hide();
- }
-
- // SHow only the correct settings.
- if (tools_button_group->get_pressed_button() == tool_select_button) {
- } else if (tools_button_group->get_pressed_button() == tool_add_remove_button) {
- tool_settings_vsep->show();
- tools_settings_erase_button->show();
- } else if (tools_button_group->get_pressed_button() == tool_add_remove_rect_button) {
+ // Show the tools and settings.
+ if (tools_button_group->get_pressed_button() == tool_setup_atlas_source_button) {
+ if (current_tile_data_editor_toolbar) {
+ current_tile_data_editor_toolbar->hide();
+ }
tool_settings_vsep->show();
tools_settings_erase_button->show();
+ tool_advanced_menu_buttom->show();
+ } else if (tools_button_group->get_pressed_button() == tool_select_button) {
+ if (current_tile_data_editor_toolbar) {
+ current_tile_data_editor_toolbar->hide();
+ }
+ tool_settings_vsep->hide();
+ tools_settings_erase_button->hide();
+ tool_advanced_menu_buttom->hide();
+ } else if (tools_button_group->get_pressed_button() == tool_paint_button) {
+ if (current_tile_data_editor_toolbar) {
+ current_tile_data_editor_toolbar->show();
+ }
+ tool_settings_vsep->hide();
+ tools_settings_erase_button->hide();
+ tool_advanced_menu_buttom->hide();
}
}
@@ -499,357 +807,336 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref<InputEven
// Update the hovered coords.
hovered_base_tile_coords = tile_atlas_view->get_atlas_tile_coords_at_pos(tile_atlas_control->get_local_mouse_position());
- // Handle the event.
- Ref<InputEventMouseMotion> mm = p_event;
- if (mm.is_valid()) {
- Vector2i start_base_tiles_coords = tile_atlas_view->get_atlas_tile_coords_at_pos(drag_start_mouse_pos);
- Vector2i last_base_tiles_coords = tile_atlas_view->get_atlas_tile_coords_at_pos(drag_last_mouse_pos);
- Vector2i new_base_tiles_coords = tile_atlas_view->get_atlas_tile_coords_at_pos(tile_atlas_control->get_local_mouse_position());
+ // Forward the event to the current tile data editor if we are in the painting mode.
+ if (tools_button_group->get_pressed_button() == tool_paint_button) {
+ if (current_tile_data_editor) {
+ current_tile_data_editor->forward_painting_atlas_gui_input(tile_atlas_view, tile_set_atlas_source, p_event);
+ }
+ // Update only what's needed.
+ tile_set_atlas_source_changed_needs_update = false;
- Vector2i grid_size = tile_set_atlas_source->get_atlas_grid_size();
+ tile_atlas_control->update();
+ tile_atlas_control_unscaled->update();
+ alternative_tiles_control->update();
+ alternative_tiles_control_unscaled->update();
+ tile_atlas_view->update();
+ return;
+ } else {
+ // Handle the event.
+ Ref<InputEventMouseMotion> mm = p_event;
+ if (mm.is_valid()) {
+ Vector2i start_base_tiles_coords = tile_atlas_view->get_atlas_tile_coords_at_pos(drag_start_mouse_pos);
+ Vector2i last_base_tiles_coords = tile_atlas_view->get_atlas_tile_coords_at_pos(drag_last_mouse_pos);
+ Vector2i new_base_tiles_coords = tile_atlas_view->get_atlas_tile_coords_at_pos(tile_atlas_control->get_local_mouse_position());
- if (drag_type == DRAG_TYPE_NONE) {
- if (selection.size() == 1) {
- // Change the cursor depending on the hovered thing.
- TileSelection selected = selection.front()->get();
- if (selected.tile != TileSetSource::INVALID_ATLAS_COORDS && selected.alternative == 0) {
- Vector2 mouse_local_pos = tile_atlas_control->get_local_mouse_position();
- Vector2i size_in_atlas = tile_set_atlas_source->get_tile_size_in_atlas(selected.tile);
- Rect2 region = tile_set_atlas_source->get_tile_texture_region(selected.tile);
- Size2 zoomed_size = resize_handle->get_size() / tile_atlas_view->get_zoom();
- Rect2 rect = region.grow_individual(zoomed_size.x, zoomed_size.y, 0, 0);
- const Vector2i coords[] = { Vector2i(0, 0), Vector2i(1, 0), Vector2i(1, 1), Vector2i(0, 1) };
- const Vector2i directions[] = { Vector2i(0, -1), Vector2i(1, 0), Vector2i(0, 1), Vector2i(-1, 0) };
- CursorShape cursor_shape = CURSOR_ARROW;
- bool can_grow[4];
- for (int i = 0; i < 4; i++) {
- can_grow[i] = tile_set_atlas_source->can_move_tile_in_atlas(selected.tile, selected.tile + directions[i]);
- can_grow[i] |= (i % 2 == 0) ? size_in_atlas.y > 1 : size_in_atlas.x > 1;
- }
- for (int i = 0; i < 4; i++) {
- Vector2 pos = rect.position + Vector2(rect.size.x, rect.size.y) * coords[i];
- if (can_grow[i] && can_grow[(i + 3) % 4] && Rect2(pos, zoomed_size).has_point(mouse_local_pos)) {
- cursor_shape = (i % 2) ? CURSOR_BDIAGSIZE : CURSOR_FDIAGSIZE;
+ Vector2i grid_size = tile_set_atlas_source->get_atlas_grid_size();
+
+ if (drag_type == DRAG_TYPE_NONE) {
+ if (selection.size() == 1) {
+ // Change the cursor depending on the hovered thing.
+ TileSelection selected = selection.front()->get();
+ if (selected.tile != TileSetSource::INVALID_ATLAS_COORDS && selected.alternative == 0) {
+ Vector2 mouse_local_pos = tile_atlas_control->get_local_mouse_position();
+ Vector2i size_in_atlas = tile_set_atlas_source->get_tile_size_in_atlas(selected.tile);
+ Rect2 region = tile_set_atlas_source->get_tile_texture_region(selected.tile);
+ Size2 zoomed_size = resize_handle->get_size() / tile_atlas_view->get_zoom();
+ Rect2 rect = region.grow_individual(zoomed_size.x, zoomed_size.y, 0, 0);
+ const Vector2i coords[] = { Vector2i(0, 0), Vector2i(1, 0), Vector2i(1, 1), Vector2i(0, 1) };
+ const Vector2i directions[] = { Vector2i(0, -1), Vector2i(1, 0), Vector2i(0, 1), Vector2i(-1, 0) };
+ CursorShape cursor_shape = CURSOR_ARROW;
+ bool can_grow[4];
+ for (int i = 0; i < 4; i++) {
+ can_grow[i] = tile_set_atlas_source->can_move_tile_in_atlas(selected.tile, selected.tile + directions[i]);
+ can_grow[i] |= (i % 2 == 0) ? size_in_atlas.y > 1 : size_in_atlas.x > 1;
}
- Vector2 next_pos = rect.position + Vector2(rect.size.x, rect.size.y) * coords[(i + 1) % 4];
- if (can_grow[i] && Rect2((pos + next_pos) / 2.0, zoomed_size).has_point(mouse_local_pos)) {
- cursor_shape = (i % 2) ? CURSOR_HSIZE : CURSOR_VSIZE;
+ for (int i = 0; i < 4; i++) {
+ Vector2 pos = rect.position + Vector2(rect.size.x, rect.size.y) * coords[i];
+ if (can_grow[i] && can_grow[(i + 3) % 4] && Rect2(pos, zoomed_size).has_point(mouse_local_pos)) {
+ cursor_shape = (i % 2) ? CURSOR_BDIAGSIZE : CURSOR_FDIAGSIZE;
+ }
+ Vector2 next_pos = rect.position + Vector2(rect.size.x, rect.size.y) * coords[(i + 1) % 4];
+ if (can_grow[i] && Rect2((pos + next_pos) / 2.0, zoomed_size).has_point(mouse_local_pos)) {
+ cursor_shape = (i % 2) ? CURSOR_HSIZE : CURSOR_VSIZE;
+ }
}
+ tile_atlas_control->set_default_cursor_shape(cursor_shape);
}
- tile_atlas_control->set_default_cursor_shape(cursor_shape);
}
- }
- } else if (drag_type == DRAG_TYPE_CREATE_BIG_TILE) {
- // Create big tile.
- new_base_tiles_coords = new_base_tiles_coords.max(Vector2i(0, 0)).min(grid_size - Vector2i(1, 1));
-
- Rect2i new_rect = Rect2i(start_base_tiles_coords, new_base_tiles_coords - start_base_tiles_coords).abs();
- new_rect.size += Vector2i(1, 1);
- // Check if the new tile can fit in the new rect.
- if (tile_set_atlas_source->can_move_tile_in_atlas(drag_current_tile, new_rect.position, new_rect.size)) {
- // Move and resize the tile.
- tile_set_atlas_source->move_tile_in_atlas(drag_current_tile, new_rect.position, new_rect.size);
- drag_current_tile = new_rect.position;
- }
- } else if (drag_type == DRAG_TYPE_CREATE_TILES) {
- // Create tiles.
- last_base_tiles_coords = last_base_tiles_coords.max(Vector2i(0, 0)).min(grid_size - Vector2i(1, 1));
- new_base_tiles_coords = new_base_tiles_coords.max(Vector2i(0, 0)).min(grid_size - Vector2i(1, 1));
-
- Vector<Point2i> line = Geometry2D::bresenham_line(last_base_tiles_coords, new_base_tiles_coords);
- for (int i = 0; i < line.size(); i++) {
- if (tile_set_atlas_source->get_tile_at_coords(line[i]) == TileSetSource::INVALID_ATLAS_COORDS) {
- tile_set_atlas_source->create_tile(line[i]);
- drag_modified_tiles.insert(line[i]);
+ } else if (drag_type == DRAG_TYPE_CREATE_BIG_TILE) {
+ // Create big tile.
+ new_base_tiles_coords = new_base_tiles_coords.max(Vector2i(0, 0)).min(grid_size - Vector2i(1, 1));
+
+ Rect2i new_rect = Rect2i(start_base_tiles_coords, new_base_tiles_coords - start_base_tiles_coords).abs();
+ new_rect.size += Vector2i(1, 1);
+ // Check if the new tile can fit in the new rect.
+ if (tile_set_atlas_source->can_move_tile_in_atlas(drag_current_tile, new_rect.position, new_rect.size)) {
+ // Move and resize the tile.
+ tile_set_atlas_source->move_tile_in_atlas(drag_current_tile, new_rect.position, new_rect.size);
+ drag_current_tile = new_rect.position;
+ }
+ } else if (drag_type == DRAG_TYPE_CREATE_TILES) {
+ // Create tiles.
+ last_base_tiles_coords = last_base_tiles_coords.max(Vector2i(0, 0)).min(grid_size - Vector2i(1, 1));
+ new_base_tiles_coords = new_base_tiles_coords.max(Vector2i(0, 0)).min(grid_size - Vector2i(1, 1));
+
+ Vector<Point2i> line = Geometry2D::bresenham_line(last_base_tiles_coords, new_base_tiles_coords);
+ for (int i = 0; i < line.size(); i++) {
+ if (tile_set_atlas_source->get_tile_at_coords(line[i]) == TileSetSource::INVALID_ATLAS_COORDS) {
+ tile_set_atlas_source->create_tile(line[i]);
+ drag_modified_tiles.insert(line[i]);
+ }
}
- }
- drag_last_mouse_pos = tile_atlas_control->get_local_mouse_position();
+ drag_last_mouse_pos = tile_atlas_control->get_local_mouse_position();
- } else if (drag_type == DRAG_TYPE_REMOVE_TILES) {
- // Remove tiles.
- last_base_tiles_coords = last_base_tiles_coords.max(Vector2i(0, 0)).min(grid_size - Vector2i(1, 1));
- new_base_tiles_coords = new_base_tiles_coords.max(Vector2i(0, 0)).min(grid_size - Vector2i(1, 1));
+ } else if (drag_type == DRAG_TYPE_REMOVE_TILES) {
+ // Remove tiles.
+ last_base_tiles_coords = last_base_tiles_coords.max(Vector2i(0, 0)).min(grid_size - Vector2i(1, 1));
+ new_base_tiles_coords = new_base_tiles_coords.max(Vector2i(0, 0)).min(grid_size - Vector2i(1, 1));
- Vector<Point2i> line = Geometry2D::bresenham_line(last_base_tiles_coords, new_base_tiles_coords);
- for (int i = 0; i < line.size(); i++) {
- Vector2i base_tile_coords = tile_set_atlas_source->get_tile_at_coords(line[i]);
- if (base_tile_coords != TileSetSource::INVALID_ATLAS_COORDS) {
- drag_modified_tiles.insert(base_tile_coords);
+ Vector<Point2i> line = Geometry2D::bresenham_line(last_base_tiles_coords, new_base_tiles_coords);
+ for (int i = 0; i < line.size(); i++) {
+ Vector2i base_tile_coords = tile_set_atlas_source->get_tile_at_coords(line[i]);
+ if (base_tile_coords != TileSetSource::INVALID_ATLAS_COORDS) {
+ drag_modified_tiles.insert(base_tile_coords);
+ }
}
- }
- drag_last_mouse_pos = tile_atlas_control->get_local_mouse_position();
- } else if (drag_type == DRAG_TYPE_MOVE_TILE) {
- // Move tile.
- Vector2 mouse_offset = (Vector2(tile_set_atlas_source->get_tile_size_in_atlas(drag_current_tile)) / 2.0 - Vector2(0.5, 0.5)) * tile_set->get_tile_size();
- Vector2i coords = tile_atlas_view->get_atlas_tile_coords_at_pos(tile_atlas_control->get_local_mouse_position() - mouse_offset);
- coords = coords.max(Vector2i(0, 0)).min(grid_size - Vector2i(1, 1));
- if (drag_current_tile != coords && tile_set_atlas_source->can_move_tile_in_atlas(drag_current_tile, coords)) {
- tile_set_atlas_source->move_tile_in_atlas(drag_current_tile, coords);
- selection.clear();
- selection.insert({ coords, 0 });
- drag_current_tile = coords;
+ drag_last_mouse_pos = tile_atlas_control->get_local_mouse_position();
+ } else if (drag_type == DRAG_TYPE_MOVE_TILE) {
+ // Move tile.
+ Vector2 mouse_offset = (Vector2(tile_set_atlas_source->get_tile_size_in_atlas(drag_current_tile)) / 2.0 - Vector2(0.5, 0.5)) * tile_set->get_tile_size();
+ Vector2i coords = tile_atlas_view->get_atlas_tile_coords_at_pos(tile_atlas_control->get_local_mouse_position() - mouse_offset);
+ coords = coords.max(Vector2i(0, 0)).min(grid_size - Vector2i(1, 1));
+ if (drag_current_tile != coords && tile_set_atlas_source->can_move_tile_in_atlas(drag_current_tile, coords)) {
+ tile_set_atlas_source->move_tile_in_atlas(drag_current_tile, coords);
+ selection.clear();
+ selection.insert({ coords, 0 });
+ drag_current_tile = coords;
- // Update only what's needed.
- tile_set_atlas_source_changed_needs_update = false;
- _update_tile_inspector();
- _update_atlas_view();
- _update_tile_id_label();
- }
- } else if (drag_type >= DRAG_TYPE_RESIZE_TOP_LEFT && drag_type <= DRAG_TYPE_RESIZE_LEFT) {
- // Resizing a tile.
- new_base_tiles_coords = new_base_tiles_coords.max(Vector2i(-1, -1)).min(grid_size);
+ // Update only what's needed.
+ tile_set_atlas_source_changed_needs_update = false;
+ _update_tile_inspector();
+ _update_atlas_view();
+ _update_tile_id_label();
+ _update_current_tile_data_editor();
+ }
+ } else if (drag_type == DRAG_TYPE_MAY_POPUP_MENU) {
+ if (Vector2(drag_start_mouse_pos).distance_to(tile_atlas_control->get_local_mouse_position()) > 5.0 * EDSCALE) {
+ drag_type = DRAG_TYPE_NONE;
+ }
+ } else if (drag_type >= DRAG_TYPE_RESIZE_TOP_LEFT && drag_type <= DRAG_TYPE_RESIZE_LEFT) {
+ // Resizing a tile.
+ new_base_tiles_coords = new_base_tiles_coords.max(Vector2i(-1, -1)).min(grid_size);
- Rect2i old_rect = Rect2i(drag_current_tile, tile_set_atlas_source->get_tile_size_in_atlas(drag_current_tile));
- Rect2i new_rect = old_rect;
+ Rect2i old_rect = Rect2i(drag_current_tile, tile_set_atlas_source->get_tile_size_in_atlas(drag_current_tile));
+ Rect2i new_rect = old_rect;
- if (drag_type == DRAG_TYPE_RESIZE_LEFT || drag_type == DRAG_TYPE_RESIZE_TOP_LEFT || drag_type == DRAG_TYPE_RESIZE_BOTTOM_LEFT) {
- new_rect.position.x = MIN(new_base_tiles_coords.x + 1, old_rect.get_end().x - 1);
- new_rect.size.x = old_rect.get_end().x - new_rect.position.x;
- }
- if (drag_type == DRAG_TYPE_RESIZE_TOP || drag_type == DRAG_TYPE_RESIZE_TOP_LEFT || drag_type == DRAG_TYPE_RESIZE_TOP_RIGHT) {
- new_rect.position.y = MIN(new_base_tiles_coords.y + 1, old_rect.get_end().y - 1);
- new_rect.size.y = old_rect.get_end().y - new_rect.position.y;
- }
+ if (drag_type == DRAG_TYPE_RESIZE_LEFT || drag_type == DRAG_TYPE_RESIZE_TOP_LEFT || drag_type == DRAG_TYPE_RESIZE_BOTTOM_LEFT) {
+ new_rect.position.x = MIN(new_base_tiles_coords.x + 1, old_rect.get_end().x - 1);
+ new_rect.size.x = old_rect.get_end().x - new_rect.position.x;
+ }
+ if (drag_type == DRAG_TYPE_RESIZE_TOP || drag_type == DRAG_TYPE_RESIZE_TOP_LEFT || drag_type == DRAG_TYPE_RESIZE_TOP_RIGHT) {
+ new_rect.position.y = MIN(new_base_tiles_coords.y + 1, old_rect.get_end().y - 1);
+ new_rect.size.y = old_rect.get_end().y - new_rect.position.y;
+ }
- if (drag_type == DRAG_TYPE_RESIZE_RIGHT || drag_type == DRAG_TYPE_RESIZE_TOP_RIGHT || drag_type == DRAG_TYPE_RESIZE_BOTTOM_RIGHT) {
- new_rect.set_end(Vector2i(MAX(new_base_tiles_coords.x, old_rect.position.x + 1), new_rect.get_end().y));
- }
- if (drag_type == DRAG_TYPE_RESIZE_BOTTOM || drag_type == DRAG_TYPE_RESIZE_BOTTOM_LEFT || drag_type == DRAG_TYPE_RESIZE_BOTTOM_RIGHT) {
- new_rect.set_end(Vector2i(new_rect.get_end().x, MAX(new_base_tiles_coords.y, old_rect.position.y + 1)));
- }
+ if (drag_type == DRAG_TYPE_RESIZE_RIGHT || drag_type == DRAG_TYPE_RESIZE_TOP_RIGHT || drag_type == DRAG_TYPE_RESIZE_BOTTOM_RIGHT) {
+ new_rect.set_end(Vector2i(MAX(new_base_tiles_coords.x, old_rect.position.x + 1), new_rect.get_end().y));
+ }
+ if (drag_type == DRAG_TYPE_RESIZE_BOTTOM || drag_type == DRAG_TYPE_RESIZE_BOTTOM_LEFT || drag_type == DRAG_TYPE_RESIZE_BOTTOM_RIGHT) {
+ new_rect.set_end(Vector2i(new_rect.get_end().x, MAX(new_base_tiles_coords.y, old_rect.position.y + 1)));
+ }
- if (tile_set_atlas_source->can_move_tile_in_atlas(drag_current_tile, new_rect.position, new_rect.size)) {
- tile_set_atlas_source->move_tile_in_atlas(drag_current_tile, new_rect.position, new_rect.size);
- selection.clear();
- selection.insert({ new_rect.position, 0 });
- drag_current_tile = new_rect.position;
+ if (tile_set_atlas_source->can_move_tile_in_atlas(drag_current_tile, new_rect.position, new_rect.size)) {
+ tile_set_atlas_source->move_tile_in_atlas(drag_current_tile, new_rect.position, new_rect.size);
+ selection.clear();
+ selection.insert({ new_rect.position, 0 });
+ drag_current_tile = new_rect.position;
- // Update only what's needed.
- tile_set_atlas_source_changed_needs_update = false;
- _update_tile_inspector();
- _update_atlas_view();
- _update_tile_id_label();
+ // Update only what's needed.
+ tile_set_atlas_source_changed_needs_update = false;
+ _update_tile_inspector();
+ _update_atlas_view();
+ _update_tile_id_label();
+ _update_current_tile_data_editor();
+ }
}
+
+ // Redraw for the hovered tile.
+ tile_atlas_control->update();
+ tile_atlas_control_unscaled->update();
+ alternative_tiles_control->update();
+ alternative_tiles_control_unscaled->update();
+ tile_atlas_view->update();
+ return;
}
- // Redraw for the hovered tile.
- tile_atlas_control->update();
- tile_atlas_control_unscaled->update();
- alternative_tiles_control->update();
- alternative_tiles_control_unscaled->update();
- tile_atlas_view->update();
- return;
- }
+ Ref<InputEventMouseButton> mb = p_event;
+ if (mb.is_valid()) {
+ Vector2 mouse_local_pos = tile_atlas_control->get_local_mouse_position();
+ if (mb->get_button_index() == MOUSE_BUTTON_LEFT) {
+ if (mb->is_pressed()) {
+ // Left click pressed.
+ if (tools_button_group->get_pressed_button() == tool_setup_atlas_source_button) {
+ if (tools_settings_erase_button->is_pressed()) {
+ // Erasing
+ if (mb->is_ctrl_pressed() || mb->is_shift_pressed()) {
+ // Remove tiles using rect.
+
+ // Setup the dragging info.
+ drag_type = DRAG_TYPE_REMOVE_TILES_USING_RECT;
+ drag_start_mouse_pos = mouse_local_pos;
+ drag_last_mouse_pos = drag_start_mouse_pos;
+ } else {
+ // Remove tiles.
- Ref<InputEventMouseButton> mb = p_event;
- if (mb.is_valid()) {
- Vector2 mouse_local_pos = tile_atlas_control->get_local_mouse_position();
- if (mb->get_button_index() == MOUSE_BUTTON_LEFT) {
- if (mb->is_pressed()) {
- // Left click pressed.
- if (tools_button_group->get_pressed_button() == tool_add_remove_button) {
- if (tools_settings_erase_button->is_pressed()) {
- // Remove tiles.
-
- // Setup the dragging info.
- drag_type = DRAG_TYPE_REMOVE_TILES;
- drag_start_mouse_pos = mouse_local_pos;
- drag_last_mouse_pos = drag_start_mouse_pos;
-
- // Remove a first tile.
- Vector2i coords = tile_atlas_view->get_atlas_tile_coords_at_pos(drag_start_mouse_pos);
- if (coords != TileSetSource::INVALID_ATLAS_COORDS) {
- coords = tile_set_atlas_source->get_tile_at_coords(coords);
- }
- if (coords != TileSetSource::INVALID_ATLAS_COORDS) {
- drag_modified_tiles.insert(coords);
- }
- } else {
- if (mb->is_shift_pressed()) {
- // Create a big tile.
- Vector2i coords = tile_atlas_view->get_atlas_tile_coords_at_pos(mouse_local_pos);
- if (coords != TileSetSource::INVALID_ATLAS_COORDS && tile_set_atlas_source->get_tile_at_coords(coords) == TileSetSource::INVALID_ATLAS_COORDS) {
- // Setup the dragging info, only if we start on an empty tile.
- drag_type = DRAG_TYPE_CREATE_BIG_TILE;
+ // Setup the dragging info.
+ drag_type = DRAG_TYPE_REMOVE_TILES;
drag_start_mouse_pos = mouse_local_pos;
drag_last_mouse_pos = drag_start_mouse_pos;
- drag_current_tile = coords;
- // Create a tile.
- tile_set_atlas_source->create_tile(coords);
+ // Remove a first tile.
+ Vector2i coords = tile_atlas_view->get_atlas_tile_coords_at_pos(drag_start_mouse_pos);
+ if (coords != TileSetSource::INVALID_ATLAS_COORDS) {
+ coords = tile_set_atlas_source->get_tile_at_coords(coords);
+ }
+ if (coords != TileSetSource::INVALID_ATLAS_COORDS) {
+ drag_modified_tiles.insert(coords);
+ }
}
} else {
- // Create tiles.
-
- // Setup the dragging info.
- drag_type = DRAG_TYPE_CREATE_TILES;
- drag_start_mouse_pos = mouse_local_pos;
- drag_last_mouse_pos = drag_start_mouse_pos;
-
- // Create a first tile if needed.
- Vector2i coords = tile_atlas_view->get_atlas_tile_coords_at_pos(drag_start_mouse_pos);
- if (coords != TileSetSource::INVALID_ATLAS_COORDS && tile_set_atlas_source->get_tile_at_coords(coords) == TileSetSource::INVALID_ATLAS_COORDS) {
- tile_set_atlas_source->create_tile(coords);
- drag_modified_tiles.insert(coords);
- }
- }
- }
- } else if (tools_button_group->get_pressed_button() == tool_add_remove_rect_button) {
- if (tools_settings_erase_button->is_pressed()) {
- // Remove tiles using rect.
-
- // Setup the dragging info.
- drag_type = DRAG_TYPE_REMOVE_TILES_USING_RECT;
- drag_start_mouse_pos = mouse_local_pos;
- drag_last_mouse_pos = drag_start_mouse_pos;
- } else {
- if (mb->is_shift_pressed()) {
- // Create a big tile.
- Vector2i coords = tile_atlas_view->get_atlas_tile_coords_at_pos(mouse_local_pos);
- if (coords != TileSetSource::INVALID_ATLAS_COORDS && tile_set_atlas_source->get_tile_at_coords(coords) == TileSetSource::INVALID_ATLAS_COORDS) {
- // Setup the dragging info, only if we start on an empty tile.
- drag_type = DRAG_TYPE_CREATE_BIG_TILE;
+ // Creating
+ if (mb->is_shift_pressed()) {
+ // Create a big tile.
+ Vector2i coords = tile_atlas_view->get_atlas_tile_coords_at_pos(mouse_local_pos);
+ if (coords != TileSetSource::INVALID_ATLAS_COORDS && tile_set_atlas_source->get_tile_at_coords(coords) == TileSetSource::INVALID_ATLAS_COORDS) {
+ // Setup the dragging info, only if we start on an empty tile.
+ drag_type = DRAG_TYPE_CREATE_BIG_TILE;
+ drag_start_mouse_pos = mouse_local_pos;
+ drag_last_mouse_pos = drag_start_mouse_pos;
+ drag_current_tile = coords;
+
+ // Create a tile.
+ tile_set_atlas_source->create_tile(coords);
+ }
+ } else if (mb->is_ctrl_pressed()) {
+ // Create tiles using rect.
+ drag_type = DRAG_TYPE_CREATE_TILES_USING_RECT;
drag_start_mouse_pos = mouse_local_pos;
drag_last_mouse_pos = drag_start_mouse_pos;
- drag_current_tile = coords;
+ } else {
+ // Create tiles.
- // Create a tile.
- tile_set_atlas_source->create_tile(coords);
+ // Setup the dragging info.
+ drag_type = DRAG_TYPE_CREATE_TILES;
+ drag_start_mouse_pos = mouse_local_pos;
+ drag_last_mouse_pos = drag_start_mouse_pos;
+
+ // Create a first tile if needed.
+ Vector2i coords = tile_atlas_view->get_atlas_tile_coords_at_pos(drag_start_mouse_pos);
+ if (coords != TileSetSource::INVALID_ATLAS_COORDS && tile_set_atlas_source->get_tile_at_coords(coords) == TileSetSource::INVALID_ATLAS_COORDS) {
+ tile_set_atlas_source->create_tile(coords);
+ drag_modified_tiles.insert(coords);
+ }
}
- } else {
- // Create tiles using rect.
- drag_type = DRAG_TYPE_CREATE_TILES_USING_RECT;
- drag_start_mouse_pos = mouse_local_pos;
- drag_last_mouse_pos = drag_start_mouse_pos;
}
- }
- } else if (tools_button_group->get_pressed_button() == tool_select_button) {
- // Dragging a handle.
- drag_type = DRAG_TYPE_NONE;
- if (selection.size() == 1) {
- TileSelection selected = selection.front()->get();
- if (selected.tile != TileSetSource::INVALID_ATLAS_COORDS && selected.alternative == 0) {
- Vector2i size_in_atlas = tile_set_atlas_source->get_tile_size_in_atlas(selected.tile);
- Rect2 region = tile_set_atlas_source->get_tile_texture_region(selected.tile);
- Size2 zoomed_size = resize_handle->get_size() / tile_atlas_view->get_zoom();
- Rect2 rect = region.grow_individual(zoomed_size.x, zoomed_size.y, 0, 0);
- const Vector2i coords[] = { Vector2i(0, 0), Vector2i(1, 0), Vector2i(1, 1), Vector2i(0, 1) };
- const Vector2i directions[] = { Vector2i(0, -1), Vector2i(1, 0), Vector2i(0, 1), Vector2i(-1, 0) };
- CursorShape cursor_shape = CURSOR_ARROW;
- bool can_grow[4];
- for (int i = 0; i < 4; i++) {
- can_grow[i] = tile_set_atlas_source->can_move_tile_in_atlas(selected.tile, selected.tile + directions[i]);
- can_grow[i] |= (i % 2 == 0) ? size_in_atlas.y > 1 : size_in_atlas.x > 1;
- }
- for (int i = 0; i < 4; i++) {
- Vector2 pos = rect.position + Vector2(rect.size.x, rect.size.y) * coords[i];
- if (can_grow[i] && can_grow[(i + 3) % 4] && Rect2(pos, zoomed_size).has_point(mouse_local_pos)) {
- drag_type = (DragType)((int)DRAG_TYPE_RESIZE_TOP_LEFT + i * 2);
- drag_start_mouse_pos = mouse_local_pos;
- drag_last_mouse_pos = drag_start_mouse_pos;
- drag_current_tile = selected.tile;
- drag_start_tile_shape = Rect2i(selected.tile, tile_set_atlas_source->get_tile_size_in_atlas(selected.tile));
- cursor_shape = (i % 2) ? CURSOR_BDIAGSIZE : CURSOR_FDIAGSIZE;
+ } else if (tools_button_group->get_pressed_button() == tool_select_button) {
+ // Dragging a handle.
+ drag_type = DRAG_TYPE_NONE;
+ if (selection.size() == 1) {
+ TileSelection selected = selection.front()->get();
+ if (selected.tile != TileSetSource::INVALID_ATLAS_COORDS && selected.alternative == 0) {
+ Vector2i size_in_atlas = tile_set_atlas_source->get_tile_size_in_atlas(selected.tile);
+ Rect2 region = tile_set_atlas_source->get_tile_texture_region(selected.tile);
+ Size2 zoomed_size = resize_handle->get_size() / tile_atlas_view->get_zoom();
+ Rect2 rect = region.grow_individual(zoomed_size.x, zoomed_size.y, 0, 0);
+ const Vector2i coords[] = { Vector2i(0, 0), Vector2i(1, 0), Vector2i(1, 1), Vector2i(0, 1) };
+ const Vector2i directions[] = { Vector2i(0, -1), Vector2i(1, 0), Vector2i(0, 1), Vector2i(-1, 0) };
+ CursorShape cursor_shape = CURSOR_ARROW;
+ bool can_grow[4];
+ for (int i = 0; i < 4; i++) {
+ can_grow[i] = tile_set_atlas_source->can_move_tile_in_atlas(selected.tile, selected.tile + directions[i]);
+ can_grow[i] |= (i % 2 == 0) ? size_in_atlas.y > 1 : size_in_atlas.x > 1;
}
- Vector2 next_pos = rect.position + Vector2(rect.size.x, rect.size.y) * coords[(i + 1) % 4];
- if (can_grow[i] && Rect2((pos + next_pos) / 2.0, zoomed_size).has_point(mouse_local_pos)) {
- drag_type = (DragType)((int)DRAG_TYPE_RESIZE_TOP + i * 2);
- drag_start_mouse_pos = mouse_local_pos;
- drag_last_mouse_pos = drag_start_mouse_pos;
- drag_current_tile = selected.tile;
- drag_start_tile_shape = Rect2i(selected.tile, tile_set_atlas_source->get_tile_size_in_atlas(selected.tile));
- cursor_shape = (i % 2) ? CURSOR_HSIZE : CURSOR_VSIZE;
+ for (int i = 0; i < 4; i++) {
+ Vector2 pos = rect.position + Vector2(rect.size.x, rect.size.y) * coords[i];
+ if (can_grow[i] && can_grow[(i + 3) % 4] && Rect2(pos, zoomed_size).has_point(mouse_local_pos)) {
+ drag_type = (DragType)((int)DRAG_TYPE_RESIZE_TOP_LEFT + i * 2);
+ drag_start_mouse_pos = mouse_local_pos;
+ drag_last_mouse_pos = drag_start_mouse_pos;
+ drag_current_tile = selected.tile;
+ drag_start_tile_shape = Rect2i(selected.tile, tile_set_atlas_source->get_tile_size_in_atlas(selected.tile));
+ cursor_shape = (i % 2) ? CURSOR_BDIAGSIZE : CURSOR_FDIAGSIZE;
+ }
+ Vector2 next_pos = rect.position + Vector2(rect.size.x, rect.size.y) * coords[(i + 1) % 4];
+ if (can_grow[i] && Rect2((pos + next_pos) / 2.0, zoomed_size).has_point(mouse_local_pos)) {
+ drag_type = (DragType)((int)DRAG_TYPE_RESIZE_TOP + i * 2);
+ drag_start_mouse_pos = mouse_local_pos;
+ drag_last_mouse_pos = drag_start_mouse_pos;
+ drag_current_tile = selected.tile;
+ drag_start_tile_shape = Rect2i(selected.tile, tile_set_atlas_source->get_tile_size_in_atlas(selected.tile));
+ cursor_shape = (i % 2) ? CURSOR_HSIZE : CURSOR_VSIZE;
+ }
}
+ tile_atlas_control->set_default_cursor_shape(cursor_shape);
}
- tile_atlas_control->set_default_cursor_shape(cursor_shape);
}
- }
- // Selecting then dragging a tile.
- if (drag_type == DRAG_TYPE_NONE) {
- TileSelection selected = { TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE };
- Vector2i coords = tile_atlas_view->get_atlas_tile_coords_at_pos(mouse_local_pos);
- if (coords != TileSetSource::INVALID_ATLAS_COORDS) {
- coords = tile_set_atlas_source->get_tile_at_coords(coords);
+ // Selecting then dragging a tile.
+ if (drag_type == DRAG_TYPE_NONE) {
+ TileSelection selected = { TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE };
+ Vector2i coords = tile_atlas_view->get_atlas_tile_coords_at_pos(mouse_local_pos);
if (coords != TileSetSource::INVALID_ATLAS_COORDS) {
- selected = { coords, 0 };
+ coords = tile_set_atlas_source->get_tile_at_coords(coords);
+ if (coords != TileSetSource::INVALID_ATLAS_COORDS) {
+ selected = { coords, 0 };
+ }
}
- }
- bool shift = mb->is_shift_pressed();
- if (!shift && selection.size() == 1 && selected.tile != TileSetSource::INVALID_ATLAS_COORDS && selection.has(selected)) {
- // Start move dragging.
- drag_type = DRAG_TYPE_MOVE_TILE;
- drag_start_mouse_pos = mouse_local_pos;
- drag_last_mouse_pos = drag_start_mouse_pos;
- drag_current_tile = selected.tile;
- drag_start_tile_shape = Rect2i(selected.tile, tile_set_atlas_source->get_tile_size_in_atlas(selected.tile));
- tile_atlas_control->set_default_cursor_shape(CURSOR_MOVE);
- } else {
- // Start selection dragging.
- drag_type = DRAG_TYPE_RECT_SELECT;
- drag_start_mouse_pos = mouse_local_pos;
- drag_last_mouse_pos = drag_start_mouse_pos;
+ bool shift = mb->is_shift_pressed();
+ if (!shift && selection.size() == 1 && selected.tile != TileSetSource::INVALID_ATLAS_COORDS && selection.has(selected)) {
+ // Start move dragging.
+ drag_type = DRAG_TYPE_MOVE_TILE;
+ drag_start_mouse_pos = mouse_local_pos;
+ drag_last_mouse_pos = drag_start_mouse_pos;
+ drag_current_tile = selected.tile;
+ drag_start_tile_shape = Rect2i(selected.tile, tile_set_atlas_source->get_tile_size_in_atlas(selected.tile));
+ tile_atlas_control->set_default_cursor_shape(CURSOR_MOVE);
+ } else {
+ // Start selection dragging.
+ drag_type = DRAG_TYPE_RECT_SELECT;
+ drag_start_mouse_pos = mouse_local_pos;
+ drag_last_mouse_pos = drag_start_mouse_pos;
+ }
}
}
+ } else {
+ // Left click released.
+ _end_dragging();
}
- } else {
- // Left click released.
- _end_dragging();
- }
- tile_atlas_control->update();
- tile_atlas_control_unscaled->update();
- alternative_tiles_control->update();
- alternative_tiles_control_unscaled->update();
- tile_atlas_view->update();
- return;
- } else if (mb->get_button_index() == MOUSE_BUTTON_RIGHT) {
- if (mb->is_pressed()) {
+ tile_atlas_control->update();
+ tile_atlas_control_unscaled->update();
+ alternative_tiles_control->update();
+ alternative_tiles_control_unscaled->update();
+ tile_atlas_view->update();
+ return;
+ } else if (mb->get_button_index() == MOUSE_BUTTON_RIGHT) {
// Right click pressed.
-
- TileSelection selected = { tile_atlas_view->get_atlas_tile_coords_at_pos(mouse_local_pos), 0 };
- if (selected.tile != TileSetSource::INVALID_ATLAS_COORDS) {
- selected.tile = tile_set_atlas_source->get_tile_at_coords(selected.tile);
- }
-
- // Set the selection if needed.
- if (selection.size() <= 1) {
- if (selected.tile != TileSetSource::INVALID_ATLAS_COORDS) {
- undo_redo->create_action(TTR("Select tiles"));
- undo_redo->add_undo_method(this, "_set_selection_from_array", _get_selection_as_array());
- selection.clear();
- selection.insert(selected);
- undo_redo->add_do_method(this, "_set_selection_from_array", _get_selection_as_array());
- undo_redo->commit_action(false);
- _update_tile_inspector();
- _update_tile_id_label();
- }
- }
-
- // Pops up the correct menu, depending on whether we have a tile or not.
- if (selected.tile != TileSetSource::INVALID_ATLAS_COORDS && selection.has(selected)) {
- // We have a tile.
- menu_option_coords = selected.tile;
- menu_option_alternative = 0;
- base_tile_popup_menu->popup(Rect2i(get_global_mouse_position(), Size2i()));
- } else if (hovered_base_tile_coords != TileSetSource::INVALID_ATLAS_COORDS) {
- // We don't have a tile, but can create one.
- menu_option_coords = hovered_base_tile_coords;
- menu_option_alternative = TileSetSource::INVALID_TILE_ALTERNATIVE;
- empty_base_tile_popup_menu->popup(Rect2i(get_global_mouse_position(), Size2i()));
+ if (mb->is_pressed()) {
+ drag_type = DRAG_TYPE_MAY_POPUP_MENU;
+ drag_start_mouse_pos = tile_atlas_control->get_local_mouse_position();
+ } else {
+ // Right click released.
+ _end_dragging();
}
- } else {
- // Right click released.
- _end_dragging();
+ tile_atlas_control->update();
+ tile_atlas_control_unscaled->update();
+ alternative_tiles_control->update();
+ alternative_tiles_control_unscaled->update();
+ tile_atlas_view->update();
+ return;
}
- tile_atlas_control->update();
- tile_atlas_control_unscaled->update();
- alternative_tiles_control->update();
- alternative_tiles_control_unscaled->update();
- tile_atlas_view->update();
- return;
}
}
}
@@ -1000,10 +1287,45 @@ void TileSetAtlasSourceEditor::_end_dragging() {
}
_update_tile_inspector();
_update_tile_id_label();
+ _update_current_tile_data_editor();
undo_redo->add_do_method(this, "_set_selection_from_array", _get_selection_as_array());
undo_redo->commit_action(false);
- break;
- }
+ } break;
+ case DRAG_TYPE_MAY_POPUP_MENU: {
+ Vector2 mouse_local_pos = tile_atlas_control->get_local_mouse_position();
+ TileSelection selected = { tile_atlas_view->get_atlas_tile_coords_at_pos(mouse_local_pos), 0 };
+ if (selected.tile != TileSetSource::INVALID_ATLAS_COORDS) {
+ selected.tile = tile_set_atlas_source->get_tile_at_coords(selected.tile);
+ }
+
+ // Set the selection if needed.
+ if (selection.size() <= 1) {
+ if (selected.tile != TileSetSource::INVALID_ATLAS_COORDS) {
+ undo_redo->create_action(TTR("Select tiles"));
+ undo_redo->add_undo_method(this, "_set_selection_from_array", _get_selection_as_array());
+ selection.clear();
+ selection.insert(selected);
+ undo_redo->add_do_method(this, "_set_selection_from_array", _get_selection_as_array());
+ undo_redo->commit_action(false);
+ _update_tile_inspector();
+ _update_tile_id_label();
+ _update_current_tile_data_editor();
+ }
+ }
+
+ // Pops up the correct menu, depending on whether we have a tile or not.
+ if (selected.tile != TileSetSource::INVALID_ATLAS_COORDS && selection.has(selected)) {
+ // We have a tile.
+ menu_option_coords = selected.tile;
+ menu_option_alternative = 0;
+ base_tile_popup_menu->popup(Rect2i(get_global_mouse_position(), Size2i()));
+ } else if (hovered_base_tile_coords != TileSetSource::INVALID_ATLAS_COORDS) {
+ // We don't have a tile, but can create one.
+ menu_option_coords = hovered_base_tile_coords;
+ menu_option_alternative = TileSetSource::INVALID_TILE_ALTERNATIVE;
+ empty_base_tile_popup_menu->popup(Rect2i(get_global_mouse_position(), Size2i()));
+ }
+ } break;
case DRAG_TYPE_RESIZE_TOP_LEFT:
case DRAG_TYPE_RESIZE_TOP:
case DRAG_TYPE_RESIZE_TOP_RIGHT:
@@ -1040,7 +1362,7 @@ Map<Vector2i, List<const PropertyInfo *>> TileSetAtlasSourceEditor::_group_prope
Vector<String> components = String(E_property->get().name).split("/", true, 1);
if (components.size() >= 1) {
Vector<String> coord_arr = components[0].split(":");
- if (coord_arr.size() == 2 && coord_arr[0].is_valid_integer() && coord_arr[1].is_valid_integer()) {
+ if (coord_arr.size() == 2 && coord_arr[0].is_valid_int() && coord_arr[1].is_valid_int()) {
Vector2i coords = Vector2i(coord_arr[0].to_int(), coord_arr[1].to_int());
per_tile[coords].push_back(&(E_property->get()));
}
@@ -1088,7 +1410,7 @@ void TileSetAtlasSourceEditor::_menu_option(int p_option) {
if (per_tile.has(selected.tile)) {
for (List<const PropertyInfo *>::Element *E_property = per_tile[selected.tile].front(); E_property; E_property = E_property->next()) {
Vector<String> components = E_property->get()->name.split("/", true, 2);
- if (components.size() >= 2 && components[1].is_valid_integer() && components[1].to_int() == selected.alternative) {
+ if (components.size() >= 2 && components[1].is_valid_int() && components[1].to_int() == selected.alternative) {
String property = E_property->get()->name;
Variant value = tile_set_atlas_source->get(property);
if (value.get_type() != Variant::NIL) {
@@ -1166,6 +1488,7 @@ void TileSetAtlasSourceEditor::_set_selection_from_array(Array p_selection) {
_update_tile_inspector();
_update_tile_id_label();
_update_atlas_view();
+ _update_current_tile_data_editor();
}
Array TileSetAtlasSourceEditor::_get_selection_as_array() {
@@ -1297,7 +1620,7 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_draw() {
tile_atlas_control->draw_rect(tile_set_atlas_source->get_tile_texture_region(hovered_tile), Color(1.0, 1.0, 1.0), false);
} else {
// Draw empty tile, only in add/remove tiles mode.
- if (tools_button_group->get_pressed_button() == tool_add_remove_button || tools_button_group->get_pressed_button() == tool_add_remove_rect_button) {
+ if (tools_button_group->get_pressed_button() == tool_setup_atlas_source_button) {
Vector2i margins = tile_set_atlas_source->get_margins();
Vector2i separation = tile_set_atlas_source->get_separation();
Vector2i tile_size = tile_set_atlas_source->get_texture_region_size();
@@ -1310,9 +1633,8 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_draw() {
}
void TileSetAtlasSourceEditor::_tile_atlas_control_unscaled_draw() {
- // Draw the preview of the selected property.
- TileDataEditor *tile_data_editor = TileSetEditor::get_singleton()->get_tile_data_editor(selected_property);
- if (tile_data_editor && tile_inspector->is_visible_in_tree()) {
+ if (current_tile_data_editor) {
+ // Draw the preview of the selected property.
for (int i = 0; i < tile_set_atlas_source->get_tiles_count(); i++) {
Vector2i coords = tile_set_atlas_source->get_tile_id(i);
Rect2i texture_region = tile_set_atlas_source->get_tile_texture_region(coords);
@@ -1321,7 +1643,41 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_unscaled_draw() {
Transform2D xform = tile_atlas_control->get_parent_control()->get_transform();
xform.translate(position);
- tile_data_editor->draw_over_tile(tile_atlas_control_unscaled, xform, *tile_set, tile_set_atlas_source_id, coords, 0, selected_property);
+ if (tools_button_group->get_pressed_button() == tool_select_button && selection.has({ coords, 0 })) {
+ continue;
+ }
+
+ TileMapCell cell;
+ cell.source_id = tile_set_atlas_source_id;
+ cell.set_atlas_coords(coords);
+ cell.alternative_tile = 0;
+ current_tile_data_editor->draw_over_tile(tile_atlas_control_unscaled, xform, cell);
+ }
+
+ // Draw the selection on top of other.
+ if (tools_button_group->get_pressed_button() == tool_select_button) {
+ for (Set<TileSelection>::Element *E = selection.front(); E; E = E->next()) {
+ if (E->get().alternative != 0) {
+ continue;
+ }
+ Rect2i texture_region = tile_set_atlas_source->get_tile_texture_region(E->get().tile);
+ Vector2i position = (texture_region.position + texture_region.get_end()) / 2 + tile_set_atlas_source->get_tile_effective_texture_offset(E->get().tile, 0);
+
+ Transform2D xform = tile_atlas_control->get_parent_control()->get_transform();
+ xform.translate(position);
+
+ TileMapCell cell;
+ cell.source_id = tile_set_atlas_source_id;
+ cell.set_atlas_coords(E->get().tile);
+ cell.alternative_tile = 0;
+ current_tile_data_editor->draw_over_tile(tile_atlas_control_unscaled, xform, cell, true);
+ }
+ }
+
+ // Call the TileData's editor custom draw function.
+ if (tools_button_group->get_pressed_button() == tool_paint_button) {
+ Transform2D xform = tile_atlas_control->get_parent_control()->get_transform();
+ current_tile_data_editor->forward_draw_over_atlas(tile_atlas_view, tile_set_atlas_source, tile_atlas_control_unscaled, xform);
}
}
}
@@ -1330,6 +1686,19 @@ void TileSetAtlasSourceEditor::_tile_alternatives_control_gui_input(const Ref<In
// Update the hovered alternative tile.
hovered_alternative_tile_coords = tile_atlas_view->get_alternative_tile_at_pos(alternative_tiles_control->get_local_mouse_position());
+ // Forward the event to the current tile data editor if we are in the painting mode.
+ if (tools_button_group->get_pressed_button() == tool_paint_button) {
+ if (current_tile_data_editor) {
+ current_tile_data_editor->forward_painting_alternatives_gui_input(tile_atlas_view, tile_set_atlas_source, p_event);
+ }
+ tile_atlas_control->update();
+ tile_atlas_control_unscaled->update();
+ alternative_tiles_control->update();
+ alternative_tiles_control_unscaled->update();
+ tile_atlas_view->update();
+ return;
+ }
+
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid()) {
tile_atlas_control->update();
@@ -1425,7 +1794,60 @@ void TileSetAtlasSourceEditor::_tile_alternatives_control_draw() {
}
void TileSetAtlasSourceEditor::_tile_alternatives_control_unscaled_draw() {
- //TODO
+ // Draw the preview of the selected property.
+ if (current_tile_data_editor) {
+ // Draw the preview of the currently selected property.
+ for (int i = 0; i < tile_set_atlas_source->get_tiles_count(); i++) {
+ Vector2i coords = tile_set_atlas_source->get_tile_id(i);
+ for (int j = 0; j < tile_set_atlas_source->get_alternative_tiles_count(coords); j++) {
+ int alternative_tile = tile_set_atlas_source->get_alternative_tile_id(coords, j);
+ if (alternative_tile == 0) {
+ continue;
+ }
+ Rect2i rect = tile_atlas_view->get_alternative_tile_rect(coords, alternative_tile);
+ Vector2 position = (rect.get_position() + rect.get_end()) / 2;
+
+ Transform2D xform = alternative_tiles_control->get_parent_control()->get_transform();
+ xform.translate(position);
+
+ if (tools_button_group->get_pressed_button() == tool_select_button && selection.has({ coords, alternative_tile })) {
+ continue;
+ }
+
+ TileMapCell cell;
+ cell.source_id = tile_set_atlas_source_id;
+ cell.set_atlas_coords(coords);
+ cell.alternative_tile = alternative_tile;
+ current_tile_data_editor->draw_over_tile(alternative_tiles_control_unscaled, xform, cell);
+ }
+ }
+
+ // Draw the selection on top of other.
+ if (tools_button_group->get_pressed_button() == tool_select_button) {
+ for (Set<TileSelection>::Element *E = selection.front(); E; E = E->next()) {
+ if (E->get().alternative == 0) {
+ continue;
+ }
+ Rect2i rect = tile_atlas_view->get_alternative_tile_rect(E->get().tile, E->get().alternative);
+ Vector2 position = (rect.get_position() + rect.get_end()) / 2;
+
+ Transform2D xform = alternative_tiles_control->get_parent_control()->get_transform();
+ xform.translate(position);
+
+ TileMapCell cell;
+ cell.source_id = tile_set_atlas_source_id;
+ cell.set_atlas_coords(E->get().tile);
+ cell.alternative_tile = E->get().alternative;
+ current_tile_data_editor->draw_over_tile(alternative_tiles_control_unscaled, xform, cell, true);
+ }
+ }
+
+ // Call the TileData's editor custom draw function.
+ if (tools_button_group->get_pressed_button() == tool_paint_button) {
+ Transform2D xform = tile_atlas_control->get_parent_control()->get_transform();
+ current_tile_data_editor->forward_draw_over_alternatives(tile_atlas_view, tile_set_atlas_source, alternative_tiles_control_unscaled, xform);
+ }
+ }
}
void TileSetAtlasSourceEditor::_tile_set_atlas_source_changed() {
@@ -1449,15 +1871,23 @@ void TileSetAtlasSourceEditor::_undo_redo_inspector_callback(Object *p_undo_redo
AtlasTileProxyObject *tile_data = Object::cast_to<AtlasTileProxyObject>(p_edited);
if (tile_data) {
Vector<String> components = String(p_property).split("/", true, 2);
- if (components.size() == 2 && components[1] == "shapes_count") {
+ if (components.size() == 2 && components[1] == "polygons_count") {
int layer_index = components[0].trim_prefix("physics_layer_").to_int();
- int new_shapes_count = p_new_value;
- int old_shapes_count = tile_data->get(vformat("physics_layer_%d/shapes_count", layer_index));
- if (new_shapes_count < old_shapes_count) {
- for (int i = new_shapes_count - 1; i < old_shapes_count; i++) {
- ADD_UNDO(tile_data, vformat("physics_layer_%d/shape_%d/shape", layer_index, i));
- ADD_UNDO(tile_data, vformat("physics_layer_%d/shape_%d/one_way", layer_index, i));
- ADD_UNDO(tile_data, vformat("physics_layer_%d/shape_%d/one_way_margin", layer_index, i));
+ int new_polygons_count = p_new_value;
+ int old_polygons_count = tile_data->get(vformat("physics_layer_%d/polygons_count", layer_index));
+ if (new_polygons_count < old_polygons_count) {
+ for (int i = new_polygons_count - 1; i < old_polygons_count; i++) {
+ ADD_UNDO(tile_data, vformat("physics_layer_%d/polygon_%d/points", layer_index, i));
+ ADD_UNDO(tile_data, vformat("physics_layer_%d/polygon_%d/one_way", layer_index, i));
+ ADD_UNDO(tile_data, vformat("physics_layer_%d/polygon_%d/one_way_margin", layer_index, i));
+ }
+ }
+ } else if (p_property == "terrain_set") {
+ int current_terrain_set = tile_data->get("terrain_set");
+ for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) {
+ TileSet::CellNeighbor bit = TileSet::CellNeighbor(i);
+ if (tile_set->is_valid_peering_bit_terrain(current_terrain_set, bit)) {
+ ADD_UNDO(tile_data, "terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]));
}
}
}
@@ -1500,7 +1930,10 @@ void TileSetAtlasSourceEditor::edit(Ref<TileSet> p_tile_set, TileSetAtlasSource
_update_fix_selected_and_hovered_tiles();
_update_tile_id_label();
_update_atlas_view();
+ _update_atlas_source_inspector();
_update_tile_inspector();
+ _update_tile_data_editors();
+ _update_current_tile_data_editor();
}
void TileSetAtlasSourceEditor::init_source() {
@@ -1616,13 +2049,13 @@ void TileSetAtlasSourceEditor::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED:
+ tool_setup_atlas_source_button->set_icon(get_theme_icon("Tools", "EditorIcons"));
tool_select_button->set_icon(get_theme_icon("ToolSelect", "EditorIcons"));
- tool_add_remove_button->set_icon(get_theme_icon("EditAddRemove", "EditorIcons"));
- tool_add_remove_rect_button->set_icon(get_theme_icon("RectangleAddRemove", "EditorIcons"));
+ tool_paint_button->set_icon(get_theme_icon("CanvasItem", "EditorIcons"));
tools_settings_erase_button->set_icon(get_theme_icon("Eraser", "EditorIcons"));
- tool_advanced_menu_buttom->set_icon(get_theme_icon("Tools", "EditorIcons"));
+ tool_advanced_menu_buttom->set_icon(get_theme_icon("GuiTabMenu", "EditorIcons"));
resize_handle = get_theme_icon("EditorHandle", "EditorIcons");
resize_handle_disabled = get_theme_icon("EditorHandleDisabled", "EditorIcons");
@@ -1636,7 +2069,10 @@ void TileSetAtlasSourceEditor::_notification(int p_what) {
_update_fix_selected_and_hovered_tiles();
_update_tile_id_label();
_update_atlas_view();
+ _update_atlas_source_inspector();
_update_tile_inspector();
+ _update_tile_data_editors();
+ _update_current_tile_data_editor();
tile_set_atlas_source_changed_needs_update = false;
}
@@ -1675,7 +2111,6 @@ TileSetAtlasSourceEditor::TileSetAtlasSourceEditor() {
// Tile inspector.
tile_inspector_label = memnew(Label);
tile_inspector_label->set_text(TTR("Tile Properties:"));
- tile_inspector_label->hide();
middle_vbox_container->add_child(tile_inspector_label);
tile_proxy_object = memnew(AtlasTileProxyObject(this));
@@ -1689,6 +2124,36 @@ TileSetAtlasSourceEditor::TileSetAtlasSourceEditor() {
tile_inspector->connect("property_selected", callable_mp(this, &TileSetAtlasSourceEditor::_inspector_property_selected));
middle_vbox_container->add_child(tile_inspector);
+ tile_inspector_no_tile_selected_label = memnew(Label);
+ tile_inspector_no_tile_selected_label->set_align(Label::ALIGN_CENTER);
+ tile_inspector_no_tile_selected_label->set_text(TTR("No tile selected."));
+ middle_vbox_container->add_child(tile_inspector_no_tile_selected_label);
+
+ // Property values palette.
+ tile_data_editors_popup = memnew(Popup);
+
+ tile_data_editors_label = memnew(Label);
+ tile_data_editors_label->set_text(TTR("Paint Properties:"));
+ middle_vbox_container->add_child(tile_data_editors_label);
+
+ tile_data_editor_dropdown_button = memnew(Button);
+ tile_data_editor_dropdown_button->connect("draw", callable_mp(this, &TileSetAtlasSourceEditor::_tile_data_editor_dropdown_button_draw));
+ tile_data_editor_dropdown_button->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_tile_data_editor_dropdown_button_pressed));
+ middle_vbox_container->add_child(tile_data_editor_dropdown_button);
+ tile_data_editor_dropdown_button->add_child(tile_data_editors_popup);
+
+ tile_data_editors_tree = memnew(Tree);
+ tile_data_editors_tree->set_hide_root(true);
+ tile_data_editors_tree->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
+ tile_data_editors_tree->set_h_scroll_enabled(false);
+ tile_data_editors_tree->set_v_scroll_enabled(false);
+ tile_data_editors_tree->connect("item_selected", callable_mp(this, &TileSetAtlasSourceEditor::_tile_data_editors_tree_selected));
+ tile_data_editors_popup->add_child(tile_data_editors_tree);
+
+ tile_data_painting_editor_container = memnew(VBoxContainer);
+ tile_data_painting_editor_container->set_h_size_flags(SIZE_EXPAND_FILL);
+ middle_vbox_container->add_child(tile_data_painting_editor_container);
+
// Atlas source inspector.
atlas_source_inspector_label = memnew(Label);
atlas_source_inspector_label->set_text(TTR("Atlas Properties:"));
@@ -1719,47 +2184,41 @@ TileSetAtlasSourceEditor::TileSetAtlasSourceEditor() {
add_child(confirm_auto_create_tiles);
// -- Toolbox --
- tools_button_group.instance();
+ tools_button_group.instantiate();
+ tools_button_group->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_fix_selected_and_hovered_tiles).unbind(1));
+ tools_button_group->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_tile_id_label).unbind(1));
+ tools_button_group->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_atlas_source_inspector).unbind(1));
+ tools_button_group->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_tile_inspector).unbind(1));
+ tools_button_group->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_tile_data_editors).unbind(1));
+ tools_button_group->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_current_tile_data_editor).unbind(1));
+ tools_button_group->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_atlas_view).unbind(1));
+ tools_button_group->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_toolbar).unbind(1));
toolbox = memnew(HBoxContainer);
right_panel->add_child(toolbox);
+ tool_setup_atlas_source_button = memnew(Button);
+ tool_setup_atlas_source_button->set_flat(true);
+ tool_setup_atlas_source_button->set_toggle_mode(true);
+ tool_setup_atlas_source_button->set_pressed(true);
+ tool_setup_atlas_source_button->set_button_group(tools_button_group);
+ tool_setup_atlas_source_button->set_tooltip(TTR("Atlas Setup. Add/Remove tiles tool (use the shift key to create big tiles, control for rectangle editing)."));
+ toolbox->add_child(tool_setup_atlas_source_button);
+
tool_select_button = memnew(Button);
tool_select_button->set_flat(true);
tool_select_button->set_toggle_mode(true);
- tool_select_button->set_pressed(true);
+ tool_select_button->set_pressed(false);
tool_select_button->set_button_group(tools_button_group);
tool_select_button->set_tooltip(TTR("Select tiles."));
- tool_select_button->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_fix_selected_and_hovered_tiles));
- tool_select_button->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_tile_id_label));
- tool_select_button->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_tile_inspector));
- tool_select_button->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_atlas_view));
- tool_select_button->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_toolbar));
toolbox->add_child(tool_select_button);
- tool_add_remove_button = memnew(Button);
- tool_add_remove_button->set_flat(true);
- tool_add_remove_button->set_toggle_mode(true);
- tool_add_remove_button->set_button_group(tools_button_group);
- tool_add_remove_button->set_tooltip(TTR("Add/Remove tiles tool (use the shift key to create big tiles)."));
- tool_add_remove_button->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_fix_selected_and_hovered_tiles));
- tool_add_remove_button->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_tile_id_label));
- tool_add_remove_button->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_tile_inspector));
- tool_add_remove_button->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_atlas_view));
- tool_add_remove_button->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_toolbar));
- toolbox->add_child(tool_add_remove_button);
-
- tool_add_remove_rect_button = memnew(Button);
- tool_add_remove_rect_button->set_flat(true);
- tool_add_remove_rect_button->set_toggle_mode(true);
- tool_add_remove_rect_button->set_button_group(tools_button_group);
- tool_add_remove_rect_button->set_tooltip(TTR("Add/Remove tiles rectangle tool (use the shift key to create big tiles)."));
- tool_add_remove_rect_button->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_fix_selected_and_hovered_tiles));
- tool_add_remove_rect_button->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_tile_id_label));
- tool_add_remove_rect_button->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_tile_inspector));
- tool_add_remove_rect_button->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_atlas_view));
- tool_add_remove_rect_button->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_toolbar));
- toolbox->add_child(tool_add_remove_rect_button);
+ tool_paint_button = memnew(Button);
+ tool_paint_button->set_flat(true);
+ tool_paint_button->set_toggle_mode(true);
+ tool_paint_button->set_button_group(tools_button_group);
+ tool_paint_button->set_tooltip(TTR("Paint properties."));
+ toolbox->add_child(tool_paint_button);
// Tool settings.
tool_settings = memnew(HBoxContainer);
@@ -1768,6 +2227,9 @@ TileSetAtlasSourceEditor::TileSetAtlasSourceEditor() {
tool_settings_vsep = memnew(VSeparator);
tool_settings->add_child(tool_settings_vsep);
+ tool_settings_tile_data_toolbar_container = memnew(HBoxContainer);
+ tool_settings->add_child(tool_settings_tile_data_toolbar_container);
+
tools_settings_erase_button = memnew(Button);
tools_settings_erase_button->set_flat(true);
tools_settings_erase_button->set_toggle_mode(true);
@@ -1775,9 +2237,6 @@ TileSetAtlasSourceEditor::TileSetAtlasSourceEditor() {
tools_settings_erase_button->set_shortcut_context(this);
tool_settings->add_child(tools_settings_erase_button);
- VSeparator *tool_advanced_vsep = memnew(VSeparator);
- toolbox->add_child(tool_advanced_vsep);
-
tool_advanced_menu_buttom = memnew(MenuButton);
tool_advanced_menu_buttom->set_flat(true);
tool_advanced_menu_buttom->get_popup()->add_item(TTR("Cleanup Tiles Outside Texture"), ADVANCED_CLEANUP_TILES_OUTSIDE_TEXTURE);
@@ -1844,7 +2303,7 @@ TileSetAtlasSourceEditor::TileSetAtlasSourceEditor() {
alternative_tiles_control_unscaled = memnew(Control);
alternative_tiles_control_unscaled->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
alternative_tiles_control_unscaled->connect("draw", callable_mp(this, &TileSetAtlasSourceEditor::_tile_alternatives_control_unscaled_draw));
- tile_atlas_view->add_control_over_atlas_tiles(alternative_tiles_control_unscaled, false);
+ tile_atlas_view->add_control_over_alternative_tiles(alternative_tiles_control_unscaled, false);
alternative_tiles_control_unscaled->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
tile_atlas_view_missing_source_label = memnew(Label);
diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.h b/editor/plugins/tiles/tile_set_atlas_source_editor.h
index 70f2cdbe01..dbb0756a16 100644
--- a/editor/plugins/tiles/tile_set_atlas_source_editor.h
+++ b/editor/plugins/tiles/tile_set_atlas_source_editor.h
@@ -32,6 +32,7 @@
#define TILE_SET_ATLAS_SOURCE_EDITOR_H
#include "tile_atlas_view.h"
+#include "tile_data_editors.h"
#include "editor/editor_node.h"
#include "scene/gui/split_container.h"
@@ -113,10 +114,27 @@ private:
bool tile_set_atlas_source_changed_needs_update = false;
+ // -- Properties painting --
+ VBoxContainer *tile_data_painting_editor_container;
+ Label *tile_data_editors_label;
+ Button *tile_data_editor_dropdown_button;
+ Popup *tile_data_editors_popup;
+ Tree *tile_data_editors_tree;
+ void _tile_data_editor_dropdown_button_draw();
+ void _tile_data_editor_dropdown_button_pressed();
+
+ // -- Tile data editors --
+ String current_property;
+ Control *current_tile_data_editor_toolbar = nullptr;
+ Map<String, TileDataEditor *> tile_data_editors;
+ TileDataEditor *current_tile_data_editor = nullptr;
+ void _tile_data_editors_tree_selected();
+
// -- Inspector --
AtlasTileProxyObject *tile_proxy_object;
Label *tile_inspector_label;
EditorInspector *tile_inspector;
+ Label *tile_inspector_no_tile_selected_label;
String selected_property;
void _inspector_property_selected(String p_property);
@@ -142,6 +160,8 @@ private:
DRAG_TYPE_RECT_SELECT,
+ DRAG_TYPE_MAY_POPUP_MENU,
+
// Warning: keep in this order.
DRAG_TYPE_RESIZE_TOP_LEFT,
DRAG_TYPE_RESIZE_TOP,
@@ -179,15 +199,16 @@ private:
// Tool buttons.
Ref<ButtonGroup> tools_button_group;
+ Button *tool_setup_atlas_source_button;
Button *tool_select_button;
- Button *tool_add_remove_button;
- Button *tool_add_remove_rect_button;
+ Button *tool_paint_button;
Label *tool_tile_id_label;
+ // Tool settings.
HBoxContainer *tool_settings;
VSeparator *tool_settings_vsep;
+ HBoxContainer *tool_settings_tile_data_toolbar_container;
Button *tools_settings_erase_button;
-
MenuButton *tool_advanced_menu_buttom;
// Selection.
@@ -226,7 +247,10 @@ private:
void _update_tile_id_label();
void _update_source_inspector();
void _update_fix_selected_and_hovered_tiles();
+ void _update_atlas_source_inspector();
void _update_tile_inspector();
+ void _update_tile_data_editors();
+ void _update_current_tile_data_editor();
void _update_manage_tile_properties_button();
void _update_atlas_view();
void _update_toolbar();
diff --git a/editor/plugins/tiles/tile_set_editor.cpp b/editor/plugins/tiles/tile_set_editor.cpp
index 11842981f3..2c2ebd107f 100644
--- a/editor/plugins/tiles/tile_set_editor.cpp
+++ b/editor/plugins/tiles/tile_set_editor.cpp
@@ -347,65 +347,23 @@ void TileSetEditor::_undo_redo_inspector_callback(Object *p_undo_redo, Object *p
int old_layer_count = tile_set->get_physics_layers_count();
if (new_layer_count < old_layer_count) {
for (int physics_layer_index = new_layer_count - 1; physics_layer_index < old_layer_count; physics_layer_index++) {
- ADD_UNDO(tile_data, vformat("physics_layer_%d/shapes_count", physics_layer_index));
- for (int shape_index = 0; shape_index < tile_data->get_collision_shapes_count(physics_layer_index); shape_index++) {
- ADD_UNDO(tile_data, vformat("physics_layer_%d/shape_%d/shape", physics_layer_index, shape_index));
- ADD_UNDO(tile_data, vformat("physics_layer_%d/shape_%d/one_way", physics_layer_index, shape_index));
- ADD_UNDO(tile_data, vformat("physics_layer_%d/shape_%d/one_way_margin", physics_layer_index, shape_index));
+ ADD_UNDO(tile_data, vformat("physics_layer_%d/polygons_count", physics_layer_index));
+ for (int polygon_index = 0; polygon_index < tile_data->get_collision_polygons_count(physics_layer_index); polygon_index++) {
+ ADD_UNDO(tile_data, vformat("physics_layer_%d/polygon_%d/points", physics_layer_index, polygon_index));
+ ADD_UNDO(tile_data, vformat("physics_layer_%d/polygon_%d/one_way", physics_layer_index, polygon_index));
+ ADD_UNDO(tile_data, vformat("physics_layer_%d/polygon_%d/one_way_margin", physics_layer_index, polygon_index));
}
}
}
} else if ((p_property == "terrains_sets_count" && tile_data->get_terrain_set() >= (int)p_new_value) ||
- (components.size() == 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_integer() && components[1] == "mode") ||
- (components.size() == 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_integer() && components[1] == "terrains_count" && tile_data->get_terrain_set() == components[0].trim_prefix("terrain_set_").to_int() && (int)p_new_value < tile_set->get_terrains_count(tile_data->get_terrain_set()))) {
+ (components.size() == 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int() && components[1] == "mode") ||
+ (components.size() == 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int() && components[1] == "terrains_count" && tile_data->get_terrain_set() == components[0].trim_prefix("terrain_set_").to_int() && (int)p_new_value < tile_set->get_terrains_count(tile_data->get_terrain_set()))) {
ADD_UNDO(tile_data, "terrain_set");
- if (tile_data->is_valid_peering_bit_terrain(TileSet::CELL_NEIGHBOR_RIGHT_SIDE)) {
- ADD_UNDO(tile_data, "terrains_peering_bit/right_side");
- }
- if (tile_data->is_valid_peering_bit_terrain(TileSet::CELL_NEIGHBOR_RIGHT_CORNER)) {
- ADD_UNDO(tile_data, "terrains_peering_bit/right_corner");
- }
- if (tile_data->is_valid_peering_bit_terrain(TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_SIDE)) {
- ADD_UNDO(tile_data, "terrains_peering_bit/bottom_right_side");
- }
- if (tile_data->is_valid_peering_bit_terrain(TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_CORNER)) {
- ADD_UNDO(tile_data, "terrains_peering_bit/bottom_right_corner");
- }
- if (tile_data->is_valid_peering_bit_terrain(TileSet::CELL_NEIGHBOR_BOTTOM_SIDE)) {
- ADD_UNDO(tile_data, "terrains_peering_bit/bottom_side");
- }
- if (tile_data->is_valid_peering_bit_terrain(TileSet::CELL_NEIGHBOR_BOTTOM_CORNER)) {
- ADD_UNDO(tile_data, "terrains_peering_bit/bottom_corner");
- }
- if (tile_data->is_valid_peering_bit_terrain(TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_SIDE)) {
- ADD_UNDO(tile_data, "terrains_peering_bit/bottom_left_side");
- }
- if (tile_data->is_valid_peering_bit_terrain(TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_CORNER)) {
- ADD_UNDO(tile_data, "terrains_peering_bit/bottom_left_corner");
- }
- if (tile_data->is_valid_peering_bit_terrain(TileSet::CELL_NEIGHBOR_LEFT_SIDE)) {
- ADD_UNDO(tile_data, "terrains_peering_bit/left_side");
- }
- if (tile_data->is_valid_peering_bit_terrain(TileSet::CELL_NEIGHBOR_LEFT_CORNER)) {
- ADD_UNDO(tile_data, "terrains_peering_bit/left_corner");
- }
- if (tile_data->is_valid_peering_bit_terrain(TileSet::CELL_NEIGHBOR_TOP_LEFT_SIDE)) {
- ADD_UNDO(tile_data, "terrains_peering_bit/top_left_side");
- }
- if (tile_data->is_valid_peering_bit_terrain(TileSet::CELL_NEIGHBOR_TOP_LEFT_CORNER)) {
- ADD_UNDO(tile_data, "terrains_peering_bit/top_left_corner");
- }
- if (tile_data->is_valid_peering_bit_terrain(TileSet::CELL_NEIGHBOR_TOP_SIDE)) {
- ADD_UNDO(tile_data, "terrains_peering_bit/top_side");
- }
- if (tile_data->is_valid_peering_bit_terrain(TileSet::CELL_NEIGHBOR_TOP_CORNER)) {
- ADD_UNDO(tile_data, "terrains_peering_bit/top_corner");
- }
- if (tile_data->is_valid_peering_bit_terrain(TileSet::CELL_NEIGHBOR_TOP_RIGHT_SIDE)) {
- ADD_UNDO(tile_data, "terrains_peering_bit/top_right_side");
- }
- if (tile_data->is_valid_peering_bit_terrain(TileSet::CELL_NEIGHBOR_TOP_RIGHT_CORNER)) {
- ADD_UNDO(tile_data, "terrains_peering_bit/top_right_corner");
+ for (int l = 0; l < TileSet::CELL_NEIGHBOR_MAX; l++) {
+ TileSet::CellNeighbor bit = TileSet::CellNeighbor(l);
+ if (tile_data->is_valid_peering_bit_terrain(bit)) {
+ ADD_UNDO(tile_data, "terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[l]));
+ }
}
} else if (p_property == "navigation_layers_count") {
int new_layer_count = p_new_value;
@@ -423,8 +381,8 @@ void TileSetEditor::_undo_redo_inspector_callback(Object *p_undo_redo, Object *p
ADD_UNDO(tile_data, vformat("custom_data_%d", custom_data_layer_index));
}
}
- } else if (components.size() == 2 && components[0].begins_with("custom_data_layer_") && components[0].trim_prefix("custom_data_layer_").is_valid_integer() && components[1] == "type") {
- int custom_data_layer = components[0].trim_prefix("custom_data_layer_").is_valid_integer();
+ } else if (components.size() == 2 && components[0].begins_with("custom_data_layer_") && components[0].trim_prefix("custom_data_layer_").is_valid_int() && components[1] == "type") {
+ int custom_data_layer = components[0].trim_prefix("custom_data_layer_").is_valid_int();
ADD_UNDO(tile_data, vformat("custom_data_%d", custom_data_layer));
}
}
@@ -440,30 +398,6 @@ void TileSetEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_drop_data_fw"), &TileSetEditor::drop_data_fw);
}
-TileDataEditor *TileSetEditor::get_tile_data_editor(String p_property) {
- Vector<String> components = String(p_property).split("/", true);
-
- if (p_property == "z_index") {
- return tile_data_integer_editor;
- } else if (p_property == "probability") {
- return tile_data_float_editor;
- } else if (p_property == "y_sort_origin") {
- return tile_data_y_sort_editor;
- } else if (p_property == "texture_offset") {
- return tile_data_texture_offset_editor;
- } else if (components.size() >= 1 && components[0].begins_with("occlusion_layer_")) {
- return tile_data_occlusion_shape_editor;
- } else if (components.size() >= 1 && components[0].begins_with("physics_layer_")) {
- return tile_data_collision_shape_editor;
- } else if (p_property == "mode" || p_property == "terrain" || (components.size() >= 1 && components[0] == "terrains_peering_bit")) {
- return tile_data_terrains_editor;
- } else if (components.size() >= 1 && components[0].begins_with("navigation_layer_")) {
- return tile_data_navigation_polygon_editor;
- }
-
- return nullptr;
-}
-
void TileSetEditor::edit(Ref<TileSet> p_tile_set) {
if (p_tile_set == tile_set) {
return;
@@ -575,14 +509,4 @@ TileSetEditor::~TileSetEditor() {
if (tile_set.is_valid()) {
tile_set->disconnect("changed", callable_mp(this, &TileSetEditor::_tile_set_changed));
}
-
- // Delete tile data editors.
- memdelete(tile_data_texture_offset_editor);
- memdelete(tile_data_y_sort_editor);
- memdelete(tile_data_integer_editor);
- memdelete(tile_data_float_editor);
- memdelete(tile_data_occlusion_shape_editor);
- memdelete(tile_data_collision_shape_editor);
- memdelete(tile_data_terrains_editor);
- memdelete(tile_data_navigation_polygon_editor);
}
diff --git a/editor/plugins/tiles/tile_set_editor.h b/editor/plugins/tiles/tile_set_editor.h
index f584c043cc..9e50aca62f 100644
--- a/editor/plugins/tiles/tile_set_editor.h
+++ b/editor/plugins/tiles/tile_set_editor.h
@@ -33,7 +33,6 @@
#include "scene/gui/box_container.h"
#include "scene/resources/tile_set.h"
-#include "tile_data_editors.h"
#include "tile_set_atlas_source_editor.h"
#include "tile_set_scenes_collection_source_editor.h"
@@ -54,16 +53,6 @@ private:
void _update_atlas_sources_list(int force_selected_id = -1);
- // List of tile data editors.
- TileDataTextureOffsetEditor *tile_data_texture_offset_editor = memnew(TileDataTextureOffsetEditor);
- TileDataYSortEditor *tile_data_y_sort_editor = memnew(TileDataYSortEditor);
- TileDataIntegerEditor *tile_data_integer_editor = memnew(TileDataIntegerEditor);
- TileDataFloatEditor *tile_data_float_editor = memnew(TileDataFloatEditor);
- TileDataOcclusionShapeEditor *tile_data_occlusion_shape_editor = memnew(TileDataOcclusionShapeEditor);
- TileDataCollisionShapeEditor *tile_data_collision_shape_editor = memnew(TileDataCollisionShapeEditor);
- TileDataTerrainsEditor *tile_data_terrains_editor = memnew(TileDataTerrainsEditor);
- TileDataNavigationPolygonEditor *tile_data_navigation_polygon_editor = memnew(TileDataNavigationPolygonEditor);
-
// -- Sources management --
Button *sources_delete_button;
MenuButton *sources_add_button;
@@ -84,7 +73,6 @@ protected:
public:
_FORCE_INLINE_ static TileSetEditor *get_singleton() { return singleton; }
- TileDataEditor *get_tile_data_editor(String property);
void edit(Ref<TileSet> p_tile_set);
void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index e393f960bd..16d36ad053 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -818,7 +818,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) {
if (is_expression) {
CodeEdit *expression_box = memnew(CodeEdit);
Ref<CodeHighlighter> expression_syntax_highlighter;
- expression_syntax_highlighter.instance();
+ expression_syntax_highlighter.instantiate();
expression_node->set_ctrl_pressed(expression_box, 0);
node->add_child(expression_box);
register_expression_edit(p_id, expression_box);
@@ -1053,7 +1053,7 @@ void VisualShaderEditor::update_custom_nodes() {
Ref<Script> script = Ref<Script>(res);
Ref<VisualShaderNodeCustom> ref;
- ref.instance();
+ ref.instantiate();
ref->set_script(script);
String name;
@@ -2209,7 +2209,7 @@ void VisualShaderEditor::_add_node(int p_idx, int p_op_idx, String p_resource_pa
bool is_custom = add_options[p_idx].is_custom;
if (!is_custom && add_options[p_idx].type != String()) {
- VisualShaderNode *vsn = Object::cast_to<VisualShaderNode>(ClassDB::instance(add_options[p_idx].type));
+ VisualShaderNode *vsn = Object::cast_to<VisualShaderNode>(ClassDB::instantiate(add_options[p_idx].type));
ERR_FAIL_COND(!vsn);
VisualShaderNodeFloatConstant *constant = Object::cast_to<VisualShaderNodeFloatConstant>(vsn);
@@ -2234,7 +2234,7 @@ void VisualShaderEditor::_add_node(int p_idx, int p_op_idx, String p_resource_pa
} else {
ERR_FAIL_COND(add_options[p_idx].script.is_null());
String base_type = add_options[p_idx].script->get_instance_base_type();
- VisualShaderNode *vsn = Object::cast_to<VisualShaderNode>(ClassDB::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);
@@ -2315,6 +2315,13 @@ void VisualShaderEditor::_add_node(int p_idx, int p_op_idx, String p_resource_pa
undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, _from_node, _from_slot, to_node, to_slot);
undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, _from_node, _from_slot, to_node, to_slot);
} else {
+ // Need to setting up Input node properly before committing since `is_port_types_compatible` (calling below) is using `mode` and `shader_type`.
+ VisualShaderNodeInput *input = Object::cast_to<VisualShaderNodeInput>(vsnode.ptr());
+ if (input) {
+ input->set_shader_mode(visual_shader->get_mode());
+ input->set_shader_type(visual_shader->get_shader_type());
+ }
+
// Attempting to connect to the first correct port.
for (int i = 0; i < vsnode->get_output_port_count(); i++) {
if (visual_shader->is_port_types_compatible(vsnode->get_output_port_type(i), input_port_type)) {
@@ -3835,7 +3842,7 @@ VisualShaderEditor::VisualShaderEditor() {
preview_vbox->add_theme_constant_override("separation", 0);
preview_text = memnew(CodeEdit);
- syntax_highlighter.instance();
+ syntax_highlighter.instantiate();
preview_vbox->add_child(preview_text);
preview_text->set_v_size_flags(Control::SIZE_EXPAND_FILL);
preview_text->set_syntax_highlighter(syntax_highlighter);
@@ -4427,10 +4434,10 @@ VisualShaderEditor::VisualShaderEditor() {
undo_redo = EditorNode::get_singleton()->get_undo_redo();
Ref<VisualShaderNodePluginDefault> default_plugin;
- default_plugin.instance();
+ default_plugin.instantiate();
add_plugin(default_plugin);
- graph_plugin.instance();
+ graph_plugin.instantiate();
property_editor = memnew(CustomPropertyEditor);
add_child(property_editor);
@@ -4885,14 +4892,14 @@ void VisualShaderNodePortPreview::_shader_changed() {
String shader_code = shader->generate_preview_shader(type, node, port, default_textures);
Ref<Shader> preview_shader;
- preview_shader.instance();
+ preview_shader.instantiate();
preview_shader->set_code(shader_code);
for (int i = 0; i < default_textures.size(); i++) {
preview_shader->set_default_texture_param(default_textures[i].name, default_textures[i].param);
}
Ref<ShaderMaterial> material;
- material.instance();
+ material.instantiate();
material->set_shader(preview_shader);
//find if a material is also being edited and copy parameters to this one
@@ -4977,7 +4984,7 @@ Ref<Resource> VisualShaderConversionPlugin::convert(const Ref<Resource> &p_resou
ERR_FAIL_COND_V(!vshader.is_valid(), Ref<Resource>());
Ref<Shader> shader;
- shader.instance();
+ shader.instantiate();
String code = vshader->get_code();
shader->set_code(code);
diff --git a/editor/project_export.cpp b/editor/project_export.cpp
index ec65694772..75736a0723 100644
--- a/editor/project_export.cpp
+++ b/editor/project_export.cpp
@@ -1110,9 +1110,9 @@ ProjectExportDialog::ProjectExportDialog() {
exclude_filters->connect("text_changed", callable_mp(this, &ProjectExportDialog::_filter_changed));
script_mode = memnew(OptionButton);
- resources_vb->add_margin_child(TTR("Script Export Mode:"), script_mode);
+ resources_vb->add_margin_child(TTR("GDScript Export Mode:"), script_mode);
script_mode->add_item(TTR("Text"), (int)EditorExportPreset::MODE_SCRIPT_TEXT);
- script_mode->add_item(TTR("Compiled"), (int)EditorExportPreset::MODE_SCRIPT_COMPILED);
+ script_mode->add_item(TTR("Compiled Bytecode (Faster Loading)"), (int)EditorExportPreset::MODE_SCRIPT_COMPILED);
script_mode->connect("item_selected", callable_mp(this, &ProjectExportDialog::_script_export_mode_changed));
// Feature tags.
@@ -1137,12 +1137,12 @@ ProjectExportDialog::ProjectExportDialog() {
enc_pck = memnew(CheckButton);
enc_pck->connect("toggled", callable_mp(this, &ProjectExportDialog::_enc_pck_changed));
- enc_pck->set_text(TTR("Encrypt exported PCK"));
+ enc_pck->set_text(TTR("Encrypt Exported PCK"));
sec_vb->add_child(enc_pck);
enc_directory = memnew(CheckButton);
enc_directory->connect("toggled", callable_mp(this, &ProjectExportDialog::_enc_directory_changed));
- enc_directory->set_text("Encrypt index (file names and info).");
+ enc_directory->set_text("Encrypt Index (File Names and Info)");
sec_vb->add_child(enc_directory);
enc_in_filters = memnew(LineEdit);
@@ -1160,9 +1160,9 @@ ProjectExportDialog::ProjectExportDialog() {
script_key = memnew(LineEdit);
script_key->connect("text_changed", callable_mp(this, &ProjectExportDialog::_script_encryption_key_changed));
script_key_error = memnew(Label);
- script_key_error->set_text("- " + TTR("Invalid Encryption Key (must be 64 characters long)"));
+ script_key_error->set_text("- " + TTR("Invalid Encryption Key (must be 64 hexadecimal characters long)"));
script_key_error->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor"));
- sec_vb->add_margin_child(TTR("Encryption Key (256-bits as hex):"), script_key);
+ sec_vb->add_margin_child(TTR("Encryption Key (256-bits as hexadecimal):"), script_key);
sec_vb->add_child(script_key_error);
sections->add_child(sec_vb);
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index fdd114bb1e..50a763f05a 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -862,7 +862,7 @@ public:
rasterizer_container->add_child(l);
Container *rshb = memnew(HBoxContainer);
rasterizer_container->add_child(rshb);
- rasterizer_button_group.instance();
+ rasterizer_button_group.instantiate();
Container *rvb = memnew(VBoxContainer);
rvb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
@@ -1145,7 +1145,7 @@ void ProjectList::load_project_icon(int p_index) {
Ref<Texture2D> icon;
if (item.icon != "") {
Ref<Image> img;
- img.instance();
+ img.instantiate();
Error err = img->load(item.icon.replace_first("res://", item.path + "/"));
if (err == OK) {
img->resize(default_icon->get_width(), default_icon->get_height(), Image::INTERPOLATE_LANCZOS);
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index ba3c9aafb4..7414c2d8e6 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -192,7 +192,7 @@ void CustomPropertyEditor::_menu_option(int p_which) {
String orig_type = res_orig->get_class();
- Object *inst = ClassDB::instance(orig_type);
+ Object *inst = ClassDB::instantiate(orig_type);
Ref<Resource> res = Ref<Resource>(Object::cast_to<Resource>(inst));
@@ -262,7 +262,7 @@ void CustomPropertyEditor::_menu_option(int p_which) {
return;
}
- Variant obj = ClassDB::instance(intype);
+ Variant obj = ClassDB::instantiate(intype);
if (!obj) {
if (ScriptServer::is_global_class(intype)) {
@@ -908,7 +908,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
}
}
- if (!is_custom_resource && !ClassDB::can_instance(t)) {
+ if (!is_custom_resource && !ClassDB::can_instantiate(t)) {
continue;
}
@@ -1078,7 +1078,7 @@ void CustomPropertyEditor::_type_create_selected(int p_idx) {
String intype = inheritors_array[p_idx];
- Variant obj = ClassDB::instance(intype);
+ Variant obj = ClassDB::instantiate(intype);
if (!obj) {
if (ScriptServer::is_global_class(intype)) {
@@ -1111,7 +1111,7 @@ void CustomPropertyEditor::_node_path_selected(NodePath p_path) {
}
Ref<ViewportTexture> vt;
- vt.instance();
+ vt.instantiate();
vt->set_viewport_path_in_scene(get_tree()->get_edited_scene_root()->get_path_to(to_node));
vt->setup_local_to_scene();
v = vt;
@@ -1268,7 +1268,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
String intype = inheritors_array[0];
if (hint == PROPERTY_HINT_RESOURCE_TYPE) {
- Variant obj = ClassDB::instance(intype);
+ Variant obj = ClassDB::instantiate(intype);
if (!obj) {
if (ScriptServer::is_global_class(intype)) {
@@ -1332,7 +1332,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
propvalues.push_back(p);
}
- Ref<Resource> res = Ref<Resource>(ClassDB::instance(res_orig->get_class()));
+ Ref<Resource> res = Ref<Resource>(ClassDB::instantiate(res_orig->get_class()));
ERR_FAIL_COND(res.is_null());
@@ -1453,7 +1453,7 @@ void CustomPropertyEditor::_modified(String p_string) {
case Variant::INT: {
String text = TS->parse_number(value_editor[0]->get_text());
Ref<Expression> expr;
- expr.instance();
+ expr.instantiate();
Error err = expr->parse(text);
if (err != OK) {
v = value_editor[0]->get_text().to_int();
@@ -1629,7 +1629,7 @@ void CustomPropertyEditor::_modified(String p_string) {
real_t CustomPropertyEditor::_parse_real_expression(String text) {
Ref<Expression> expr;
- expr.instance();
+ expr.instantiate();
Error err = expr->parse(text);
real_t out;
if (err != OK) {
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 8d6b7f3389..2114ca41d3 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -58,7 +58,7 @@ void SceneTreeDock::_nodes_drag_begin() {
}
void SceneTreeDock::_quick_open() {
- instance_scenes(quick_open->get_selected_files(), scene_tree->get_selected());
+ instantiate_scenes(quick_open->get_selected_files(), scene_tree->get_selected());
}
void SceneTreeDock::_input(Ref<InputEvent> p_event) {
@@ -89,7 +89,7 @@ void SceneTreeDock::_unhandled_key_input(Ref<InputEvent> p_event) {
} else if (ED_IS_SHORTCUT("scene_tree/add_child_node", p_event)) {
_tool_selected(TOOL_NEW);
} else if (ED_IS_SHORTCUT("scene_tree/instance_scene", p_event)) {
- _tool_selected(TOOL_INSTANCE);
+ _tool_selected(TOOL_INSTANTIATE);
} else if (ED_IS_SHORTCUT("scene_tree/expand_collapse_all", p_event)) {
_tool_selected(TOOL_EXPAND_COLLAPSE);
} else if (ED_IS_SHORTCUT("scene_tree/cut_node", p_event)) {
@@ -128,13 +128,13 @@ void SceneTreeDock::_unhandled_key_input(Ref<InputEvent> p_event) {
accept_event();
}
-void SceneTreeDock::instance(const String &p_file) {
+void SceneTreeDock::instantiate(const String &p_file) {
Vector<String> scenes;
scenes.push_back(p_file);
- instance_scenes(scenes, scene_tree->get_selected());
+ instantiate_scenes(scenes, scene_tree->get_selected());
}
-void SceneTreeDock::instance_scenes(const Vector<String> &p_files, Node *p_parent) {
+void SceneTreeDock::instantiate_scenes(const Vector<String> &p_files, Node *p_parent) {
Node *parent = p_parent;
if (!parent) {
@@ -147,18 +147,18 @@ void SceneTreeDock::instance_scenes(const Vector<String> &p_files, Node *p_paren
if (!parent) {
if (p_files.size() == 1) {
- accept->set_text(TTR("No parent to instance a child at."));
+ accept->set_text(TTR("No parent to instantiate a child at."));
} else {
- accept->set_text(TTR("No parent to instance the scenes at."));
+ accept->set_text(TTR("No parent to instantiate the scenes at."));
}
accept->popup_centered();
return;
};
- _perform_instance_scenes(p_files, parent, -1);
+ _perform_instantiate_scenes(p_files, parent, -1);
}
-void SceneTreeDock::_perform_instance_scenes(const Vector<String> &p_files, Node *parent, int p_pos) {
+void SceneTreeDock::_perform_instantiate_scenes(const Vector<String> &p_files, Node *parent, int p_pos) {
ERR_FAIL_COND(!parent);
Vector<Node *> instances;
@@ -175,8 +175,8 @@ void SceneTreeDock::_perform_instance_scenes(const Vector<String> &p_files, Node
break;
}
- Node *instanced_scene = sdata->instance(PackedScene::GEN_EDIT_STATE_INSTANCE);
- if (!instanced_scene) {
+ Node *instantiated_scene = sdata->instantiate(PackedScene::GEN_EDIT_STATE_INSTANCE);
+ if (!instantiated_scene) {
current_option = -1;
accept->set_text(vformat(TTR("Error instancing scene from %s"), p_files[i]));
accept->popup_centered();
@@ -185,7 +185,7 @@ void SceneTreeDock::_perform_instance_scenes(const Vector<String> &p_files, Node
}
if (edited_scene->get_filename() != "") {
- if (_cyclical_dependency_exists(edited_scene->get_filename(), instanced_scene)) {
+ if (_cyclical_dependency_exists(edited_scene->get_filename(), instantiated_scene)) {
accept->set_text(vformat(TTR("Cannot instance the scene '%s' because the current scene exists within one of its nodes."), p_files[i]));
accept->popup_centered();
error = true;
@@ -193,9 +193,9 @@ void SceneTreeDock::_perform_instance_scenes(const Vector<String> &p_files, Node
}
}
- instanced_scene->set_filename(ProjectSettings::get_singleton()->localize_path(p_files[i]));
+ instantiated_scene->set_filename(ProjectSettings::get_singleton()->localize_path(p_files[i]));
- instances.push_back(instanced_scene);
+ instances.push_back(instantiated_scene);
}
if (error) {
@@ -208,19 +208,19 @@ void SceneTreeDock::_perform_instance_scenes(const Vector<String> &p_files, Node
editor_data->get_undo_redo().create_action(TTR("Instance Scene(s)"));
for (int i = 0; i < instances.size(); i++) {
- Node *instanced_scene = instances[i];
+ Node *instantiated_scene = instances[i];
- editor_data->get_undo_redo().add_do_method(parent, "add_child", instanced_scene);
+ editor_data->get_undo_redo().add_do_method(parent, "add_child", instantiated_scene);
if (p_pos >= 0) {
- editor_data->get_undo_redo().add_do_method(parent, "move_child", instanced_scene, p_pos + i);
+ editor_data->get_undo_redo().add_do_method(parent, "move_child", instantiated_scene, p_pos + i);
}
- editor_data->get_undo_redo().add_do_method(instanced_scene, "set_owner", edited_scene);
+ editor_data->get_undo_redo().add_do_method(instantiated_scene, "set_owner", edited_scene);
editor_data->get_undo_redo().add_do_method(editor_selection, "clear");
- editor_data->get_undo_redo().add_do_method(editor_selection, "add_node", instanced_scene);
- editor_data->get_undo_redo().add_do_reference(instanced_scene);
- editor_data->get_undo_redo().add_undo_method(parent, "remove_child", instanced_scene);
+ editor_data->get_undo_redo().add_do_method(editor_selection, "add_node", instantiated_scene);
+ editor_data->get_undo_redo().add_do_reference(instantiated_scene);
+ editor_data->get_undo_redo().add_undo_method(parent, "remove_child", instantiated_scene);
- String new_name = parent->validate_child_name(instanced_scene);
+ String new_name = parent->validate_child_name(instantiated_scene);
EditorDebuggerNode *ed = EditorDebuggerNode::get_singleton();
editor_data->get_undo_redo().add_do_method(ed, "live_debug_instance_node", edited_scene->get_path_to(parent), p_files[i], new_name);
editor_data->get_undo_redo().add_undo_method(ed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(parent)).plus_file(new_name)));
@@ -241,8 +241,8 @@ void SceneTreeDock::_replace_with_branch_scene(const String &p_file, Node *base)
return;
}
- Node *instanced_scene = sdata->instance(PackedScene::GEN_EDIT_STATE_INSTANCE);
- if (!instanced_scene) {
+ Node *instantiated_scene = sdata->instantiate(PackedScene::GEN_EDIT_STATE_INSTANCE);
+ if (!instantiated_scene) {
accept->set_text(vformat(TTR("Error instancing scene from %s"), p_file));
accept->popup_centered();
return;
@@ -254,10 +254,10 @@ void SceneTreeDock::_replace_with_branch_scene(const String &p_file, Node *base)
Node *parent = base->get_parent();
int pos = base->get_index();
undo_redo->add_do_method(parent, "remove_child", base);
- undo_redo->add_undo_method(parent, "remove_child", instanced_scene);
- undo_redo->add_do_method(parent, "add_child", instanced_scene);
+ undo_redo->add_undo_method(parent, "remove_child", instantiated_scene);
+ undo_redo->add_do_method(parent, "add_child", instantiated_scene);
undo_redo->add_undo_method(parent, "add_child", base);
- undo_redo->add_do_method(parent, "move_child", instanced_scene, pos);
+ undo_redo->add_do_method(parent, "move_child", instantiated_scene, pos);
undo_redo->add_undo_method(parent, "move_child", base, pos);
List<Node *> owned;
@@ -266,17 +266,17 @@ void SceneTreeDock::_replace_with_branch_scene(const String &p_file, Node *base)
for (List<Node *>::Element *F = owned.front(); F; F = F->next()) {
owners.push_back(F->get());
}
- undo_redo->add_do_method(instanced_scene, "set_owner", edited_scene);
+ undo_redo->add_do_method(instantiated_scene, "set_owner", edited_scene);
undo_redo->add_undo_method(this, "_set_owners", edited_scene, owners);
undo_redo->add_do_method(editor_selection, "clear");
undo_redo->add_undo_method(editor_selection, "clear");
- undo_redo->add_do_method(editor_selection, "add_node", instanced_scene);
+ undo_redo->add_do_method(editor_selection, "add_node", instantiated_scene);
undo_redo->add_undo_method(editor_selection, "add_node", base);
- undo_redo->add_do_property(scene_tree, "set_selected", instanced_scene);
+ undo_redo->add_do_property(scene_tree, "set_selected", instantiated_scene);
undo_redo->add_undo_property(scene_tree, "set_selected", base);
- undo_redo->add_do_reference(instanced_scene);
+ undo_redo->add_do_reference(instantiated_scene);
undo_redo->add_undo_reference(base);
undo_redo->commit_action();
}
@@ -313,7 +313,7 @@ bool SceneTreeDock::_track_inherit(const String &p_target_scene_path, Node *p_de
String path = ss->get_path();
Ref<PackedScene> data = ResourceLoader::load(path);
if (data.is_valid()) {
- p = data->instance(PackedScene::GEN_EDIT_STATE_INSTANCE);
+ p = data->instantiate(PackedScene::GEN_EDIT_STATE_INSTANCE);
if (!p) {
continue;
}
@@ -388,7 +388,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
emit_signal("add_node_used");
}
} break;
- case TOOL_INSTANCE: {
+ case TOOL_INSTANTIATE: {
if (!profile_allow_editing) {
break;
}
@@ -400,7 +400,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
}
quick_open->popup_dialog("PackedScene", true);
- quick_open->set_title(TTR("Instance Child Scene"));
+ quick_open->set_title(TTR("Instantiate Child Scene"));
if (!p_confirm_override) {
emit_signal("add_node_used");
}
@@ -881,7 +881,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if (node == editor_data->get_edited_scene_root()) {
msg = vformat(TTR("Delete the root node \"%s\"?"), node->get_name());
} else if (node->get_filename() == "" && node->get_child_count() > 0) {
- // Display this message only for non-instanced scenes
+ // 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());
@@ -922,13 +922,13 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
Node *tocopy = selection.front()->get();
if (tocopy == scene) {
- accept->set_text(TTR("Can't save the root node branch as an instanced scene.\nTo create an editable copy of the current scene, duplicate it using the FileSystem dock context menu\nor create an inherited scene using Scene > New Inherited Scene... instead."));
+ accept->set_text(TTR("Can't save the root node branch as an instantiated scene.\nTo create an editable copy of the current scene, duplicate it using the FileSystem dock context menu\nor create an inherited scene using Scene > New Inherited Scene... instead."));
accept->popup_centered();
break;
}
if (tocopy != editor_data->get_edited_scene_root() && tocopy->get_filename() != "") {
- accept->set_text(TTR("Can't save the branch of an already instanced scene.\nTo create a variation of a scene, you can make an inherited scene based on the instanced scene using Scene > New Inherited Scene... instead."));
+ accept->set_text(TTR("Can't save the branch of an already instantiated scene.\nTo create a variation of a scene, you can make an inherited scene based on the instantiated scene using Scene > New Inherited Scene... instead."));
accept->popup_centered();
break;
}
@@ -1103,14 +1103,14 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if (TOOL_CREATE_FAVORITE == p_tool) {
String name = selected_favorite_root.get_slicec(' ', 0);
if (ScriptServer::is_global_class(name)) {
- new_node = Object::cast_to<Node>(ClassDB::instance(ScriptServer::get_global_class_native_base(name)));
+ new_node = Object::cast_to<Node>(ClassDB::instantiate(ScriptServer::get_global_class_native_base(name)));
Ref<Script> script = ResourceLoader::load(ScriptServer::get_global_class_path(name), "Script");
if (new_node && script.is_valid()) {
new_node->set_script(script);
new_node->set_name(name);
}
} else {
- new_node = Object::cast_to<Node>(ClassDB::instance(selected_favorite_root));
+ new_node = Object::cast_to<Node>(ClassDB::instantiate(selected_favorite_root));
}
if (!new_node) {
@@ -1640,7 +1640,7 @@ bool SceneTreeDock::_validate_no_instance() {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
if (E->get() != edited_scene && E->get()->get_filename() != "") {
- accept->set_text(TTR("This operation can't be done on instanced scenes."));
+ accept->set_text(TTR("This operation can't be done on instantiated scenes."));
accept->popup_centered();
return false;
}
@@ -2218,7 +2218,7 @@ void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node, bool p_keep_prop
Node *newnode = p_by_node;
if (p_keep_properties) {
- Node *default_oldnode = Object::cast_to<Node>(ClassDB::instance(n->get_class()));
+ Node *default_oldnode = Object::cast_to<Node>(ClassDB::instantiate(n->get_class()));
List<PropertyInfo> pinfo;
n->get_property_list(&pinfo);
@@ -2459,7 +2459,7 @@ void SceneTreeDock::_files_dropped(Vector<String> p_files, NodePath p_to, int p_
int to_pos = -1;
_normalize_drop(node, to_pos, p_type);
- _perform_instance_scenes(p_files, node, to_pos);
+ _perform_instantiate_scenes(p_files, node, to_pos);
}
void SceneTreeDock::_script_dropped(String p_file, NodePath p_to) {
@@ -2542,7 +2542,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
menu->clear();
if (profile_allow_editing) {
menu->add_icon_shortcut(get_theme_icon("Add", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW);
- menu->add_icon_shortcut(get_theme_icon("Instance", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANCE);
+ menu->add_icon_shortcut(get_theme_icon("Instance", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANTIATE);
}
menu->set_size(Size2(1, 1));
@@ -2575,7 +2575,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
}
menu->add_icon_shortcut(get_theme_icon("Add", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW);
- menu->add_icon_shortcut(get_theme_icon("Instance", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANCE);
+ menu->add_icon_shortcut(get_theme_icon("Instance", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANTIATE);
}
menu->add_icon_shortcut(get_theme_icon("Collapse", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/expand_collapse_all"), TOOL_EXPAND_COLLAPSE);
menu->add_separator();
@@ -2813,7 +2813,7 @@ void SceneTreeDock::open_add_child_dialog() {
}
void SceneTreeDock::open_instance_child_dialog() {
- _tool_selected(TOOL_INSTANCE, true);
+ _tool_selected(TOOL_INSTANTIATE, true);
}
void SceneTreeDock::add_remote_tree_editor(Control *p_remote) {
@@ -2959,7 +2959,7 @@ void SceneTreeDock::_clear_clipboard() {
void SceneTreeDock::_create_remap_for_node(Node *p_node, Map<RES, RES> &r_remap) {
List<PropertyInfo> props;
p_node->get_property_list(&props);
- bool is_instanced = EditorPropertyRevert::may_node_be_in_instance(p_node);
+ bool is_instantiated = EditorPropertyRevert::may_node_be_in_instance(p_node);
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) {
@@ -2970,9 +2970,9 @@ void SceneTreeDock::_create_remap_for_node(Node *p_node, Map<RES, RES> &r_remap)
if (v.is_ref()) {
RES res = v;
if (res.is_valid()) {
- if (is_instanced) {
+ if (is_instantiated) {
Variant orig;
- if (EditorPropertyRevert::get_instanced_node_original_property(p_node, E->get().name, orig)) {
+ if (EditorPropertyRevert::get_instantiated_node_original_property(p_node, E->get().name, orig)) {
if (!EditorPropertyRevert::is_node_property_different(p_node, v, orig)) {
continue;
}
@@ -3020,7 +3020,7 @@ void SceneTreeDock::_bind_methods() {
ClassDB::bind_method(D_METHOD("_input"), &SceneTreeDock::_input);
ClassDB::bind_method(D_METHOD("_update_script_button"), &SceneTreeDock::_update_script_button);
- ClassDB::bind_method(D_METHOD("instance"), &SceneTreeDock::instance);
+ ClassDB::bind_method(D_METHOD("instantiate"), &SceneTreeDock::instantiate);
ClassDB::bind_method(D_METHOD("get_tree_editor"), &SceneTreeDock::get_tree_editor);
ClassDB::bind_method(D_METHOD("replace_node"), &SceneTreeDock::replace_node);
@@ -3054,7 +3054,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel
ED_SHORTCUT("scene_tree/rename", TTR("Rename"), KEY_F2);
ED_SHORTCUT("scene_tree/batch_rename", TTR("Batch Rename"), KEY_MASK_SHIFT | KEY_F2);
ED_SHORTCUT("scene_tree/add_child_node", TTR("Add Child Node"), KEY_MASK_CMD | KEY_A);
- ED_SHORTCUT("scene_tree/instance_scene", TTR("Instance Child Scene"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_A);
+ ED_SHORTCUT("scene_tree/instance_scene", TTR("Instantiate Child Scene"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_A);
ED_SHORTCUT("scene_tree/expand_collapse_all", TTR("Expand/Collapse All"));
ED_SHORTCUT("scene_tree/cut_node", TTR("Cut"), KEY_MASK_CMD | KEY_X);
ED_SHORTCUT("scene_tree/copy_node", TTR("Copy"), KEY_MASK_CMD | KEY_C);
@@ -3083,8 +3083,8 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel
button_instance = memnew(Button);
button_instance->set_flat(true);
- button_instance->connect("pressed", callable_mp(this, &SceneTreeDock::_tool_selected), make_binds(TOOL_INSTANCE, false));
- button_instance->set_tooltip(TTR("Instance a scene file as a Node. Creates an inherited scene if no root node exists."));
+ button_instance->connect("pressed", callable_mp(this, &SceneTreeDock::_tool_selected), make_binds(TOOL_INSTANTIATE, false));
+ button_instance->set_tooltip(TTR("Instantiate a scene file as a Node. Creates an inherited scene if no root node exists."));
button_instance->set_shortcut(ED_GET_SHORTCUT("scene_tree/instance_scene"));
filter_hbc->add_child(button_instance);
diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h
index 53f31375f8..a313337540 100644
--- a/editor/scene_tree_dock.h
+++ b/editor/scene_tree_dock.h
@@ -55,7 +55,7 @@ class SceneTreeDock : public VBoxContainer {
enum Tool {
TOOL_NEW,
- TOOL_INSTANCE,
+ TOOL_INSTANTIATE,
TOOL_EXPAND_COLLAPSE,
TOOL_CUT,
TOOL_COPY,
@@ -224,7 +224,7 @@ class SceneTreeDock : public VBoxContainer {
void _filter_changed(const String &p_filter);
- void _perform_instance_scenes(const Vector<String> &p_files, Node *parent, int p_pos);
+ void _perform_instantiate_scenes(const Vector<String> &p_files, Node *parent, int p_pos);
void _replace_with_branch_scene(const String &p_file, Node *base);
void _file_selected(String p_file);
@@ -259,8 +259,8 @@ public:
void import_subscene();
void set_edited_scene(Node *p_scene);
- void instance(const String &p_file);
- void instance_scenes(const Vector<String> &p_files, Node *p_parent = nullptr);
+ void instantiate(const String &p_file);
+ void instantiate_scenes(const Vector<String> &p_files, Node *p_parent = nullptr);
void set_selected(Node *p_node, bool p_emit_selected = false);
void fill_path_renames(Node *p_node, Node *p_new_parent, List<Pair<NodePath, NodePath>> *p_renames);
void perform_node_renames(Node *p_base, List<Pair<NodePath, NodePath>> *p_renames, Map<Ref<Animation>, Set<int>> *r_rem_anims = nullptr);
diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp
index a5620f8cc5..3aa04e4dc3 100644
--- a/editor/scene_tree_editor.cpp
+++ b/editor/scene_tree_editor.cpp
@@ -944,7 +944,7 @@ Variant SceneTreeEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from
Node *n = get_node(np);
if (n) {
- // Only allow selection if not part of an instanced scene.
+ // Only allow selection if not part of an instantiated scene.
if (!n->get_owner() || n->get_owner() == get_scene_node() || n->get_owner()->get_filename() == String()) {
selected.push_back(n);
icons.push_back(next->get_icon(0));
diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp
index c05a3c2f89..c2c99ed17f 100644
--- a/editor/settings_config_dialog.cpp
+++ b/editor/settings_config_dialog.cpp
@@ -285,7 +285,7 @@ void EditorSettingsDialog::_update_shortcuts() {
event_strings.push_back(I->get()->as_text());
// Only check if the events have been the same so far - once one fails, we don't need to check any more.
- if (same_as_defaults && !key_default_events[count]->shortcut_match(I->get())) {
+ if (same_as_defaults && !key_default_events[count]->is_match(I->get())) {
same_as_defaults = false;
}
count++;
diff --git a/main/main.cpp b/main/main.cpp
index 667aebebae..9e3b5c9ba2 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -34,6 +34,7 @@
#include "core/core_string_names.h"
#include "core/crypto/crypto.h"
#include "core/debugger/engine_debugger.h"
+#include "core/extension/extension_api_dump.h"
#include "core/input/input.h"
#include "core/input/input_map.h"
#include "core/io/dir_access.h"
@@ -174,7 +175,9 @@ static int frame_delay = 0;
static bool disable_render_loop = false;
static int fixed_fps = -1;
static bool print_fps = false;
-
+#ifdef TOOLS_ENABLED
+static bool dump_extension_api = false;
+#endif
bool profile_gpu = false;
/* Helper methods */
@@ -406,6 +409,8 @@ Error Main::test_setup() {
translation_server = memnew(TranslationServer);
+ register_core_extensions();
+
// From `Main::setup2()`.
preregister_module_types();
preregister_server_types();
@@ -887,7 +892,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
auto_build_solutions = true;
editor = true;
cmdline_tool = true;
-#ifdef DEBUG_METHODS_ENABLED
+
} else if (I->get() == "--gdnative-generate-json-api" || I->get() == "--gdnative-generate-json-builtin-api") {
// Register as an editor instance to use low-end fallback if relevant.
editor = true;
@@ -895,7 +900,13 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
// We still pass it to the main arguments since the argument handling itself is not done in this function
main_args.push_back(I->get());
-#endif
+ } else if (I->get() == "--dump-extension-api") {
+ // Register as an editor instance to use low-end fallback if relevant.
+ editor = true;
+ cmdline_tool = true;
+ dump_extension_api = true;
+ print_line("dump extension?");
+ main_args.push_back(I->get());
} else if (I->get() == "--export" || I->get() == "--export-debug" ||
I->get() == "--export-pack") { // Export project
// Actually handling is done in start().
@@ -1198,6 +1209,8 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
OS::get_singleton()->set_cmdline(execpath, main_args);
+ register_core_extensions(); //before display
+
GLOBAL_DEF("rendering/driver/driver_name", "Vulkan");
ProjectSettings::get_singleton()->set_custom_property_info("rendering/driver/driver_name",
PropertyInfo(Variant::STRING,
@@ -1669,7 +1682,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
boot_logo_path = boot_logo_path.strip_edges();
if (boot_logo_path != String()) {
- boot_logo.instance();
+ boot_logo.instantiate();
Error load_err = ImageLoader::load_image(boot_logo_path, boot_logo);
if (load_err) {
ERR_PRINT("Non-existing or invalid boot splash at '" + boot_logo_path + "'. Loading default splash.");
@@ -2004,6 +2017,11 @@ bool Main::start() {
return false;
}
+
+ if (dump_extension_api) {
+ NativeExtensionAPIDump::generate_extension_json_file("extension_api.json");
+ return false;
+ }
#endif
if (script == "" && game_path == "" && String(GLOBAL_GET("application/run/main_scene")) != "") {
@@ -2037,9 +2055,9 @@ bool Main::start() {
return false;
}
- if (script_res->can_instance()) {
+ if (script_res->can_instantiate()) {
StringName instance_type = script_res->get_instance_base_type();
- Object *obj = ClassDB::instance(instance_type);
+ Object *obj = ClassDB::instantiate(instance_type);
MainLoop *script_loop = Object::cast_to<MainLoop>(obj);
if (!script_loop) {
if (obj) {
@@ -2060,7 +2078,7 @@ bool Main::start() {
String script_path = ScriptServer::get_global_class_path(main_loop_type);
Ref<Script> script_res = ResourceLoader::load(script_path);
StringName script_base = ScriptServer::get_global_class_native_base(main_loop_type);
- Object *obj = ClassDB::instance(script_base);
+ Object *obj = ClassDB::instantiate(script_base);
MainLoop *script_loop = Object::cast_to<MainLoop>(obj);
if (!script_loop) {
if (obj) {
@@ -2083,7 +2101,7 @@ bool Main::start() {
DisplayServer::get_singleton()->alert("Error: MainLoop type doesn't exist: " + main_loop_type);
return false;
} else {
- Object *ml = ClassDB::instance(main_loop_type);
+ Object *ml = ClassDB::instantiate(main_loop_type);
ERR_FAIL_COND_V_MSG(!ml, false, "Can't instance MainLoop type.");
main_loop = Object::cast_to<MainLoop>(ml);
@@ -2140,14 +2158,14 @@ bool Main::start() {
Node *n = nullptr;
if (res->is_class("PackedScene")) {
Ref<PackedScene> ps = res;
- n = ps->instance();
+ n = ps->instantiate();
} else if (res->is_class("Script")) {
Ref<Script> script_res = res;
StringName ibt = script_res->get_instance_base_type();
bool valid_type = ClassDB::is_parent_class(ibt, "Node");
ERR_CONTINUE_MSG(!valid_type, "Script does not inherit a Node: " + info.path);
- Object *obj = ClassDB::instance(ibt);
+ Object *obj = ClassDB::instantiate(ibt);
ERR_CONTINUE_MSG(obj == nullptr,
"Cannot instance script for autoload, expected 'Node' inheritance, got: " +
@@ -2350,7 +2368,7 @@ bool Main::start() {
Node *scene = nullptr;
Ref<PackedScene> scenedata = ResourceLoader::load(local_game_path);
if (scenedata.is_valid()) {
- scene = scenedata->instance();
+ scene = scenedata->instantiate();
}
ERR_FAIL_COND_V_MSG(!scene, false, "Failed loading scene: " + local_game_path);
@@ -2375,7 +2393,7 @@ bool Main::start() {
String iconpath = GLOBAL_DEF("application/config/icon", "Variant()");
if ((iconpath != "") && (!hasicon)) {
Ref<Image> icon;
- icon.instance();
+ icon.instantiate();
if (ImageLoader::load_image(iconpath, icon) == OK) {
DisplayServer::get_singleton()->set_icon(icon);
hasicon = true;
diff --git a/modules/basis_universal/register_types.cpp b/modules/basis_universal/register_types.cpp
index 772ac87dbf..23639a4f2f 100644
--- a/modules/basis_universal/register_types.cpp
+++ b/modules/basis_universal/register_types.cpp
@@ -260,7 +260,7 @@ static Ref<Image> basis_universal_unpacker(const Vector<uint8_t> &p_buffer) {
};
};
- image.instance();
+ image.instantiate();
image->create(info.m_width, info.m_height, info.m_total_levels > 1, imgfmt, gpudata);
return image;
diff --git a/modules/basis_universal/texture_basisu.cpp b/modules/basis_universal/texture_basisu.cpp
index 6a5f6313c4..9e917420ce 100644
--- a/modules/basis_universal/texture_basisu.cpp
+++ b/modules/basis_universal/texture_basisu.cpp
@@ -130,7 +130,7 @@ void TextureBasisU::set_basisu_data(const Vector<uint8_t>& p_data) {
};
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create(info.m_width, info.m_height, info.m_total_levels > 1, imgfmt, gpudata);
RenderingServer::get_singleton()->texture_allocate(texture, tex_size.x, tex_size.y, 0, img->get_format(), RS::TEXTURE_TYPE_2D, flags);
diff --git a/modules/bmp/image_loader_bmp.cpp b/modules/bmp/image_loader_bmp.cpp
index 27b49a6609..171895ed24 100644
--- a/modules/bmp/image_loader_bmp.cpp
+++ b/modules/bmp/image_loader_bmp.cpp
@@ -298,7 +298,7 @@ static Ref<Image> _bmp_mem_loader_func(const uint8_t *p_bmp, int p_size) {
Error open_memfile_error = memfile.open_custom(p_bmp, p_size);
ERR_FAIL_COND_V_MSG(open_memfile_error, Ref<Image>(), "Could not create memfile for BMP image buffer.");
Ref<Image> img;
- img.instance();
+ img.instantiate();
Error load_error = ImageLoaderBMP().load_image(img, &memfile, false, 1.0f);
ERR_FAIL_COND_V_MSG(load_error, Ref<Image>(), "Failed to load BMP image.");
return img;
diff --git a/modules/camera/camera_osx.mm b/modules/camera/camera_osx.mm
index 9b59b68075..6bc56add20 100644
--- a/modules/camera/camera_osx.mm
+++ b/modules/camera/camera_osx.mm
@@ -162,7 +162,7 @@
uint8_t *w = img_data[0].ptrw();
memcpy(w, dataY, new_width * new_height);
- img[0].instance();
+ img[0].instantiate();
img[0]->create(new_width, new_height, 0, Image::FORMAT_R8, img_data[0]);
}
@@ -181,7 +181,7 @@
memcpy(w, dataCbCr, 2 * new_width * new_height);
///TODO GLES2 doesn't support FORMAT_RG8, need to do some form of conversion
- img[1].instance();
+ img[1].instantiate();
img[1]->create(new_width, new_height, 0, Image::FORMAT_RG8, img_data[1]);
}
@@ -341,7 +341,7 @@ void CameraOSX::update_feeds() {
if (!found) {
Ref<CameraFeedOSX> newfeed;
- newfeed.instance();
+ newfeed.instantiate();
newfeed->set_device(device);
// assume display camera so inverse
diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp
index d6690bb96c..6b0c2604e3 100644
--- a/modules/csg/csg_shape.cpp
+++ b/modules/csg/csg_shape.cpp
@@ -44,7 +44,7 @@ void CSGShape3D::set_use_collision(bool p_enable) {
}
if (use_collision) {
- root_collision_shape.instance();
+ root_collision_shape.instantiate();
root_collision_instance = PhysicsServer3D::get_singleton()->body_create();
PhysicsServer3D::get_singleton()->body_set_mode(root_collision_instance, PhysicsServer3D::BODY_MODE_STATIC);
PhysicsServer3D::get_singleton()->body_set_state(root_collision_instance, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
@@ -411,7 +411,7 @@ void CSGShape3D::_update_shape() {
}
}
- root_mesh.instance();
+ root_mesh.instantiate();
//create surfaces
for (int i = 0; i < surfaces.size(); i++) {
@@ -498,7 +498,7 @@ void CSGShape3D::_notification(int p_what) {
}
if (use_collision && is_root_shape()) {
- root_collision_shape.instance();
+ root_collision_shape.instantiate();
root_collision_instance = PhysicsServer3D::get_singleton()->body_create();
PhysicsServer3D::get_singleton()->body_set_mode(root_collision_instance, PhysicsServer3D::BODY_MODE_STATIC);
PhysicsServer3D::get_singleton()->body_set_state(root_collision_instance, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
diff --git a/modules/csg/doc_classes/CSGBox3D.xml b/modules/csg/doc_classes/CSGBox3D.xml
index b1d0454b76..5bb1c4e75b 100644
--- a/modules/csg/doc_classes/CSGBox3D.xml
+++ b/modules/csg/doc_classes/CSGBox3D.xml
@@ -14,7 +14,7 @@
<member name="material" type="Material" setter="set_material" getter="get_material">
The material used to render the box.
</member>
- <member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3( 2, 2, 2 )">
+ <member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3(2, 2, 2)">
The box's width, height and depth.
</member>
</members>
diff --git a/modules/csg/doc_classes/CSGPolygon3D.xml b/modules/csg/doc_classes/CSGPolygon3D.xml
index c55fa0983e..4f29786779 100644
--- a/modules/csg/doc_classes/CSGPolygon3D.xml
+++ b/modules/csg/doc_classes/CSGPolygon3D.xml
@@ -38,7 +38,7 @@
<member name="path_rotation" type="int" setter="set_path_rotation" getter="get_path_rotation" enum="CSGPolygon3D.PathRotation">
The method by which each slice is rotated along the path when [member mode] is [constant MODE_PATH].
</member>
- <member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array( 0, 0, 0, 1, 1, 1, 1, 0 )">
+ <member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array(0, 0, 0, 1, 1, 1, 1, 0)">
Point array that defines the shape that we'll extrude.
</member>
<member name="smooth_faces" type="bool" setter="set_smooth_faces" getter="get_smooth_faces" default="false">
diff --git a/modules/dds/register_types.cpp b/modules/dds/register_types.cpp
index 1444d33171..60282c3f36 100644
--- a/modules/dds/register_types.cpp
+++ b/modules/dds/register_types.cpp
@@ -35,7 +35,7 @@
static Ref<ResourceFormatDDS> resource_loader_dds;
void register_dds_types() {
- resource_loader_dds.instance();
+ resource_loader_dds.instantiate();
ResourceLoader::add_resource_format_loader(resource_loader_dds);
}
diff --git a/modules/fbx/data/fbx_material.cpp b/modules/fbx/data/fbx_material.cpp
index d54ac86e9f..cf5d70fa5b 100644
--- a/modules/fbx/data/fbx_material.cpp
+++ b/modules/fbx/data/fbx_material.cpp
@@ -160,7 +160,7 @@ Ref<StandardMaterial3D> FBXMaterial::import_material(ImportState &state) {
const String p_fbx_current_directory = state.path;
Ref<StandardMaterial3D> spatial_material;
- spatial_material.instance();
+ spatial_material.instantiate();
// read the material file
// is material two sided
@@ -223,7 +223,7 @@ Ref<StandardMaterial3D> FBXMaterial::import_material(ImportState &state) {
} else if (fbx_texture_data != nullptr && fbx_texture_data->Media() != nullptr && fbx_texture_data->Media()->IsEmbedded()) {
// This is an embedded texture. Extract it.
Ref<Image> image;
- //image.instance(); // oooo double instance bug? why make Image::_png_blah call
+ //image.instantiate(); // oooo double instance bug? why make Image::_png_blah call
const String extension = texture_name.get_extension().to_upper();
if (extension == "PNG") {
@@ -256,7 +256,7 @@ Ref<StandardMaterial3D> FBXMaterial::import_material(ImportState &state) {
}
Ref<ImageTexture> image_texture;
- image_texture.instance();
+ image_texture.instantiate();
image_texture->create_from_image(image);
texture = image_texture;
@@ -324,7 +324,7 @@ Ref<StandardMaterial3D> FBXMaterial::import_material(ImportState &state) {
if (spatial_material.is_null()) {
// Done here so if no data no material is created.
- spatial_material.instance();
+ spatial_material.instantiate();
}
const FBXDocParser::TypedProperty<real_t> *real_value = dynamic_cast<const FBXDocParser::TypedProperty<real_t> *>(prop);
@@ -420,7 +420,7 @@ Ref<StandardMaterial3D> FBXMaterial::import_material(ImportState &state) {
} break;
case PROPERTY_DESC_COAT_ROUGHNESS: {
// meaning is that approx equal to zero is disabled not actually zero. ;)
- if (real_value && Math::is_equal_approx(real_value->Value(), 0.0f)) {
+ if (real_value && Math::is_zero_approx(real_value->Value())) {
print_verbose("clearcoat real value: " + rtos(real_value->Value()));
spatial_material->set_clearcoat_gloss(1.0 - real_value->Value());
} else {
@@ -428,7 +428,7 @@ Ref<StandardMaterial3D> FBXMaterial::import_material(ImportState &state) {
}
} break;
case PROPERTY_DESC_EMISSIVE: {
- if (real_value && Math::is_equal_approx(real_value->Value(), 0.0f)) {
+ if (real_value && Math::is_zero_approx(real_value->Value())) {
print_verbose("Emissive real value: " + rtos(real_value->Value()));
spatial_material->set_emission_energy(real_value->Value());
} else if (vector_value && !vector_value->Value().is_equal_approx(Vector3(0, 0, 0))) {
diff --git a/modules/fbx/data/fbx_mesh_data.cpp b/modules/fbx/data/fbx_mesh_data.cpp
index 8f32c523f9..0d33b8e7c6 100644
--- a/modules/fbx/data/fbx_mesh_data.cpp
+++ b/modules/fbx/data/fbx_mesh_data.cpp
@@ -211,7 +211,7 @@ EditorSceneImporterMeshNode3D *FBXMeshData::create_fbx_mesh(const ImportState &s
const int surface_id = polygon_surfaces[*polygon_id];
if (surfaces.has(surface_id) == false) {
SurfaceData sd;
- sd.surface_tool.instance();
+ sd.surface_tool.instantiate();
sd.surface_tool->begin(Mesh::PRIMITIVE_TRIANGLES);
if (surface_id < 0) {
@@ -316,7 +316,7 @@ EditorSceneImporterMeshNode3D *FBXMeshData::create_fbx_mesh(const ImportState &s
Vector3 *normals_ptr = morph_data->normals.ptrw();
Ref<SurfaceTool> morph_st;
- morph_st.instance();
+ morph_st.instantiate();
morph_st->begin(Mesh::PRIMITIVE_TRIANGLES);
for (unsigned int vi = 0; vi < surface->vertices_map.size(); vi += 1) {
@@ -345,7 +345,7 @@ EditorSceneImporterMeshNode3D *FBXMeshData::create_fbx_mesh(const ImportState &s
// Phase 6. Compose the mesh and return it.
Ref<EditorSceneImporterMesh> mesh;
- mesh.instance();
+ mesh.instantiate();
// Add blend shape info.
for (const String *morph_name = morphs.next(nullptr); morph_name != nullptr; morph_name = morphs.next(morph_name)) {
diff --git a/modules/fbx/editor_scene_importer_fbx.cpp b/modules/fbx/editor_scene_importer_fbx.cpp
index 40deaae74d..e3f36ef3e3 100644
--- a/modules/fbx/editor_scene_importer_fbx.cpp
+++ b/modules/fbx/editor_scene_importer_fbx.cpp
@@ -373,7 +373,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
scene_root->add_child(state.root);
state.root->set_owner(scene_root);
- state.fbx_root_node.instance();
+ state.fbx_root_node.instantiate();
state.fbx_root_node->godot_node = state.root;
// Size relative to cm.
@@ -389,11 +389,11 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
// Enabled by default.
state.enable_animation_import = true;
Ref<FBXNode> root_node;
- root_node.instance();
+ root_node.instantiate();
// make sure fake noFBXDocParser::PropertyPtr ptrde always has a transform too ;)
Ref<PivotTransform> pivot_transform;
- pivot_transform.instance();
+ pivot_transform.instantiate();
root_node->pivot_transform = pivot_transform;
root_node->node_name = "root node";
root_node->current_node_id = 0;
@@ -479,7 +479,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
if (state.renderer_mesh_data.has(mesh_id)) {
mesh_vertex_data = state.renderer_mesh_data[mesh_id];
} else {
- mesh_vertex_data.instance();
+ mesh_vertex_data.instantiate();
state.renderer_mesh_data.insert(mesh_id, mesh_vertex_data);
}
@@ -535,7 +535,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
ERR_CONTINUE_MSG(!mat, "Could not convert fbx material by id: " + itos(material_id));
Ref<FBXMaterial> material;
- material.instance();
+ material.instantiate();
material->set_imported_material(mat);
Ref<StandardMaterial3D> godot_material = material->import_material(state);
@@ -575,7 +575,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
if (state.skeleton_map.has(armature_id)) {
fbx_skeleton_inst = state.skeleton_map[armature_id];
} else {
- fbx_skeleton_inst.instance();
+ fbx_skeleton_inst.instantiate();
state.skeleton_map.insert(armature_id, fbx_skeleton_inst);
}
@@ -650,7 +650,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
if (state.renderer_mesh_data.has(mesh_id)) {
mesh_data_precached = state.renderer_mesh_data[mesh_id];
} else {
- mesh_data_precached.instance();
+ mesh_data_precached.instantiate();
state.renderer_mesh_data.insert(mesh_id, mesh_data_precached);
}
@@ -735,7 +735,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
Ref<Skin> skin;
if (!state.MeshSkins.has(mesh_id)) {
print_verbose("Created new skin");
- skin.instance();
+ skin.instantiate();
state.MeshSkins.insert(mesh_id, skin);
} else {
print_verbose("Grabbed skin");
@@ -848,7 +848,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
}
Ref<Animation> animation;
- animation.instance();
+ animation.instantiate();
animation->set_name(animation_name);
animation->set_length(duration);
@@ -1312,7 +1312,7 @@ void EditorSceneImporterFBX::BuildDocumentBones(Ref<FBXBone> p_parent_bone,
// declare our bone element reference (invalid, unless we create a bone in this step)
// this lets us pass valid armature information into children objects and this is why we moved this up here
- // previously this was created .instanced() on the same line.
+ // previously this was created .instantiated() on the same line.
Ref<FBXBone> bone_element;
if (model != nullptr) {
@@ -1324,7 +1324,7 @@ void EditorSceneImporterFBX::BuildDocumentBones(Ref<FBXBone> p_parent_bone,
ERR_FAIL_COND_MSG(state.fbx_bone_map.has(limb_node->ID()), "[serious] duplicate LimbNode detected");
bool parent_is_bone = state.fbx_bone_map.find(p_id);
- bone_element.instance();
+ bone_element.instantiate();
// used to build the bone hierarchy in the skeleton
bone_element->parent_bone_id = parent_is_bone ? p_id : 0;
@@ -1404,12 +1404,12 @@ void EditorSceneImporterFBX::BuildDocumentNodes(
uint64_t current_node_id = model->ID();
Ref<FBXNode> new_node;
- new_node.instance();
+ new_node.instantiate();
new_node->current_node_id = current_node_id;
new_node->node_name = ImportUtils::FBXNodeToName(model->Name());
Ref<PivotTransform> fbx_transform;
- fbx_transform.instance();
+ fbx_transform.instantiate();
fbx_transform->set_parent(parent_transform);
fbx_transform->set_model(model);
fbx_transform->debug_pivot_xform("name: " + new_node->node_name);
diff --git a/modules/fbx/fbx_parser/FBXParser.cpp b/modules/fbx/fbx_parser/FBXParser.cpp
index 163518d18f..a92b23f4ee 100644
--- a/modules/fbx/fbx_parser/FBXParser.cpp
+++ b/modules/fbx/fbx_parser/FBXParser.cpp
@@ -1167,7 +1167,7 @@ Transform3D ReadMatrix(const ElementPtr element) {
// clean values to prevent any IBM damage on inverse() / affine_inverse()
for (float &value : values) {
- if (::Math::is_equal_approx(0, value)) {
+ if (::Math::is_zero_approx(value)) {
value = 0;
}
}
diff --git a/modules/fbx/register_types.cpp b/modules/fbx/register_types.cpp
index c0591dbc77..b615c91cd2 100644
--- a/modules/fbx/register_types.cpp
+++ b/modules/fbx/register_types.cpp
@@ -36,7 +36,7 @@
#ifdef TOOLS_ENABLED
static void _editor_init() {
Ref<EditorSceneImporterFBX> import_fbx;
- import_fbx.instance();
+ import_fbx.instantiate();
ResourceImporterScene::get_singleton()->add_importer(import_fbx);
}
#endif
diff --git a/modules/fbx/tools/import_utils.h b/modules/fbx/tools/import_utils.h
index 7625f67256..fbe7dbd82f 100644
--- a/modules/fbx/tools/import_utils.h
+++ b/modules/fbx/tools/import_utils.h
@@ -137,15 +137,15 @@ public:
static Vector3 safe_import_vector3(const Vector3 &p_vec) {
Vector3 vector = p_vec;
- if (Math::is_equal_approx(0, vector.x)) {
+ if (Math::is_zero_approx(vector.x)) {
vector.x = 0;
}
- if (Math::is_equal_approx(0, vector.y)) {
+ if (Math::is_zero_approx(vector.y)) {
vector.y = 0;
}
- if (Math::is_equal_approx(0, vector.z)) {
+ if (Math::is_zero_approx(vector.z)) {
vector.z = 0;
}
return vector;
@@ -317,7 +317,7 @@ public:
// }
// } else {
// Ref<Image> img;
- // img.instance();
+ // img.instantiate();
// PoolByteArray arr;
// uint32_t size = tex->mWidth * tex->mHeight;
// arr.resize(size);
@@ -362,7 +362,7 @@ public:
// if (found) {
// image_state.raw_image = AssimpUtils::load_image(state, state.assimp_scene, path);
// if (image_state.raw_image.is_valid()) {
- // image_state.texture.instance();
+ // image_state.texture.instantiate();
// image_state.texture->create_from_image(image_state.raw_image);
// image_state.texture->set_storage(ImageTexture::STORAGE_COMPRESS_LOSSY);
// return true;
diff --git a/modules/fbx/tools/validation_tools.h b/modules/fbx/tools/validation_tools.h
index 6c15eb7e12..906a721045 100644
--- a/modules/fbx/tools/validation_tools.h
+++ b/modules/fbx/tools/validation_tools.h
@@ -34,8 +34,7 @@
#ifdef TOOLS_ENABLED
#include "core/io/file_access.h"
-#include "core/io/json.h"
-#include "core/string/ustring.h"
+#include "core/string/print_string.h"
#include "core/templates/local_vector.h"
#include "core/templates/map.h"
diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp
index e552f443cf..1ff591a87f 100644
--- a/modules/gdnative/gdnative.cpp
+++ b/modules/gdnative/gdnative.cpp
@@ -52,7 +52,7 @@ extern const godot_gdnative_core_api_struct api_struct;
Map<String, Vector<Ref<GDNative>>> GDNativeLibrary::loaded_libraries;
GDNativeLibrary::GDNativeLibrary() {
- config_file.instance();
+ config_file.instantiate();
symbol_prefix = default_symbol_prefix;
load_once = default_load_once;
@@ -112,7 +112,7 @@ bool GDNativeLibrary::_get(const StringName &p_name, Variant &r_property) const
}
void GDNativeLibrary::reset_state() {
- config_file.instance();
+ config_file.instantiate();
current_library_path = "";
current_dependencies.clear();
symbol_prefix = default_symbol_prefix;
@@ -252,7 +252,7 @@ void GDNativeLibrary::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_symbol_prefix", "symbol_prefix"), &GDNativeLibrary::set_symbol_prefix);
ClassDB::bind_method(D_METHOD("set_reloadable", "reloadable"), &GDNativeLibrary::set_reloadable);
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "config_file", PROPERTY_HINT_RESOURCE_TYPE, "ConfigFile", 0), "set_config_file", "get_config_file");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "config_file", PROPERTY_HINT_RESOURCE_TYPE, "ConfigFile", PROPERTY_USAGE_NONE), "set_config_file", "get_config_file");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "load_once"), "set_load_once", "should_load_once");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "singleton"), "set_singleton", "is_singleton");
@@ -532,7 +532,7 @@ Error GDNative::get_symbol(StringName p_procedure_name, void *&r_handle, bool p_
RES GDNativeLibraryResourceLoader::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_cache_mode) {
Ref<GDNativeLibrary> lib;
- lib.instance();
+ lib.instantiate();
Ref<ConfigFile> config = lib->get_config_file();
diff --git a/modules/gdnative/gdnative_library_editor_plugin.cpp b/modules/gdnative/gdnative_library_editor_plugin.cpp
index b4ac0d886e..bdbf151393 100644
--- a/modules/gdnative/gdnative_library_editor_plugin.cpp
+++ b/modules/gdnative/gdnative_library_editor_plugin.cpp
@@ -356,12 +356,12 @@ GDNativeLibraryEditor::GDNativeLibraryEditor() {
tree->set_column_titles_visible(true);
tree->set_columns(4);
tree->set_column_expand(0, false);
- tree->set_column_min_width(0, int(200 * EDSCALE));
+ tree->set_column_custom_minimum_width(0, int(200 * EDSCALE));
tree->set_column_title(0, TTR("Platform"));
tree->set_column_title(1, TTR("Dynamic Library"));
tree->set_column_title(2, TTR("Dependencies"));
tree->set_column_expand(3, false);
- tree->set_column_min_width(3, int(110 * EDSCALE));
+ tree->set_column_custom_minimum_width(3, int(110 * EDSCALE));
tree->connect("button_pressed", callable_mp(this, &GDNativeLibraryEditor::_on_item_button));
tree->connect("item_collapsed", callable_mp(this, &GDNativeLibraryEditor::_on_item_collapsed));
tree->connect("item_activated", callable_mp(this, &GDNativeLibraryEditor::_on_item_activated));
diff --git a/modules/gdnative/include/gdnative/variant.h b/modules/gdnative/include/gdnative/variant.h
index dd4f76cf57..a88bd2878a 100644
--- a/modules/gdnative/include/gdnative/variant.h
+++ b/modules/gdnative/include/gdnative/variant.h
@@ -164,7 +164,7 @@ typedef void (*godot_validated_keyed_getter)(const godot_variant *p_base, const
typedef bool (*godot_validated_keyed_checker)(const godot_variant *p_base, const godot_variant *p_key, bool *r_valid);
typedef void (*godot_ptr_keyed_setter)(void *p_base, const void *p_key, const void *p_value);
typedef void (*godot_ptr_keyed_getter)(const void *p_base, const void *p_key, void *r_value);
-typedef bool (*godot_ptr_keyed_checker)(const godot_variant *p_base, const godot_variant *p_key);
+typedef uint32_t (*godot_ptr_keyed_checker)(const godot_variant *p_base, const godot_variant *p_key);
typedef void (*godot_validated_utility_function)(godot_variant *r_return, const godot_variant **p_arguments, int p_argument_count);
typedef void (*godot_ptr_utility_function)(void *r_return, const void **p_arguments, int p_argument_count);
diff --git a/modules/gdnative/include/pluginscript/godot_pluginscript.h b/modules/gdnative/include/pluginscript/godot_pluginscript.h
index 34ed4f097d..02ee4066d0 100644
--- a/modules/gdnative/include/pluginscript/godot_pluginscript.h
+++ b/modules/gdnative/include/pluginscript/godot_pluginscript.h
@@ -132,7 +132,7 @@ typedef struct {
godot_bool can_inherit_from_file;
godot_string (*get_template_source_code)(godot_pluginscript_language_data *p_data, const godot_string *p_class_name, const godot_string *p_base_class_name);
- godot_bool (*validate)(godot_pluginscript_language_data *p_data, const godot_string *p_script, int *r_line_error, int *r_col_error, godot_string *r_test_error, const godot_string *p_path, godot_packed_string_array *r_functions);
+ godot_bool (*validate)(godot_pluginscript_language_data *p_data, const godot_string *p_script, const godot_string *p_path, godot_packed_string_array *r_functions, godot_array *r_errors); // errors = Array of Dictionary with "line", "column", "message" keys
int (*find_function)(godot_pluginscript_language_data *p_data, const godot_string *p_function, const godot_string *p_code); // Can be nullptr
godot_string (*make_function)(godot_pluginscript_language_data *p_data, const godot_string *p_class, const godot_string *p_name, const godot_packed_string_array *p_args);
godot_error (*complete_code)(godot_pluginscript_language_data *p_data, const godot_string *p_code, const godot_string *p_path, godot_object *p_owner, godot_array *r_options, godot_bool *r_force, godot_string *r_call_hint);
diff --git a/modules/gdnative/nativescript/api_generator.cpp b/modules/gdnative/nativescript/api_generator.cpp
index 57717010f7..4f696f2a39 100644
--- a/modules/gdnative/nativescript/api_generator.cpp
+++ b/modules/gdnative/nativescript/api_generator.cpp
@@ -251,7 +251,7 @@ List<ClassAPI> generate_c_api_classes() {
class_api.singleton_name = name;
}
}
- class_api.is_instantiable = !class_api.is_singleton && ClassDB::can_instance(class_name);
+ class_api.is_instantiable = !class_api.is_singleton && ClassDB::can_instantiate(class_name);
{
List<StringName> inheriters;
diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp
index 6c2d038654..3695f6b9a3 100644
--- a/modules/gdnative/nativescript/nativescript.cpp
+++ b/modules/gdnative/nativescript/nativescript.cpp
@@ -170,7 +170,7 @@ String NativeScript::get_script_class_icon_path() const {
return script_class_icon_path;
}
-bool NativeScript::can_instance() const {
+bool NativeScript::can_instantiate() const {
NativeScriptDesc *script_data = get_script_desc();
#ifdef TOOLS_ENABLED
@@ -503,7 +503,7 @@ Variant NativeScript::_new(const Variant **p_args, int p_argcount, Callable::Cal
Object *owner = nullptr;
if (!(script_data->base_native_type == "")) {
- owner = ClassDB::instance(script_data->base_native_type);
+ owner = ClassDB::instantiate(script_data->base_native_type);
} else {
owner = memnew(RefCounted);
}
@@ -1035,7 +1035,7 @@ Ref<Script> NativeScriptLanguage::get_template(const String &p_class_name, const
return Ref<NativeScript>(s);
}
-bool NativeScriptLanguage::validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_functions, List<ScriptLanguage::Warning> *r_warnings, Set<int> *r_safe_lines) const {
+bool NativeScriptLanguage::validate(const String &p_script, const String &p_path, List<String> *r_functions, List<ScriptLanguage::ScriptError> *r_errors, List<ScriptLanguage::Warning> *r_warnings, Set<int> *r_safe_lines) const {
return true;
}
@@ -1422,7 +1422,7 @@ void NativeScriptLanguage::init_library(const Ref<GDNativeLibrary> &lib) {
if (!E) {
Ref<GDNative> gdn;
- gdn.instance();
+ gdn.instantiate();
gdn->set_library(lib);
// TODO check the return value?
diff --git a/modules/gdnative/nativescript/nativescript.h b/modules/gdnative/nativescript/nativescript.h
index 1756321281..777a878660 100644
--- a/modules/gdnative/nativescript/nativescript.h
+++ b/modules/gdnative/nativescript/nativescript.h
@@ -137,7 +137,7 @@ public:
void set_script_class_icon_path(String p_icon_path);
String get_script_class_icon_path() const;
- virtual bool can_instance() const override;
+ virtual bool can_instantiate() const override;
virtual Ref<Script> get_base_script() const override; //for script inheritance
@@ -317,7 +317,7 @@ public:
virtual void get_comment_delimiters(List<String> *p_delimiters) const;
virtual void get_string_delimiters(List<String> *p_delimiters) const;
virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const;
- virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_functions, List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const;
+ virtual bool validate(const String &p_script, const String &p_path, List<String> *r_functions, List<ScriptLanguage::ScriptError> *r_errors = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const;
virtual Script *create_script() const;
virtual bool has_named_classes() const;
virtual bool supports_builtin_mode() const;
diff --git a/modules/gdnative/nativescript/register_types.cpp b/modules/gdnative/nativescript/register_types.cpp
index 0353ab2092..0191cfd809 100644
--- a/modules/gdnative/nativescript/register_types.cpp
+++ b/modules/gdnative/nativescript/register_types.cpp
@@ -50,10 +50,10 @@ void register_nativescript_types() {
native_script_language->set_language_index(ScriptServer::get_language_count());
ScriptServer::register_language(native_script_language);
- resource_saver_gdns.instance();
+ resource_saver_gdns.instantiate();
ResourceSaver::add_resource_format_saver(resource_saver_gdns);
- resource_loader_gdns.instance();
+ resource_loader_gdns.instantiate();
ResourceLoader::add_resource_format_loader(resource_loader_gdns);
}
diff --git a/modules/gdnative/pluginscript/pluginscript_language.cpp b/modules/gdnative/pluginscript/pluginscript_language.cpp
index 0291ae560b..79aba342c9 100644
--- a/modules/gdnative/pluginscript/pluginscript_language.cpp
+++ b/modules/gdnative/pluginscript/pluginscript_language.cpp
@@ -112,20 +112,29 @@ Ref<Script> PluginScriptLanguage::get_template(const String &p_class_name, const
return script;
}
-bool PluginScriptLanguage::validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_functions, List<ScriptLanguage::Warning> *r_warnings, Set<int> *r_safe_lines) const {
+bool PluginScriptLanguage::validate(const String &p_script, const String &p_path, List<String> *r_functions, List<ScriptLanguage::ScriptError> *r_errors, List<ScriptLanguage::Warning> *r_warnings, Set<int> *r_safe_lines) const {
PackedStringArray functions;
+ Array errors;
if (_desc.validate) {
bool ret = _desc.validate(
_data,
(godot_string *)&p_script,
- &r_line_error,
- &r_col_error,
- (godot_string *)&r_test_error,
(godot_string *)&p_path,
- (godot_packed_string_array *)&functions);
+ (godot_packed_string_array *)&functions,
+ (godot_array *)&errors);
for (int i = 0; i < functions.size(); i++) {
r_functions->push_back(functions[i]);
}
+ if (r_errors) {
+ for (int i = 0; i < errors.size(); i++) {
+ Dictionary error = errors[i];
+ ScriptLanguage::ScriptError e;
+ e.line = error["line"];
+ e.column = error["column"];
+ e.message = error["message"];
+ r_errors->push_back(e);
+ }
+ }
return ret;
}
return true;
diff --git a/modules/gdnative/pluginscript/pluginscript_language.h b/modules/gdnative/pluginscript/pluginscript_language.h
index 957bf355ca..26ab4a95e3 100644
--- a/modules/gdnative/pluginscript/pluginscript_language.h
+++ b/modules/gdnative/pluginscript/pluginscript_language.h
@@ -75,7 +75,7 @@ public:
virtual void get_comment_delimiters(List<String> *p_delimiters) const;
virtual void get_string_delimiters(List<String> *p_delimiters) const;
virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const;
- virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const;
+ virtual bool validate(const String &p_script, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptLanguage::ScriptError> *r_errors = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const;
virtual Script *create_script() const;
virtual bool has_named_classes() const;
virtual bool supports_builtin_mode() const;
diff --git a/modules/gdnative/pluginscript/pluginscript_script.cpp b/modules/gdnative/pluginscript/pluginscript_script.cpp
index 1dabb1db63..7fc8178e34 100644
--- a/modules/gdnative/pluginscript/pluginscript_script.cpp
+++ b/modules/gdnative/pluginscript/pluginscript_script.cpp
@@ -38,13 +38,13 @@
#ifdef DEBUG_ENABLED
#define __ASSERT_SCRIPT_REASON "Cannot retrieve PluginScript class for this script, is your code correct?"
-#define ASSERT_SCRIPT_VALID() \
- { \
- ERR_FAIL_COND_MSG(!can_instance(), __ASSERT_SCRIPT_REASON); \
+#define ASSERT_SCRIPT_VALID() \
+ { \
+ ERR_FAIL_COND_MSG(!can_instantiate(), __ASSERT_SCRIPT_REASON); \
}
-#define ASSERT_SCRIPT_VALID_V(ret) \
- { \
- ERR_FAIL_COND_V_MSG(!can_instance(), ret, __ASSERT_SCRIPT_REASON); \
+#define ASSERT_SCRIPT_VALID_V(ret) \
+ { \
+ ERR_FAIL_COND_V_MSG(!can_instantiate(), ret, __ASSERT_SCRIPT_REASON); \
}
#else
#define ASSERT_SCRIPT_VALID()
@@ -96,7 +96,7 @@ Variant PluginScript::_new(const Variant **p_args, int p_argcount, Callable::Cal
if (get_instance_base_type() == "") {
owner = memnew(RefCounted);
} else {
- owner = ClassDB::instance(get_instance_base_type());
+ owner = ClassDB::instantiate(get_instance_base_type());
}
if (!owner) {
@@ -133,7 +133,7 @@ void PluginScript::_placeholder_erased(PlaceHolderScriptInstance *p_placeholder)
#endif
-bool PluginScript::can_instance() const {
+bool PluginScript::can_instantiate() const {
bool can = _valid || (!_tool && !ScriptServer::is_scripting_enabled());
return can;
}
@@ -198,7 +198,7 @@ ScriptInstance *PluginScript::instance_create(Object *p_this) {
StringName base_type = get_instance_base_type();
if (base_type) {
if (!ClassDB::is_parent_class(p_this->get_class_name(), base_type)) {
- String msg = "Script inherits from native type '" + String(base_type) + "', so it can't be instanced in object of type: '" + p_this->get_class() + "'";
+ String msg = "Script inherits from native type '" + String(base_type) + "', so it can't be instantiated in object of type: '" + p_this->get_class() + "'";
// TODO: implement PluginscriptLanguage::debug_break_parse
// if (EngineDebugger::is_active()) {
// _language->debug_break_parse(get_path(), 0, msg);
diff --git a/modules/gdnative/pluginscript/pluginscript_script.h b/modules/gdnative/pluginscript/pluginscript_script.h
index 97989a19d8..838195147f 100644
--- a/modules/gdnative/pluginscript/pluginscript_script.h
+++ b/modules/gdnative/pluginscript/pluginscript_script.h
@@ -92,7 +92,7 @@ public:
return _icon_path;
}
- virtual bool can_instance() const override;
+ virtual bool can_instantiate() const override;
virtual Ref<Script> get_base_script() const override; //for script inheritance
diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp
index cf19c0c44c..8e20a2b90d 100644
--- a/modules/gdnative/register_types.cpp
+++ b/modules/gdnative/register_types.cpp
@@ -230,7 +230,7 @@ static void editor_init_callback() {
ProjectSettingsEditor::get_singleton()->get_tabs()->add_child(library_editor);
Ref<GDNativeExportPlugin> export_plugin;
- export_plugin.instance();
+ export_plugin.instantiate();
EditorExport::get_singleton()->add_export_plugin(export_plugin);
@@ -262,10 +262,10 @@ void register_gdnative_types() {
ClassDB::register_class<GDNativeLibrary>();
ClassDB::register_class<GDNative>();
- resource_loader_gdnlib.instance();
+ resource_loader_gdnlib.instantiate();
ResourceLoader::add_resource_format_loader(resource_loader_gdnlib);
- resource_saver_gdnlib.instance();
+ resource_saver_gdnlib.instantiate();
ResourceSaver::add_resource_format_saver(resource_saver_gdnlib);
GDNativeCallRegistry::singleton = memnew(GDNativeCallRegistry);
@@ -298,7 +298,7 @@ void register_gdnative_types() {
Ref<GDNativeLibrary> lib = ResourceLoader::load(path);
Ref<GDNative> singleton;
- singleton.instance();
+ singleton.instantiate();
singleton->set_library(lib);
if (!singleton->initialize()) {
diff --git a/modules/gdnative/videodecoder/register_types.cpp b/modules/gdnative/videodecoder/register_types.cpp
index 394831daeb..e822d42312 100644
--- a/modules/gdnative/videodecoder/register_types.cpp
+++ b/modules/gdnative/videodecoder/register_types.cpp
@@ -36,7 +36,7 @@
static Ref<ResourceFormatLoaderVideoStreamGDNative> resource_loader_vsgdnative;
void register_videodecoder_types() {
- resource_loader_vsgdnative.instance();
+ resource_loader_vsgdnative.instantiate();
ResourceLoader::add_resource_format_loader(resource_loader_vsgdnative, true);
ClassDB::register_class<VideoStreamGDNative>();
diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.cpp b/modules/gdnative/videodecoder/video_stream_gdnative.cpp
index 8b0434c7dd..26b044c0ef 100644
--- a/modules/gdnative/videodecoder/video_stream_gdnative.cpp
+++ b/modules/gdnative/videodecoder/video_stream_gdnative.cpp
@@ -122,7 +122,7 @@ bool VideoStreamPlaybackGDNative::open_file(const String &p_file) {
samples_decoded = 0;
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create((int)texture_size.width, false, (int)texture_size.height, Image::FORMAT_RGBA8);
texture->create_from_image(img);
diff --git a/modules/gdnative/xr/xr_interface_gdnative.cpp b/modules/gdnative/xr/xr_interface_gdnative.cpp
index ff959affa3..e51542e23d 100644
--- a/modules/gdnative/xr/xr_interface_gdnative.cpp
+++ b/modules/gdnative/xr/xr_interface_gdnative.cpp
@@ -258,7 +258,7 @@ void GDAPI godot_xr_register_interface(const godot_xr_interface_gdnative *p_inte
ERR_FAIL_COND_MSG(p_interface->version.major < 4, "GDNative XR interfaces build for Godot 3.x are not supported.");
Ref<XRInterfaceGDNative> new_interface;
- new_interface.instance();
+ new_interface.instantiate();
new_interface->set_interface((const godot_xr_interface_gdnative *)p_interface);
XRServer::get_singleton()->add_interface(new_interface);
}
@@ -331,7 +331,7 @@ godot_int GDAPI godot_xr_add_controller(char *p_device_name, godot_int p_hand, g
ERR_FAIL_NULL_V(input, 0);
Ref<XRPositionalTracker> new_tracker;
- new_tracker.instance();
+ new_tracker.instantiate();
new_tracker->set_tracker_name(p_device_name);
new_tracker->set_tracker_type(XRServer::TRACKER_CONTROLLER);
if (p_hand == 1) {
@@ -412,7 +412,7 @@ void GDAPI godot_xr_set_controller_button(godot_int p_controller_id, godot_int p
if (tracker.is_valid()) {
int joyid = tracker->get_joy_id();
if (joyid != -1) {
- input->joy_button(joyid, p_button, p_is_pressed);
+ input->joy_button(joyid, (JoyButton)p_button, p_is_pressed);
}
}
}
@@ -431,7 +431,7 @@ void GDAPI godot_xr_set_controller_axis(godot_int p_controller_id, godot_int p_a
Input::JoyAxisValue jx;
jx.min = p_can_be_negative ? -1 : 0;
jx.value = p_value;
- input->joy_axis(joyid, p_axis, jx);
+ input->joy_axis(joyid, (JoyAxis)p_axis, jx);
}
}
}
diff --git a/modules/gdnavigation/navigation_mesh_generator.cpp b/modules/gdnavigation/navigation_mesh_generator.cpp
index d69c9114b9..0d8330c1da 100644
--- a/modules/gdnavigation/navigation_mesh_generator.cpp
+++ b/modules/gdnavigation/navigation_mesh_generator.cpp
@@ -177,7 +177,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform3D p_accumulated_transfor
BoxShape3D *box = Object::cast_to<BoxShape3D>(*s);
if (box) {
Ref<BoxMesh> box_mesh;
- box_mesh.instance();
+ box_mesh.instantiate();
box_mesh->set_size(box->get_size());
mesh = box_mesh;
}
@@ -185,7 +185,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform3D p_accumulated_transfor
CapsuleShape3D *capsule = Object::cast_to<CapsuleShape3D>(*s);
if (capsule) {
Ref<CapsuleMesh> capsule_mesh;
- capsule_mesh.instance();
+ capsule_mesh.instantiate();
capsule_mesh->set_radius(capsule->get_radius());
capsule_mesh->set_mid_height(capsule->get_height() / 2.0);
mesh = capsule_mesh;
@@ -194,7 +194,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform3D p_accumulated_transfor
CylinderShape3D *cylinder = Object::cast_to<CylinderShape3D>(*s);
if (cylinder) {
Ref<CylinderMesh> cylinder_mesh;
- cylinder_mesh.instance();
+ cylinder_mesh.instantiate();
cylinder_mesh->set_height(cylinder->get_height());
cylinder_mesh->set_bottom_radius(cylinder->get_radius());
cylinder_mesh->set_top_radius(cylinder->get_radius());
@@ -204,7 +204,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform3D p_accumulated_transfor
SphereShape3D *sphere = Object::cast_to<SphereShape3D>(*s);
if (sphere) {
Ref<SphereMesh> sphere_mesh;
- sphere_mesh.instance();
+ sphere_mesh.instantiate();
sphere_mesh->set_radius(sphere->get_radius());
sphere_mesh->set_height(sphere->get_radius() * 2.0);
mesh = sphere_mesh;
@@ -255,7 +255,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform3D p_accumulated_transfor
for (int i = 0; i < meshes.size(); i += 2) {
Ref<Mesh> mesh = meshes[i + 1];
if (mesh.is_valid()) {
- _add_mesh(mesh, p_accumulated_transform * xform * meshes[i], p_verticies, p_indices);
+ _add_mesh(mesh, p_accumulated_transform * xform * (Transform3D)meshes[i], p_verticies, p_indices);
}
}
}
diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml
index 58620f2b3e..839aa6b3c6 100644
--- a/modules/gdscript/doc_classes/@GDScript.xml
+++ b/modules/gdscript/doc_classes/@GDScript.xml
@@ -177,7 +177,7 @@
[b]Note:[/b] Resource paths can be obtained by right clicking on a resource in the Assets Panel and choosing "Copy Path" or by dragging the file from the FileSystem dock into the script.
[codeblock]
# Instance a scene.
- var diamond = preload("res://diamond.tscn").instance()
+ var diamond = preload("res://diamond.tscn").instantiate()
[/codeblock]
</description>
</method>
diff --git a/modules/gdscript/editor/gdscript_highlighter.cpp b/modules/gdscript/editor/gdscript_highlighter.cpp
index b867b03903..79ec9eb65f 100644
--- a/modules/gdscript/editor/gdscript_highlighter.cpp
+++ b/modules/gdscript/editor/gdscript_highlighter.cpp
@@ -622,6 +622,6 @@ void GDScriptSyntaxHighlighter::add_color_region(const String &p_start_key, cons
Ref<EditorSyntaxHighlighter> GDScriptSyntaxHighlighter::_create() const {
Ref<GDScriptSyntaxHighlighter> syntax_highlighter;
- syntax_highlighter.instance();
+ syntax_highlighter.instantiate();
return syntax_highlighter;
}
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp
index 1567576009..397776ba1a 100644
--- a/modules/gdscript/gdscript.cpp
+++ b/modules/gdscript/gdscript.cpp
@@ -72,7 +72,7 @@ void GDScriptNativeClass::_bind_methods() {
}
Variant GDScriptNativeClass::_new() {
- Object *o = instance();
+ Object *o = instantiate();
ERR_FAIL_COND_V_MSG(!o, Variant(), "Class type: '" + String(name) + "' is not instantiable.");
RefCounted *rc = Object::cast_to<RefCounted>(o);
@@ -83,8 +83,8 @@ Variant GDScriptNativeClass::_new() {
}
}
-Object *GDScriptNativeClass::instance() {
- return ClassDB::instance(name);
+Object *GDScriptNativeClass::instantiate() {
+ return ClassDB::instantiate(name);
}
void GDScript::_super_implicit_constructor(GDScript *p_script, GDScriptInstance *p_instance, Callable::CallError &r_error) {
@@ -170,7 +170,7 @@ Variant GDScript::_new(const Variant **p_args, int p_argcount, Callable::CallErr
ERR_FAIL_COND_V(_baseptr->native.is_null(), Variant());
if (_baseptr->native.ptr()) {
- owner = _baseptr->native->instance();
+ owner = _baseptr->native->instantiate();
} else {
owner = memnew(RefCounted); //by default, no base means use reference
}
@@ -196,7 +196,7 @@ Variant GDScript::_new(const Variant **p_args, int p_argcount, Callable::CallErr
}
}
-bool GDScript::can_instance() const {
+bool GDScript::can_instantiate() const {
#ifdef TOOLS_ENABLED
return valid && (tool || ScriptServer::is_scripting_enabled());
#else
@@ -346,9 +346,9 @@ ScriptInstance *GDScript::instance_create(Object *p_this) {
if (top->native.is_valid()) {
if (!ClassDB::is_parent_class(p_this->get_class_name(), top->native->get_name())) {
if (EngineDebugger::is_active()) {
- GDScriptLanguage::get_singleton()->debug_break_parse(get_path(), 1, "Script inherits from native type '" + String(top->native->get_name()) + "', so it can't be instanced in object of type: '" + p_this->get_class() + "'");
+ GDScriptLanguage::get_singleton()->debug_break_parse(get_path(), 1, "Script inherits from native type '" + String(top->native->get_name()) + "', so it can't be instantiated in object of type: '" + p_this->get_class() + "'");
}
- ERR_FAIL_V_MSG(nullptr, "Script inherits from native type '" + String(top->native->get_name()) + "', so it can't be instanced in object of type '" + p_this->get_class() + "'" + ".");
+ ERR_FAIL_V_MSG(nullptr, "Script inherits from native type '" + String(top->native->get_name()) + "', so it can't be instantiated in object of type '" + p_this->get_class() + "'" + ".");
}
}
@@ -2256,7 +2256,7 @@ RES ResourceFormatLoaderGDScript::load(const String &p_path, const String &p_ori
if (script.is_null()) {
// Don't fail loading because of parsing error.
- script.instance();
+ script.instantiate();
}
if (r_error) {
diff --git a/modules/gdscript/gdscript.h b/modules/gdscript/gdscript.h
index 602553bb1a..078b7a2fd0 100644
--- a/modules/gdscript/gdscript.h
+++ b/modules/gdscript/gdscript.h
@@ -51,7 +51,7 @@ protected:
public:
_FORCE_INLINE_ const StringName &get_name() const { return name; }
Variant _new();
- Object *instance();
+ Object *instantiate();
GDScriptNativeClass(const StringName &p_name);
};
@@ -80,10 +80,10 @@ class GDScript : public Script {
GDScript *_base = nullptr; //fast pointer access
GDScript *_owner = nullptr; //for subclasses
- Set<StringName> members; //members are just indices to the instanced script.
+ Set<StringName> members; //members are just indices to the instantiated script.
Map<StringName, Variant> constants;
Map<StringName, GDScriptFunction *> member_functions;
- Map<StringName, MemberInfo> member_indices; //members are just indices to the instanced script.
+ Map<StringName, MemberInfo> member_indices; //members are just indices to the instantiated script.
Map<StringName, Ref<GDScript>> subclasses;
Map<StringName, Vector<StringName>> _signals;
Vector<MultiplayerAPI::RPCConfig> rpc_functions;
@@ -196,7 +196,7 @@ public:
StringName debug_get_member_by_index(int p_idx) const;
Variant _new(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
- virtual bool can_instance() const override;
+ virtual bool can_instantiate() const override;
virtual Ref<Script> get_base_script() const override;
@@ -447,7 +447,7 @@ public:
virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const;
virtual bool is_using_templates();
virtual void make_template(const String &p_class_name, const String &p_base_class_name, Ref<Script> &p_script);
- virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const;
+ virtual bool validate(const String &p_script, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptLanguage::ScriptError> *r_errors = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const;
virtual Script *create_script() const;
virtual bool has_named_classes() const;
virtual bool supports_builtin_mode() const;
diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp
index c3edc813d2..e7fb33a6a7 100644
--- a/modules/gdscript/gdscript_analyzer.cpp
+++ b/modules/gdscript/gdscript_analyzer.cpp
@@ -229,7 +229,7 @@ Error GDScriptAnalyzer::resolve_inheritance(GDScriptParser::ClassNode *p_class,
push_error(vformat(R"(Could not resolve super class inheritance from "%s".)", name), p_class);
return err;
}
- } else if (class_exists(name) && ClassDB::can_instance(GDScriptParser::get_real_class_name(name))) {
+ } else if (class_exists(name) && ClassDB::can_instantiate(GDScriptParser::get_real_class_name(name))) {
base.kind = GDScriptParser::DataType::NATIVE;
base.native_type = name;
} else {
@@ -1779,10 +1779,10 @@ void GDScriptAnalyzer::reduce_binary_op(GDScriptParser::BinaryOpNode *p_binary_o
} else {
if (p_binary_op->variant_op < Variant::OP_MAX) {
bool valid = false;
- result = get_operation_type(p_binary_op->variant_op, p_binary_op->left_operand->get_datatype(), right_type, valid, p_binary_op);
+ result = get_operation_type(p_binary_op->variant_op, left_type, right_type, valid, p_binary_op);
if (!valid) {
- push_error(vformat(R"(Invalid operands "%s" and "%s" for "%s" operator.)", p_binary_op->left_operand->get_datatype().to_string(), right_type.to_string(), Variant::get_operator_name(p_binary_op->variant_op)), p_binary_op);
+ push_error(vformat(R"(Invalid operands "%s" and "%s" for "%s" operator.)", left_type.to_string(), right_type.to_string(), Variant::get_operator_name(p_binary_op->variant_op)), p_binary_op);
}
} else {
if (p_binary_op->operation == GDScriptParser::BinaryOpNode::OP_TYPE_TEST) {
@@ -2349,6 +2349,7 @@ void GDScriptAnalyzer::reduce_identifier_from_base(GDScriptParser::IdentifierNod
GDScriptParser::DataType result;
result.type_source = GDScriptParser::DataType::ANNOTATED_EXPLICIT;
result.kind = GDScriptParser::DataType::ENUM_VALUE;
+ result.builtin_type = base.builtin_type;
result.native_type = base.native_type;
result.enum_type = name;
p_identifier->set_datatype(result);
@@ -3446,6 +3447,7 @@ GDScriptParser::DataType GDScriptAnalyzer::get_operation_type(Variant::Operator
}
r_valid = true;
+ result.type_source = GDScriptParser::DataType::ANNOTATED_INFERRED;
result.kind = GDScriptParser::DataType::BUILTIN;
result.builtin_type = Variant::get_operator_return_type(p_operation, a_type, b_type);
diff --git a/modules/gdscript/gdscript_byte_codegen.cpp b/modules/gdscript/gdscript_byte_codegen.cpp
index 6998cc5bb7..5a297cc50a 100644
--- a/modules/gdscript/gdscript_byte_codegen.cpp
+++ b/modules/gdscript/gdscript_byte_codegen.cpp
@@ -554,6 +554,14 @@ void GDScriptByteCodeGenerator::write_unary_operator(const Address &p_target, Va
void GDScriptByteCodeGenerator::write_binary_operator(const Address &p_target, Variant::Operator p_operator, const Address &p_left_operand, const Address &p_right_operand) {
if (HAS_BUILTIN_TYPE(p_left_operand) && HAS_BUILTIN_TYPE(p_right_operand)) {
+ if (p_target.mode == Address::TEMPORARY) {
+ Variant::Type result_type = Variant::get_operator_return_type(p_operator, p_left_operand.type.builtin_type, p_right_operand.type.builtin_type);
+ Variant::Type temp_type = temporaries[p_target.address].type;
+ if (result_type != temp_type) {
+ write_type_adjust(p_target, result_type);
+ }
+ }
+
// Gather specific operator.
Variant::ValidatedOperatorEvaluator op_func = Variant::get_validated_operator_evaluator(p_operator, p_left_operand.type.builtin_type, p_right_operand.type.builtin_type);
diff --git a/modules/gdscript/gdscript_cache.cpp b/modules/gdscript/gdscript_cache.cpp
index a3b1fb93f9..1a844bf241 100644
--- a/modules/gdscript/gdscript_cache.cpp
+++ b/modules/gdscript/gdscript_cache.cpp
@@ -134,7 +134,7 @@ Ref<GDScriptParserRef> GDScriptCache::get_parser(const String &p_path, GDScriptP
return ref;
}
GDScriptParser *parser = memnew(GDScriptParser);
- ref.instance();
+ ref.instantiate();
ref->parser = parser;
ref->path = p_path;
singleton->parser_map[p_path] = ref.ptr();
@@ -180,7 +180,7 @@ Ref<GDScript> GDScriptCache::get_shallow_script(const String &p_path, const Stri
}
Ref<GDScript> script;
- script.instance();
+ script.instantiate();
script->set_path(p_path, true);
script->set_script_path(p_path);
script->load_source_code(p_path);
diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp
index 6d6b9e15af..7fa8e9c067 100644
--- a/modules/gdscript/gdscript_compiler.cpp
+++ b/modules/gdscript/gdscript_compiler.cpp
@@ -2587,7 +2587,7 @@ void GDScriptCompiler::_make_scripts(GDScript *p_script, const GDScriptParser::C
if (orphan_subclass.is_valid()) {
subclass = orphan_subclass;
} else {
- subclass.instance();
+ subclass.instantiate();
}
}
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index 18b7810919..b149828a2f 100644
--- a/modules/gdscript/gdscript_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -104,7 +104,7 @@ Ref<Script> GDScriptLanguage::get_template(const String &p_class_name, const Str
_template = _get_processed_template(_template, p_base_class_name);
Ref<GDScript> script;
- script.instance();
+ script.instantiate();
script->set_source_code(_template);
return script;
@@ -131,7 +131,7 @@ static void get_function_names_recursively(const GDScriptParser::ClassNode *p_cl
}
}
-bool GDScriptLanguage::validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_functions, List<ScriptLanguage::Warning> *r_warnings, Set<int> *r_safe_lines) const {
+bool GDScriptLanguage::validate(const String &p_script, const String &p_path, List<String> *r_functions, List<ScriptLanguage::ScriptError> *r_errors, List<ScriptLanguage::Warning> *r_warnings, Set<int> *r_safe_lines) const {
GDScriptParser parser;
GDScriptAnalyzer analyzer(&parser);
@@ -156,10 +156,16 @@ bool GDScriptLanguage::validate(const String &p_script, int &r_line_error, int &
}
#endif
if (err) {
- GDScriptParser::ParserError parse_error = parser.get_errors().front()->get();
- r_line_error = parse_error.line;
- r_col_error = parse_error.column;
- r_test_error = parse_error.message;
+ if (r_errors) {
+ for (const List<GDScriptParser::ParserError>::Element *E = parser.get_errors().front(); E; E = E->next()) {
+ const GDScriptParser::ParserError &pe = E->get();
+ ScriptLanguage::ScriptError e;
+ e.line = pe.line;
+ e.column = pe.column;
+ e.message = pe.message;
+ r_errors->push_back(e);
+ }
+ }
return false;
} else {
const GDScriptParser::ClassNode *cl = parser.get_tree();
@@ -2378,7 +2384,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
r_forced = r_result.size() > 0;
}
-Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptCodeCompletionOption> *r_options, bool &r_forced, String &r_call_hint) {
+::Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptCodeCompletionOption> *r_options, bool &r_forced, String &r_call_hint) {
const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", false) ? "'" : "\"";
GDScriptParser parser;
@@ -2894,7 +2900,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
Variant v;
REF v_ref;
if (base_type.builtin_type == Variant::OBJECT) {
- v_ref.instance();
+ v_ref.instantiate();
v = v_ref;
} else {
Callable::CallError err;
@@ -2929,7 +2935,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
return ERR_CANT_RESOLVE;
}
-Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol, const String &p_path, Object *p_owner, LookupResult &r_result) {
+::Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol, const String &p_path, Object *p_owner, LookupResult &r_result) {
//before parsing, try the usual stuff
if (ClassDB::class_exists(p_symbol)) {
r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS;
diff --git a/modules/gdscript/language_server/gdscript_extend_parser.cpp b/modules/gdscript/language_server/gdscript_extend_parser.cpp
index 15236d900d..f817964a3c 100644
--- a/modules/gdscript/language_server/gdscript_extend_parser.cpp
+++ b/modules/gdscript/language_server/gdscript_extend_parser.cpp
@@ -32,7 +32,6 @@
#include "../gdscript.h"
#include "../gdscript_analyzer.h"
-#include "core/io/json.h"
#include "gdscript_language_protocol.h"
#include "gdscript_workspace.h"
@@ -183,7 +182,7 @@ void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *p
symbol.detail += ": " + m.get_datatype().to_string();
}
if (m.variable->initializer != nullptr && m.variable->initializer->is_constant) {
- symbol.detail += " = " + JSON::print(m.variable->initializer->reduced_value);
+ symbol.detail += " = " + m.variable->initializer->reduced_value.to_json_string();
}
symbol.documentation = parse_documentation(LINE_NUMBER_TO_INDEX(m.variable->start_line));
@@ -224,10 +223,10 @@ void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *p
}
}
} else {
- value_text = JSON::print(default_value);
+ value_text = default_value.to_json_string();
}
} else {
- value_text = JSON::print(default_value);
+ value_text = default_value.to_json_string();
}
if (!value_text.is_empty()) {
symbol.detail += " = " + value_text;
@@ -353,8 +352,7 @@ void ExtendGDScriptParser::parse_function_symbol(const GDScriptParser::FunctionN
parameters += ": " + parameter->get_datatype().to_string();
}
if (parameter->default_value != nullptr) {
- String value = JSON::print(parameter->default_value->reduced_value);
- parameters += " = " + value;
+ parameters += " = " + parameter->default_value->reduced_value.to_json_string();
}
}
r_symbol.detail += parameters + ")";
diff --git a/modules/gdscript/language_server/gdscript_language_protocol.cpp b/modules/gdscript/language_server/gdscript_language_protocol.cpp
index c16a7fa889..0d1f98778e 100644
--- a/modules/gdscript/language_server/gdscript_language_protocol.cpp
+++ b/modules/gdscript/language_server/gdscript_language_protocol.cpp
@@ -31,7 +31,6 @@
#include "gdscript_language_protocol.h"
#include "core/config/project_settings.h"
-#include "core/io/json.h"
#include "editor/doc_tools.h"
#include "editor/editor_log.h"
#include "editor/editor_node.h"
@@ -194,7 +193,7 @@ Dictionary GDScriptLanguageProtocol::initialize(const Dictionary &p_params) {
vformat("GDScriptLanguageProtocol: Can't initialize invalid peer '%d'.", latest_client_id));
Ref<LSPeer> peer = clients.get(latest_client_id);
if (peer != nullptr) {
- String msg = JSON::print(request);
+ String msg = Variant(request).to_json_string();
msg = format_output(msg);
(*peer)->res_queue.push_back(msg.utf8());
}
@@ -280,7 +279,7 @@ void GDScriptLanguageProtocol::notify_client(const String &p_method, const Varia
ERR_FAIL_COND(peer == nullptr);
Dictionary message = make_notification(p_method, p_params);
- String msg = JSON::print(message);
+ String msg = Variant(message).to_json_string();
msg = format_output(msg);
peer->res_queue.push_back(msg.utf8());
}
@@ -294,10 +293,10 @@ bool GDScriptLanguageProtocol::is_goto_native_symbols_enabled() const {
}
GDScriptLanguageProtocol::GDScriptLanguageProtocol() {
- server.instance();
+ server.instantiate();
singleton = this;
- workspace.instance();
- text_document.instance();
+ workspace.instantiate();
+ text_document.instantiate();
set_scope("textDocument", text_document.ptr());
set_scope("completionItem", text_document.ptr());
set_scope("workspace", workspace.ptr());
diff --git a/modules/gdscript/language_server/gdscript_workspace.cpp b/modules/gdscript/language_server/gdscript_workspace.cpp
index d83f77ed82..1915c92cbf 100644
--- a/modules/gdscript/language_server/gdscript_workspace.cpp
+++ b/modules/gdscript/language_server/gdscript_workspace.cpp
@@ -426,7 +426,7 @@ Node *GDScriptWorkspace::_get_owner_scene_node(String p_path) {
RES owner_res = ResourceLoader::load(owner_path);
if (Object::cast_to<PackedScene>(owner_res.ptr())) {
Ref<PackedScene> owner_packed_scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*owner_res));
- owner_scene_node = owner_packed_scene->instance();
+ owner_scene_node = owner_packed_scene->instantiate();
break;
}
}
diff --git a/modules/gdscript/register_types.cpp b/modules/gdscript/register_types.cpp
index 867142019f..ad4ed8bf71 100644
--- a/modules/gdscript/register_types.cpp
+++ b/modules/gdscript/register_types.cpp
@@ -92,12 +92,12 @@ public:
static void _editor_init() {
Ref<EditorExportGDScript> gd_export;
- gd_export.instance();
+ gd_export.instantiate();
EditorExport::get_singleton()->add_export_plugin(gd_export);
#ifdef TOOLS_ENABLED
Ref<GDScriptSyntaxHighlighter> gdscript_syntax_highlighter;
- gdscript_syntax_highlighter.instance();
+ gdscript_syntax_highlighter.instantiate();
ScriptEditor::get_singleton()->register_syntax_highlighter(gdscript_syntax_highlighter);
#endif
@@ -117,10 +117,10 @@ void register_gdscript_types() {
script_language_gd = memnew(GDScriptLanguage);
ScriptServer::register_language(script_language_gd);
- resource_loader_gd.instance();
+ resource_loader_gd.instantiate();
ResourceLoader::add_resource_format_loader(resource_loader_gd);
- resource_saver_gd.instance();
+ resource_saver_gd.instantiate();
ResourceSaver::add_resource_format_saver(resource_saver_gd);
gdscript_cache = memnew(GDScriptCache);
@@ -128,7 +128,7 @@ void register_gdscript_types() {
#ifdef TOOLS_ENABLED
EditorNode::add_init_callback(_editor_init);
- gdscript_translation_parser_plugin.instance();
+ gdscript_translation_parser_plugin.instantiate();
EditorTranslationParser::get_singleton()->add_parser(gdscript_translation_parser_plugin, EditorTranslationParser::STANDARD);
#endif // TOOLS_ENABLED
diff --git a/modules/gdscript/tests/gdscript_test_runner.cpp b/modules/gdscript/tests/gdscript_test_runner.cpp
index 67bc927517..b7faebb4ef 100644
--- a/modules/gdscript/tests/gdscript_test_runner.cpp
+++ b/modules/gdscript/tests/gdscript_test_runner.cpp
@@ -75,14 +75,14 @@ void init_autoloads() {
Node *n = nullptr;
if (res->is_class("PackedScene")) {
Ref<PackedScene> ps = res;
- n = ps->instance();
+ n = ps->instantiate();
} else if (res->is_class("Script")) {
Ref<Script> script_res = res;
StringName ibt = script_res->get_instance_base_type();
bool valid_type = ClassDB::is_parent_class(ibt, "Node");
ERR_CONTINUE_MSG(!valid_type, "Script does not inherit a Node: " + info.path);
- Object *obj = ClassDB::instance(ibt);
+ Object *obj = ClassDB::instantiate(ibt);
ERR_CONTINUE_MSG(obj == nullptr,
"Cannot instance script for autoload, expected 'Node' inheritance, got: " +
@@ -420,7 +420,7 @@ GDScriptTest::TestResult GDScriptTest::execute_test_code(bool p_is_generating) {
// Create script.
Ref<GDScript> script;
- script.instance();
+ script.instantiate();
script->set_path(source_file);
script->set_script_path(source_file);
err = script->load_source_code(source_file);
@@ -510,7 +510,7 @@ GDScriptTest::TestResult GDScriptTest::execute_test_code(bool p_is_generating) {
script->reload();
// Create object instance for test.
- Object *obj = ClassDB::instance(script->get_native()->get_name());
+ Object *obj = ClassDB::instantiate(script->get_native()->get_name());
Ref<RefCounted> obj_ref;
if (obj->is_ref_counted()) {
obj_ref = Ref<RefCounted>(Object::cast_to<RefCounted>(obj));
diff --git a/modules/gdscript/tests/test_gdscript.cpp b/modules/gdscript/tests/test_gdscript.cpp
index c37d52febd..7aa5895981 100644
--- a/modules/gdscript/tests/test_gdscript.cpp
+++ b/modules/gdscript/tests/test_gdscript.cpp
@@ -165,7 +165,7 @@ static void test_compiler(const String &p_code, const String &p_script_path, con
GDScriptCompiler compiler;
Ref<GDScript> script;
- script.instance();
+ script.instantiate();
script->set_path(p_script_path);
err = compiler.compile(&parser, script.ptr(), false);
diff --git a/modules/gltf/doc_classes/GLTFAccessor.xml b/modules/gltf/doc_classes/GLTFAccessor.xml
index a1f596f7dd..41a318ce19 100644
--- a/modules/gltf/doc_classes/GLTFAccessor.xml
+++ b/modules/gltf/doc_classes/GLTFAccessor.xml
@@ -17,9 +17,9 @@
</member>
<member name="count" type="int" setter="set_count" getter="get_count" default="0">
</member>
- <member name="max" type="PackedFloat64Array" setter="set_max" getter="get_max" default="PackedFloat64Array( )">
+ <member name="max" type="PackedFloat64Array" setter="set_max" getter="get_max" default="PackedFloat64Array()">
</member>
- <member name="min" type="PackedFloat64Array" setter="set_min" getter="get_min" default="PackedFloat64Array( )">
+ <member name="min" type="PackedFloat64Array" setter="set_min" getter="get_min" default="PackedFloat64Array()">
</member>
<member name="normalized" type="bool" setter="set_normalized" getter="get_normalized" default="false">
</member>
diff --git a/modules/gltf/doc_classes/GLTFLight.xml b/modules/gltf/doc_classes/GLTFLight.xml
index bfeaf9a86e..f51d287685 100644
--- a/modules/gltf/doc_classes/GLTFLight.xml
+++ b/modules/gltf/doc_classes/GLTFLight.xml
@@ -9,7 +9,7 @@
<methods>
</methods>
<members>
- <member name="color" type="Color" setter="set_color" getter="get_color" default="Color( 0, 0, 0, 1 )">
+ <member name="color" type="Color" setter="set_color" getter="get_color" default="Color(0, 0, 0, 1)">
</member>
<member name="inner_cone_angle" type="float" setter="set_inner_cone_angle" getter="get_inner_cone_angle" default="0.0">
</member>
diff --git a/modules/gltf/doc_classes/GLTFMesh.xml b/modules/gltf/doc_classes/GLTFMesh.xml
index 55f79d2c55..fd7e4a169e 100644
--- a/modules/gltf/doc_classes/GLTFMesh.xml
+++ b/modules/gltf/doc_classes/GLTFMesh.xml
@@ -9,7 +9,7 @@
<methods>
</methods>
<members>
- <member name="blend_weights" type="PackedFloat32Array" setter="set_blend_weights" getter="get_blend_weights" default="PackedFloat32Array( )">
+ <member name="blend_weights" type="PackedFloat32Array" setter="set_blend_weights" getter="get_blend_weights" default="PackedFloat32Array()">
</member>
<member name="mesh" type="EditorSceneImporterMesh" setter="set_mesh" getter="get_mesh">
</member>
diff --git a/modules/gltf/doc_classes/GLTFNode.xml b/modules/gltf/doc_classes/GLTFNode.xml
index 5d84d7088b..bfbb12df4d 100644
--- a/modules/gltf/doc_classes/GLTFNode.xml
+++ b/modules/gltf/doc_classes/GLTFNode.xml
@@ -11,7 +11,7 @@
<members>
<member name="camera" type="int" setter="set_camera" getter="get_camera" default="-1">
</member>
- <member name="children" type="PackedInt32Array" setter="set_children" getter="get_children" default="PackedInt32Array( )">
+ <member name="children" type="PackedInt32Array" setter="set_children" getter="get_children" default="PackedInt32Array()">
</member>
<member name="height" type="int" setter="set_height" getter="get_height" default="-1">
</member>
@@ -23,17 +23,17 @@
</member>
<member name="parent" type="int" setter="set_parent" getter="get_parent" default="-1">
</member>
- <member name="rotation" type="Quaternion" setter="set_rotation" getter="get_rotation" default="Quaternion( 0, 0, 0, 1 )">
+ <member name="rotation" type="Quaternion" setter="set_rotation" getter="get_rotation" default="Quaternion(0, 0, 0, 1)">
</member>
- <member name="scale" type="Vector3" setter="set_scale" getter="get_scale" default="Vector3( 1, 1, 1 )">
+ <member name="scale" type="Vector3" setter="set_scale" getter="get_scale" default="Vector3(1, 1, 1)">
</member>
<member name="skeleton" type="int" setter="set_skeleton" getter="get_skeleton" default="-1">
</member>
<member name="skin" type="int" setter="set_skin" getter="get_skin" default="-1">
</member>
- <member name="translation" type="Vector3" setter="set_translation" getter="get_translation" default="Vector3( 0, 0, 0 )">
+ <member name="translation" type="Vector3" setter="set_translation" getter="get_translation" default="Vector3(0, 0, 0)">
</member>
- <member name="xform" type="Transform3D" setter="set_xform" getter="get_xform" default="Transform3D( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )">
+ <member name="xform" type="Transform3D" setter="set_xform" getter="get_xform" default="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)">
</member>
</members>
<constants>
diff --git a/modules/gltf/doc_classes/GLTFSkeleton.xml b/modules/gltf/doc_classes/GLTFSkeleton.xml
index 9680c27705..40563c9ac6 100644
--- a/modules/gltf/doc_classes/GLTFSkeleton.xml
+++ b/modules/gltf/doc_classes/GLTFSkeleton.xml
@@ -57,9 +57,9 @@
</method>
</methods>
<members>
- <member name="joints" type="PackedInt32Array" setter="set_joints" getter="get_joints" default="PackedInt32Array( )">
+ <member name="joints" type="PackedInt32Array" setter="set_joints" getter="get_joints" default="PackedInt32Array()">
</member>
- <member name="roots" type="PackedInt32Array" setter="set_roots" getter="get_roots" default="PackedInt32Array( )">
+ <member name="roots" type="PackedInt32Array" setter="set_roots" getter="get_roots" default="PackedInt32Array()">
</member>
</members>
<constants>
diff --git a/modules/gltf/doc_classes/GLTFSkin.xml b/modules/gltf/doc_classes/GLTFSkin.xml
index 5a80c7097a..e20e127e52 100644
--- a/modules/gltf/doc_classes/GLTFSkin.xml
+++ b/modules/gltf/doc_classes/GLTFSkin.xml
@@ -53,13 +53,13 @@
<members>
<member name="godot_skin" type="Skin" setter="set_godot_skin" getter="get_godot_skin">
</member>
- <member name="joints" type="PackedInt32Array" setter="set_joints" getter="get_joints" default="PackedInt32Array( )">
+ <member name="joints" type="PackedInt32Array" setter="set_joints" getter="get_joints" default="PackedInt32Array()">
</member>
- <member name="joints_original" type="PackedInt32Array" setter="set_joints_original" getter="get_joints_original" default="PackedInt32Array( )">
+ <member name="joints_original" type="PackedInt32Array" setter="set_joints_original" getter="get_joints_original" default="PackedInt32Array()">
</member>
- <member name="non_joints" type="PackedInt32Array" setter="set_non_joints" getter="get_non_joints" default="PackedInt32Array( )">
+ <member name="non_joints" type="PackedInt32Array" setter="set_non_joints" getter="get_non_joints" default="PackedInt32Array()">
</member>
- <member name="roots" type="PackedInt32Array" setter="set_roots" getter="get_roots" default="PackedInt32Array( )">
+ <member name="roots" type="PackedInt32Array" setter="set_roots" getter="get_roots" default="PackedInt32Array()">
</member>
<member name="skeleton" type="int" setter="set_skeleton" getter="get_skeleton" default="-1">
</member>
diff --git a/modules/gltf/doc_classes/GLTFSpecGloss.xml b/modules/gltf/doc_classes/GLTFSpecGloss.xml
index 68cc7c845d..6e9c419649 100644
--- a/modules/gltf/doc_classes/GLTFSpecGloss.xml
+++ b/modules/gltf/doc_classes/GLTFSpecGloss.xml
@@ -9,7 +9,7 @@
<methods>
</methods>
<members>
- <member name="diffuse_factor" type="Color" setter="set_diffuse_factor" getter="get_diffuse_factor" default="Color( 1, 1, 1, 1 )">
+ <member name="diffuse_factor" type="Color" setter="set_diffuse_factor" getter="get_diffuse_factor" default="Color(1, 1, 1, 1)">
</member>
<member name="diffuse_img" type="Image" setter="set_diffuse_img" getter="get_diffuse_img">
</member>
@@ -17,7 +17,7 @@
</member>
<member name="spec_gloss_img" type="Image" setter="set_spec_gloss_img" getter="get_spec_gloss_img">
</member>
- <member name="specular_factor" type="Color" setter="set_specular_factor" getter="get_specular_factor" default="Color( 1, 1, 1, 1 )">
+ <member name="specular_factor" type="Color" setter="set_specular_factor" getter="get_specular_factor" default="Color(1, 1, 1, 1)">
</member>
</members>
<constants>
diff --git a/modules/gltf/doc_classes/GLTFState.xml b/modules/gltf/doc_classes/GLTFState.xml
index 8255cd73d0..a7b5b7b43e 100644
--- a/modules/gltf/doc_classes/GLTFState.xml
+++ b/modules/gltf/doc_classes/GLTFState.xml
@@ -243,9 +243,9 @@
</method>
</methods>
<members>
- <member name="buffers" type="Array" setter="set_buffers" getter="get_buffers" default="[ ]">
+ <member name="buffers" type="Array" setter="set_buffers" getter="get_buffers" default="[]">
</member>
- <member name="glb_data" type="PackedByteArray" setter="set_glb_data" getter="get_glb_data" default="PackedByteArray( )">
+ <member name="glb_data" type="PackedByteArray" setter="set_glb_data" getter="get_glb_data" default="PackedByteArray()">
</member>
<member name="json" type="Dictionary" setter="set_json" getter="get_json" default="{}">
</member>
@@ -253,7 +253,7 @@
</member>
<member name="minor_version" type="int" setter="set_minor_version" getter="get_minor_version" default="0">
</member>
- <member name="root_nodes" type="Array" setter="set_root_nodes" getter="get_root_nodes" default="[ ]">
+ <member name="root_nodes" type="Array" setter="set_root_nodes" getter="get_root_nodes" default="[]">
</member>
<member name="scene_name" type="String" setter="set_scene_name" getter="get_scene_name" default="&quot;&quot;">
</member>
diff --git a/modules/gltf/doc_classes/PackedSceneGLTF.xml b/modules/gltf/doc_classes/PackedSceneGLTF.xml
index a04c6ef0b6..a22111e9b7 100644
--- a/modules/gltf/doc_classes/PackedSceneGLTF.xml
+++ b/modules/gltf/doc_classes/PackedSceneGLTF.xml
@@ -51,7 +51,7 @@
</method>
</methods>
<members>
- <member name="_bundled" type="Dictionary" setter="_set_bundled_scene" getter="_get_bundled_scene" override="true" default="{&quot;conn_count&quot;: 0,&quot;conns&quot;: PackedInt32Array( ),&quot;editable_instances&quot;: [ ],&quot;names&quot;: PackedStringArray( ),&quot;node_count&quot;: 0,&quot;node_paths&quot;: [ ],&quot;nodes&quot;: PackedInt32Array( ),&quot;variants&quot;: [ ],&quot;version&quot;: 2}" />
+ <member name="_bundled" type="Dictionary" setter="_set_bundled_scene" getter="_get_bundled_scene" override="true" default="{&quot;conn_count&quot;: 0,&quot;conns&quot;: PackedInt32Array(),&quot;editable_instances&quot;: [],&quot;names&quot;: PackedStringArray(),&quot;node_count&quot;: 0,&quot;node_paths&quot;: [],&quot;nodes&quot;: PackedInt32Array(),&quot;variants&quot;: [],&quot;version&quot;: 2}" />
</members>
<constants>
</constants>
diff --git a/modules/gltf/editor_scene_exporter_gltf_plugin.cpp b/modules/gltf/editor_scene_exporter_gltf_plugin.cpp
index 4cdaccde6f..ae080bcc9a 100644
--- a/modules/gltf/editor_scene_exporter_gltf_plugin.cpp
+++ b/modules/gltf/editor_scene_exporter_gltf_plugin.cpp
@@ -49,7 +49,7 @@ bool SceneExporterGLTFPlugin::has_main_screen() const {
SceneExporterGLTFPlugin::SceneExporterGLTFPlugin(EditorNode *p_node) {
editor = p_node;
- convert_gltf2.instance();
+ convert_gltf2.instantiate();
file_export_lib = memnew(EditorFileDialog);
editor->get_gui_base()->add_child(file_export_lib);
file_export_lib->connect("file_selected", callable_mp(this, &SceneExporterGLTFPlugin::_gltf2_dialog_action));
diff --git a/modules/gltf/editor_scene_importer_gltf.cpp b/modules/gltf/editor_scene_importer_gltf.cpp
index 21b4bb75fb..cef5278f03 100644
--- a/modules/gltf/editor_scene_importer_gltf.cpp
+++ b/modules/gltf/editor_scene_importer_gltf.cpp
@@ -30,7 +30,6 @@
#include "core/crypto/crypto_core.h"
#include "core/io/file_access.h"
-#include "core/io/json.h"
#include "core/math/disjoint_set.h"
#include "core/math/math_defs.h"
#include "core/os/os.h"
@@ -60,7 +59,7 @@ Node *EditorSceneImporterGLTF::import_scene(const String &p_path,
List<String> *r_missing_deps,
Error *r_err) {
Ref<PackedSceneGLTF> importer;
- importer.instance();
+ importer.instantiate();
return importer->import_scene(p_path, p_flags, p_bake_fps, r_missing_deps, r_err, Ref<GLTFState>());
}
@@ -91,13 +90,13 @@ Node *PackedSceneGLTF::import_scene(const String &p_path, uint32_t p_flags,
Error *r_err,
Ref<GLTFState> r_state) {
if (r_state == Ref<GLTFState>()) {
- r_state.instance();
+ r_state.instantiate();
}
r_state->use_named_skin_binds =
p_flags & EditorSceneImporter::IMPORT_USE_NAMED_SKIN_BINDS;
Ref<GLTFDocument> gltf_document;
- gltf_document.instance();
+ gltf_document.instantiate();
Error err = gltf_document->parse(r_state, p_path);
if (r_err) {
*r_err = err;
@@ -139,9 +138,9 @@ void PackedSceneGLTF::save_scene(Node *p_node, const String &p_path,
*r_err = err;
}
Ref<GLTFDocument> gltf_document;
- gltf_document.instance();
+ gltf_document.instantiate();
Ref<GLTFState> state;
- state.instance();
+ state.instantiate();
err = gltf_document->serialize(state, p_node, p_path);
if (r_err) {
*r_err = err;
@@ -172,7 +171,7 @@ Error PackedSceneGLTF::export_gltf(Node *p_root, String p_path,
int32_t flags = p_flags;
real_t baked_fps = p_bake_fps;
Ref<PackedSceneGLTF> exporter;
- exporter.instance();
+ exporter.instantiate();
exporter->save_scene(p_root, path, "", flags, baked_fps, &deps, &err);
int32_t error_code = err;
if (error_code != 0) {
diff --git a/modules/gltf/editor_scene_importer_gltf.h b/modules/gltf/editor_scene_importer_gltf.h
index af1a885f2b..566d5cfd34 100644
--- a/modules/gltf/editor_scene_importer_gltf.h
+++ b/modules/gltf/editor_scene_importer_gltf.h
@@ -32,7 +32,6 @@
#define EDITOR_SCENE_IMPORTER_GLTF_H
#include "core/config/project_settings.h"
-#include "core/io/json.h"
#include "core/object/object.h"
#include "core/templates/vector.h"
#include "editor/import/resource_importer_scene.h"
diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp
index 988a75ac93..a5080f9c41 100644
--- a/modules/gltf/gltf_document.cpp
+++ b/modules/gltf/gltf_document.cpp
@@ -238,15 +238,13 @@ Error GLTFDocument::_parse_json(const String &p_path, Ref<GLTFState> state) {
String text;
text.parse_utf8((const char *)array.ptr(), array.size());
- String err_txt;
- int err_line;
- Variant v;
- err = JSON::parse(text, v, err_txt, err_line);
+ JSON json;
+ err = json.parse(text);
if (err != OK) {
- _err_print_error("", p_path.utf8().get_data(), err_line, err_txt.utf8().get_data(), ERR_HANDLER_SCRIPT);
+ _err_print_error("", p_path.utf8().get_data(), json.get_error_line(), json.get_error_message().utf8().get_data(), ERR_HANDLER_SCRIPT);
return err;
}
- state->json = v;
+ state->json = json.get_data();
return OK;
}
@@ -299,16 +297,14 @@ Error GLTFDocument::_parse_glb(const String &p_path, Ref<GLTFState> state) {
String text;
text.parse_utf8((const char *)json_data.ptr(), json_data.size());
- String err_txt;
- int err_line;
- Variant v;
- err = JSON::parse(text, v, err_txt, err_line);
+ JSON json;
+ err = json.parse(text);
if (err != OK) {
- _err_print_error("", p_path.utf8().get_data(), err_line, err_txt.utf8().get_data(), ERR_HANDLER_SCRIPT);
+ _err_print_error("", p_path.utf8().get_data(), json.get_error_line(), json.get_error_message().utf8().get_data(), ERR_HANDLER_SCRIPT);
return err;
}
- state->json = v;
+ state->json = json.get_data();
//data?
@@ -569,7 +565,7 @@ Error GLTFDocument::_parse_nodes(Ref<GLTFState> state) {
const Array &nodes = state->json["nodes"];
for (int i = 0; i < nodes.size(); i++) {
Ref<GLTFNode> node;
- node.instance();
+ node.instantiate();
const Dictionary &n = nodes[i];
if (n.has("name")) {
@@ -830,7 +826,7 @@ Error GLTFDocument::_parse_buffer_views(Ref<GLTFState> state) {
const Dictionary &d = buffers[i];
Ref<GLTFBufferView> buffer_view;
- buffer_view.instance();
+ buffer_view.instantiate();
ERR_FAIL_COND_V(!d.has("buffer"), ERR_PARSE_ERROR);
buffer_view->buffer = d["buffer"];
@@ -976,7 +972,7 @@ Error GLTFDocument::_parse_accessors(Ref<GLTFState> state) {
const Dictionary &d = accessors[i];
Ref<GLTFAccessor> accessor;
- accessor.instance();
+ accessor.instantiate();
ERR_FAIL_COND_V(!d.has("componentType"), ERR_PARSE_ERROR);
accessor->component_type = d["componentType"];
@@ -1118,7 +1114,7 @@ Error GLTFDocument::_encode_buffer_view(Ref<GLTFState> state, const double *src,
}
Ref<GLTFBufferView> bv;
- bv.instance();
+ bv.instantiate();
const uint32_t offset = bv->byte_offset = byte_offset;
Vector<uint8_t> &gltf_buffer = state->buffers.write[0];
@@ -1512,7 +1508,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_ints(Ref<GLTFState> state, c
ERR_FAIL_COND_V(attribs.size() == 0, -1);
Ref<GLTFAccessor> accessor;
- accessor.instance();
+ accessor.instantiate();
GLTFBufferIndex buffer_view_i;
int64_t size = state->buffers[0].size();
const GLTFDocument::GLTFType type = GLTFDocument::TYPE_SCALAR;
@@ -1596,7 +1592,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_vec2(Ref<GLTFState> state, c
ERR_FAIL_COND_V(attribs.size() % element_count != 0, -1);
Ref<GLTFAccessor> accessor;
- accessor.instance();
+ accessor.instantiate();
GLTFBufferIndex buffer_view_i;
int64_t size = state->buffers[0].size();
const GLTFDocument::GLTFType type = GLTFDocument::TYPE_VEC2;
@@ -1645,7 +1641,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_color(Ref<GLTFState> state,
ERR_FAIL_COND_V(attribs.size() % element_count != 0, -1);
Ref<GLTFAccessor> accessor;
- accessor.instance();
+ accessor.instantiate();
GLTFBufferIndex buffer_view_i;
int64_t size = state->buffers[0].size();
const GLTFDocument::GLTFType type = GLTFDocument::TYPE_VEC4;
@@ -1710,7 +1706,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_weights(Ref<GLTFState> state
ERR_FAIL_COND_V(attribs.size() % element_count != 0, -1);
Ref<GLTFAccessor> accessor;
- accessor.instance();
+ accessor.instantiate();
GLTFBufferIndex buffer_view_i;
int64_t size = state->buffers[0].size();
const GLTFDocument::GLTFType type = GLTFDocument::TYPE_VEC4;
@@ -1757,7 +1753,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_joints(Ref<GLTFState> state,
ERR_FAIL_COND_V(attribs.size() % element_count != 0, -1);
Ref<GLTFAccessor> accessor;
- accessor.instance();
+ accessor.instantiate();
GLTFBufferIndex buffer_view_i;
int64_t size = state->buffers[0].size();
const GLTFDocument::GLTFType type = GLTFDocument::TYPE_VEC4;
@@ -1806,7 +1802,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_quaternions(Ref<GLTFState> s
ERR_FAIL_COND_V(attribs.size() % element_count != 0, -1);
Ref<GLTFAccessor> accessor;
- accessor.instance();
+ accessor.instantiate();
GLTFBufferIndex buffer_view_i;
int64_t size = state->buffers[0].size();
const GLTFDocument::GLTFType type = GLTFDocument::TYPE_VEC4;
@@ -1871,7 +1867,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_floats(Ref<GLTFState> state,
ERR_FAIL_COND_V(!attribs.size(), -1);
Ref<GLTFAccessor> accessor;
- accessor.instance();
+ accessor.instantiate();
GLTFBufferIndex buffer_view_i;
int64_t size = state->buffers[0].size();
const GLTFDocument::GLTFType type = GLTFDocument::TYPE_SCALAR;
@@ -1917,7 +1913,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_vec3(Ref<GLTFState> state, c
ERR_FAIL_COND_V(attribs.size() % element_count != 0, -1);
Ref<GLTFAccessor> accessor;
- accessor.instance();
+ accessor.instantiate();
GLTFBufferIndex buffer_view_i;
int64_t size = state->buffers[0].size();
const GLTFDocument::GLTFType type = GLTFDocument::TYPE_VEC3;
@@ -1985,7 +1981,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_xform(Ref<GLTFState> state,
ERR_FAIL_COND_V(attribs.size() % element_count != 0, -1);
Ref<GLTFAccessor> accessor;
- accessor.instance();
+ accessor.instantiate();
GLTFBufferIndex buffer_view_i;
int64_t size = state->buffers[0].size();
const GLTFDocument::GLTFType type = GLTFDocument::TYPE_MAT4;
@@ -2335,7 +2331,7 @@ Error GLTFDocument::_serialize_meshes(Ref<GLTFState> state) {
//generate indices because they need to be swapped for CW/CCW
const Vector<Vector3> &vertices = array[Mesh::ARRAY_VERTEX];
Ref<SurfaceTool> st;
- st.instance();
+ st.instantiate();
st->create_from_triangle_arrays(array);
st->index();
Vector<int32_t> generated_indices = st->commit_to_arrays()[Mesh::ARRAY_INDEX];
@@ -2459,7 +2455,7 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> state) {
Dictionary d = meshes[i];
Ref<GLTFMesh> mesh;
- mesh.instance();
+ mesh.instantiate();
bool has_vertex_color = false;
ERR_FAIL_COND_V(!d.has("primitives"), ERR_PARSE_ERROR);
@@ -2467,7 +2463,7 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> state) {
Array primitives = d["primitives"];
const Dictionary &extras = d.has("extras") ? (Dictionary)d["extras"] : Dictionary();
Ref<EditorSceneImporterMesh> import_mesh;
- import_mesh.instance();
+ import_mesh.instantiate();
String mesh_name = "mesh";
if (d.has("name") && !String(d["name"]).is_empty()) {
mesh_name = d["name"];
@@ -2652,7 +2648,7 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> state) {
if (generate_tangents) {
//must generate mikktspace tangents.. ergh..
Ref<SurfaceTool> st;
- st.instance();
+ st.instantiate();
st->create_from_triangle_arrays(array);
if (a.has("JOINTS_0") && a.has("JOINTS_1")) {
st->set_skin_weight_count(SurfaceTool::SKIN_8_WEIGHTS);
@@ -2771,7 +2767,7 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> state) {
if (generate_tangents) {
Ref<SurfaceTool> st;
- st.instance();
+ st.instantiate();
st->create_from_triangle_arrays(array_copy);
if (a.has("JOINTS_0") && a.has("JOINTS_1")) {
st->set_skin_weight_count(SurfaceTool::SKIN_8_WEIGHTS);
@@ -2799,7 +2795,7 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> state) {
} else if (has_vertex_color) {
Ref<StandardMaterial3D> mat3d;
- mat3d.instance();
+ mat3d.instantiate();
mat3d->set_flag(BaseMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
mat = mat3d;
}
@@ -2847,7 +2843,7 @@ Error GLTFDocument::_serialize_images(Ref<GLTFState> state, const String &p_path
GLTFBufferViewIndex bvi;
Ref<GLTFBufferView> bv;
- bv.instance();
+ bv.instantiate();
const GLTFBufferIndex bi = 0;
bv->buffer = bi;
@@ -2879,7 +2875,7 @@ Error GLTFDocument::_serialize_images(Ref<GLTFState> state, const String &p_path
name = _gen_unique_name(state, name);
name = name.pad_zeros(3);
Ref<_Directory> dir;
- dir.instance();
+ dir.instantiate();
String texture_dir = "textures";
String new_texture_dir = p_path.get_base_dir() + "/" + texture_dir;
dir->open(p_path.get_base_dir());
@@ -3038,7 +3034,7 @@ Error GLTFDocument::_parse_images(Ref<GLTFState> state, const String &p_base_pat
}
Ref<ImageTexture> t;
- t.instance();
+ t.instantiate();
t->create_from_image(img);
state->images.push_back(t);
@@ -3079,7 +3075,7 @@ Error GLTFDocument::_parse_textures(Ref<GLTFState> state) {
ERR_FAIL_COND_V(!d.has("source"), ERR_PARSE_ERROR);
Ref<GLTFTexture> t;
- t.instance();
+ t.instantiate();
t->set_src_image(d["source"]);
state->textures.push_back(t);
}
@@ -3090,7 +3086,7 @@ Error GLTFDocument::_parse_textures(Ref<GLTFState> state) {
GLTFTextureIndex GLTFDocument::_set_texture(Ref<GLTFState> state, Ref<Texture2D> p_texture) {
ERR_FAIL_COND_V(p_texture.is_null(), -1);
Ref<GLTFTexture> gltf_texture;
- gltf_texture.instance();
+ gltf_texture.instantiate();
ERR_FAIL_COND_V(p_texture->get_image().is_null(), -1);
GLTFImageIndex gltf_src_image_i = state->images.size();
state->images.push_back(p_texture);
@@ -3163,9 +3159,9 @@ Error GLTFDocument::_serialize_materials(Ref<GLTFState> state) {
Ref<Texture2D> ao_texture = material->get_texture(BaseMaterial3D::TEXTURE_AMBIENT_OCCLUSION);
BaseMaterial3D::TextureChannel ao_channel = material->get_ao_texture_channel();
Ref<ImageTexture> orm_texture;
- orm_texture.instance();
+ orm_texture.instantiate();
Ref<Image> orm_image;
- orm_image.instance();
+ orm_image.instantiate();
int32_t height = 0;
int32_t width = 0;
Ref<Image> ao_image;
@@ -3285,7 +3281,7 @@ Error GLTFDocument::_serialize_materials(Ref<GLTFState> state) {
if (material->get_feature(BaseMaterial3D::FEATURE_NORMAL_MAPPING)) {
Dictionary nt;
Ref<ImageTexture> tex;
- tex.instance();
+ tex.instantiate();
{
Ref<Texture2D> normal_texture = material->get_texture(BaseMaterial3D::TEXTURE_NORMAL);
// Code for uncompressing RG normal maps
@@ -3373,7 +3369,7 @@ Error GLTFDocument::_parse_materials(Ref<GLTFState> state) {
const Dictionary &d = materials[i];
Ref<StandardMaterial3D> material;
- material.instance();
+ material.instantiate();
if (d.has("name") && !String(d["name"]).is_empty()) {
material->set_name(d["name"]);
} else {
@@ -3389,7 +3385,7 @@ Error GLTFDocument::_parse_materials(Ref<GLTFState> state) {
Dictionary sgm = pbr_spec_gloss_extensions["KHR_materials_pbrSpecularGlossiness"];
Ref<GLTFSpecGloss> spec_gloss;
- spec_gloss.instance();
+ spec_gloss.instantiate();
if (sgm.has("diffuseTexture")) {
const Dictionary &diffuse_texture_dict = sgm["diffuseTexture"];
if (diffuse_texture_dict.has("index")) {
@@ -3572,7 +3568,7 @@ void GLTFDocument::spec_gloss_to_rough_metal(Ref<GLTFSpecGloss> r_spec_gloss, Re
return;
}
Ref<Image> rm_img;
- rm_img.instance();
+ rm_img.instantiate();
bool has_roughness = false;
bool has_metal = false;
p_material->set_roughness(1.0f);
@@ -3600,7 +3596,7 @@ void GLTFDocument::spec_gloss_to_rough_metal(Ref<GLTFSpecGloss> r_spec_gloss, Re
if (!Math::is_equal_approx(mr.g, 1.0f)) {
has_roughness = true;
}
- if (!Math::is_equal_approx(mr.b, 0.0f)) {
+ if (!Math::is_zero_approx(mr.b)) {
has_metal = true;
}
mr.g *= r_spec_gloss->gloss_factor;
@@ -3614,11 +3610,11 @@ void GLTFDocument::spec_gloss_to_rough_metal(Ref<GLTFSpecGloss> r_spec_gloss, Re
rm_img->generate_mipmaps();
r_spec_gloss->diffuse_img->generate_mipmaps();
Ref<ImageTexture> diffuse_image_texture;
- diffuse_image_texture.instance();
+ diffuse_image_texture.instantiate();
diffuse_image_texture->create_from_image(r_spec_gloss->diffuse_img);
p_material->set_texture(BaseMaterial3D::TEXTURE_ALBEDO, diffuse_image_texture);
Ref<ImageTexture> rm_image_texture;
- rm_image_texture.instance();
+ rm_image_texture.instantiate();
rm_image_texture->create_from_image(rm_img);
if (has_roughness) {
p_material->set_texture(BaseMaterial3D::TEXTURE_ROUGHNESS, rm_image_texture);
@@ -3894,7 +3890,7 @@ Error GLTFDocument::_parse_skins(Ref<GLTFState> state) {
const Dictionary &d = skins[i];
Ref<GLTFSkin> skin;
- skin.instance();
+ skin.instantiate();
ERR_FAIL_COND_V(!d.has("joints"), ERR_PARSE_ERROR);
@@ -4022,7 +4018,7 @@ Error GLTFDocument::_determine_skeletons(Ref<GLTFState> state) {
for (GLTFSkeletonIndex skel_i = 0; skel_i < skeleton_owners.size(); ++skel_i) {
const GLTFNodeIndex skeleton_owner = skeleton_owners[skel_i];
Ref<GLTFSkeleton> skeleton;
- skeleton.instance();
+ skeleton.instantiate();
Vector<GLTFNodeIndex> skeleton_nodes;
skeleton_sets.get_members(skeleton_nodes, skeleton_owner);
@@ -4270,7 +4266,7 @@ Error GLTFDocument::_create_skins(Ref<GLTFState> state) {
Ref<GLTFSkin> gltf_skin = state->skins.write[skin_i];
Ref<Skin> skin;
- skin.instance();
+ skin.instantiate();
// Some skins don't have IBM's! What absolute monsters!
const bool has_ibms = !gltf_skin->inverse_binds.is_empty();
@@ -4452,7 +4448,7 @@ Error GLTFDocument::_parse_lights(Ref<GLTFState> state) {
const Dictionary &d = lights[light_i];
Ref<GLTFLight> light;
- light.instance();
+ light.instantiate();
ERR_FAIL_COND_V(!d.has("type"), ERR_PARSE_ERROR);
const String &type = d["type"];
light->type = type;
@@ -4497,7 +4493,7 @@ Error GLTFDocument::_parse_cameras(Ref<GLTFState> state) {
const Dictionary &d = cameras[i];
Ref<GLTFCamera> camera;
- camera.instance();
+ camera.instantiate();
ERR_FAIL_COND_V(!d.has("type"), ERR_PARSE_ERROR);
const String &type = d["type"];
if (type == "orthographic") {
@@ -4700,7 +4696,7 @@ Error GLTFDocument::_parse_animations(Ref<GLTFState> state) {
const Dictionary &d = animations[i];
Ref<GLTFAnimation> animation;
- animation.instance();
+ animation.instantiate();
if (!d.has("channels") || !d.has("samplers")) {
continue;
@@ -4868,7 +4864,7 @@ GLTFMeshIndex GLTFDocument::_convert_mesh_instance(Ref<GLTFState> state, MeshIns
return -1;
}
Ref<EditorSceneImporterMesh> import_mesh;
- import_mesh.instance();
+ import_mesh.instantiate();
Ref<Mesh> godot_mesh = p_mesh_instance->get_mesh();
if (godot_mesh.is_null()) {
return -1;
@@ -4905,7 +4901,7 @@ GLTFMeshIndex GLTFDocument::_convert_mesh_instance(Ref<GLTFState> state, MeshIns
blend_weights.write[blend_i] = 0.0f;
}
Ref<GLTFMesh> gltf_mesh;
- gltf_mesh.instance();
+ gltf_mesh.instantiate();
gltf_mesh->set_mesh(import_mesh);
gltf_mesh->set_blend_weights(blend_weights);
GLTFMeshIndex mesh_i = state->meshes.size();
@@ -5010,7 +5006,7 @@ GLTFCameraIndex GLTFDocument::_convert_camera(Ref<GLTFState> state, Camera3D *p_
print_verbose("glTF: Converting camera: " + p_camera->get_name());
Ref<GLTFCamera> c;
- c.instance();
+ c.instantiate();
if (p_camera->get_projection() == Camera3D::Projection::PROJECTION_PERSPECTIVE) {
c->set_perspective(true);
@@ -5031,7 +5027,7 @@ GLTFLightIndex GLTFDocument::_convert_light(Ref<GLTFState> state, Light3D *p_lig
print_verbose("glTF: Converting light: " + p_light->get_name());
Ref<GLTFLight> l;
- l.instance();
+ l.instantiate();
l->color = p_light->get_color();
if (cast_to<DirectionalLight3D>(p_light)) {
l->type = "directional";
@@ -5066,7 +5062,7 @@ GLTFLightIndex GLTFDocument::_convert_light(Ref<GLTFState> state, Light3D *p_lig
GLTFSkeletonIndex GLTFDocument::_convert_skeleton(Ref<GLTFState> state, Skeleton3D *p_skeleton) {
print_verbose("glTF: Converting skeleton: " + p_skeleton->get_name());
Ref<GLTFSkeleton> gltf_skeleton;
- gltf_skeleton.instance();
+ gltf_skeleton.instantiate();
gltf_skeleton->set_name(_gen_unique_name(state, p_skeleton->get_name()));
gltf_skeleton->godot_skeleton = p_skeleton;
GLTFSkeletonIndex skeleton_i = state->skeletons.size();
@@ -5096,7 +5092,7 @@ void GLTFDocument::_convert_scene_node(Ref<GLTFState> state, Node *p_current, No
return;
}
Ref<GLTFNode> gltf_node;
- gltf_node.instance();
+ gltf_node.instantiate();
gltf_node->set_name(_gen_unique_name(state, p_current->get_name()));
if (cast_to<Node3D>(p_current)) {
Node3D *spatial = cast_to<Node3D>(p_current);
@@ -5162,9 +5158,9 @@ void GLTFDocument::_convert_csg_shape_to_gltf(Node *p_current, GLTFNodeIndex p_g
mat = csg->get_material_override();
}
Ref<GLTFMesh> gltf_mesh;
- gltf_mesh.instance();
+ gltf_mesh.instantiate();
Ref<EditorSceneImporterMesh> import_mesh;
- import_mesh.instance();
+ import_mesh.instantiate();
Ref<ArrayMesh> array_mesh = csg->get_meshes()[1];
for (int32_t surface_i = 0; surface_i < array_mesh->get_surface_count(); surface_i++) {
import_mesh->add_surface(Mesh::PrimitiveType::PRIMITIVE_TRIANGLES, array_mesh->surface_get_arrays(surface_i), Array(), Dictionary(), mat, array_mesh->surface_get_name(surface_i));
@@ -5250,7 +5246,7 @@ void GLTFDocument::_convert_grid_map_to_gltf(Node *p_scene_parent, const GLTFNod
cell_xform.set_origin(grid_map->map_to_world(
Vector3(cell_location.x, cell_location.y, cell_location.z)));
Ref<GLTFMesh> gltf_mesh;
- gltf_mesh.instance();
+ gltf_mesh.instantiate();
gltf_mesh = import_mesh_node;
new_gltf_node->mesh = state->meshes.size();
state->meshes.push_back(gltf_mesh);
@@ -5287,14 +5283,14 @@ void GLTFDocument::_convert_mult_mesh_instance_to_gltf(Node *p_scene_parent, con
Ref<ArrayMesh> mm = multi_mesh->get_mesh();
if (mm.is_valid()) {
Ref<EditorSceneImporterMesh> mesh;
- mesh.instance();
+ mesh.instantiate();
for (int32_t surface_i = 0; surface_i < mm->get_surface_count(); surface_i++) {
Array surface = mm->surface_get_arrays(surface_i);
mesh->add_surface(mm->surface_get_primitive_type(surface_i), surface, Array(), Dictionary(),
mm->surface_get_material(surface_i), mm->get_name());
}
Ref<GLTFMesh> gltf_mesh;
- gltf_mesh.instance();
+ gltf_mesh.instantiate();
gltf_mesh->set_name(multi_mesh->get_name());
gltf_mesh->set_mesh(mesh);
new_gltf_node->mesh = state->meshes.size();
@@ -5541,6 +5537,8 @@ struct EditorSceneImporterGLTFInterpolate<Quaternion> {
template <class T>
T GLTFDocument::_interpolate_track(const Vector<float> &p_times, const Vector<T> &p_values, const float p_time, const GLTFAnimation::Interpolation p_interp) {
+ ERR_FAIL_COND_V(!p_values.size(), T());
+ ERR_FAIL_COND_V(p_times.size() != p_values.size(), p_values[0]);
//could use binary search, worth it?
int idx = -1;
for (int i = 0; i < p_times.size(); i++) {
@@ -5615,7 +5613,7 @@ void GLTFDocument::_import_animation(Ref<GLTFState> state, AnimationPlayer *ap,
}
Ref<Animation> animation;
- animation.instance();
+ animation.instantiate();
animation->set_name(name);
if (anim->get_loop()) {
@@ -5826,7 +5824,7 @@ void GLTFDocument::_convert_mesh_instances(Ref<GLTFState> state) {
skin = skeleton->register_skin(nullptr)->get_skin();
}
Ref<GLTFSkin> gltf_skin;
- gltf_skin.instance();
+ gltf_skin.instantiate();
Array json_joints;
GLTFSkeletonIndex skeleton_gltf_i = -1;
@@ -5868,7 +5866,7 @@ void GLTFDocument::_convert_mesh_instances(Ref<GLTFState> state) {
BoneId bone_index = skeleton->find_bone(godot_bone_name);
ERR_CONTINUE(bone_index == -1);
Ref<GLTFNode> joint_node;
- joint_node.instance();
+ joint_node.instantiate();
String gltf_bone_name = _gen_unique_bone_name(state, skeleton_gltf_i, godot_bone_name);
joint_node->set_name(gltf_bone_name);
@@ -6190,7 +6188,7 @@ GLTFAnimation::Track GLTFDocument::_convert_animation_track(Ref<GLTFState> state
void GLTFDocument::_convert_animation(Ref<GLTFState> state, AnimationPlayer *ap, String p_animation_track_name) {
Ref<Animation> animation = ap->get_animation(p_animation_track_name);
Ref<GLTFAnimation> gltf_animation;
- gltf_animation.instance();
+ gltf_animation.instantiate();
gltf_animation->set_name(_gen_unique_name(state, p_animation_track_name));
for (int32_t track_i = 0; track_i < animation->get_track_count(); track_i++) {
@@ -6584,7 +6582,7 @@ Error GLTFDocument::_serialize_file(Ref<GLTFState> state, const String p_path) {
FileAccessRef f = FileAccess::open(p_path, FileAccess::WRITE, &err);
ERR_FAIL_COND_V(!f, FAILED);
- String json = JSON::print(state->json);
+ String json = Variant(state->json).to_json_string();
const uint32_t magic = 0x46546C67; // GLTF
const int32_t header_size = 12;
@@ -6625,7 +6623,7 @@ Error GLTFDocument::_serialize_file(Ref<GLTFState> state, const String p_path) {
ERR_FAIL_COND_V(!f, FAILED);
f->create(FileAccess::ACCESS_RESOURCES);
- String json = JSON::print(state->json);
+ String json = Variant(state->json).to_json_string();
f->store_string(json);
f->close();
}
diff --git a/modules/gltf/register_types.cpp b/modules/gltf/register_types.cpp
index dc995c9249..d11c7cb9cd 100644
--- a/modules/gltf/register_types.cpp
+++ b/modules/gltf/register_types.cpp
@@ -51,7 +51,7 @@
#ifdef TOOLS_ENABLED
static void _editor_init() {
Ref<EditorSceneImporterGLTF> import_gltf;
- import_gltf.instance();
+ import_gltf.instantiate();
ResourceImporterScene::get_singleton()->add_importer(import_gltf);
}
#endif
diff --git a/modules/gridmap/doc_classes/GridMap.xml b/modules/gridmap/doc_classes/GridMap.xml
index fb0a2c9953..a2c8e8eabf 100644
--- a/modules/gridmap/doc_classes/GridMap.xml
+++ b/modules/gridmap/doc_classes/GridMap.xml
@@ -203,7 +203,7 @@
The scale of the cell items.
This does not affect the size of the grid cells themselves, only the items in them. This can be used to make cell items overlap their neighbors.
</member>
- <member name="cell_size" type="Vector3" setter="set_cell_size" getter="get_cell_size" default="Vector3( 2, 2, 2 )">
+ <member name="cell_size" type="Vector3" setter="set_cell_size" getter="get_cell_size" default="Vector3(2, 2, 2)">
The dimensions of the grid's cells.
This does not affect the size of the meshes. See [member cell_scale].
</member>
diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp
index 45af59622f..c62e7acd62 100644
--- a/modules/gridmap/grid_map.cpp
+++ b/modules/gridmap/grid_map.cpp
@@ -1012,7 +1012,7 @@ void GridMap::make_baked_meshes(bool p_gen_lightmap_uv, float p_lightmap_uv_texe
Ref<Material> surf_mat = mesh->surface_get_material(i);
if (!mat_map.has(surf_mat)) {
Ref<SurfaceTool> st;
- st.instance();
+ st.instantiate();
st->begin(Mesh::PRIMITIVE_TRIANGLES);
st->set_material(surf_mat);
mat_map[surf_mat] = st;
@@ -1024,7 +1024,7 @@ void GridMap::make_baked_meshes(bool p_gen_lightmap_uv, float p_lightmap_uv_texe
for (Map<OctantKey, Map<Ref<Material>, Ref<SurfaceTool>>>::Element *E = surface_map.front(); E; E = E->next()) {
Ref<ArrayMesh> mesh;
- mesh.instance();
+ mesh.instantiate();
for (Map<Ref<Material>, Ref<SurfaceTool>>::Element *F = E->get().front(); F; F = F->next()) {
F->get()->commit(mesh);
}
diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp
index 80551de1ba..a2f570e6a5 100644
--- a/modules/gridmap/grid_map_editor_plugin.cpp
+++ b/modules/gridmap/grid_map_editor_plugin.cpp
@@ -1085,7 +1085,7 @@ void GridMapEditor::_notification(int p_what) {
if (input_action == INPUT_PAINT) {
// Simulate mouse released event to stop drawing when editor focus exists.
Ref<InputEventMouseButton> release;
- release.instance();
+ release.instantiate();
release->set_button_index(MOUSE_BUTTON_LEFT);
forward_spatial_input_event(nullptr, release);
}
@@ -1356,7 +1356,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
Array d;
d.resize(RS::ARRAY_MAX);
- inner_mat.instance();
+ inner_mat.instantiate();
inner_mat->set_albedo(Color(0.7, 0.7, 1.0, 0.2));
inner_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
inner_mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
@@ -1365,14 +1365,14 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
RenderingServer::get_singleton()->mesh_add_surface_from_arrays(selection_mesh, RS::PRIMITIVE_TRIANGLES, d);
RenderingServer::get_singleton()->mesh_surface_set_material(selection_mesh, 0, inner_mat->get_rid());
- outer_mat.instance();
+ outer_mat.instantiate();
outer_mat->set_albedo(Color(0.7, 0.7, 1.0, 0.8));
outer_mat->set_on_top_of_alpha();
outer_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
outer_mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
- selection_floor_mat.instance();
+ selection_floor_mat.instantiate();
selection_floor_mat->set_albedo(Color(0.80, 0.80, 1.0, 1));
selection_floor_mat->set_on_top_of_alpha();
selection_floor_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
@@ -1399,7 +1399,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
_set_selection(false);
- indicator_mat.instance();
+ indicator_mat.instantiate();
indicator_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
indicator_mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
indicator_mat->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true);
diff --git a/modules/jpg/image_loader_jpegd.cpp b/modules/jpg/image_loader_jpegd.cpp
index d237544d66..b5e4753e8d 100644
--- a/modules/jpg/image_loader_jpegd.cpp
+++ b/modules/jpg/image_loader_jpegd.cpp
@@ -127,7 +127,7 @@ void ImageLoaderJPG::get_recognized_extensions(List<String> *p_extensions) const
static Ref<Image> _jpegd_mem_loader_func(const uint8_t *p_png, int p_size) {
Ref<Image> img;
- img.instance();
+ img.instantiate();
Error err = jpeg_load_image_from_buffer(img.ptr(), p_png, p_size);
ERR_FAIL_COND_V(err, Ref<Image>());
return img;
diff --git a/modules/jsonrpc/jsonrpc.cpp b/modules/jsonrpc/jsonrpc.cpp
index 306c0ff087..3d0759d83e 100644
--- a/modules/jsonrpc/jsonrpc.cpp
+++ b/modules/jsonrpc/jsonrpc.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "jsonrpc.h"
+
#include "core/io/json.h"
JSONRPC::JSONRPC() {
@@ -156,19 +157,17 @@ String JSONRPC::process_string(const String &p_input) {
}
Variant ret;
- Variant input;
- String err_message;
- int err_line;
- if (OK != JSON::parse(p_input, input, err_message, err_line)) {
- ret = make_response_error(JSONRPC::PARSE_ERROR, "Parse error");
+ JSON json;
+ if (json.parse(p_input) == OK) {
+ ret = process_action(json.get_data(), true);
} else {
- ret = process_action(input, true);
+ ret = make_response_error(JSONRPC::PARSE_ERROR, "Parse error");
}
if (ret.get_type() == Variant::NIL) {
return "";
}
- return JSON::print(ret);
+ return ret.to_json_string();
}
void JSONRPC::set_scope(const String &p_scope, Object *p_obj) {
diff --git a/modules/lightmapper_rd/lightmapper_rd.cpp b/modules/lightmapper_rd/lightmapper_rd.cpp
index 3b0fbb1c47..b75cf6502e 100644
--- a/modules/lightmapper_rd/lightmapper_rd.cpp
+++ b/modules/lightmapper_rd/lightmapper_rd.cpp
@@ -248,13 +248,13 @@ Lightmapper::BakeError LightmapperRD::_blit_meshes_into_atlas(int p_max_texture_
for (int i = 0; i < atlas_slices; i++) {
Ref<Image> albedo;
- albedo.instance();
+ albedo.instantiate();
albedo->create(atlas_size.width, atlas_size.height, false, Image::FORMAT_RGBA8);
albedo->set_as_black();
albedo_images.write[i] = albedo;
Ref<Image> emission;
- emission.instance();
+ emission.instantiate();
emission->create(atlas_size.width, atlas_size.height, false, Image::FORMAT_RGBAH);
emission->set_as_black();
emission_images.write[i] = emission;
@@ -479,7 +479,7 @@ void LightmapperRD::_create_acceleration_structures(RenderingDevice *rd, Size2i
}
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create(grid_size, grid_size, false, Image::FORMAT_L8, grid_usage);
img->save_png("res://grid_layer_" + itos(1000 + i).substr(1, 3) + ".png");
}
@@ -725,7 +725,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
panorama_tex = p_environment_panorama;
panorama_tex->convert(Image::FORMAT_RGBAF);
} else {
- panorama_tex.instance();
+ panorama_tex.instantiate();
panorama_tex->create(8, 8, false, Image::FORMAT_RGBAF);
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
@@ -782,7 +782,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
//shaders
Ref<RDShaderFile> raster_shader;
- raster_shader.instance();
+ raster_shader.instantiate();
Error err = raster_shader->parse_versions_from_text(lm_raster_shader_glsl);
if (err != OK) {
raster_shader->print_errors("raster_shader");
@@ -915,7 +915,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
for (int i = 0; i < atlas_slices; i++) {
Vector<uint8_t> s = rd->texture_get_data(position_tex, i);
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create(atlas_size.width, atlas_size.height, false, Image::FORMAT_RGBAF, s);
img->save_exr("res://1_position_" + itos(i) + ".exr", false);
@@ -933,7 +933,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
/* Plot direct light */
Ref<RDShaderFile> compute_shader;
- compute_shader.instance();
+ compute_shader.instantiate();
err = compute_shader->parse_versions_from_text(lm_compute_shader_glsl, p_bake_sh ? "\n#define USE_SH_LIGHTMAPS\n" : "");
if (err != OK) {
FREE_TEXTURES
@@ -1129,7 +1129,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
for (int i = 0; i < atlas_slices; i++) {
Vector<uint8_t> s = rd->texture_get_data(light_source_tex, i);
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create(atlas_size.width, atlas_size.height, false, Image::FORMAT_RGBAH, s);
img->save_exr("res://2_light_primary_" + itos(i) + ".exr", false);
}
@@ -1379,12 +1379,12 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
#if 0
for (int i = 0; i < probe_positions.size(); i++) {
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create(6, 4, false, Image::FORMAT_RGB8);
for (int j = 0; j < 6; j++) {
Vector<uint8_t> s = rd->texture_get_data(lightprobe_tex, i * 6 + j);
Ref<Image> img2;
- img2.instance();
+ img2.instantiate();
img2->create(2, 2, false, Image::FORMAT_RGBAF, s);
img2->convert(Image::FORMAT_RGB8);
img->blit_rect(img2, Rect2(0, 0, 2, 2), Point2((j % 3) * 2, (j / 3) * 2));
@@ -1405,7 +1405,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
for (int i = 0; i < atlas_slices * (p_bake_sh ? 4 : 1); i++) {
Vector<uint8_t> s = rd->texture_get_data(light_accum_tex, i);
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create(atlas_size.width, atlas_size.height, false, Image::FORMAT_RGBAH, s);
Ref<Image> denoised = denoiser->denoise_image(img);
@@ -1432,7 +1432,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
for (int i = 0; i < atlas_slices * (p_bake_sh ? 4 : 1); i++) {
Vector<uint8_t> s = rd->texture_get_data(light_accum_tex, i);
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create(atlas_size.width, atlas_size.height, false, Image::FORMAT_RGBAH, s);
img->save_exr("res://4_light_secondary_" + itos(i) + ".exr", false);
}
@@ -1484,7 +1484,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
for (int i = 0; i < atlas_slices * (p_bake_sh ? 4 : 1); i++) {
Vector<uint8_t> s = rd->texture_get_data(light_accum_tex, i);
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create(atlas_size.width, atlas_size.height, false, Image::FORMAT_RGBAH, s);
img->convert(Image::FORMAT_RGBA8);
img->save_png("res://5_dilated_" + itos(i) + ".png");
@@ -1494,7 +1494,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
/* BLEND SEAMS */
//shaders
Ref<RDShaderFile> blendseams_shader;
- blendseams_shader.instance();
+ blendseams_shader.instantiate();
err = blendseams_shader->parse_versions_from_text(lm_blendseams_shader_glsl);
if (err != OK) {
FREE_TEXTURES
@@ -1641,7 +1641,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
for (int i = 0; i < atlas_slices * (p_bake_sh ? 4 : 1); i++) {
Vector<uint8_t> s = rd->texture_get_data(light_accum_tex, i);
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create(atlas_size.width, atlas_size.height, false, Image::FORMAT_RGBAH, s);
img->save_exr("res://5_blendseams" + itos(i) + ".exr", false);
}
@@ -1653,7 +1653,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
for (int i = 0; i < atlas_slices * (p_bake_sh ? 4 : 1); i++) {
Vector<uint8_t> s = rd->texture_get_data(light_accum_tex, i);
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create(atlas_size.width, atlas_size.height, false, Image::FORMAT_RGBAH, s);
img->convert(Image::FORMAT_RGBH); //remove alpha
bake_textures.push_back(img);
@@ -1668,7 +1668,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
#ifdef DEBUG_TEXTURES
{
Ref<Image> img2;
- img2.instance();
+ img2.instantiate();
img2->create(probe_values.size(), 1, false, Image::FORMAT_RGBAF, probe_data);
img2->save_exr("res://6_lightprobes.exr", false);
}
diff --git a/modules/mbedtls/crypto_mbedtls.cpp b/modules/mbedtls/crypto_mbedtls.cpp
index 3cd2da3d85..774da5a324 100644
--- a/modules/mbedtls/crypto_mbedtls.cpp
+++ b/modules/mbedtls/crypto_mbedtls.cpp
@@ -324,7 +324,7 @@ void CryptoMbedTLS::load_default_certificates(String p_path) {
Ref<CryptoKey> CryptoMbedTLS::generate_rsa(int p_bytes) {
Ref<CryptoKeyMbedTLS> out;
- out.instance();
+ out.instantiate();
int ret = mbedtls_pk_setup(&(out->pkey), mbedtls_pk_info_from_type(MBEDTLS_PK_RSA));
ERR_FAIL_COND_V(ret != 0, nullptr);
ret = mbedtls_rsa_gen_key(mbedtls_pk_rsa(out->pkey), mbedtls_ctr_drbg_random, &ctr_drbg, p_bytes, 65537);
@@ -366,7 +366,7 @@ Ref<X509Certificate> CryptoMbedTLS::generate_self_signed_certificate(Ref<CryptoK
buf[4095] = '\0'; // Make sure strlen can't fail.
Ref<X509CertificateMbedTLS> out;
- out.instance();
+ out.instantiate();
out->load_from_memory(buf, strlen((char *)buf) + 1); // Use strlen to find correct output size.
return out;
}
diff --git a/modules/mbedtls/dtls_server_mbedtls.cpp b/modules/mbedtls/dtls_server_mbedtls.cpp
index 5d895d8579..b1b6b3844b 100644
--- a/modules/mbedtls/dtls_server_mbedtls.cpp
+++ b/modules/mbedtls/dtls_server_mbedtls.cpp
@@ -45,7 +45,7 @@ void DTLSServerMbedTLS::stop() {
Ref<PacketPeerDTLS> DTLSServerMbedTLS::take_connection(Ref<PacketPeerUDP> p_udp_peer) {
Ref<PacketPeerMbedDTLS> out;
- out.instance();
+ out.instantiate();
ERR_FAIL_COND_V(!out.is_valid(), out);
ERR_FAIL_COND_V(!p_udp_peer.is_valid(), out);
@@ -68,7 +68,7 @@ void DTLSServerMbedTLS::finalize() {
}
DTLSServerMbedTLS::DTLSServerMbedTLS() {
- _cookies.instance();
+ _cookies.instantiate();
}
DTLSServerMbedTLS::~DTLSServerMbedTLS() {
diff --git a/modules/mbedtls/packet_peer_mbed_dtls.cpp b/modules/mbedtls/packet_peer_mbed_dtls.cpp
index 11c9f64e21..114bf49e9e 100644
--- a/modules/mbedtls/packet_peer_mbed_dtls.cpp
+++ b/modules/mbedtls/packet_peer_mbed_dtls.cpp
@@ -245,7 +245,7 @@ int PacketPeerMbedDTLS::get_max_packet_size() const {
}
PacketPeerMbedDTLS::PacketPeerMbedDTLS() {
- ssl_ctx.instance();
+ ssl_ctx.instantiate();
}
PacketPeerMbedDTLS::~PacketPeerMbedDTLS() {
diff --git a/modules/mbedtls/stream_peer_mbedtls.cpp b/modules/mbedtls/stream_peer_mbedtls.cpp
index bc72b04fa4..5727f5f82f 100644
--- a/modules/mbedtls/stream_peer_mbedtls.cpp
+++ b/modules/mbedtls/stream_peer_mbedtls.cpp
@@ -273,7 +273,7 @@ int StreamPeerMbedTLS::get_available_bytes() const {
}
StreamPeerMbedTLS::StreamPeerMbedTLS() {
- ssl_ctx.instance();
+ ssl_ctx.instantiate();
}
StreamPeerMbedTLS::~StreamPeerMbedTLS() {
diff --git a/modules/minimp3/audio_stream_mp3.cpp b/modules/minimp3/audio_stream_mp3.cpp
index 600bbe9bb5..2cc974322d 100644
--- a/modules/minimp3/audio_stream_mp3.cpp
+++ b/modules/minimp3/audio_stream_mp3.cpp
@@ -126,7 +126,7 @@ Ref<AudioStreamPlayback> AudioStreamMP3::instance_playback() {
"to it. AudioStreamMP3 should not be created from the "
"inspector or with `.new()`. Instead, load an audio file.");
- mp3s.instance();
+ mp3s.instantiate();
mp3s->mp3_stream = Ref<AudioStreamMP3>(this);
mp3s->mp3d = (mp3dec_ex_t *)memalloc(sizeof(mp3dec_ex_t));
diff --git a/modules/minimp3/doc_classes/AudioStreamMP3.xml b/modules/minimp3/doc_classes/AudioStreamMP3.xml
index 92e777ca0f..5507329a18 100644
--- a/modules/minimp3/doc_classes/AudioStreamMP3.xml
+++ b/modules/minimp3/doc_classes/AudioStreamMP3.xml
@@ -11,7 +11,7 @@
<methods>
</methods>
<members>
- <member name="data" type="PackedByteArray" setter="set_data" getter="get_data" default="PackedByteArray( )">
+ <member name="data" type="PackedByteArray" setter="set_data" getter="get_data" default="PackedByteArray()">
Contains the audio data in bytes.
</member>
<member name="loop" type="bool" setter="set_loop" getter="has_loop" default="false">
diff --git a/modules/minimp3/register_types.cpp b/modules/minimp3/register_types.cpp
index 4ab4c743d6..27ea512b69 100644
--- a/modules/minimp3/register_types.cpp
+++ b/modules/minimp3/register_types.cpp
@@ -41,7 +41,7 @@ void register_minimp3_types() {
#ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint()) {
Ref<ResourceImporterMP3> mp3_import;
- mp3_import.instance();
+ mp3_import.instantiate();
ResourceFormatImporter::get_singleton()->add_importer(mp3_import);
}
#endif
diff --git a/modules/minimp3/resource_importer_mp3.cpp b/modules/minimp3/resource_importer_mp3.cpp
index dc16125726..dc360c12ba 100644
--- a/modules/minimp3/resource_importer_mp3.cpp
+++ b/modules/minimp3/resource_importer_mp3.cpp
@@ -90,7 +90,7 @@ Error ResourceImporterMP3::import(const String &p_source_file, const String &p_s
memdelete(f);
Ref<AudioStreamMP3> mp3_stream;
- mp3_stream.instance();
+ mp3_stream.instantiate();
mp3_stream->set_data(data);
ERR_FAIL_COND_V(!mp3_stream->get_data().size(), ERR_FILE_CORRUPT);
diff --git a/modules/mobile_vr/register_types.cpp b/modules/mobile_vr/register_types.cpp
index e7d33ba8a7..7d138aa4c9 100644
--- a/modules/mobile_vr/register_types.cpp
+++ b/modules/mobile_vr/register_types.cpp
@@ -37,7 +37,7 @@ void register_mobile_vr_types() {
if (XRServer::get_singleton()) {
Ref<MobileVRInterface> mobile_vr;
- mobile_vr.instance();
+ mobile_vr.instantiate();
XRServer::get_singleton()->add_interface(mobile_vr);
}
}
diff --git a/modules/mono/class_db_api_json.cpp b/modules/mono/class_db_api_json.cpp
index bd02ec0eac..25193a1352 100644
--- a/modules/mono/class_db_api_json.cpp
+++ b/modules/mono/class_db_api_json.cpp
@@ -240,7 +240,8 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) {
FileAccessRef f = FileAccess::open(p_output_file, FileAccess::WRITE);
ERR_FAIL_COND_MSG(!f, "Cannot open file '" + p_output_file + "'.");
- f->store_string(JSON::print(classes_dict, /*indent: */ "\t"));
+ JSON json;
+ f->store_string(json.stringify(classes_dict, "\t"));
f->close();
print_line(String() + "ClassDB API JSON written to: " + ProjectSettings::get_singleton()->globalize_path(p_output_file));
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index 576256b6ec..c48230f524 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -38,7 +38,6 @@
#include "core/debugger/engine_debugger.h"
#include "core/debugger/script_debugger.h"
#include "core/io/file_access.h"
-#include "core/io/json.h"
#include "core/os/mutex.h"
#include "core/os/os.h"
#include "core/os/thread.h"
@@ -376,7 +375,7 @@ Ref<Script> CSharpLanguage::get_template(const String &p_class_name, const Strin
.replace("%CLASS%", class_name_no_spaces);
Ref<CSharpScript> script;
- script.instance();
+ script.instantiate();
script->set_source_code(script_template);
script->set_name(class_name_no_spaces);
@@ -3050,7 +3049,7 @@ void CSharpScript::update_script_class_info(Ref<CSharpScript> p_script) {
p_script->load_script_signals(p_script->script_class, p_script->native);
}
-bool CSharpScript::can_instance() const {
+bool CSharpScript::can_instantiate() const {
#ifdef TOOLS_ENABLED
bool extra_cond = tool || ScriptServer::is_scripting_enabled();
#else
@@ -3183,7 +3182,7 @@ Variant CSharpScript::_new(const Variant **p_args, int p_argcount, Callable::Cal
GD_MONO_SCOPE_THREAD_ATTACH;
- Object *owner = ClassDB::instance(NATIVE_GDMONOCLASS_NAME(native));
+ Object *owner = ClassDB::instantiate(NATIVE_GDMONOCLASS_NAME(native));
REF ref;
RefCounted *r = Object::cast_to<RefCounted>(owner);
@@ -3217,10 +3216,10 @@ ScriptInstance *CSharpScript::instance_create(Object *p_this) {
if (EngineDebugger::is_active()) {
CSharpLanguage::get_singleton()->debug_break_parse(get_path(), 0,
"Script inherits from native type '" + String(native_name) +
- "', so it can't be instanced in object of type: '" + p_this->get_class() + "'");
+ "', so it can't be instantiated in object of type: '" + p_this->get_class() + "'");
}
ERR_FAIL_V_MSG(nullptr, "Script inherits from native type '" + String(native_name) +
- "', so it can't be instanced in object of type: '" + p_this->get_class() + "'.");
+ "', so it can't be instantiated in object of type: '" + p_this->get_class() + "'.");
}
}
diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.h
index 965e882c5b..da6b60aee2 100644
--- a/modules/mono/csharp_script.h
+++ b/modules/mono/csharp_script.h
@@ -191,7 +191,7 @@ protected:
void _get_property_list(List<PropertyInfo> *p_properties) const;
public:
- bool can_instance() const override;
+ bool can_instantiate() const override;
StringName get_instance_base_type() const override;
ScriptInstance *instance_create(Object *p_this) override;
PlaceHolderScriptInstance *placeholder_instance_create(Object *p_this) override;
@@ -455,9 +455,8 @@ public:
Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const override;
bool is_using_templates() override;
void make_template(const String &p_class_name, const String &p_base_class_name, Ref<Script> &p_script) override;
- /* TODO */ bool validate(const String &p_script, int &r_line_error, int &r_col_error,
- String &r_test_error, const String &p_path, List<String> *r_functions,
- List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const override {
+ /* TODO */ bool validate(const String &p_script, const String &p_path, List<String> *r_functions,
+ List<ScriptLanguage::ScriptError> *r_errors = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const override {
return true;
}
String validate_path(const String &p_path) const override;
diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp
index 7e944ed4a5..620b031ddb 100644
--- a/modules/mono/editor/bindings_generator.cpp
+++ b/modules/mono/editor/bindings_generator.cpp
@@ -3058,17 +3058,17 @@ bool BindingsGenerator::_arg_default_value_from_variant(const Variant &p_val, Ar
} break;
case Variant::AABB: {
AABB aabb = p_val.operator ::AABB();
- r_iarg.default_argument = "new AABB(new Vector3" + aabb.position.operator String() + ", new Vector3" + aabb.position.operator String() + ")";
+ r_iarg.default_argument = "new AABB(new Vector3" + aabb.position.operator String() + ", new Vector3" + aabb.size.operator String() + ")";
r_iarg.def_param_mode = ArgumentInterface::NULLABLE_VAL;
} break;
case Variant::RECT2: {
Rect2 rect = p_val.operator Rect2();
- r_iarg.default_argument = "new Rect2(new Vector2" + rect.position.operator String() + ", new Vector2" + rect.position.operator String() + ")";
+ r_iarg.default_argument = "new Rect2(new Vector2" + rect.position.operator String() + ", new Vector2" + rect.size.operator String() + ")";
r_iarg.def_param_mode = ArgumentInterface::NULLABLE_VAL;
} break;
case Variant::RECT2I: {
Rect2i rect = p_val.operator Rect2i();
- r_iarg.default_argument = "new Rect2i(new Vector2i" + rect.position.operator String() + ", new Vector2i" + rect.position.operator String() + ")";
+ r_iarg.default_argument = "new Rect2i(new Vector2i" + rect.position.operator String() + ", new Vector2i" + rect.size.operator String() + ")";
r_iarg.def_param_mode = ArgumentInterface::NULLABLE_VAL;
} break;
case Variant::COLOR:
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/PackedSceneExtensions.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/PackedSceneExtensions.cs
index 763f470504..214bbf5179 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/PackedSceneExtensions.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/PackedSceneExtensions.cs
@@ -8,9 +8,9 @@ namespace Godot
/// `Node.NotificationInstanced` notification on the root node.
/// </summary>
/// <typeparam name="T">The type to cast to. Should be a descendant of Node.</typeparam>
- public T Instance<T>(PackedScene.GenEditState editState = (PackedScene.GenEditState)0) where T : class
+ public T Instantiate<T>(PackedScene.GenEditState editState = (PackedScene.GenEditState)0) where T : class
{
- return (T)(object)Instance(editState);
+ return (T)(object)Instantiate(editState);
}
/// <summary>
@@ -19,9 +19,9 @@ namespace Godot
/// `Node.NotificationInstanced` notification on the root node.
/// </summary>
/// <typeparam name="T">The type to cast to. Should be a descendant of Node.</typeparam>
- public T InstanceOrNull<T>(PackedScene.GenEditState editState = (PackedScene.GenEditState)0) where T : class
+ public T InstantiateOrNull<T>(PackedScene.GenEditState editState = (PackedScene.GenEditState)0) where T : class
{
- return Instance(editState) as T;
+ return Instantiate(editState) as T;
}
}
}
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs
index b087b4c200..817103994a 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs
@@ -114,6 +114,23 @@ namespace Godot
}
/// <summary>
+ /// Returns the angle between this quaternion and `to`.
+ /// This is the magnitude of the angle you would need to rotate
+ /// by to get from one to the other.
+ ///
+ /// Note: This method has an abnormally high amount
+ /// of floating-point error, so methods such as
+ /// <see cref="Mathf.IsZeroApprox"/> will not work reliably.
+ /// </summary>
+ /// <param name="to">The other quaternion.</param>
+ /// <returns>The angle between the quaternions.</returns>
+ public real_t AngleTo(Quaternion to)
+ {
+ real_t dot = Dot(to);
+ return Mathf.Acos(Mathf.Clamp(dot * dot * 2 - 1, -1, 1));
+ }
+
+ /// <summary>
/// Performs a cubic spherical interpolation between quaternions `preA`,
/// this vector, `b`, and `postB`, by the given amount `t`.
/// </summary>
diff --git a/modules/mono/glue/base_object_glue.cpp b/modules/mono/glue/base_object_glue.cpp
index 2b6d2761ca..2b87c2d9a4 100644
--- a/modules/mono/glue/base_object_glue.cpp
+++ b/modules/mono/glue/base_object_glue.cpp
@@ -153,10 +153,10 @@ MonoObject *godot_icall_Object_weakref(Object *p_ptr) {
return nullptr;
}
- wref.instance();
+ wref.instantiate();
wref->set_ref(r);
} else {
- wref.instance();
+ wref.instantiate();
wref->set_obj(p_ptr);
}
diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp
index a3acfbd995..02d875f669 100644
--- a/modules/mono/mono_gd/gd_mono.cpp
+++ b/modules/mono/mono_gd/gd_mono.cpp
@@ -691,7 +691,7 @@ static bool try_get_cached_api_hash_for(const String &p_api_assemblies_dir, bool
}
Ref<ConfigFile> cfg;
- cfg.instance();
+ cfg.instantiate();
Error cfg_err = cfg->load(cached_api_hash_path);
ERR_FAIL_COND_V(cfg_err != OK, false);
@@ -717,7 +717,7 @@ static void create_cached_api_hash_for(const String &p_api_assemblies_dir) {
String cached_api_hash_path = p_api_assemblies_dir.plus_file("api_hash_cache.cfg");
Ref<ConfigFile> cfg;
- cfg.instance();
+ cfg.instantiate();
cfg->set_value("core", "modified_time", FileAccess::get_modified_time(core_api_assembly_path));
cfg->set_value("editor", "modified_time", FileAccess::get_modified_time(editor_api_assembly_path));
diff --git a/modules/mono/mono_gd/gd_mono_utils.cpp b/modules/mono/mono_gd/gd_mono_utils.cpp
index df45cb8e92..0b9a577e01 100644
--- a/modules/mono/mono_gd/gd_mono_utils.cpp
+++ b/modules/mono/mono_gd/gd_mono_utils.cpp
@@ -238,7 +238,7 @@ GDMonoClass *get_class_native_base(GDMonoClass *p_class) {
MonoObject *create_managed_for_godot_object(GDMonoClass *p_class, const StringName &p_native, Object *p_object) {
bool parent_is_object_class = ClassDB::is_parent_class(p_object->get_class_name(), p_native);
ERR_FAIL_COND_V_MSG(!parent_is_object_class, nullptr,
- "Type inherits from native type '" + p_native + "', so it can't be instanced in object of type: '" + p_object->get_class() + "'.");
+ "Type inherits from native type '" + p_native + "', so it can't be instantiated in object of type: '" + p_object->get_class() + "'.");
MonoObject *mono_object = mono_object_new(mono_domain_get(), p_class->get_mono_ptr());
ERR_FAIL_NULL_V(mono_object, nullptr);
diff --git a/modules/mono/register_types.cpp b/modules/mono/register_types.cpp
index 80eb47bfd4..b4a6bfdcd4 100644
--- a/modules/mono/register_types.cpp
+++ b/modules/mono/register_types.cpp
@@ -52,10 +52,10 @@ void register_mono_types() {
script_language_cs->set_language_index(ScriptServer::get_language_count());
ScriptServer::register_language(script_language_cs);
- resource_loader_cs.instance();
+ resource_loader_cs.instantiate();
ResourceLoader::add_resource_format_loader(resource_loader_cs);
- resource_saver_cs.instance();
+ resource_saver_cs.instantiate();
ResourceSaver::add_resource_format_saver(resource_saver_cs);
}
diff --git a/modules/opensimplex/doc_classes/NoiseTexture.xml b/modules/opensimplex/doc_classes/NoiseTexture.xml
index a12412a9cd..2ae7f8cad9 100644
--- a/modules/opensimplex/doc_classes/NoiseTexture.xml
+++ b/modules/opensimplex/doc_classes/NoiseTexture.xml
@@ -31,7 +31,7 @@
<member name="noise" type="OpenSimplexNoise" setter="set_noise" getter="get_noise">
The [OpenSimplexNoise] instance used to generate the noise.
</member>
- <member name="noise_offset" type="Vector2" setter="set_noise_offset" getter="get_noise_offset" default="Vector2( 0, 0 )">
+ <member name="noise_offset" type="Vector2" setter="set_noise_offset" getter="get_noise_offset" default="Vector2(0, 0)">
An offset used to specify the noise space coordinate of the top left corner of the generated noise. This value is ignored if [member seamless] is enabled.
</member>
<member name="seamless" type="bool" setter="set_seamless" getter="get_seamless" default="false">
diff --git a/modules/opensimplex/doc_classes/OpenSimplexNoise.xml b/modules/opensimplex/doc_classes/OpenSimplexNoise.xml
index 2fdbd61ee7..4d45e41cc3 100644
--- a/modules/opensimplex/doc_classes/OpenSimplexNoise.xml
+++ b/modules/opensimplex/doc_classes/OpenSimplexNoise.xml
@@ -31,7 +31,7 @@
</argument>
<argument index="1" name="height" type="int">
</argument>
- <argument index="2" name="noise_offset" type="Vector2" default="Vector2( 0, 0 )">
+ <argument index="2" name="noise_offset" type="Vector2" default="Vector2(0, 0)">
</argument>
<description>
Generate a noise image in [constant Image.FORMAT_L8] format with the requested [code]width[/code] and [code]height[/code], based on the current noise parameters. If [code]noise_offset[/code] is specified, then the offset value is used as the coordinates of the top-left corner of the generated noise.
diff --git a/modules/opensimplex/noise_texture.cpp b/modules/opensimplex/noise_texture.cpp
index 9e0155da94..66c52ffbf9 100644
--- a/modules/opensimplex/noise_texture.cpp
+++ b/modules/opensimplex/noise_texture.cpp
@@ -187,6 +187,7 @@ Ref<OpenSimplexNoise> NoiseTexture::get_noise() {
}
void NoiseTexture::set_width(int p_width) {
+ ERR_FAIL_COND(p_width <= 0);
if (p_width == size.x) {
return;
}
@@ -195,6 +196,7 @@ void NoiseTexture::set_width(int p_width) {
}
void NoiseTexture::set_height(int p_height) {
+ ERR_FAIL_COND(p_height <= 0);
if (p_height == size.y) {
return;
}
diff --git a/modules/pvr/image_compress_pvrtc.cpp b/modules/pvr/image_compress_pvrtc.cpp
index 4d0430fa92..f33912cec0 100644
--- a/modules/pvr/image_compress_pvrtc.cpp
+++ b/modules/pvr/image_compress_pvrtc.cpp
@@ -52,7 +52,7 @@ static void _compress_pvrtc1_4bpp(Image *p_img) {
bool use_alpha = img->detect_alpha();
Ref<Image> new_img;
- new_img.instance();
+ new_img.instantiate();
new_img->create(img->get_width(), img->get_height(), img->has_mipmaps(), use_alpha ? Image::FORMAT_PVRTC1_4A : Image::FORMAT_PVRTC1_4);
Vector<uint8_t> data = new_img->get_data();
diff --git a/modules/pvr/register_types.cpp b/modules/pvr/register_types.cpp
index aeac564c93..ef72087d25 100644
--- a/modules/pvr/register_types.cpp
+++ b/modules/pvr/register_types.cpp
@@ -36,7 +36,7 @@
static Ref<ResourceFormatPVR> resource_loader_pvr;
void register_pvr_types() {
- resource_loader_pvr.instance();
+ resource_loader_pvr.instantiate();
ResourceLoader::add_resource_format_loader(resource_loader_pvr);
_register_pvrtc_compress_func();
diff --git a/modules/regex/doc_classes/RegExMatch.xml b/modules/regex/doc_classes/RegExMatch.xml
index cfe00f83ee..492519d3d9 100644
--- a/modules/regex/doc_classes/RegExMatch.xml
+++ b/modules/regex/doc_classes/RegExMatch.xml
@@ -51,7 +51,7 @@
<member name="names" type="Dictionary" setter="" getter="get_names" default="{}">
A dictionary of named groups and its corresponding group number. Only groups that were matched are included. If multiple groups have the same name, that name would refer to the first matching one.
</member>
- <member name="strings" type="Array" setter="" getter="get_strings" default="[ ]">
+ <member name="strings" type="Array" setter="" getter="get_strings" default="[]">
An [Array] of the match and its capturing groups.
</member>
<member name="subject" type="String" setter="" getter="get_subject" default="&quot;&quot;">
diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
index 78b4749939..768b419348 100644
--- a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
+++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
@@ -129,7 +129,7 @@ Ref<AudioStreamPlayback> AudioStreamOGGVorbis::instance_playback() {
"to it. AudioStreamOGGVorbis should not be created from the "
"inspector or with `.new()`. Instead, load an audio file.");
- ovs.instance();
+ ovs.instantiate();
ovs->vorbis_stream = Ref<AudioStreamOGGVorbis>(this);
ovs->ogg_alloc.alloc_buffer = (char *)memalloc(decode_mem_size);
ovs->ogg_alloc.alloc_buffer_length_in_bytes = decode_mem_size;
diff --git a/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml b/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml
index 8a1bb62e24..94fdff5d43 100644
--- a/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml
+++ b/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml
@@ -11,7 +11,7 @@
<methods>
</methods>
<members>
- <member name="data" type="PackedByteArray" setter="set_data" getter="get_data" default="PackedByteArray( )">
+ <member name="data" type="PackedByteArray" setter="set_data" getter="get_data" default="PackedByteArray()">
Contains the audio data in bytes.
</member>
<member name="loop" type="bool" setter="set_loop" getter="has_loop" default="false">
diff --git a/modules/stb_vorbis/register_types.cpp b/modules/stb_vorbis/register_types.cpp
index 6f7eb53bc8..d9c6c06d65 100644
--- a/modules/stb_vorbis/register_types.cpp
+++ b/modules/stb_vorbis/register_types.cpp
@@ -41,7 +41,7 @@ void register_stb_vorbis_types() {
#ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint()) {
Ref<ResourceImporterOGGVorbis> ogg_import;
- ogg_import.instance();
+ ogg_import.instantiate();
ResourceFormatImporter::get_singleton()->add_importer(ogg_import);
}
#endif
diff --git a/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp b/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp
index a0de5e5f0f..85de698efd 100644
--- a/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp
+++ b/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp
@@ -90,7 +90,7 @@ Error ResourceImporterOGGVorbis::import(const String &p_source_file, const Strin
memdelete(f);
Ref<AudioStreamOGGVorbis> ogg_stream;
- ogg_stream.instance();
+ ogg_stream.instantiate();
ogg_stream->set_data(data);
ERR_FAIL_COND_V(!ogg_stream->get_data().size(), ERR_FILE_CORRUPT);
diff --git a/modules/text_server_adv/dynamic_font_adv.cpp b/modules/text_server_adv/dynamic_font_adv.cpp
index c29aac05bb..62eedebb59 100644
--- a/modules/text_server_adv/dynamic_font_adv.cpp
+++ b/modules/text_server_adv/dynamic_font_adv.cpp
@@ -420,7 +420,7 @@ DynamicFontDataAdvanced::Character DynamicFontDataAdvanced::bitmap_to_character(
Ref<Image> img = memnew(Image(tex.texture_size, tex.texture_size, 0, require_format, tex.imgdata));
if (tex.texture.is_null()) {
- tex.texture.instance();
+ tex.texture.instantiate();
tex.texture->create_from_image(img);
} else {
tex.texture->update(img); //update
diff --git a/modules/text_server_fb/dynamic_font_fb.cpp b/modules/text_server_fb/dynamic_font_fb.cpp
index a261ba8f37..7e77987074 100644
--- a/modules/text_server_fb/dynamic_font_fb.cpp
+++ b/modules/text_server_fb/dynamic_font_fb.cpp
@@ -306,7 +306,7 @@ DynamicFontDataFallback::Character DynamicFontDataFallback::bitmap_to_character(
Ref<Image> img = memnew(Image(tex.texture_size, tex.texture_size, 0, require_format, tex.imgdata));
if (tex.texture.is_null()) {
- tex.texture.instance();
+ tex.texture.instantiate();
tex.texture->create_from_image(img);
} else {
tex.texture->update(img); //update
diff --git a/modules/tga/image_loader_tga.cpp b/modules/tga/image_loader_tga.cpp
index 6eaa2d24a8..f0d7c335bd 100644
--- a/modules/tga/image_loader_tga.cpp
+++ b/modules/tga/image_loader_tga.cpp
@@ -343,7 +343,7 @@ static Ref<Image> _tga_mem_loader_func(const uint8_t *p_tga, int p_size) {
Error open_memfile_error = memfile.open_custom(p_tga, p_size);
ERR_FAIL_COND_V_MSG(open_memfile_error, Ref<Image>(), "Could not create memfile for TGA image buffer.");
Ref<Image> img;
- img.instance();
+ img.instantiate();
Error load_error = ImageLoaderTGA().load_image(img, &memfile, false, 1.0f);
ERR_FAIL_COND_V_MSG(load_error, Ref<Image>(), "Failed to load TGA image.");
return img;
diff --git a/modules/theora/register_types.cpp b/modules/theora/register_types.cpp
index 0218b8c7a4..fd6c9dcd3c 100644
--- a/modules/theora/register_types.cpp
+++ b/modules/theora/register_types.cpp
@@ -35,7 +35,7 @@
static Ref<ResourceFormatLoaderTheora> resource_loader_theora;
void register_theora_types() {
- resource_loader_theora.instance();
+ resource_loader_theora.instantiate();
ResourceLoader::add_resource_format_loader(resource_loader_theora, true);
ClassDB::register_class<VideoStreamTheora>();
diff --git a/modules/theora/video_stream_theora.cpp b/modules/theora/video_stream_theora.cpp
index 4400445f30..40be067a91 100644
--- a/modules/theora/video_stream_theora.cpp
+++ b/modules/theora/video_stream_theora.cpp
@@ -335,7 +335,7 @@ void VideoStreamPlaybackTheora::set_file(const String &p_file) {
size.y = h;
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create(w, h, false, Image::FORMAT_RGBA8);
} else {
diff --git a/modules/upnp/upnp.cpp b/modules/upnp/upnp.cpp
index 8e4e833d45..efe618012a 100644
--- a/modules/upnp/upnp.cpp
+++ b/modules/upnp/upnp.cpp
@@ -92,7 +92,7 @@ int UPNP::discover(int timeout, int ttl, const String &device_filter) {
void UPNP::add_device_to_list(UPNPDev *dev, UPNPDev *devlist) {
Ref<UPNPDevice> new_device;
- new_device.instance();
+ new_device.instantiate();
new_device->set_description_url(dev->descURL);
new_device->set_service_type(dev->st);
diff --git a/modules/visual_script/doc_classes/VisualScript.xml b/modules/visual_script/doc_classes/VisualScript.xml
index 0798375a96..9d51bd86a2 100644
--- a/modules/visual_script/doc_classes/VisualScript.xml
+++ b/modules/visual_script/doc_classes/VisualScript.xml
@@ -39,7 +39,7 @@
</argument>
<argument index="1" name="node" type="VisualScriptNode">
</argument>
- <argument index="2" name="position" type="Vector2" default="Vector2( 0, 0 )">
+ <argument index="2" name="position" type="Vector2" default="Vector2(0, 0)">
</argument>
<description>
Add a node to the VisualScript.
diff --git a/modules/visual_script/doc_classes/VisualScriptComment.xml b/modules/visual_script/doc_classes/VisualScriptComment.xml
index 243338ea52..02cec97b27 100644
--- a/modules/visual_script/doc_classes/VisualScriptComment.xml
+++ b/modules/visual_script/doc_classes/VisualScriptComment.xml
@@ -15,7 +15,7 @@
<member name="description" type="String" setter="set_description" getter="get_description" default="&quot;&quot;">
The text inside the comment node.
</member>
- <member name="size" type="Vector2" setter="set_size" getter="get_size" default="Vector2( 150, 150 )">
+ <member name="size" type="Vector2" setter="set_size" getter="get_size" default="Vector2(150, 150)">
The comment node's size (in pixels).
</member>
<member name="title" type="String" setter="set_title" getter="get_title" default="&quot;Comment&quot;">
diff --git a/modules/visual_script/doc_classes/VisualScriptFunctionState.xml b/modules/visual_script/doc_classes/VisualScriptFunctionState.xml
index 9ed71bf10e..16c1629fe4 100644
--- a/modules/visual_script/doc_classes/VisualScriptFunctionState.xml
+++ b/modules/visual_script/doc_classes/VisualScriptFunctionState.xml
@@ -28,7 +28,7 @@
<method name="resume">
<return type="Variant">
</return>
- <argument index="0" name="args" type="Array" default="[ ]">
+ <argument index="0" name="args" type="Array" default="[]">
</argument>
<description>
</description>
diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp
index 7badb1b717..d49060bea8 100644
--- a/modules/visual_script/visual_script.cpp
+++ b/modules/visual_script/visual_script.cpp
@@ -725,7 +725,7 @@ int VisualScript::get_available_id() const {
/////////////////////////////////
-bool VisualScript::can_instance() const {
+bool VisualScript::can_instantiate() const {
return true; // ScriptServer::is_scripting_enabled();
}
@@ -1958,7 +1958,7 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o
for (const Set<int>::Element *F = node_ids.front(); F; F = F->next()) {
Ref<VisualScriptNode> node = script->nodes[F->get()].node;
- VisualScriptNodeInstance *instance = node->instance(this); // Create instance.
+ VisualScriptNodeInstance *instance = node->instantiate(this); // Create instance.
ERR_FAIL_COND(!instance);
instance->base = node.ptr();
@@ -2262,7 +2262,7 @@ void VisualScriptLanguage::get_string_delimiters(List<String> *p_delimiters) con
Ref<Script> VisualScriptLanguage::get_template(const String &p_class_name, const String &p_base_class_name) const {
Ref<VisualScript> script;
- script.instance();
+ script.instantiate();
script->set_instance_base_type(p_base_class_name);
return script;
}
@@ -2276,7 +2276,7 @@ void VisualScriptLanguage::make_template(const String &p_class_name, const Strin
script->set_instance_base_type(p_base_class_name);
}
-bool VisualScriptLanguage::validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_functions, List<ScriptLanguage::Warning> *r_warnings, Set<int> *r_safe_lines) const {
+bool VisualScriptLanguage::validate(const String &p_script, const String &p_path, List<String> *r_functions, List<ScriptLanguage::ScriptError> *r_errors, List<ScriptLanguage::Warning> *r_warnings, Set<int> *r_safe_lines) const {
return false;
}
diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h
index 438ec99a56..932ebeb27f 100644
--- a/modules/visual_script/visual_script.h
+++ b/modules/visual_script/visual_script.h
@@ -87,7 +87,7 @@ public:
void set_breakpoint(bool p_breakpoint);
bool is_breakpoint() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) = 0;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) = 0;
struct TypeGuess {
Variant::Type type = Variant::NIL;
@@ -325,7 +325,7 @@ public:
void set_instance_base_type(const StringName &p_type);
- virtual bool can_instance() const override;
+ virtual bool can_instantiate() const override;
virtual Ref<Script> get_base_script() const override;
virtual StringName get_instance_base_type() const override;
@@ -571,7 +571,7 @@ public:
virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const;
virtual bool is_using_templates();
virtual void make_template(const String &p_class_name, const String &p_base_class_name, Ref<Script> &p_script);
- virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const;
+ virtual bool validate(const String &p_script, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptLanguage::ScriptError> *r_errors = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const;
virtual Script *create_script() const;
virtual bool has_named_classes() const;
virtual bool supports_builtin_mode() const;
@@ -619,7 +619,7 @@ public:
template <class T>
static Ref<VisualScriptNode> create_node_generic(const String &p_name) {
Ref<T> node;
- node.instance();
+ node.instantiate();
return node;
}
diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp
index a3133f126d..f17ad62531 100644
--- a/modules/visual_script/visual_script_builtin_funcs.cpp
+++ b/modules/visual_script/visual_script_builtin_funcs.cpp
@@ -1187,7 +1187,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptBuiltinFunc::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptBuiltinFunc::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceBuiltinFunc *instance = memnew(VisualScriptNodeInstanceBuiltinFunc);
instance->node = this;
instance->instance = p_instance;
diff --git a/modules/visual_script/visual_script_builtin_funcs.h b/modules/visual_script/visual_script_builtin_funcs.h
index 1fafaf1d98..7196d4b46a 100644
--- a/modules/visual_script/visual_script_builtin_funcs.h
+++ b/modules/visual_script/visual_script_builtin_funcs.h
@@ -139,7 +139,7 @@ public:
void set_func(BuiltinFunc p_which);
BuiltinFunc get_func();
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptBuiltinFunc(VisualScriptBuiltinFunc::BuiltinFunc func);
VisualScriptBuiltinFunc();
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp
index 96f103f95a..69920a81b6 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -1300,10 +1300,10 @@ void VisualScriptEditor::_create_function_dialog() {
void VisualScriptEditor::_create_function() {
String name = _validate_name((func_name_box->get_text() == "") ? "new_func" : func_name_box->get_text());
selected = name;
- Vector2 ofs = _get_available_pos();
+ Vector2 pos = _get_available_pos();
Ref<VisualScriptFunction> func_node;
- func_node.instance();
+ func_node.instantiate();
func_node->set_name(name);
for (int i = 0; i < func_input_vbox->get_child_count(); i++) {
@@ -1322,7 +1322,7 @@ void VisualScriptEditor::_create_function() {
undo_redo->create_action(TTR("Add Function"));
undo_redo->add_do_method(script.ptr(), "add_function", name, func_node_id);
undo_redo->add_undo_method(script.ptr(), "remove_function", name);
- undo_redo->add_do_method(script.ptr(), "add_node", func_node_id, func_node, ofs);
+ undo_redo->add_do_method(script.ptr(), "add_node", func_node_id, func_node, pos);
undo_redo->add_undo_method(script.ptr(), "remove_node", func_node_id);
undo_redo->add_do_method(this, "_update_members");
undo_redo->add_undo_method(this, "_update_members");
@@ -1417,16 +1417,16 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt
} else if (p_button == 0) {
String name = _validate_name("new_function");
selected = name;
- Vector2 ofs = _get_available_pos();
+ Vector2 pos = _get_available_pos();
Ref<VisualScriptFunction> func_node;
- func_node.instance();
+ func_node.instantiate();
func_node->set_name(name);
int fn_id = script->get_available_id();
undo_redo->create_action(TTR("Add Function"));
undo_redo->add_do_method(script.ptr(), "add_function", name, fn_id);
- undo_redo->add_do_method(script.ptr(), "add_node", fn_id, func_node, ofs);
+ undo_redo->add_do_method(script.ptr(), "add_node", fn_id, func_node, pos);
undo_redo->add_undo_method(script.ptr(), "remove_function", name);
undo_redo->add_do_method(script.ptr(), "remove_node", fn_id);
undo_redo->add_do_method(this, "_update_members");
@@ -1621,17 +1621,19 @@ void VisualScriptEditor::_expression_text_changed(const String &p_text, int p_id
updating_graph = false;
}
-Vector2 VisualScriptEditor::_get_available_pos(bool centered, Vector2 ofs) const {
- if (centered) {
- ofs = graph->get_scroll_ofs() + graph->get_size() * 0.5;
- }
-
+Vector2 VisualScriptEditor::_get_pos_in_graph(Vector2 p_point) const {
+ Vector2 pos = (graph->get_scroll_ofs() + p_point) / (graph->get_zoom() * EDSCALE);
if (graph->is_using_snap()) {
int snap = graph->get_snap();
- ofs = ofs.snapped(Vector2(snap, snap));
+ pos = pos.snapped(Vector2(snap, snap));
}
+ return pos;
+}
- ofs /= EDSCALE;
+Vector2 VisualScriptEditor::_get_available_pos(bool p_centered, Vector2 p_pos) const {
+ if (p_centered) {
+ p_pos = _get_pos_in_graph(graph->get_size() * 0.5);
+ }
while (true) {
bool exists = false;
@@ -1639,8 +1641,8 @@ Vector2 VisualScriptEditor::_get_available_pos(bool centered, Vector2 ofs) const
script->get_node_list(&existing);
for (List<int>::Element *E = existing.front(); E; E = E->next()) {
Point2 pos = script->get_node_position(E->get());
- if (pos.distance_to(ofs) < 50) {
- ofs += Vector2(graph->get_snap(), graph->get_snap());
+ if (pos.distance_to(p_pos) < 50) {
+ p_pos += Vector2(graph->get_snap(), graph->get_snap());
exists = true;
break;
}
@@ -1651,7 +1653,7 @@ Vector2 VisualScriptEditor::_get_available_pos(bool centered, Vector2 ofs) const
break;
}
- return ofs;
+ return p_pos;
}
String VisualScriptEditor::_validate_name(const String &p_name) const {
@@ -2049,16 +2051,9 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
return;
}
- Vector2 ofs = graph->get_scroll_ofs() + p_point;
-
- if (graph->is_using_snap()) {
- int snap = graph->get_snap();
- ofs = ofs.snapped(Vector2(snap, snap));
- }
-
- ofs /= EDSCALE;
+ Vector2 pos = _get_pos_in_graph(p_point);
- int new_id = _create_new_node_from_name(d["node_type"], ofs);
+ int new_id = _create_new_node_from_name(d["node_type"], pos);
Node *node = graph->get_node(itos(new_id));
if (node) {
@@ -2073,23 +2068,17 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
#else
bool use_set = Input::get_singleton()->is_key_pressed(KEY_CTRL);
#endif
- Vector2 ofs = graph->get_scroll_ofs() + p_point;
- if (graph->is_using_snap()) {
- int snap = graph->get_snap();
- ofs = ofs.snapped(Vector2(snap, snap));
- }
-
- ofs /= EDSCALE;
+ Vector2 pos = _get_pos_in_graph(p_point);
Ref<VisualScriptNode> vnode;
if (use_set) {
Ref<VisualScriptVariableSet> vnodes;
- vnodes.instance();
+ vnodes.instantiate();
vnodes->set_variable(d["variable"]);
vnode = vnodes;
} else {
Ref<VisualScriptVariableGet> vnodeg;
- vnodeg.instance();
+ vnodeg.instantiate();
vnodeg->set_variable(d["variable"]);
vnode = vnodeg;
}
@@ -2097,7 +2086,7 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
int new_id = script->get_available_id();
undo_redo->create_action(TTR("Add Node"));
- undo_redo->add_do_method(script.ptr(), "add_node", new_id, vnode, ofs);
+ undo_redo->add_do_method(script.ptr(), "add_node", new_id, vnode, pos);
undo_redo->add_undo_method(script.ptr(), "remove_node", new_id);
undo_redo->add_do_method(this, "_update_graph");
undo_redo->add_undo_method(this, "_update_graph");
@@ -2111,22 +2100,16 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
if (String(d["type"]) == "visual_script_function_drag") {
- Vector2 ofs = graph->get_scroll_ofs() + p_point;
- if (graph->is_using_snap()) {
- int snap = graph->get_snap();
- ofs = ofs.snapped(Vector2(snap, snap));
- }
-
- ofs /= EDSCALE;
+ Vector2 pos = _get_pos_in_graph(p_point);
Ref<VisualScriptFunctionCall> vnode;
- vnode.instance();
+ vnode.instantiate();
vnode->set_call_mode(VisualScriptFunctionCall::CALL_MODE_SELF);
int new_id = script->get_available_id();
undo_redo->create_action(TTR("Add Node"));
- undo_redo->add_do_method(script.ptr(), "add_node", new_id, vnode, ofs);
+ undo_redo->add_do_method(script.ptr(), "add_node", new_id, vnode, pos);
undo_redo->add_do_method(vnode.ptr(), "set_base_type", script->get_instance_base_type());
undo_redo->add_do_method(vnode.ptr(), "set_function", d["function"]);
@@ -2143,22 +2126,16 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
if (String(d["type"]) == "visual_script_signal_drag") {
- Vector2 ofs = graph->get_scroll_ofs() + p_point;
- if (graph->is_using_snap()) {
- int snap = graph->get_snap();
- ofs = ofs.snapped(Vector2(snap, snap));
- }
-
- ofs /= EDSCALE;
+ Vector2 pos = _get_pos_in_graph(p_point);
Ref<VisualScriptEmitSignal> vnode;
- vnode.instance();
+ vnode.instantiate();
vnode->set_signal(d["signal"]);
int new_id = script->get_available_id();
undo_redo->create_action(TTR("Add Node"));
- undo_redo->add_do_method(script.ptr(), "add_node", new_id, vnode, ofs);
+ undo_redo->add_do_method(script.ptr(), "add_node", new_id, vnode, pos);
undo_redo->add_undo_method(script.ptr(), "remove_node", new_id);
undo_redo->add_do_method(this, "_update_graph");
undo_redo->add_undo_method(this, "_update_graph");
@@ -2172,22 +2149,16 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
if (String(d["type"]) == "resource") {
- Vector2 ofs = graph->get_scroll_ofs() + p_point;
- if (graph->is_using_snap()) {
- int snap = graph->get_snap();
- ofs = ofs.snapped(Vector2(snap, snap));
- }
-
- ofs /= EDSCALE;
+ Vector2 pos = _get_pos_in_graph(p_point);
Ref<VisualScriptPreload> prnode;
- prnode.instance();
+ prnode.instantiate();
prnode->set_preload(d["resource"]);
int new_id = script->get_available_id();
undo_redo->create_action(TTR("Add Preload Node"));
- undo_redo->add_do_method(script.ptr(), "add_node", new_id, prnode, ofs);
+ undo_redo->add_do_method(script.ptr(), "add_node", new_id, prnode, pos);
undo_redo->add_undo_method(script.ptr(), "remove_node", new_id);
undo_redo->add_do_method(this, "_update_graph");
undo_redo->add_undo_method(this, "_update_graph");
@@ -2201,13 +2172,7 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
if (String(d["type"]) == "files") {
- Vector2 ofs = graph->get_scroll_ofs() + p_point;
- if (graph->is_using_snap()) {
- int snap = graph->get_snap();
- ofs = ofs.snapped(Vector2(snap, snap));
- }
-
- ofs /= EDSCALE;
+ Vector2 pos = _get_pos_in_graph(p_point);
Array files = d["files"];
@@ -2224,14 +2189,14 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
Ref<VisualScriptPreload> prnode;
- prnode.instance();
+ prnode.instantiate();
prnode->set_preload(res);
- undo_redo->add_do_method(script.ptr(), "add_node", new_id, prnode, ofs);
+ undo_redo->add_do_method(script.ptr(), "add_node", new_id, prnode, pos);
undo_redo->add_undo_method(script.ptr(), "remove_node", new_id);
new_ids.push_back(new_id);
new_id++;
- ofs += Vector2(20, 20) * EDSCALE;
+ pos += Vector2(20, 20);
}
undo_redo->add_do_method(this, "_update_graph");
@@ -2264,13 +2229,7 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
Array nodes = d["nodes"];
- Vector2 ofs = graph->get_scroll_ofs() + p_point;
-
- if (graph->is_using_snap()) {
- int snap = graph->get_snap();
- ofs = ofs.snapped(Vector2(snap, snap));
- }
- ofs /= EDSCALE;
+ Vector2 pos = _get_pos_in_graph(p_point);
undo_redo->create_action(TTR("Add Node(s) From Tree"));
int base_id = script->get_available_id();
@@ -2290,13 +2249,13 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
if (use_node) {
Ref<VisualScriptSceneNode> scene_node;
- scene_node.instance();
+ scene_node.instantiate();
scene_node->set_node_path(sn->get_path_to(node));
n = scene_node;
} else {
// ! Doesn't work properly.
Ref<VisualScriptFunctionCall> call;
- call.instance();
+ call.instantiate();
call->set_call_mode(VisualScriptFunctionCall::CALL_MODE_NODE_PATH);
call->set_base_path(sn->get_path_to(node));
call->set_base_type(node->get_class());
@@ -2305,11 +2264,11 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
selecting_method_id = base_id;
}
- undo_redo->add_do_method(script.ptr(), "add_node", base_id, n, ofs);
+ undo_redo->add_do_method(script.ptr(), "add_node", base_id, n, pos);
undo_redo->add_undo_method(script.ptr(), "remove_node", base_id);
base_id++;
- ofs += Vector2(25, 25);
+ pos += Vector2(25, 25);
}
undo_redo->add_do_method(this, "_update_graph");
undo_redo->add_undo_method(this, "_update_graph");
@@ -2331,14 +2290,8 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
Node *node = Object::cast_to<Node>(obj);
- Vector2 ofs = graph->get_scroll_ofs() + p_point;
-
- if (graph->is_using_snap()) {
- int snap = graph->get_snap();
- ofs = ofs.snapped(Vector2(snap, snap));
- }
+ Vector2 pos = _get_pos_in_graph(p_point);
- ofs /= EDSCALE;
#ifdef OSX_ENABLED
bool use_get = Input::get_singleton()->is_key_pressed(KEY_META);
#else
@@ -2358,7 +2311,7 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
if (!use_get) {
Ref<VisualScriptPropertySet> pset;
- pset.instance();
+ pset.instantiate();
pset->set_call_mode(VisualScriptPropertySet::CALL_MODE_INSTANCE);
pset->set_base_type(obj->get_class());
/*if (use_value) {
@@ -2368,14 +2321,14 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
vnode = pset;
} else {
Ref<VisualScriptPropertyGet> pget;
- pget.instance();
+ pget.instantiate();
pget->set_call_mode(VisualScriptPropertyGet::CALL_MODE_INSTANCE);
pget->set_base_type(obj->get_class());
vnode = pget;
}
- undo_redo->add_do_method(script.ptr(), "add_node", base_id, vnode, ofs);
+ undo_redo->add_do_method(script.ptr(), "add_node", base_id, vnode, pos);
undo_redo->add_do_method(vnode.ptr(), "set_property", d["property"]);
if (!use_get) {
undo_redo->add_do_method(vnode.ptr(), "set_default_input_value", 0, d["value"]);
@@ -2400,7 +2353,7 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
if (!use_get) {
Ref<VisualScriptPropertySet> pset;
- pset.instance();
+ pset.instantiate();
if (sn == node) {
pset->set_call_mode(VisualScriptPropertySet::CALL_MODE_SELF);
} else {
@@ -2411,7 +2364,7 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
vnode = pset;
} else {
Ref<VisualScriptPropertyGet> pget;
- pget.instance();
+ pget.instantiate();
if (sn == node) {
pget->set_call_mode(VisualScriptPropertyGet::CALL_MODE_SELF);
} else {
@@ -2420,7 +2373,7 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
vnode = pget;
}
- undo_redo->add_do_method(script.ptr(), "add_node", base_id, vnode, ofs);
+ undo_redo->add_do_method(script.ptr(), "add_node", base_id, vnode, pos);
undo_redo->add_do_method(vnode.ptr(), "set_property", d["property"]);
if (!use_get) {
undo_redo->add_do_method(vnode.ptr(), "set_default_input_value", 0, d["value"]);
@@ -2666,7 +2619,7 @@ void VisualScriptEditor::add_callback(const String &p_function, PackedStringArra
}
Ref<VisualScriptFunction> func;
- func.instance();
+ func.instantiate();
for (int i = 0; i < p_args.size(); i++) {
String name = p_args[i];
Variant::Type type = Variant::NIL;
@@ -3009,7 +2962,7 @@ void VisualScriptEditor::_graph_connect_to_empty(const String &p_from, int p_fro
if (!vsn.is_valid()) {
return;
}
- if (vsn->get_output_value_port_count()) {
+ if (vsn->get_output_value_port_count() || vsn->get_output_sequence_port_count()) {
port_action_pos = p_release_pos;
}
@@ -3075,19 +3028,12 @@ VisualScriptNode::TypeGuess VisualScriptEditor::_guess_output_type(int p_port_ac
}
void VisualScriptEditor::_port_action_menu(int p_option) {
- Vector2 ofs = graph->get_scroll_ofs() + port_action_pos;
- if (graph->is_using_snap()) {
- int snap = graph->get_snap();
- ofs = ofs.snapped(Vector2(snap, snap));
- }
- ofs /= EDSCALE;
-
Set<int> vn;
switch (p_option) {
case CREATE_CALL_SET_GET: {
Ref<VisualScriptFunctionCall> n;
- n.instance();
+ n.instantiate();
VisualScriptNode::TypeGuess tg = _guess_output_type(port_action_node, port_action_output, vn);
@@ -3172,13 +3118,7 @@ void VisualScriptEditor::connect_data(Ref<VisualScriptNode> vnode_old, Ref<Visua
}
void VisualScriptEditor::_selected_connect_node(const String &p_text, const String &p_category, const bool p_connecting) {
- Vector2 ofs = graph->get_scroll_ofs() + port_action_pos;
- if (graph->is_using_snap()) {
- int snap = graph->get_snap();
- ofs = ofs.snapped(Vector2(snap, snap));
- }
- ofs /= EDSCALE;
- ofs /= graph->get_zoom();
+ Vector2 pos = _get_pos_in_graph(port_action_pos);
Set<int> vn;
@@ -3216,7 +3156,7 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri
}
undo_redo->create_action(TTR("Add Node"));
- undo_redo->add_do_method(script.ptr(), "add_node", new_id, vnode_new, ofs);
+ undo_redo->add_do_method(script.ptr(), "add_node", new_id, vnode_new, pos);
if (vnode_old.is_valid() && p_connecting) {
connect_seq(vnode_old, vnode_new, new_id);
connect_data(vnode_old, vnode_new, new_id);
@@ -3234,16 +3174,16 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri
if (p_category == String("method")) {
Ref<VisualScriptFunctionCall> n;
- n.instance();
+ n.instantiate();
vnode = n;
} else if (p_category == String("set")) {
Ref<VisualScriptPropertySet> n;
- n.instance();
+ n.instantiate();
vnode = n;
script_prop_set = n;
} else if (p_category == String("get")) {
Ref<VisualScriptPropertyGet> n;
- n.instance();
+ n.instantiate();
n->set_property(p_text);
vnode = n;
}
@@ -3251,35 +3191,35 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri
if (p_category == String("action")) {
if (p_text == "VisualScriptCondition") {
Ref<VisualScriptCondition> n;
- n.instance();
+ n.instantiate();
vnode = n;
}
if (p_text == "VisualScriptSwitch") {
Ref<VisualScriptSwitch> n;
- n.instance();
+ n.instantiate();
vnode = n;
} else if (p_text == "VisualScriptSequence") {
Ref<VisualScriptSequence> n;
- n.instance();
+ n.instantiate();
vnode = n;
} else if (p_text == "VisualScriptIterator") {
Ref<VisualScriptIterator> n;
- n.instance();
+ n.instantiate();
vnode = n;
} else if (p_text == "VisualScriptWhile") {
Ref<VisualScriptWhile> n;
- n.instance();
+ n.instantiate();
vnode = n;
} else if (p_text == "VisualScriptReturn") {
Ref<VisualScriptReturn> n;
- n.instance();
+ n.instantiate();
vnode = n;
}
}
int new_id = script->get_available_id();
undo_redo->create_action(TTR("Add Node"));
- undo_redo->add_do_method(script.ptr(), "add_node", new_id, vnode, ofs);
+ undo_redo->add_do_method(script.ptr(), "add_node", new_id, vnode, pos);
undo_redo->add_undo_method(script.ptr(), "remove_node", new_id);
undo_redo->add_do_method(this, "_update_graph", new_id);
undo_redo->add_undo_method(this, "_update_graph", new_id);
@@ -3468,7 +3408,7 @@ void VisualScriptEditor::_selected_new_virtual_method(const String &p_text, cons
selected = name;
Ref<VisualScriptFunction> func_node;
- func_node.instance();
+ func_node.instantiate();
func_node->set_name(name);
int fn_id = script->get_available_id();
undo_redo->create_action(TTR("Add Function"));
@@ -3478,18 +3418,18 @@ void VisualScriptEditor::_selected_new_virtual_method(const String &p_text, cons
func_node->add_argument(minfo.arguments[i].type, minfo.arguments[i].name, -1, minfo.arguments[i].hint, minfo.arguments[i].hint_string);
}
- Vector2 ofs = _get_available_pos();
+ Vector2 pos = _get_available_pos();
- undo_redo->add_do_method(script.ptr(), "add_node", fn_id, func_node, ofs);
+ undo_redo->add_do_method(script.ptr(), "add_node", fn_id, func_node, pos);
undo_redo->add_undo_method(script.ptr(), "remove_node", fn_id);
if (minfo.return_val.type != Variant::NIL || minfo.return_val.usage & PROPERTY_USAGE_NIL_IS_VARIANT) {
Ref<VisualScriptReturn> ret_node;
- ret_node.instance();
+ ret_node.instantiate();
ret_node->set_return_type(minfo.return_val.type);
ret_node->set_enable_return_value(true);
ret_node->set_name(name);
int nid = script->get_available_id() + 1;
- undo_redo->add_do_method(script.ptr(), "add_node", nid, ret_node, _get_available_pos(false, ofs + Vector2(500, 0)));
+ undo_redo->add_do_method(script.ptr(), "add_node", nid, ret_node, _get_available_pos(false, pos + Vector2(500, 0)));
undo_redo->add_undo_method(script.ptr(), "remove_node", nid);
}
@@ -3993,16 +3933,16 @@ void VisualScriptEditor::_menu_option(int p_what) {
{
String new_fn = _validate_name("new_function");
- Vector2 ofs = _get_available_pos(false, script->get_node_position(start_node) - Vector2(80, 150));
+ Vector2 pos = _get_available_pos(false, script->get_node_position(start_node) - Vector2(80, 150));
Ref<VisualScriptFunction> func_node;
- func_node.instance();
+ func_node.instantiate();
func_node->set_name(new_fn);
undo_redo->create_action(TTR("Create Function"));
undo_redo->add_do_method(script.ptr(), "add_function", new_fn, fn_id);
- undo_redo->add_do_method(script.ptr(), "add_node", fn_id, func_node, ofs);
+ undo_redo->add_do_method(script.ptr(), "add_node", fn_id, func_node, pos);
undo_redo->add_undo_method(script.ptr(), "remove_function", new_fn);
undo_redo->add_undo_method(script.ptr(), "remove_node", fn_id);
undo_redo->add_do_method(this, "_update_members");
@@ -4041,12 +3981,12 @@ void VisualScriptEditor::_menu_option(int p_what) {
int m = 1;
for (Set<int>::Element *G = end_nodes.front(); G; G = G->next()) {
Ref<VisualScriptReturn> ret_node;
- ret_node.instance();
+ ret_node.instantiate();
int ret_id = fn_id + (m++);
selections.insert(ret_id);
- Vector2 ofsi = _get_available_pos(false, script->get_node_position(G->get()) + Vector2(80, -100));
- undo_redo->add_do_method(script.ptr(), "add_node", ret_id, ret_node, ofsi);
+ Vector2 posi = _get_available_pos(false, script->get_node_position(G->get()) + Vector2(80, -100));
+ undo_redo->add_do_method(script.ptr(), "add_node", ret_id, ret_node, posi);
undo_redo->add_undo_method(script.ptr(), "remove_node", ret_id);
undo_redo->add_do_method(script.ptr(), "sequence_connect", G->get(), 0, ret_id);
@@ -4529,7 +4469,7 @@ void VisualScriptEditor::register_editor() {
Ref<VisualScriptNode> _VisualScriptEditor::create_node_custom(const String &p_name) {
Ref<VisualScriptCustomNode> node;
- node.instance();
+ node.instantiate();
node->set_script(singleton->custom_nodes[p_name]);
return node;
}
diff --git a/modules/visual_script/visual_script_editor.h b/modules/visual_script/visual_script_editor.h
index ca06b807cc..1f0f087be7 100644
--- a/modules/visual_script/visual_script_editor.h
+++ b/modules/visual_script/visual_script_editor.h
@@ -226,7 +226,8 @@ class VisualScriptEditor : public ScriptEditorBase {
void _update_node_size(int p_id);
void _port_name_focus_out(const Node *p_name_box, int p_id, int p_port, bool is_input);
- Vector2 _get_available_pos(bool centered = true, Vector2 ofs = Vector2()) const;
+ Vector2 _get_pos_in_graph(Vector2 p_point) const;
+ Vector2 _get_available_pos(bool p_centered = true, Vector2 p_pos = Vector2()) const;
bool node_has_sequence_connections(int p_id);
diff --git a/modules/visual_script/visual_script_expression.cpp b/modules/visual_script/visual_script_expression.cpp
index cb4230bea9..d63fbeb726 100644
--- a/modules/visual_script/visual_script_expression.cpp
+++ b/modules/visual_script/visual_script_expression.cpp
@@ -1498,7 +1498,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptExpression::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptExpression::instantiate(VisualScriptInstance *p_instance) {
_compile_expression();
VisualScriptNodeInstanceExpression *instance = memnew(VisualScriptNodeInstanceExpression);
instance->instance = p_instance;
diff --git a/modules/visual_script/visual_script_expression.h b/modules/visual_script/visual_script_expression.h
index c35075ea53..ef16222b42 100644
--- a/modules/visual_script/visual_script_expression.h
+++ b/modules/visual_script/visual_script_expression.h
@@ -273,7 +273,7 @@ public:
virtual String get_text() const override;
virtual String get_category() const override { return "operators"; }
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptExpression();
~VisualScriptExpression();
diff --git a/modules/visual_script/visual_script_flow_control.cpp b/modules/visual_script/visual_script_flow_control.cpp
index e977f9c96b..af86f90b25 100644
--- a/modules/visual_script/visual_script_flow_control.cpp
+++ b/modules/visual_script/visual_script_flow_control.cpp
@@ -138,7 +138,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptReturn::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptReturn::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceReturn *instance = memnew(VisualScriptNodeInstanceReturn);
instance->node = this;
instance->instance = p_instance;
@@ -154,7 +154,7 @@ VisualScriptReturn::VisualScriptReturn() {
template <bool with_value>
static Ref<VisualScriptNode> create_return_node(const String &p_name) {
Ref<VisualScriptReturn> node;
- node.instance();
+ node.instantiate();
node->set_enable_return_value(with_value);
return node;
}
@@ -231,7 +231,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptCondition::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptCondition::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceCondition *instance = memnew(VisualScriptNodeInstanceCondition);
instance->node = this;
instance->instance = p_instance;
@@ -311,7 +311,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptWhile::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptWhile::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceWhile *instance = memnew(VisualScriptNodeInstanceWhile);
instance->node = this;
instance->instance = p_instance;
@@ -435,7 +435,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptIterator::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptIterator::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceIterator *instance = memnew(VisualScriptNodeInstanceIterator);
instance->node = this;
instance->instance = p_instance;
@@ -534,7 +534,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptSequence::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptSequence::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceSequence *instance = memnew(VisualScriptNodeInstanceSequence);
instance->node = this;
instance->instance = p_instance;
@@ -618,7 +618,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptSwitch::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptSwitch::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceSwitch *instance = memnew(VisualScriptNodeInstanceSwitch);
instance->instance = p_instance;
instance->case_count = case_values.size();
@@ -831,7 +831,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptTypeCast::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptTypeCast::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceTypeCast *instance = memnew(VisualScriptNodeInstanceTypeCast);
instance->instance = p_instance;
instance->base_type = base_type;
diff --git a/modules/visual_script/visual_script_flow_control.h b/modules/visual_script/visual_script_flow_control.h
index d9c4dedafd..73822fcc37 100644
--- a/modules/visual_script/visual_script_flow_control.h
+++ b/modules/visual_script/visual_script_flow_control.h
@@ -64,7 +64,7 @@ public:
void set_enable_return_value(bool p_enable);
bool is_return_value_enabled() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptReturn();
};
@@ -91,7 +91,7 @@ public:
virtual String get_text() const override;
virtual String get_category() const override { return "flow_control"; }
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptCondition();
};
@@ -118,7 +118,7 @@ public:
virtual String get_text() const override;
virtual String get_category() const override { return "flow_control"; }
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptWhile();
};
@@ -145,7 +145,7 @@ public:
virtual String get_text() const override;
virtual String get_category() const override { return "flow_control"; }
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptIterator();
};
@@ -177,7 +177,7 @@ public:
void set_steps(int p_steps);
int get_steps() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptSequence();
};
@@ -220,7 +220,7 @@ public:
virtual String get_text() const override;
virtual String get_category() const override { return "flow_control"; }
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptSwitch();
};
@@ -258,7 +258,7 @@ public:
virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const override;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptTypeCast();
};
diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp
index a0ba7b1962..43e1d38a16 100644
--- a/modules/visual_script/visual_script_func_nodes.cpp
+++ b/modules/visual_script/visual_script_func_nodes.cpp
@@ -856,7 +856,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptFunctionCall::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptFunctionCall::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceFunctionCall *instance = memnew(VisualScriptNodeInstanceFunctionCall);
instance->node = this;
instance->instance = p_instance;
@@ -891,7 +891,7 @@ VisualScriptFunctionCall::VisualScriptFunctionCall() {
template <VisualScriptFunctionCall::CallMode cmode>
static Ref<VisualScriptNode> create_function_call_node(const String &p_name) {
Ref<VisualScriptFunctionCall> node;
- node.instance();
+ node.instantiate();
node->set_call_mode(cmode);
return node;
}
@@ -1587,7 +1587,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptPropertySet::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptPropertySet::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstancePropertySet *instance = memnew(VisualScriptNodeInstancePropertySet);
instance->node = this;
instance->instance = p_instance;
@@ -1618,7 +1618,7 @@ VisualScriptPropertySet::VisualScriptPropertySet() {
template <VisualScriptPropertySet::CallMode cmode>
static Ref<VisualScriptNode> create_property_set_node(const String &p_name) {
Ref<VisualScriptPropertySet> node;
- node.instance();
+ node.instantiate();
node->set_call_mode(cmode);
return node;
}
@@ -2175,7 +2175,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptPropertyGet::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptPropertyGet::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstancePropertyGet *instance = memnew(VisualScriptNodeInstancePropertyGet);
instance->node = this;
instance->instance = p_instance;
@@ -2197,7 +2197,7 @@ VisualScriptPropertyGet::VisualScriptPropertyGet() {
template <VisualScriptPropertyGet::CallMode cmode>
static Ref<VisualScriptNode> create_property_get_node(const String &p_name) {
Ref<VisualScriptPropertyGet> node;
- node.instance();
+ node.instantiate();
node->set_call_mode(cmode);
return node;
}
@@ -2321,7 +2321,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptEmitSignal::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptEmitSignal::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceEmitSignal *instance = memnew(VisualScriptNodeInstanceEmitSignal);
instance->node = this;
instance->instance = p_instance;
@@ -2340,7 +2340,7 @@ static Ref<VisualScriptNode> create_basic_type_call_node(const String &p_name) {
String method = path[3];
Ref<VisualScriptFunctionCall> node;
- node.instance();
+ node.instantiate();
Variant::Type type = Variant::VARIANT_MAX;
diff --git a/modules/visual_script/visual_script_func_nodes.h b/modules/visual_script/visual_script_func_nodes.h
index 2ff9b7a981..eb17be1fbe 100644
--- a/modules/visual_script/visual_script_func_nodes.h
+++ b/modules/visual_script/visual_script_func_nodes.h
@@ -125,7 +125,7 @@ public:
void set_rpc_call_mode(RPCCallMode p_mode);
RPCCallMode get_rpc_call_mode() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const override;
@@ -231,7 +231,7 @@ public:
void set_assign_op(AssignOp p_op);
AssignOp get_assign_op() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const override;
VisualScriptPropertySet();
@@ -314,7 +314,7 @@ public:
void set_index(const StringName &p_type);
StringName get_index() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptPropertyGet();
};
@@ -351,7 +351,7 @@ public:
void set_signal(const StringName &p_type);
StringName get_signal() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptEmitSignal();
};
diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp
index 07dc3dfaf6..f168a5942e 100644
--- a/modules/visual_script/visual_script_nodes.cpp
+++ b/modules/visual_script/visual_script_nodes.cpp
@@ -296,7 +296,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptFunction::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptFunction::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceFunction *instance = memnew(VisualScriptNodeInstanceFunction);
instance->node = this;
instance->instance = p_instance;
@@ -791,7 +791,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptComposeArray::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptComposeArray::instantiate(VisualScriptInstance *p_instance) {
VisualScriptComposeArrayNode *instance = memnew(VisualScriptComposeArrayNode);
instance->input_count = inputports.size();
return instance;
@@ -912,73 +912,135 @@ PropertyInfo VisualScriptOperator::get_output_value_port_info(int p_idx) const {
return pinfo;
}
-static const char *op_names[] = {
- //comparison
- "Are Equal", //OP_EQUAL,
- "Are Not Equal", //OP_NOT_EQUAL,
- "Less Than", //OP_LESS,
- "Less Than or Equal", //OP_LESS_EQUAL,
- "Greater Than", //OP_GREATER,
- "Greater Than or Equal", //OP_GREATER_EQUAL,
- //mathematic
- "Add", //OP_ADD,
- "Subtract", //OP_SUBTRACT,
- "Multiply", //OP_MULTIPLY,
- "Divide", //OP_DIVIDE,
- "Negate", //OP_NEGATE,
- "Positive", //OP_POSITIVE,
- "Remainder", //OP_MODULE,
- "Concatenate", //OP_STRING_CONCAT,
- //bitwise
- "Bit Shift Left", //OP_SHIFT_LEFT,
- "Bit Shift Right", //OP_SHIFT_RIGHT,
- "Bit And", //OP_BIT_AND,
- "Bit Or", //OP_BIT_OR,
- "Bit Xor", //OP_BIT_XOR,
- "Bit Negate", //OP_BIT_NEGATE,
- //logic
- "And", //OP_AND,
- "Or", //OP_OR,
- "Xor", //OP_XOR,
- "Not", //OP_NOT,
- //containment
- "In", //OP_IN,
-};
-
String VisualScriptOperator::get_caption() const {
- static const char32_t *op_names[] = {
- //comparison
- U"A = B", //OP_EQUAL,
- U"A \u2260 B", //OP_NOT_EQUAL,
- U"A < B", //OP_LESS,
- U"A \u2264 B", //OP_LESS_EQUAL,
- U"A > B", //OP_GREATER,
- U"A \u2265 B", //OP_GREATER_EQUAL,
- //mathematic
- U"A + B", //OP_ADD,
- U"A - B", //OP_SUBTRACT,
- U"A \u00D7 B", //OP_MULTIPLY,
- U"A \u00F7 B", //OP_DIVIDE,
- U"\u00AC A", //OP_NEGATE,
- U"+ A", //OP_POSITIVE,
- U"A mod B", //OP_MODULE,
- U"A .. B", //OP_STRING_CONCAT,
- //bitwise
- U"A << B", //OP_SHIFT_LEFT,
- U"A >> B", //OP_SHIFT_RIGHT,
- U"A & B", //OP_BIT_AND,
- U"A | B", //OP_BIT_OR,
- U"A ^ B", //OP_BIT_XOR,
- U"~A", //OP_BIT_NEGATE,
- //logic
- U"A and B", //OP_AND,
- U"A or B", //OP_OR,
- U"A xor B", //OP_XOR,
- U"not A", //OP_NOT,
- U"A in B", //OP_IN,
-
- };
- return op_names[op];
+ switch (op) {
+ // comparison
+ case Variant::OP_EQUAL:
+ return U"A = B";
+ case Variant::OP_NOT_EQUAL:
+ return U"A \u2260 B";
+ case Variant::OP_LESS:
+ return U"A < B";
+ case Variant::OP_LESS_EQUAL:
+ return U"A \u2264 B";
+ case Variant::OP_GREATER:
+ return U"A > B";
+ case Variant::OP_GREATER_EQUAL:
+ return U"A \u2265 B";
+
+ // mathematic
+ case Variant::OP_ADD:
+ return U"A + B";
+ case Variant::OP_SUBTRACT:
+ return U"A - B";
+ case Variant::OP_MULTIPLY:
+ return U"A \u00D7 B";
+ case Variant::OP_DIVIDE:
+ return U"A \u00F7 B";
+ case Variant::OP_NEGATE:
+ return U"\u00AC A";
+ case Variant::OP_POSITIVE:
+ return U"+ A";
+ case Variant::OP_MODULE:
+ return U"A mod B";
+
+ // bitwise
+ case Variant::OP_SHIFT_LEFT:
+ return U"A << B";
+ case Variant::OP_SHIFT_RIGHT:
+ return U"A >> B";
+ case Variant::OP_BIT_AND:
+ return U"A & B";
+ case Variant::OP_BIT_OR:
+ return U"A | B";
+ case Variant::OP_BIT_XOR:
+ return U"A ^ B";
+ case Variant::OP_BIT_NEGATE:
+ return U"~A";
+
+ // logic
+ case Variant::OP_AND:
+ return U"A and B";
+ case Variant::OP_OR:
+ return U"A or B";
+ case Variant::OP_XOR:
+ return U"A xor B";
+ case Variant::OP_NOT:
+ return U"not A";
+ case Variant::OP_IN:
+ return U"A in B";
+
+ default: {
+ ERR_FAIL_V_MSG(
+ U"Unknown node",
+ U"Unknown node type encountered, caption not available.");
+ }
+ }
+}
+
+String VisualScriptOperator::get_operator_name(Variant::Operator p_op) {
+ switch (p_op) {
+ // comparison
+ case Variant::OP_EQUAL:
+ return "Are Equal";
+ case Variant::OP_NOT_EQUAL:
+ return "Are Not Equal";
+ case Variant::OP_LESS:
+ return "Less Than";
+ case Variant::OP_LESS_EQUAL:
+ return "Less Than or Equal";
+ case Variant::OP_GREATER:
+ return "Greater Than";
+ case Variant::OP_GREATER_EQUAL:
+ return "Greater Than or Equal";
+
+ // mathematic
+ case Variant::OP_ADD:
+ return "Add";
+ case Variant::OP_SUBTRACT:
+ return "Subtract";
+ case Variant::OP_MULTIPLY:
+ return "Multiply";
+ case Variant::OP_DIVIDE:
+ return "Divide";
+ case Variant::OP_NEGATE:
+ return "Negate";
+ case Variant::OP_POSITIVE:
+ return "Positive";
+ case Variant::OP_MODULE:
+ return "Remainder";
+
+ // bitwise
+ case Variant::OP_SHIFT_LEFT:
+ return "Bit Shift Left";
+ case Variant::OP_SHIFT_RIGHT:
+ return "Bit Shift Right";
+ case Variant::OP_BIT_AND:
+ return "Bit And";
+ case Variant::OP_BIT_OR:
+ return "Bit Or";
+ case Variant::OP_BIT_XOR:
+ return "Bit Xor";
+ case Variant::OP_BIT_NEGATE:
+ return "Bit Negate";
+
+ // logic
+ case Variant::OP_AND:
+ return "And";
+ case Variant::OP_OR:
+ return "Or";
+ case Variant::OP_XOR:
+ return "Xor";
+ case Variant::OP_NOT:
+ return "Not";
+ case Variant::OP_IN:
+ return "In";
+
+ default: {
+ ERR_FAIL_INDEX_V(p_op, Variant::OP_MAX, "");
+ return "Unknown Operator";
+ }
+ }
}
void VisualScriptOperator::set_operator(Variant::Operator p_op) {
@@ -1018,7 +1080,7 @@ void VisualScriptOperator::_bind_methods() {
if (i > 0) {
types += ",";
}
- types += op_names[i];
+ types += get_operator_name(static_cast<Variant::Operator>(i));
}
String argt = "Any";
@@ -1051,9 +1113,9 @@ public:
r_error_str = *p_outputs[0];
} else {
if (unary) {
- r_error_str = String(op_names[op]) + RTR(": Invalid argument of type: ") + Variant::get_type_name(p_inputs[0]->get_type());
+ r_error_str = String(Variant::get_operator_name(op)) + RTR(": Invalid argument of type: ") + Variant::get_type_name(p_inputs[0]->get_type());
} else {
- r_error_str = String(op_names[op]) + RTR(": Invalid arguments: ") + "A: " + Variant::get_type_name(p_inputs[0]->get_type()) + " B: " + Variant::get_type_name(p_inputs[1]->get_type());
+ r_error_str = String(Variant::get_operator_name(op)) + RTR(": Invalid arguments: ") + "A: " + Variant::get_type_name(p_inputs[0]->get_type()) + " B: " + Variant::get_type_name(p_inputs[1]->get_type());
}
}
}
@@ -1062,7 +1124,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptOperator::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptOperator::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceOperator *instance = memnew(VisualScriptNodeInstanceOperator);
instance->unary = get_input_value_port_count() == 1;
instance->op = op;
@@ -1077,7 +1139,7 @@ VisualScriptOperator::VisualScriptOperator() {
template <Variant::Operator OP>
static Ref<VisualScriptNode> create_op_node(const String &p_name) {
Ref<VisualScriptOperator> node;
- node.instance();
+ node.instantiate();
node->set_operator(OP);
return node;
}
@@ -1169,7 +1231,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptSelect::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptSelect::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceSelect *instance = memnew(VisualScriptNodeInstanceSelect);
return instance;
}
@@ -1277,7 +1339,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptVariableGet::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptVariableGet::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceVariableGet *instance = memnew(VisualScriptNodeInstanceVariableGet);
instance->node = this;
instance->instance = p_instance;
@@ -1389,7 +1451,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptVariableSet::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptVariableSet::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceVariableSet *instance = memnew(VisualScriptNodeInstanceVariableSet);
instance->node = this;
instance->instance = p_instance;
@@ -1504,7 +1566,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptConstant::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptConstant::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceConstant *instance = memnew(VisualScriptNodeInstanceConstant);
instance->constant = value;
return instance;
@@ -1597,7 +1659,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptPreload::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptPreload::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstancePreload *instance = memnew(VisualScriptNodeInstancePreload);
instance->preload = preload;
return instance;
@@ -1662,7 +1724,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptIndexGet::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptIndexGet::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceIndexGet *instance = memnew(VisualScriptNodeInstanceIndexGet);
return instance;
}
@@ -1732,7 +1794,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptIndexSet::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptIndexSet::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceIndexSet *instance = memnew(VisualScriptNodeInstanceIndexSet);
return instance;
}
@@ -1798,7 +1860,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptGlobalConstant::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptGlobalConstant::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceGlobalConstant *instance = memnew(VisualScriptNodeInstanceGlobalConstant);
instance->index = index;
return instance;
@@ -1916,7 +1978,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptClassConstant::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptClassConstant::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceClassConstant *instance = memnew(VisualScriptNodeInstanceClassConstant);
instance->value = ClassDB::get_integer_constant(base_type, name, &instance->valid);
return instance;
@@ -2050,7 +2112,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptBasicTypeConstant::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptBasicTypeConstant::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceBasicTypeConstant *instance = memnew(VisualScriptNodeInstanceBasicTypeConstant);
instance->value = Variant::get_constant_value(type, name, &instance->valid);
return instance;
@@ -2174,7 +2236,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptMathConstant::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptMathConstant::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceMathConstant *instance = memnew(VisualScriptNodeInstanceMathConstant);
instance->value = const_value[constant];
return instance;
@@ -2268,7 +2330,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptEngineSingleton::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptEngineSingleton::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceEngineSingleton *instance = memnew(VisualScriptNodeInstanceEngineSingleton);
instance->singleton = Engine::get_singleton()->get_singleton_object(singleton);
return instance;
@@ -2394,7 +2456,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptSceneNode::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptSceneNode::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceSceneNode *instance = memnew(VisualScriptNodeInstanceSceneNode);
instance->node = this;
instance->instance = p_instance;
@@ -2574,7 +2636,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptSceneTree::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptSceneTree::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceSceneTree *instance = memnew(VisualScriptNodeInstanceSceneTree);
instance->node = this;
instance->instance = p_instance;
@@ -2655,7 +2717,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptResourcePath::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptResourcePath::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceResourcePath *instance = memnew(VisualScriptNodeInstanceResourcePath);
instance->path = path;
return instance;
@@ -2727,7 +2789,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptSelf::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptSelf::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceSelf *instance = memnew(VisualScriptNodeInstanceSelf);
instance->instance = p_instance;
return instance;
@@ -2908,7 +2970,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptCustomNode::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptCustomNode::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceCustomNode *instance = memnew(VisualScriptNodeInstanceCustomNode);
instance->instance = p_instance;
instance->node = this;
@@ -3059,7 +3121,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptSubCall::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptSubCall::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceSubCall *instance = memnew(VisualScriptNodeInstanceSubCall);
instance->instance = p_instance;
Ref<Script> script = get_script();
@@ -3172,7 +3234,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptComment::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptComment::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceComment *instance = memnew(VisualScriptNodeInstanceComment);
instance->instance = p_instance;
return instance;
@@ -3279,7 +3341,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptConstructor::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptConstructor::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceConstructor *instance = memnew(VisualScriptNodeInstanceConstructor);
instance->instance = p_instance;
instance->type = type;
@@ -3308,7 +3370,7 @@ static Ref<VisualScriptNode> create_constructor_node(const String &p_name) {
ERR_FAIL_COND_V(!constructor_map.has(p_name), Ref<VisualScriptNode>());
Ref<VisualScriptConstructor> vsc;
- vsc.instance();
+ vsc.instantiate();
vsc->set_constructor_type(constructor_map[p_name].first);
vsc->set_constructor(constructor_map[p_name].second);
@@ -3389,7 +3451,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptLocalVar::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptLocalVar::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceLocalVar *instance = memnew(VisualScriptNodeInstanceLocalVar);
instance->instance = p_instance;
instance->name = name;
@@ -3497,7 +3559,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptLocalVarSet::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptLocalVarSet::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceLocalVarSet *instance = memnew(VisualScriptNodeInstanceLocalVarSet);
instance->instance = p_instance;
instance->name = name;
@@ -3634,7 +3696,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptInputAction::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptInputAction::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceInputAction *instance = memnew(VisualScriptNodeInstanceInputAction);
instance->instance = p_instance;
instance->action = name;
@@ -3812,7 +3874,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptDeconstruct::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptDeconstruct::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceDeconstruct *instance = memnew(VisualScriptNodeInstanceDeconstruct);
instance->instance = p_instance;
instance->outputs.resize(elements.size());
@@ -3849,7 +3911,7 @@ VisualScriptDeconstruct::VisualScriptDeconstruct() {
template <Variant::Type T>
static Ref<VisualScriptNode> create_node_deconst_typed(const String &p_name) {
Ref<VisualScriptDeconstruct> node;
- node.instance();
+ node.instantiate();
node->set_deconstruct_type(T);
return node;
}
diff --git a/modules/visual_script/visual_script_nodes.h b/modules/visual_script/visual_script_nodes.h
index 7392443e4e..b599b92b3a 100644
--- a/modules/visual_script/visual_script_nodes.h
+++ b/modules/visual_script/visual_script_nodes.h
@@ -97,7 +97,7 @@ public:
void set_rpc_mode(MultiplayerAPI::RPCMode p_mode);
MultiplayerAPI::RPCMode get_rpc_mode() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
virtual void reset_state() override;
@@ -192,7 +192,7 @@ public:
virtual String get_text() const override;
virtual String get_category() const override { return "functions"; }
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptComposeArray();
};
@@ -227,7 +227,9 @@ public:
void set_typed(Variant::Type p_op);
Variant::Type get_typed() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ static String get_operator_name(Variant::Operator p_op);
+
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptOperator();
};
@@ -259,7 +261,7 @@ public:
void set_typed(Variant::Type p_op);
Variant::Type get_typed() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptSelect();
};
@@ -291,7 +293,7 @@ public:
void set_variable(StringName p_variable);
StringName get_variable() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptVariableGet();
};
@@ -323,7 +325,7 @@ public:
void set_variable(StringName p_variable);
StringName get_variable() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptVariableSet();
};
@@ -359,7 +361,7 @@ public:
void set_constant_value(Variant p_value);
Variant get_constant_value() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptConstant();
};
@@ -390,7 +392,7 @@ public:
void set_preload(const Ref<Resource> &p_preload);
Ref<Resource> get_preload() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptPreload();
};
@@ -413,7 +415,7 @@ public:
virtual String get_caption() const override;
virtual String get_category() const override { return "operators"; }
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptIndexGet();
};
@@ -436,7 +438,7 @@ public:
virtual String get_caption() const override;
virtual String get_category() const override { return "operators"; }
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptIndexSet();
};
@@ -466,7 +468,7 @@ public:
void set_global_constant(int p_which);
int get_global_constant();
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptGlobalConstant();
};
@@ -502,7 +504,7 @@ public:
void set_base_type(const StringName &p_which);
StringName get_base_type();
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptClassConstant();
};
@@ -539,7 +541,7 @@ public:
void set_basic_type(Variant::Type p_which);
Variant::Type get_basic_type() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptBasicTypeConstant();
};
@@ -586,7 +588,7 @@ public:
void set_math_constant(MathConstant p_which);
MathConstant get_math_constant();
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptMathConstant();
};
@@ -621,7 +623,7 @@ public:
void set_singleton(const String &p_string);
String get_singleton();
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const override;
@@ -655,7 +657,7 @@ public:
void set_node_path(const NodePath &p_path);
NodePath get_node_path();
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const override;
@@ -684,7 +686,7 @@ public:
virtual String get_caption() const override;
virtual String get_category() const override { return "data"; }
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const override;
@@ -717,7 +719,7 @@ public:
void set_resource_path(const String &p_path);
String get_resource_path();
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptResourcePath();
};
@@ -743,7 +745,7 @@ public:
virtual String get_caption() const override;
virtual String get_category() const override { return "data"; }
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const override;
@@ -788,7 +790,7 @@ public:
virtual String get_text() const override;
virtual String get_category() const override;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
void _script_changed();
@@ -819,7 +821,7 @@ public:
virtual String get_text() const override;
virtual String get_category() const override;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptSubCall();
};
@@ -859,7 +861,7 @@ public:
void set_size(const Size2 &p_size);
Size2 get_size() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptComment();
};
@@ -894,7 +896,7 @@ public:
void set_constructor(const Dictionary &p_info);
Dictionary get_constructor() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptConstructor();
};
@@ -929,7 +931,7 @@ public:
void set_var_type(Variant::Type p_type);
Variant::Type get_var_type() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptLocalVar();
};
@@ -965,7 +967,7 @@ public:
void set_var_type(Variant::Type p_type);
Variant::Type get_var_type() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptLocalVarSet();
};
@@ -1010,7 +1012,7 @@ public:
void set_action_mode(Mode p_mode);
Mode get_action_mode() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptInputAction();
};
@@ -1056,7 +1058,7 @@ public:
void set_deconstruct_type(Variant::Type p_type);
Variant::Type get_deconstruct_type() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptDeconstruct();
};
diff --git a/modules/visual_script/visual_script_yield_nodes.cpp b/modules/visual_script/visual_script_yield_nodes.cpp
index 52fe659983..2e1b0a3e99 100644
--- a/modules/visual_script/visual_script_yield_nodes.cpp
+++ b/modules/visual_script/visual_script_yield_nodes.cpp
@@ -113,7 +113,7 @@ public:
}
Ref<VisualScriptFunctionState> state;
- state.instance();
+ state.instantiate();
int ret = STEP_YIELD_BIT;
switch (mode) {
@@ -138,7 +138,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptYield::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptYield::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceYield *instance = memnew(VisualScriptNodeInstanceYield);
//instance->instance=p_instance;
instance->mode = yield_mode;
@@ -202,7 +202,7 @@ VisualScriptYield::VisualScriptYield() {
template <VisualScriptYield::YieldMode MODE>
static Ref<VisualScriptNode> create_yield_node(const String &p_name) {
Ref<VisualScriptYield> node;
- node.instance();
+ node.instantiate();
node->set_yield_mode(MODE);
return node;
}
@@ -548,7 +548,7 @@ public:
}
Ref<VisualScriptFunctionState> state;
- state.instance();
+ state.instantiate();
state->connect_to_signal(object, signal, Array());
@@ -559,7 +559,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptYieldSignal::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptYieldSignal::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceYieldSignal *instance = memnew(VisualScriptNodeInstanceYieldSignal);
instance->node = this;
instance->instance = p_instance;
@@ -578,7 +578,7 @@ VisualScriptYieldSignal::VisualScriptYieldSignal() {
template <VisualScriptYieldSignal::CallMode cmode>
static Ref<VisualScriptNode> create_yield_signal_node(const String &p_name) {
Ref<VisualScriptYieldSignal> node;
- node.instance();
+ node.instantiate();
node->set_call_mode(cmode);
return node;
}
diff --git a/modules/visual_script/visual_script_yield_nodes.h b/modules/visual_script/visual_script_yield_nodes.h
index cc7ce0a1c6..fa596173a6 100644
--- a/modules/visual_script/visual_script_yield_nodes.h
+++ b/modules/visual_script/visual_script_yield_nodes.h
@@ -76,7 +76,7 @@ public:
void set_wait_time(float p_time);
float get_wait_time();
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptYield();
};
@@ -135,7 +135,7 @@ public:
void set_call_mode(CallMode p_mode);
CallMode get_call_mode() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptYieldSignal();
};
diff --git a/modules/webm/register_types.cpp b/modules/webm/register_types.cpp
index 82157a71c9..9cfaba83c1 100644
--- a/modules/webm/register_types.cpp
+++ b/modules/webm/register_types.cpp
@@ -35,7 +35,7 @@
static Ref<ResourceFormatLoaderWebm> resource_loader_webm;
void register_webm_types() {
- resource_loader_webm.instance();
+ resource_loader_webm.instantiate();
ResourceLoader::add_resource_format_loader(resource_loader_webm, true);
ClassDB::register_class<VideoStreamWebm>();
diff --git a/modules/webm/video_stream_webm.cpp b/modules/webm/video_stream_webm.cpp
index 6ec0bde7bd..12e0f5bd25 100644
--- a/modules/webm/video_stream_webm.cpp
+++ b/modules/webm/video_stream_webm.cpp
@@ -116,7 +116,7 @@ bool VideoStreamPlaybackWebm::open_file(const String &p_file) {
frame_data.resize((webm->getWidth() * webm->getHeight()) << 2);
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create(webm->getWidth(), webm->getHeight(), false, Image::FORMAT_RGBA8);
texture->create_from_image(img);
diff --git a/modules/webp/image_loader_webp.cpp b/modules/webp/image_loader_webp.cpp
index 772445190c..5bebad2b53 100644
--- a/modules/webp/image_loader_webp.cpp
+++ b/modules/webp/image_loader_webp.cpp
@@ -205,7 +205,7 @@ Error webp_load_image_from_buffer(Image *p_image, const uint8_t *p_buffer, int p
static Ref<Image> _webp_mem_loader_func(const uint8_t *p_png, int p_size) {
Ref<Image> img;
- img.instance();
+ img.instantiate();
Error err = webp_load_image_from_buffer(img.ptr(), p_png, p_size);
ERR_FAIL_COND_V(err, Ref<Image>());
return img;
diff --git a/modules/websocket/doc_classes/WebSocketClient.xml b/modules/websocket/doc_classes/WebSocketClient.xml
index d362bcc10f..6af610c689 100644
--- a/modules/websocket/doc_classes/WebSocketClient.xml
+++ b/modules/websocket/doc_classes/WebSocketClient.xml
@@ -17,11 +17,11 @@
</return>
<argument index="0" name="url" type="String">
</argument>
- <argument index="1" name="protocols" type="PackedStringArray" default="PackedStringArray( )">
+ <argument index="1" name="protocols" type="PackedStringArray" default="PackedStringArray()">
</argument>
<argument index="2" name="gd_mp_api" type="bool" default="false">
</argument>
- <argument index="3" name="custom_headers" type="PackedStringArray" default="PackedStringArray( )">
+ <argument index="3" name="custom_headers" type="PackedStringArray" default="PackedStringArray()">
</argument>
<description>
Connects to the given URL requesting one of the given [code]protocols[/code] as sub-protocol. If the list empty (default), no sub-protocol will be requested.
diff --git a/modules/websocket/doc_classes/WebSocketServer.xml b/modules/websocket/doc_classes/WebSocketServer.xml
index f7805209e2..7bc0d64718 100644
--- a/modules/websocket/doc_classes/WebSocketServer.xml
+++ b/modules/websocket/doc_classes/WebSocketServer.xml
@@ -63,7 +63,7 @@
</return>
<argument index="0" name="port" type="int">
</argument>
- <argument index="1" name="protocols" type="PackedStringArray" default="PackedStringArray( )">
+ <argument index="1" name="protocols" type="PackedStringArray" default="PackedStringArray()">
</argument>
<argument index="2" name="gd_mp_api" type="bool" default="false">
</argument>
@@ -89,6 +89,9 @@
<member name="ca_chain" type="X509Certificate" setter="set_ca_chain" getter="get_ca_chain">
When using SSL (see [member private_key] and [member ssl_certificate]), you can set this to a valid [X509Certificate] to be provided as additional CA chain information during the SSL handshake.
</member>
+ <member name="handshake_timeout" type="float" setter="set_handshake_timeout" getter="get_handshake_timeout" default="3.0">
+ The time in seconds before a pending client (i.e. a client that has not yet finished the HTTP handshake) is considered stale and forcefully disconnected.
+ </member>
<member name="private_key" type="CryptoKey" setter="set_private_key" getter="get_private_key">
When set to a valid [CryptoKey] (along with [member ssl_certificate]) will cause the server to require SSL instead of regular TCP (i.e. the [code]wss://[/code] protocol).
</member>
diff --git a/modules/websocket/websocket_client.cpp b/modules/websocket/websocket_client.cpp
index 1e9183ebfa..af1dc8ff54 100644
--- a/modules/websocket/websocket_client.cpp
+++ b/modules/websocket/websocket_client.cpp
@@ -42,9 +42,9 @@ Error WebSocketClient::connect_to_url(String p_url, const Vector<String> p_proto
_is_multiplayer = gd_mp_api;
String host = p_url;
- String path = "/";
- String scheme = "";
- int port = 80;
+ String path;
+ String scheme;
+ int port = 0;
Error err = p_url.parse_url(scheme, host, port, path);
ERR_FAIL_COND_V_MSG(err != OK, err, "Invalid URL: " + p_url);
@@ -55,6 +55,9 @@ Error WebSocketClient::connect_to_url(String p_url, const Vector<String> p_proto
if (port == 0) {
port = ssl ? 443 : 80;
}
+ if (path.is_empty()) {
+ path = "/";
+ }
return connect_to_host(host, path, port, ssl, p_protocols, p_custom_headers);
}
@@ -123,12 +126,12 @@ void WebSocketClient::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_verify_ssl_enabled", "enabled"), &WebSocketClient::set_verify_ssl_enabled);
ClassDB::bind_method(D_METHOD("is_verify_ssl_enabled"), &WebSocketClient::is_verify_ssl_enabled);
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "verify_ssl", PROPERTY_HINT_NONE, "", 0), "set_verify_ssl_enabled", "is_verify_ssl_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "verify_ssl", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_verify_ssl_enabled", "is_verify_ssl_enabled");
ClassDB::bind_method(D_METHOD("get_trusted_ssl_certificate"), &WebSocketClient::get_trusted_ssl_certificate);
ClassDB::bind_method(D_METHOD("set_trusted_ssl_certificate"), &WebSocketClient::set_trusted_ssl_certificate);
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "trusted_ssl_certificate", PROPERTY_HINT_RESOURCE_TYPE, "X509Certificate", 0), "set_trusted_ssl_certificate", "get_trusted_ssl_certificate");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "trusted_ssl_certificate", PROPERTY_HINT_RESOURCE_TYPE, "X509Certificate", PROPERTY_USAGE_NONE), "set_trusted_ssl_certificate", "get_trusted_ssl_certificate");
ADD_SIGNAL(MethodInfo("data_received"));
ADD_SIGNAL(MethodInfo("connection_established", PropertyInfo(Variant::STRING, "protocol")));
diff --git a/modules/websocket/websocket_server.cpp b/modules/websocket/websocket_server.cpp
index 7cf68b835c..9b2d04f14f 100644
--- a/modules/websocket/websocket_server.cpp
+++ b/modules/websocket/websocket_server.cpp
@@ -55,15 +55,19 @@ void WebSocketServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_private_key"), &WebSocketServer::get_private_key);
ClassDB::bind_method(D_METHOD("set_private_key"), &WebSocketServer::set_private_key);
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "private_key", PROPERTY_HINT_RESOURCE_TYPE, "CryptoKey", 0), "set_private_key", "get_private_key");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "private_key", PROPERTY_HINT_RESOURCE_TYPE, "CryptoKey", PROPERTY_USAGE_NONE), "set_private_key", "get_private_key");
ClassDB::bind_method(D_METHOD("get_ssl_certificate"), &WebSocketServer::get_ssl_certificate);
ClassDB::bind_method(D_METHOD("set_ssl_certificate"), &WebSocketServer::set_ssl_certificate);
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "ssl_certificate", PROPERTY_HINT_RESOURCE_TYPE, "X509Certificate", 0), "set_ssl_certificate", "get_ssl_certificate");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "ssl_certificate", PROPERTY_HINT_RESOURCE_TYPE, "X509Certificate", PROPERTY_USAGE_NONE), "set_ssl_certificate", "get_ssl_certificate");
ClassDB::bind_method(D_METHOD("get_ca_chain"), &WebSocketServer::get_ca_chain);
ClassDB::bind_method(D_METHOD("set_ca_chain"), &WebSocketServer::set_ca_chain);
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "ca_chain", PROPERTY_HINT_RESOURCE_TYPE, "X509Certificate", 0), "set_ca_chain", "get_ca_chain");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "ca_chain", PROPERTY_HINT_RESOURCE_TYPE, "X509Certificate", PROPERTY_USAGE_NONE), "set_ca_chain", "get_ca_chain");
+
+ ClassDB::bind_method(D_METHOD("get_handshake_timeout"), &WebSocketServer::get_handshake_timeout);
+ ClassDB::bind_method(D_METHOD("set_handshake_timeout", "timeout"), &WebSocketServer::set_handshake_timeout);
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "handshake_timeout"), "set_handshake_timeout", "get_handshake_timeout");
ADD_SIGNAL(MethodInfo("client_close_request", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::INT, "code"), PropertyInfo(Variant::STRING, "reason")));
ADD_SIGNAL(MethodInfo("client_disconnected", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::BOOL, "was_clean_close")));
@@ -108,6 +112,15 @@ void WebSocketServer::set_ca_chain(Ref<X509Certificate> p_ca_chain) {
ca_chain = p_ca_chain;
}
+float WebSocketServer::get_handshake_timeout() const {
+ return handshake_timeout / 1000.0;
+}
+
+void WebSocketServer::set_handshake_timeout(float p_timeout) {
+ ERR_FAIL_COND(p_timeout <= 0.0);
+ handshake_timeout = p_timeout * 1000;
+}
+
NetworkedMultiplayerPeer::ConnectionStatus WebSocketServer::get_connection_status() const {
if (is_listening()) {
return CONNECTION_CONNECTED;
diff --git a/modules/websocket/websocket_server.h b/modules/websocket/websocket_server.h
index bc5e591e7b..26864f3085 100644
--- a/modules/websocket/websocket_server.h
+++ b/modules/websocket/websocket_server.h
@@ -48,6 +48,7 @@ protected:
Ref<CryptoKey> private_key;
Ref<X509Certificate> ssl_cert;
Ref<X509Certificate> ca_chain;
+ uint32_t handshake_timeout = 3000;
public:
virtual Error listen(int p_port, const Vector<String> p_protocols = Vector<String>(), bool gd_mp_api = false) = 0;
@@ -78,6 +79,9 @@ public:
Ref<X509Certificate> get_ca_chain() const;
void set_ca_chain(Ref<X509Certificate> p_ca_chain);
+ float get_handshake_timeout() const;
+ void set_handshake_timeout(float p_timeout);
+
WebSocketServer();
~WebSocketServer();
};
diff --git a/modules/websocket/wsl_client.cpp b/modules/websocket/wsl_client.cpp
index 111d2178d6..74017fedd7 100644
--- a/modules/websocket/wsl_client.cpp
+++ b/modules/websocket/wsl_client.cpp
@@ -158,6 +158,7 @@ bool WSLClient::_verify_headers(String &r_protocol) {
Error WSLClient::connect_to_host(String p_host, String p_path, uint16_t p_port, bool p_ssl, const Vector<String> p_protocols, const Vector<String> p_custom_headers) {
ERR_FAIL_COND_V(_connection.is_valid(), ERR_ALREADY_IN_USE);
+ ERR_FAIL_COND_V(p_path.is_empty(), ERR_INVALID_PARAMETER);
_peer = Ref<WSLPeer>(memnew(WSLPeer));
IPAddress addr;
@@ -337,8 +338,8 @@ Error WSLClient::set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer
}
WSLClient::WSLClient() {
- _peer.instance();
- _tcp.instance();
+ _peer.instantiate();
+ _tcp.instantiate();
disconnect_from_host();
}
diff --git a/modules/websocket/wsl_server.cpp b/modules/websocket/wsl_server.cpp
index dc5b23c31e..ccdb6e9292 100644
--- a/modules/websocket/wsl_server.cpp
+++ b/modules/websocket/wsl_server.cpp
@@ -95,8 +95,8 @@ bool WSLServer::PendingPeer::_parse_request(const Vector<String> p_protocols) {
return true;
}
-Error WSLServer::PendingPeer::do_handshake(const Vector<String> p_protocols) {
- if (OS::get_singleton()->get_ticks_msec() - time > WSL_SERVER_TIMEOUT) {
+Error WSLServer::PendingPeer::do_handshake(const Vector<String> p_protocols, uint64_t p_timeout) {
+ if (OS::get_singleton()->get_ticks_msec() - time > p_timeout) {
return ERR_TIMEOUT;
}
if (use_ssl) {
@@ -188,7 +188,7 @@ void WSLServer::poll() {
List<Ref<PendingPeer>> remove_peers;
for (List<Ref<PendingPeer>>::Element *E = _pending.front(); E; E = E->next()) {
Ref<PendingPeer> ppeer = E->get();
- Error err = ppeer->do_handshake(_protocols);
+ Error err = ppeer->do_handshake(_protocols, handshake_timeout);
if (err == ERR_BUSY) {
continue;
} else if (err != OK) {
@@ -301,7 +301,7 @@ Error WSLServer::set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer
}
WSLServer::WSLServer() {
- _server.instance();
+ _server.instantiate();
}
WSLServer::~WSLServer() {
diff --git a/modules/websocket/wsl_server.h b/modules/websocket/wsl_server.h
index 39177a16a8..a428c89f4f 100644
--- a/modules/websocket/wsl_server.h
+++ b/modules/websocket/wsl_server.h
@@ -40,8 +40,6 @@
#include "core/io/stream_peer_tcp.h"
#include "core/io/tcp_server.h"
-#define WSL_SERVER_TIMEOUT 1000
-
class WSLServer : public WebSocketServer {
GDCIIMPL(WSLServer, WebSocketServer);
@@ -64,7 +62,7 @@ private:
CharString response;
int response_sent = 0;
- Error do_handshake(const Vector<String> p_protocols);
+ Error do_handshake(const Vector<String> p_protocols, uint64_t p_timeout);
};
int _in_buf_size = DEF_BUF_SHIFT;
diff --git a/modules/webxr/register_types.cpp b/modules/webxr/register_types.cpp
index 8baf7e05b8..6df0234811 100644
--- a/modules/webxr/register_types.cpp
+++ b/modules/webxr/register_types.cpp
@@ -38,7 +38,7 @@ void register_webxr_types() {
#ifdef JAVASCRIPT_ENABLED
Ref<WebXRInterfaceJS> webxr;
- webxr.instance();
+ webxr.instantiate();
XRServer::get_singleton()->add_interface(webxr);
#endif
}
diff --git a/modules/webxr/webxr_interface_js.cpp b/modules/webxr/webxr_interface_js.cpp
index 13981e73e1..2eab0cdb07 100644
--- a/modules/webxr/webxr_interface_js.cpp
+++ b/modules/webxr/webxr_interface_js.cpp
@@ -400,7 +400,7 @@ void WebXRInterfaceJS::_update_tracker(int p_controller_id) {
Ref<XRPositionalTracker> tracker = xr_server->find_by_type_and_id(XRServer::TRACKER_CONTROLLER, p_controller_id + 1);
if (godot_webxr_is_controller_connected(p_controller_id)) {
if (tracker.is_null()) {
- tracker.instance();
+ tracker.instantiate();
tracker->set_tracker_type(XRServer::TRACKER_CONTROLLER);
// Controller id's 0 and 1 are always the left and right hands.
if (p_controller_id < 2) {
diff --git a/platform/android/display_server_android.cpp b/platform/android/display_server_android.cpp
index ff61eeaee1..66a2013c4e 100644
--- a/platform/android/display_server_android.cpp
+++ b/platform/android/display_server_android.cpp
@@ -410,8 +410,6 @@ DisplayServerAndroid::DisplayServerAndroid(const String &p_rendering_driver, Dis
keep_screen_on = GLOBAL_GET("display/window/energy_saving/keep_screen_on");
- buttons_state = 0;
-
#if defined(OPENGL_ENABLED)
if (rendering_driver == "opengl") {
bool gl_initialization_error = false;
@@ -484,16 +482,16 @@ DisplayServerAndroid::~DisplayServerAndroid() {
void DisplayServerAndroid::process_joy_event(DisplayServerAndroid::JoypadEvent p_event) {
switch (p_event.type) {
case JOY_EVENT_BUTTON:
- Input::get_singleton()->joy_button(p_event.device, p_event.index, p_event.pressed);
+ Input::get_singleton()->joy_button(p_event.device, (JoyButton)p_event.index, p_event.pressed);
break;
case JOY_EVENT_AXIS:
Input::JoyAxisValue value;
value.min = -1;
value.value = p_event.value;
- Input::get_singleton()->joy_axis(p_event.device, p_event.index, value);
+ Input::get_singleton()->joy_axis(p_event.device, (JoyAxis)p_event.index, value);
break;
case JOY_EVENT_HAT:
- Input::get_singleton()->joy_hat(p_event.device, p_event.hat);
+ Input::get_singleton()->joy_hat(p_event.device, (HatMask)p_event.hat);
break;
default:
return;
@@ -528,7 +526,7 @@ void DisplayServerAndroid::process_key_event(int p_keycode, int p_scancode, int
}
Ref<InputEventKey> ev;
- ev.instance();
+ ev.instantiate();
int val = unicode;
int keycode = android_get_keysym(p_keycode);
int phy_keycode = android_get_keysym(p_scancode);
@@ -575,7 +573,7 @@ void DisplayServerAndroid::process_touch(int p_event, int p_pointer, const Vecto
//end all if exist
for (int i = 0; i < touch.size(); i++) {
Ref<InputEventScreenTouch> ev;
- ev.instance();
+ ev.instantiate();
ev->set_index(touch[i].id);
ev->set_pressed(false);
ev->set_position(touch[i].pos);
@@ -592,7 +590,7 @@ void DisplayServerAndroid::process_touch(int p_event, int p_pointer, const Vecto
//send touch
for (int i = 0; i < touch.size(); i++) {
Ref<InputEventScreenTouch> ev;
- ev.instance();
+ ev.instantiate();
ev->set_index(touch[i].id);
ev->set_pressed(true);
ev->set_position(touch[i].pos);
@@ -618,7 +616,7 @@ void DisplayServerAndroid::process_touch(int p_event, int p_pointer, const Vecto
continue; //no move unncesearily
Ref<InputEventScreenDrag> ev;
- ev.instance();
+ ev.instantiate();
ev->set_index(touch[i].id);
ev->set_position(p_points[idx].pos);
ev->set_relative(p_points[idx].pos - touch[i].pos);
@@ -633,7 +631,7 @@ void DisplayServerAndroid::process_touch(int p_event, int p_pointer, const Vecto
//end all if exist
for (int i = 0; i < touch.size(); i++) {
Ref<InputEventScreenTouch> ev;
- ev.instance();
+ ev.instantiate();
ev->set_index(touch[i].id);
ev->set_pressed(false);
ev->set_position(touch[i].pos);
@@ -649,7 +647,7 @@ void DisplayServerAndroid::process_touch(int p_event, int p_pointer, const Vecto
touch.push_back(tp);
Ref<InputEventScreenTouch> ev;
- ev.instance();
+ ev.instantiate();
ev->set_index(tp.id);
ev->set_pressed(true);
@@ -664,7 +662,7 @@ void DisplayServerAndroid::process_touch(int p_event, int p_pointer, const Vecto
for (int i = 0; i < touch.size(); i++) {
if (touch[i].id == p_pointer) {
Ref<InputEventScreenTouch> ev;
- ev.instance();
+ ev.instantiate();
ev->set_index(touch[i].id);
ev->set_pressed(false);
ev->set_position(touch[i].pos);
@@ -685,7 +683,7 @@ void DisplayServerAndroid::process_hover(int p_type, Point2 p_pos) {
case AMOTION_EVENT_ACTION_HOVER_ENTER: // hover enter
case AMOTION_EVENT_ACTION_HOVER_EXIT: { // hover exit
Ref<InputEventMouseMotion> ev;
- ev.instance();
+ ev.instantiate();
_set_key_modifier_state(ev);
ev->set_position(p_pos);
ev->set_global_position(p_pos);
@@ -697,12 +695,12 @@ void DisplayServerAndroid::process_hover(int p_type, Point2 p_pos) {
}
void DisplayServerAndroid::process_mouse_event(int input_device, int event_action, int event_android_buttons_mask, Point2 event_pos, float event_vertical_factor, float event_horizontal_factor) {
- int event_buttons_mask = _android_button_mask_to_godot_button_mask(event_android_buttons_mask);
+ MouseButton event_buttons_mask = _android_button_mask_to_godot_button_mask(event_android_buttons_mask);
switch (event_action) {
case AMOTION_EVENT_ACTION_BUTTON_PRESS:
case AMOTION_EVENT_ACTION_BUTTON_RELEASE: {
Ref<InputEventMouseButton> ev;
- ev.instance();
+ ev.instantiate();
_set_key_modifier_state(ev);
if ((input_device & AINPUT_SOURCE_MOUSE) == AINPUT_SOURCE_MOUSE) {
ev->set_position(event_pos);
@@ -712,7 +710,7 @@ void DisplayServerAndroid::process_mouse_event(int input_device, int event_actio
ev->set_global_position(hover_prev_pos);
}
ev->set_pressed(event_action == AMOTION_EVENT_ACTION_BUTTON_PRESS);
- int changed_button_mask = buttons_state ^ event_buttons_mask;
+ MouseButton changed_button_mask = MouseButton(buttons_state ^ event_buttons_mask);
buttons_state = event_buttons_mask;
@@ -723,7 +721,7 @@ void DisplayServerAndroid::process_mouse_event(int input_device, int event_actio
case AMOTION_EVENT_ACTION_MOVE: {
Ref<InputEventMouseMotion> ev;
- ev.instance();
+ ev.instantiate();
_set_key_modifier_state(ev);
if ((input_device & AINPUT_SOURCE_MOUSE) == AINPUT_SOURCE_MOUSE) {
ev->set_position(event_pos);
@@ -740,7 +738,7 @@ void DisplayServerAndroid::process_mouse_event(int input_device, int event_actio
} break;
case AMOTION_EVENT_ACTION_SCROLL: {
Ref<InputEventMouseButton> ev;
- ev.instance();
+ ev.instantiate();
if ((input_device & AINPUT_SOURCE_MOUSE) == AINPUT_SOURCE_MOUSE) {
ev->set_position(event_pos);
ev->set_global_position(event_pos);
@@ -765,11 +763,11 @@ void DisplayServerAndroid::process_mouse_event(int input_device, int event_actio
}
}
-void DisplayServerAndroid::_wheel_button_click(int event_buttons_mask, const Ref<InputEventMouseButton> &ev, int wheel_button, float factor) {
+void DisplayServerAndroid::_wheel_button_click(MouseButton event_buttons_mask, const Ref<InputEventMouseButton> &ev, MouseButton wheel_button, float factor) {
Ref<InputEventMouseButton> evd = ev->duplicate();
_set_key_modifier_state(evd);
evd->set_button_index(wheel_button);
- evd->set_button_mask(event_buttons_mask ^ (1 << (wheel_button - 1)));
+ evd->set_button_mask(MouseButton(event_buttons_mask ^ (1 << (wheel_button - 1))));
evd->set_factor(factor);
Input::get_singleton()->accumulate_input_event(evd);
Ref<InputEventMouseButton> evdd = evd->duplicate();
@@ -779,9 +777,9 @@ void DisplayServerAndroid::_wheel_button_click(int event_buttons_mask, const Ref
}
void DisplayServerAndroid::process_double_tap(int event_android_button_mask, Point2 p_pos) {
- int event_button_mask = _android_button_mask_to_godot_button_mask(event_android_button_mask);
+ MouseButton event_button_mask = _android_button_mask_to_godot_button_mask(event_android_button_mask);
Ref<InputEventMouseButton> ev;
- ev.instance();
+ ev.instantiate();
_set_key_modifier_state(ev);
ev->set_position(p_pos);
ev->set_global_position(p_pos);
@@ -792,7 +790,7 @@ void DisplayServerAndroid::process_double_tap(int event_android_button_mask, Poi
Input::get_singleton()->accumulate_input_event(ev);
}
-int DisplayServerAndroid::_button_index_from_mask(int button_mask) {
+MouseButton DisplayServerAndroid::_button_index_from_mask(MouseButton button_mask) {
switch (button_mask) {
case MOUSE_BUTTON_MASK_LEFT:
return MOUSE_BUTTON_LEFT;
@@ -805,13 +803,13 @@ int DisplayServerAndroid::_button_index_from_mask(int button_mask) {
case MOUSE_BUTTON_MASK_XBUTTON2:
return MOUSE_BUTTON_XBUTTON2;
default:
- return 0;
+ return MOUSE_BUTTON_NONE;
}
}
void DisplayServerAndroid::process_scroll(Point2 p_pos) {
Ref<InputEventPanGesture> ev;
- ev.instance();
+ ev.instantiate();
_set_key_modifier_state(ev);
ev->set_position(p_pos);
ev->set_delta(p_pos - scroll_prev_pos);
@@ -863,12 +861,12 @@ Point2i DisplayServerAndroid::mouse_get_position() const {
return hover_prev_pos;
}
-int DisplayServerAndroid::mouse_get_button_state() const {
+MouseButton DisplayServerAndroid::mouse_get_button_state() const {
return buttons_state;
}
-int DisplayServerAndroid::_android_button_mask_to_godot_button_mask(int android_button_mask) {
- int godot_button_mask = 0;
+MouseButton DisplayServerAndroid::_android_button_mask_to_godot_button_mask(int android_button_mask) {
+ MouseButton godot_button_mask = MOUSE_BUTTON_NONE;
if (android_button_mask & AMOTION_EVENT_BUTTON_PRIMARY) {
godot_button_mask |= MOUSE_BUTTON_MASK_LEFT;
}
diff --git a/platform/android/display_server_android.h b/platform/android/display_server_android.h
index a2f47dcccb..a39271d524 100644
--- a/platform/android/display_server_android.h
+++ b/platform/android/display_server_android.h
@@ -68,7 +68,7 @@ private:
bool control_mem = false;
bool meta_mem = false;
- int buttons_state;
+ MouseButton buttons_state = MOUSE_BUTTON_NONE;
// https://developer.android.com/reference/android/view/PointerIcon
// mapping between Godot's cursor shape to Android's'
@@ -120,11 +120,11 @@ private:
void _set_key_modifier_state(Ref<InputEventWithModifiers> ev);
- static int _button_index_from_mask(int button_mask);
+ static MouseButton _button_index_from_mask(MouseButton button_mask);
- static int _android_button_mask_to_godot_button_mask(int android_button_mask);
+ static MouseButton _android_button_mask_to_godot_button_mask(int android_button_mask);
- void _wheel_button_click(int event_buttons_mask, const Ref<InputEventMouseButton> &ev, int wheel_button, float factor);
+ void _wheel_button_click(MouseButton event_buttons_mask, const Ref<InputEventMouseButton> &ev, MouseButton wheel_button, float factor);
public:
static DisplayServerAndroid *get_singleton();
@@ -219,7 +219,7 @@ public:
void notify_surface_changed(int p_width, int p_height);
virtual Point2i mouse_get_position() const;
- virtual int mouse_get_button_state() const;
+ virtual MouseButton mouse_get_button_state() const;
DisplayServerAndroid(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error);
~DisplayServerAndroid();
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp
index 1a0c206e28..d01232665b 100644
--- a/platform/android/export/export.cpp
+++ b/platform/android/export/export.cpp
@@ -1461,7 +1461,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
String project_splash_path = ProjectSettings::get_singleton()->get("application/boot_splash/image");
if (!project_splash_path.is_empty()) {
- splash_image.instance();
+ splash_image.instantiate();
print_verbose("Loading splash image: " + project_splash_path);
const Error err = ImageLoader::load_image(project_splash_path, splash_image);
if (err) {
@@ -1501,7 +1501,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
}
print_verbose("Creating splash background color image.");
- splash_bg_color_image.instance();
+ splash_bg_color_image.instantiate();
splash_bg_color_image->create(splash_image->get_width(), splash_image->get_height(), false, splash_image->get_format());
splash_bg_color_image->fill(bg_color);
@@ -1512,9 +1512,9 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
void load_icon_refs(const Ref<EditorExportPreset> &p_preset, Ref<Image> &icon, Ref<Image> &foreground, Ref<Image> &background) {
String project_icon_path = ProjectSettings::get_singleton()->get("application/config/icon");
- icon.instance();
- foreground.instance();
- background.instance();
+ icon.instantiate();
+ foreground.instantiate();
+ background.instantiate();
// Regular icon: user selection -> project icon -> default.
String path = static_cast<String>(p_preset->get(launcher_icon_option)).strip_edges();
@@ -1849,7 +1849,7 @@ public:
err = OS::get_singleton()->execute(adb, args, &output, &rv, true);
print_verbose(output);
if (err || rv != 0) {
- EditorNode::add_io_error("Could not install to device.");
+ EditorNode::add_io_error("Could not install to device: " + output);
CLEANUP_AND_RETURN(ERR_CANT_CREATE);
}
@@ -2568,19 +2568,35 @@ public:
// Sensitive additions must be done below the logging statement.
print_verbose("Build Android project using gradle command: " + String("\n") + build_command + " " + join_list(cmdline, String(" ")));
- if (should_sign && !p_debug) {
- // Pass the release keystore info as well
- String release_keystore = p_preset->get("keystore/release");
- String release_username = p_preset->get("keystore/release_user");
- String release_password = p_preset->get("keystore/release_password");
- if (!FileAccess::exists(release_keystore)) {
- EditorNode::add_io_error("Could not find keystore, unable to export.");
- return ERR_FILE_CANT_OPEN;
- }
+ if (should_sign) {
+ if (p_debug) {
+ String debug_keystore = p_preset->get("keystore/debug");
+ String debug_password = p_preset->get("keystore/debug_password");
+ String debug_user = p_preset->get("keystore/debug_user");
+
+ if (debug_keystore.is_empty()) {
+ debug_keystore = EditorSettings::get_singleton()->get("export/android/debug_keystore");
+ debug_password = EditorSettings::get_singleton()->get("export/android/debug_keystore_pass");
+ debug_user = EditorSettings::get_singleton()->get("export/android/debug_keystore_user");
+ }
- cmdline.push_back("-Prelease_keystore_file=" + release_keystore); // argument to specify the release keystore file.
- cmdline.push_back("-Prelease_keystore_alias=" + release_username); // argument to specify the release keystore alias.
- cmdline.push_back("-Prelease_keystore_password=" + release_password); // argument to specity the release keystore password.
+ cmdline.push_back("-Pdebug_keystore_file=" + debug_keystore); // argument to specify the debug keystore file.
+ cmdline.push_back("-Pdebug_keystore_alias=" + debug_user); // argument to specify the debug keystore alias.
+ cmdline.push_back("-Pdebug_keystore_password=" + debug_password); // argument to specify the debug keystore password.
+ } else {
+ // Pass the release keystore info as well
+ String release_keystore = p_preset->get("keystore/release");
+ String release_username = p_preset->get("keystore/release_user");
+ String release_password = p_preset->get("keystore/release_password");
+ if (!FileAccess::exists(release_keystore)) {
+ EditorNode::add_io_error("Could not find keystore, unable to export.");
+ return ERR_FILE_CANT_OPEN;
+ }
+
+ cmdline.push_back("-Prelease_keystore_file=" + release_keystore); // argument to specify the release keystore file.
+ cmdline.push_back("-Prelease_keystore_alias=" + release_username); // argument to specify the release keystore alias.
+ cmdline.push_back("-Prelease_keystore_password=" + release_password); // argument to specify the release keystore password.
+ }
}
int result = EditorNode::get_singleton()->execute_and_show_output(TTR("Building Android Project (gradle)"), build_command, cmdline);
@@ -2941,11 +2957,11 @@ public:
EditorExportPlatformAndroid() {
Ref<Image> img = memnew(Image(_android_logo));
- logo.instance();
+ logo.instantiate();
logo->create_from_image(img);
img = Ref<Image>(memnew(Image(_android_run_icon)));
- run_icon.instance();
+ run_icon.instantiate();
run_icon->create_from_image(img);
devices_changed.set();
diff --git a/platform/android/java/app/build.gradle b/platform/android/java/app/build.gradle
index 1b1fb47bd8..18e07c3762 100644
--- a/platform/android/java/app/build.gradle
+++ b/platform/android/java/app/build.gradle
@@ -6,7 +6,7 @@ buildscript {
repositories {
google()
- jcenter()
+ mavenCentral()
}
dependencies {
classpath libraries.androidGradlePlugin
@@ -18,9 +18,8 @@ apply plugin: 'com.android.application'
allprojects {
repositories {
- mavenCentral()
google()
- jcenter()
+ mavenCentral()
// Godot user plugins custom maven repos
String[] mavenRepos = getGodotPluginsMavenRepos()
@@ -113,6 +112,15 @@ android {
}
signingConfigs {
+ debug {
+ if (hasCustomDebugKeystore()) {
+ storeFile new File(getDebugKeystoreFile())
+ storePassword getDebugKeystorePassword()
+ keyAlias getDebugKeyAlias()
+ keyPassword getDebugKeystorePassword()
+ }
+ }
+
release {
File keystoreFile = new File(getReleaseKeystoreFile())
if (keystoreFile.isFile()) {
diff --git a/platform/android/java/app/config.gradle b/platform/android/java/app/config.gradle
index b278d15bdf..81fc87b7ef 100644
--- a/platform/android/java/app/config.gradle
+++ b/platform/android/java/app/config.gradle
@@ -1,11 +1,11 @@
ext.versions = [
- androidGradlePlugin: '4.0.1',
+ androidGradlePlugin: '4.2.1',
compileSdk : 29,
minSdk : 18,
targetSdk : 29,
buildTools : '30.0.3',
supportCoreUtils : '1.0.0',
- kotlinVersion : '1.4.10',
+ kotlinVersion : '1.5.10',
v4Support : '1.0.0',
javaVersion : 1.8,
ndkVersion : '21.4.7075529' // Also update 'platform/android/detect.py#get_project_ndk_version()' when this is updated.
@@ -191,6 +191,35 @@ ext.getGodotPluginsLocalBinaries = { ->
return binDeps
}
+ext.getDebugKeystoreFile = { ->
+ String keystoreFile = project.hasProperty("debug_keystore_file") ? project.property("debug_keystore_file") : ""
+ if (keystoreFile == null || keystoreFile.isEmpty()) {
+ keystoreFile = "."
+ }
+ return keystoreFile
+}
+
+ext.hasCustomDebugKeystore = { ->
+ File keystoreFile = new File(getDebugKeystoreFile())
+ return keystoreFile.isFile()
+}
+
+ext.getDebugKeystorePassword = { ->
+ String keystorePassword = project.hasProperty("debug_keystore_password") ? project.property("debug_keystore_password") : ""
+ if (keystorePassword == null || keystorePassword.isEmpty()) {
+ keystorePassword = "android"
+ }
+ return keystorePassword
+}
+
+ext.getDebugKeyAlias = { ->
+ String keyAlias = project.hasProperty("debug_keystore_alias") ? project.property("debug_keystore_alias") : ""
+ if (keyAlias == null || keyAlias.isEmpty()) {
+ keyAlias = "androiddebugkey"
+ }
+ return keyAlias
+}
+
ext.getReleaseKeystoreFile = { ->
String keystoreFile = project.hasProperty("release_keystore_file") ? project.property("release_keystore_file") : ""
if (keystoreFile == null || keystoreFile.isEmpty()) {
diff --git a/platform/android/java/build.gradle b/platform/android/java/build.gradle
index a28888d80d..ee24a46d9f 100644
--- a/platform/android/java/build.gradle
+++ b/platform/android/java/build.gradle
@@ -5,7 +5,7 @@ buildscript {
repositories {
google()
- jcenter()
+ mavenCentral()
}
dependencies {
classpath libraries.androidGradlePlugin
@@ -16,7 +16,6 @@ buildscript {
allprojects {
repositories {
google()
- jcenter()
mavenCentral()
}
}
diff --git a/platform/android/java/gradle/wrapper/gradle-wrapper.properties b/platform/android/java/gradle/wrapper/gradle-wrapper.properties
index a7d8a0f310..74c5636f8a 100644
--- a/platform/android/java/gradle/wrapper/gradle-wrapper.properties
+++ b/platform/android/java/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Mon Sep 02 02:44:30 PDT 2019
+#Wed Jun 23 23:42:22 PDT 2021
distributionBase=GRADLE_USER_HOME
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
distributionPath=wrapper/dists
-zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
+zipStoreBase=GRADLE_USER_HOME
diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp
index d59366bb64..4c66789a83 100644
--- a/platform/android/java_godot_lib_jni.cpp
+++ b/platform/android/java_godot_lib_jni.cpp
@@ -324,15 +324,15 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyhat(JNIEnv *env, j
int hat = 0;
if (p_hat_x != 0) {
if (p_hat_x < 0)
- hat |= Input::HAT_MASK_LEFT;
+ hat |= HatMask::HAT_MASK_LEFT;
else
- hat |= Input::HAT_MASK_RIGHT;
+ hat |= HatMask::HAT_MASK_RIGHT;
}
if (p_hat_y != 0) {
if (p_hat_y < 0)
- hat |= Input::HAT_MASK_UP;
+ hat |= HatMask::HAT_MASK_UP;
else
- hat |= Input::HAT_MASK_DOWN;
+ hat |= HatMask::HAT_MASK_DOWN;
}
jevent.hat = hat;
diff --git a/platform/android/plugin/godot_plugin_jni.cpp b/platform/android/plugin/godot_plugin_jni.cpp
index ba3e9fa20f..cf0c02e2bf 100644
--- a/platform/android/plugin/godot_plugin_jni.cpp
+++ b/platform/android/plugin/godot_plugin_jni.cpp
@@ -43,7 +43,7 @@ extern "C" {
JNIEXPORT void JNICALL Java_org_godotengine_godot_plugin_GodotPlugin_nativeRegisterSingleton(JNIEnv *env, jclass clazz, jstring name, jobject obj) {
String singname = jstring_to_string(name, env);
- JNISingleton *s = (JNISingleton *)ClassDB::instance("JNISingleton");
+ JNISingleton *s = (JNISingleton *)ClassDB::instantiate("JNISingleton");
s->set_instance(env->NewGlobalRef(obj));
jni_singletons[singname] = s;
diff --git a/platform/iphone/display_server_iphone.mm b/platform/iphone/display_server_iphone.mm
index 9e74de0842..74d7419715 100644
--- a/platform/iphone/display_server_iphone.mm
+++ b/platform/iphone/display_server_iphone.mm
@@ -224,7 +224,7 @@ void DisplayServerIPhone::_window_callback(const Callable &p_callable, const Var
void DisplayServerIPhone::touch_press(int p_idx, int p_x, int p_y, bool p_pressed, bool p_double_click) {
if (!GLOBAL_DEF("debug/disable_touch", false)) {
Ref<InputEventScreenTouch> ev;
- ev.instance();
+ ev.instantiate();
ev->set_index(p_idx);
ev->set_pressed(p_pressed);
@@ -236,7 +236,7 @@ void DisplayServerIPhone::touch_press(int p_idx, int p_x, int p_y, bool p_presse
void DisplayServerIPhone::touch_drag(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_y) {
if (!GLOBAL_DEF("debug/disable_touch", false)) {
Ref<InputEventScreenDrag> ev;
- ev.instance();
+ ev.instantiate();
ev->set_index(p_idx);
ev->set_position(Vector2(p_x, p_y));
ev->set_relative(Vector2(p_x - p_prev_x, p_y - p_prev_y));
@@ -256,7 +256,7 @@ void DisplayServerIPhone::touches_cancelled(int p_idx) {
void DisplayServerIPhone::key(uint32_t p_key, bool p_pressed) {
Ref<InputEventKey> ev;
- ev.instance();
+ ev.instantiate();
ev->set_echo(false);
ev->set_pressed(p_pressed);
ev->set_keycode(p_key);
diff --git a/platform/iphone/export/export.cpp b/platform/iphone/export/export.cpp
index e2df573b09..1d1961ac2f 100644
--- a/platform/iphone/export/export.cpp
+++ b/platform/iphone/export/export.cpp
@@ -367,6 +367,26 @@ void EditorExportPlatformIOS::get_export_options(List<ExportOption> *r_options)
for (int i = 0; i < found_plugins.size(); i++) {
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "plugins/" + found_plugins[i].name), false));
}
+
+ for (int i = 0; i < found_plugins.size(); i++) {
+ // Editable plugin plist values
+ PluginConfigIOS plugin = found_plugins[i];
+ const String *K = nullptr;
+
+ while ((K = plugin.plist.next(K))) {
+ String key = *K;
+ PluginConfigIOS::PlistItem item = plugin.plist[key];
+ switch (item.type) {
+ case PluginConfigIOS::PlistItemType::STRING_INPUT: {
+ String preset_name = "plugins_plist/" + key;
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, preset_name), item.value));
+ } break;
+ default:
+ continue;
+ }
+ }
+ }
+
plugins_changed.clear();
plugins = found_plugins;
@@ -820,7 +840,7 @@ Error EditorExportPlatformIOS::_export_loading_screen_file(const Ref<EditorExpor
if (custom_launch_image_2x.length() > 0 && custom_launch_image_3x.length() > 0) {
Ref<Image> image;
String image_path = p_dest_dir.plus_file("splash@2x.png");
- image.instance();
+ image.instantiate();
Error err = image->load(custom_launch_image_2x);
if (err) {
@@ -834,7 +854,7 @@ Error EditorExportPlatformIOS::_export_loading_screen_file(const Ref<EditorExpor
image.unref();
image_path = p_dest_dir.plus_file("splash@3x.png");
- image.instance();
+ image.instantiate();
err = image->load(custom_launch_image_3x);
if (err) {
@@ -851,7 +871,7 @@ Error EditorExportPlatformIOS::_export_loading_screen_file(const Ref<EditorExpor
const String splash_path = ProjectSettings::get_singleton()->get("application/boot_splash/image");
if (!splash_path.is_empty()) {
- splash.instance();
+ splash.instantiate();
const Error err = splash->load(splash_path);
if (err) {
splash.unref();
@@ -1467,13 +1487,28 @@ Error EditorExportPlatformIOS::_export_ios_plugins(const Ref<EditorExportPreset>
while ((K = plugin.plist.next(K))) {
String key = *K;
- String value = plugin.plist[key];
+ PluginConfigIOS::PlistItem item = plugin.plist[key];
+
+ String value;
+
+ switch (item.type) {
+ case PluginConfigIOS::PlistItemType::STRING_INPUT: {
+ String preset_name = "plugins_plist/" + key;
+ String input_value = p_preset->get(preset_name);
+ value = "<string>" + input_value + "</string>";
+ } break;
+ default:
+ value = item.value;
+ break;
+ }
if (key.is_empty() || value.is_empty()) {
continue;
}
- plist_values[key] = value;
+ String plist_key = "<key>" + key + "</key>";
+
+ plist_values[plist_key] = value;
}
// CPP Code
@@ -1500,7 +1535,7 @@ Error EditorExportPlatformIOS::_export_ios_plugins(const Ref<EditorExportPreset>
continue;
}
- p_config_data.plist_content += "<key>" + key + "</key><string>" + value + "</string>\n";
+ p_config_data.plist_content += key + value + "\n";
}
}
@@ -1999,7 +2034,7 @@ bool EditorExportPlatformIOS::can_export(const Ref<EditorExportPreset> &p_preset
EditorExportPlatformIOS::EditorExportPlatformIOS() {
Ref<Image> img = memnew(Image(_iphone_logo));
- logo.instance();
+ logo.instantiate();
logo->create_from_image(img);
plugins_changed.set();
@@ -2014,7 +2049,7 @@ EditorExportPlatformIOS::~EditorExportPlatformIOS() {
void register_iphone_exporter() {
Ref<EditorExportPlatformIOS> platform;
- platform.instance();
+ platform.instantiate();
EditorExport::get_singleton()->add_export_platform(platform);
}
diff --git a/platform/iphone/plugin/godot_plugin_config.h b/platform/iphone/plugin/godot_plugin_config.h
index 4d0c67bfff..06770260aa 100644
--- a/platform/iphone/plugin/godot_plugin_config.h
+++ b/platform/iphone/plugin/godot_plugin_config.h
@@ -70,6 +70,20 @@ struct PluginConfigIOS {
inline static const char *PLIST_SECTION = "plist";
+ enum PlistItemType {
+ UNKNOWN,
+ STRING,
+ INTEGER,
+ BOOLEAN,
+ RAW,
+ STRING_INPUT,
+ };
+
+ struct PlistItem {
+ PlistItemType type;
+ String value;
+ };
+
// Set to true when the config file is properly loaded.
bool valid_config = false;
bool supports_targets = false;
@@ -93,8 +107,10 @@ struct PluginConfigIOS {
Vector<String> linker_flags;
// Optional plist section
- // Supports only string types for now
- HashMap<String, String> plist;
+ // String value is default value.
+ // Currently supports `string`, `boolean`, `integer`, `raw`, `string_input` types
+ // <name>:<type> = <value>
+ HashMap<String, PlistItem> plist;
};
static inline String resolve_local_dependency_path(String plugin_config_dir, String dependency_path) {
@@ -273,13 +289,68 @@ static inline PluginConfigIOS load_plugin_config(Ref<ConfigFile> config_file, co
config_file->get_section_keys(PluginConfigIOS::PLIST_SECTION, &keys);
for (int i = 0; i < keys.size(); i++) {
- String value = config_file->get_value(PluginConfigIOS::PLIST_SECTION, keys[i], String());
+ Vector<String> key_components = keys[i].split(":");
+
+ String key_value = "";
+ PluginConfigIOS::PlistItemType key_type = PluginConfigIOS::PlistItemType::UNKNOWN;
+
+ if (key_components.size() == 1) {
+ key_value = key_components[0];
+ key_type = PluginConfigIOS::PlistItemType::STRING;
+ } else if (key_components.size() == 2) {
+ key_value = key_components[0];
+
+ if (key_components[1].to_lower() == "string") {
+ key_type = PluginConfigIOS::PlistItemType::STRING;
+ } else if (key_components[1].to_lower() == "integer") {
+ key_type = PluginConfigIOS::PlistItemType::INTEGER;
+ } else if (key_components[1].to_lower() == "boolean") {
+ key_type = PluginConfigIOS::PlistItemType::BOOLEAN;
+ } else if (key_components[1].to_lower() == "raw") {
+ key_type = PluginConfigIOS::PlistItemType::RAW;
+ } else if (key_components[1].to_lower() == "string_input") {
+ key_type = PluginConfigIOS::PlistItemType::STRING_INPUT;
+ }
+ }
- if (value.is_empty()) {
+ if (key_value.is_empty() || key_type == PluginConfigIOS::PlistItemType::UNKNOWN) {
continue;
}
- plugin_config.plist[keys[i]] = value;
+ String value;
+
+ switch (key_type) {
+ case PluginConfigIOS::PlistItemType::STRING: {
+ String raw_value = config_file->get_value(PluginConfigIOS::PLIST_SECTION, keys[i], String());
+ value = "<string>" + raw_value + "</string>";
+ } break;
+ case PluginConfigIOS::PlistItemType::INTEGER: {
+ int raw_value = config_file->get_value(PluginConfigIOS::PLIST_SECTION, keys[i], 0);
+ Dictionary value_dictionary;
+ String value_format = "<integer>$value</integer>";
+ value_dictionary["value"] = raw_value;
+ value = value_format.format(value_dictionary, "$_");
+ } break;
+ case PluginConfigIOS::PlistItemType::BOOLEAN:
+ if (config_file->get_value(PluginConfigIOS::PLIST_SECTION, keys[i], false)) {
+ value = "<true/>";
+ } else {
+ value = "<false/>";
+ }
+ break;
+ case PluginConfigIOS::PlistItemType::RAW: {
+ String raw_value = config_file->get_value(PluginConfigIOS::PLIST_SECTION, keys[i], String());
+ value = raw_value;
+ } break;
+ case PluginConfigIOS::PlistItemType::STRING_INPUT: {
+ String raw_value = config_file->get_value(PluginConfigIOS::PLIST_SECTION, keys[i], String());
+ value = raw_value;
+ } break;
+ default:
+ continue;
+ }
+
+ plugin_config.plist[key_value] = PluginConfigIOS::PlistItem{ key_type, value };
}
}
diff --git a/platform/javascript/display_server_javascript.cpp b/platform/javascript/display_server_javascript.cpp
index 1cc05a2e19..f1b92264e2 100644
--- a/platform/javascript/display_server_javascript.cpp
+++ b/platform/javascript/display_server_javascript.cpp
@@ -128,7 +128,7 @@ void DisplayServerJavaScript::dom2godot_mod(T *emscripten_event_ptr, Ref<InputEv
Ref<InputEventKey> DisplayServerJavaScript::setup_key_event(const EmscriptenKeyboardEvent *emscripten_event) {
Ref<InputEventKey> ev;
- ev.instance();
+ ev.instantiate();
ev->set_echo(emscripten_event->repeat);
dom2godot_mod(emscripten_event, ev);
ev->set_keycode(dom_code2godot_scancode(emscripten_event->code, emscripten_event->key, false));
@@ -181,7 +181,7 @@ EM_BOOL DisplayServerJavaScript::mouse_button_callback(int p_event_type, const E
DisplayServerJavaScript *display = get_singleton();
Ref<InputEventMouseButton> ev;
- ev.instance();
+ ev.instantiate();
ev->set_pressed(p_event_type == EMSCRIPTEN_EVENT_MOUSEDOWN);
ev->set_position(compute_position_in_canvas(p_event->clientX, p_event->clientY));
ev->set_global_position(ev->get_position());
@@ -229,8 +229,8 @@ EM_BOOL DisplayServerJavaScript::mouse_button_callback(int p_event_type, const E
}
Input *input = Input::get_singleton();
- int mask = input->get_mouse_button_mask();
- int button_flag = 1 << (ev->get_button_index() - 1);
+ MouseButton mask = input->get_mouse_button_mask();
+ MouseButton button_flag = MouseButton(1 << (ev->get_button_index() - 1));
if (ev->is_pressed()) {
// Since the event is consumed, focus manually. The containing iframe,
// if exists, may not have focus yet, so focus even if already focused.
@@ -261,7 +261,7 @@ EM_BOOL DisplayServerJavaScript::mousemove_callback(int p_event_type, const Emsc
return false;
Ref<InputEventMouseMotion> ev;
- ev.instance();
+ ev.instantiate();
dom2godot_mod(p_event, ev);
ev->set_button_mask(input_mask);
@@ -452,7 +452,7 @@ EM_BOOL DisplayServerJavaScript::wheel_callback(int p_event_type, const Emscript
Input *input = Input::get_singleton();
Ref<InputEventMouseButton> ev;
- ev.instance();
+ ev.instantiate();
ev->set_position(input->get_mouse_position());
ev->set_global_position(ev->get_position());
@@ -478,11 +478,11 @@ EM_BOOL DisplayServerJavaScript::wheel_callback(int p_event_type, const Emscript
int button_flag = 1 << (ev->get_button_index() - 1);
ev->set_pressed(true);
- ev->set_button_mask(input->get_mouse_button_mask() | button_flag);
+ ev->set_button_mask(MouseButton(input->get_mouse_button_mask() | button_flag));
input->parse_input_event(ev);
ev->set_pressed(false);
- ev->set_button_mask(input->get_mouse_button_mask() & ~button_flag);
+ ev->set_button_mask(MouseButton(input->get_mouse_button_mask() & ~button_flag));
input->parse_input_event(ev);
return true;
@@ -492,7 +492,7 @@ EM_BOOL DisplayServerJavaScript::wheel_callback(int p_event_type, const Emscript
EM_BOOL DisplayServerJavaScript::touch_press_callback(int p_event_type, const EmscriptenTouchEvent *p_event, void *p_user_data) {
DisplayServerJavaScript *display = get_singleton();
Ref<InputEventScreenTouch> ev;
- ev.instance();
+ ev.instantiate();
int lowest_id_index = -1;
for (int i = 0; i < p_event->numTouches; ++i) {
const EmscriptenTouchPoint &touch = p_event->touches[i];
@@ -514,7 +514,7 @@ EM_BOOL DisplayServerJavaScript::touch_press_callback(int p_event_type, const Em
EM_BOOL DisplayServerJavaScript::touchmove_callback(int p_event_type, const EmscriptenTouchEvent *p_event, void *p_user_data) {
DisplayServerJavaScript *display = get_singleton();
Ref<InputEventScreenDrag> ev;
- ev.instance();
+ ev.instantiate();
int lowest_id_index = -1;
for (int i = 0; i < p_event->numTouches; ++i) {
const EmscriptenTouchPoint &touch = p_event->touches[i];
@@ -553,12 +553,12 @@ void DisplayServerJavaScript::vk_input_text_callback(const char *p_text, int p_c
Input *input = Input::get_singleton();
Ref<InputEventKey> k;
for (int i = 0; i < p_cursor; i++) {
- k.instance();
+ k.instantiate();
k->set_pressed(true);
k->set_echo(false);
k->set_keycode(KEY_RIGHT);
input->parse_input_event(k);
- k.instance();
+ k.instantiate();
k->set_pressed(false);
k->set_echo(false);
k->set_keycode(KEY_RIGHT);
diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp
index 7e49feee61..51c72e10eb 100644
--- a/platform/javascript/export/export.cpp
+++ b/platform/javascript/export/export.cpp
@@ -29,7 +29,6 @@
/*************************************************************************/
#include "core/io/image_loader.h"
-#include "core/io/json.h"
#include "core/io/stream_peer_ssl.h"
#include "core/io/tcp_server.h"
#include "core/io/zip_io.h"
@@ -91,7 +90,7 @@ public:
mimes["png"] = "image/png";
mimes["svg"] = "image/svg";
mimes["wasm"] = "application/wasm";
- server.instance();
+ server.instantiate();
stop();
}
@@ -136,8 +135,11 @@ public:
// Wrong protocol
ERR_FAIL_COND_MSG(req[0] != "GET" || req[2] != "HTTP/1.1", "Invalid method or HTTP version.");
- const String req_file = req[1].get_file();
- const String req_ext = req[1].get_extension();
+ const int query_index = req[1].find_char('?');
+ const String path = (query_index == -1) ? req[1] : req[1].substr(0, query_index);
+
+ const String req_file = path.get_file();
+ const String req_ext = path.get_extension();
const String cache_path = EditorPaths::get_singleton()->get_cache_dir().plus_file("web");
const String filepath = cache_path.plus_file(req_file);
@@ -290,7 +292,7 @@ class EditorExportPlatformJavaScript : public EditorExportPlatform {
Ref<Image> _get_project_icon() const {
Ref<Image> icon;
- icon.instance();
+ icon.instantiate();
const String icon_path = String(GLOBAL_GET("application/config/icon")).strip_edges();
if (icon_path.is_empty() || ImageLoader::load_image(icon_path, icon) != OK) {
return EditorNode::get_singleton()->get_editor_theme()->get_icon("DefaultProjectIcon", "EditorIcons")->get_image();
@@ -300,7 +302,7 @@ class EditorExportPlatformJavaScript : public EditorExportPlatform {
Ref<Image> _get_project_splash() const {
Ref<Image> splash;
- splash.instance();
+ splash.instantiate();
const String splash_path = String(GLOBAL_GET("application/boot_splash/image")).strip_edges();
if (splash_path.is_empty() || ImageLoader::load_image(splash_path, splash) != OK) {
return Ref<Image>(memnew(Image(boot_splash_png)));
@@ -465,7 +467,7 @@ void EditorExportPlatformJavaScript::_fix_html(Vector<uint8_t> &p_html, const Re
}
// Replaces HTML string
- const String str_config = JSON::print(config);
+ const String str_config = Variant(config).to_json_string();
const String custom_head_include = p_preset->get("html/head_include");
Map<String, String> replaces;
replaces["$GODOT_URL"] = p_name + ".js";
@@ -482,7 +484,7 @@ Error EditorExportPlatformJavaScript::_add_manifest_icon(const String &p_path, c
Ref<Image> icon;
if (!p_icon.is_empty()) {
- icon.instance();
+ icon.instantiate();
const Error err = ImageLoader::load_image(p_icon, icon);
if (err != OK) {
EditorNode::get_singleton()->show_warning(TTR("Could not read file:") + "\n" + p_icon);
@@ -518,7 +520,7 @@ Error EditorExportPlatformJavaScript::_build_pwa(const Ref<EditorExportPreset> &
replaces["@GODOT_NAME@"] = name;
replaces["@GODOT_OFFLINE_PAGE@"] = name + ".offline.html";
Array files;
- replaces["@GODOT_OPT_CACHE@"] = JSON::print(files);
+ replaces["@GODOT_OPT_CACHE@"] = Variant(files).to_json_string();
files.push_back(name + ".html");
files.push_back(name + ".js");
files.push_back(name + ".wasm");
@@ -537,7 +539,7 @@ Error EditorExportPlatformJavaScript::_build_pwa(const Ref<EditorExportPreset> &
files.push_back(p_shared_objects[i].path.get_file());
}
}
- replaces["@GODOT_CACHE@"] = JSON::print(files);
+ replaces["@GODOT_CACHE@"] = Variant(files).to_json_string();
const String sw_path = dir.plus_file(name + ".service.worker.js");
Vector<uint8_t> sw;
@@ -605,7 +607,7 @@ Error EditorExportPlatformJavaScript::_build_pwa(const Ref<EditorExportPreset> &
}
manifest["icons"] = icons_arr;
- CharString cs = JSON::print(manifest).utf8();
+ CharString cs = Variant(manifest).to_json_string().utf8();
err = _write_or_error((const uint8_t *)cs.get_data(), cs.length(), dir.plus_file(name + ".manifest.json"));
if (err != OK) {
return err;
@@ -965,22 +967,22 @@ void EditorExportPlatformJavaScript::_server_thread_poll(void *data) {
}
EditorExportPlatformJavaScript::EditorExportPlatformJavaScript() {
- server.instance();
+ server.instantiate();
server_thread.start(_server_thread_poll, this);
Ref<Image> img = memnew(Image(_javascript_logo));
- logo.instance();
+ logo.instantiate();
logo->create_from_image(img);
img = Ref<Image>(memnew(Image(_javascript_run_icon)));
- run_icon.instance();
+ run_icon.instantiate();
run_icon->create_from_image(img);
Ref<Theme> theme = EditorNode::get_singleton()->get_editor_theme();
if (theme.is_valid()) {
stop_icon = theme->get_icon("Stop", "EditorIcons");
} else {
- stop_icon.instance();
+ stop_icon.instantiate();
}
}
@@ -1001,6 +1003,6 @@ void register_javascript_exporter() {
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/web/ssl_certificate", PROPERTY_HINT_GLOBAL_FILE, "*.crt,*.pem"));
Ref<EditorExportPlatformJavaScript> platform;
- platform.instance();
+ platform.instantiate();
EditorExport::get_singleton()->add_export_platform(platform);
}
diff --git a/platform/javascript/http_client_javascript.cpp b/platform/javascript/http_client_javascript.cpp
index a6cf4b0eb8..f7d78abcea 100644
--- a/platform/javascript/http_client_javascript.cpp
+++ b/platform/javascript/http_client_javascript.cpp
@@ -28,45 +28,19 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "core/io/http_client.h"
+#include "http_client_javascript.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "stddef.h"
-
-typedef enum {
- GODOT_JS_FETCH_STATE_REQUESTING = 0,
- GODOT_JS_FETCH_STATE_BODY = 1,
- GODOT_JS_FETCH_STATE_DONE = 2,
- GODOT_JS_FETCH_STATE_ERROR = -1,
-} godot_js_fetch_state_t;
-
-extern int godot_js_fetch_create(const char *p_method, const char *p_url, const char **p_headers, int p_headers_len, const uint8_t *p_body, int p_body_len);
-extern int godot_js_fetch_read_headers(int p_id, void (*parse_callback)(int p_size, const char **p_headers, void *p_ref), void *p_ref);
-extern int godot_js_fetch_read_chunk(int p_id, uint8_t *p_buf, int p_buf_size);
-extern void godot_js_fetch_free(int p_id);
-extern godot_js_fetch_state_t godot_js_fetch_state_get(int p_id);
-extern int godot_js_fetch_body_length_get(int p_id);
-extern int godot_js_fetch_http_status_get(int p_id);
-extern int godot_js_fetch_is_chunked(int p_id);
-
-#ifdef __cplusplus
-}
-#endif
-
-void HTTPClient::_parse_headers(int p_len, const char **p_headers, void *p_ref) {
- HTTPClient *client = static_cast<HTTPClient *>(p_ref);
+void HTTPClientJavaScript::_parse_headers(int p_len, const char **p_headers, void *p_ref) {
+ HTTPClientJavaScript *client = static_cast<HTTPClientJavaScript *>(p_ref);
for (int i = 0; i < p_len; i++) {
client->response_headers.push_back(String::utf8(p_headers[i]));
}
}
-Error HTTPClient::connect_to_host(const String &p_host, int p_port, bool p_ssl, bool p_verify_host) {
+Error HTTPClientJavaScript::connect_to_host(const String &p_host, int p_port, bool p_ssl, bool p_verify_host) {
close();
if (p_ssl && !p_verify_host) {
- WARN_PRINT("Disabling HTTPClient's host verification is not supported for the HTML5 platform, host will be verified");
+ WARN_PRINT("Disabling HTTPClientJavaScript's host verification is not supported for the HTML5 platform, host will be verified");
}
port = p_port;
@@ -97,15 +71,15 @@ Error HTTPClient::connect_to_host(const String &p_host, int p_port, bool p_ssl,
return OK;
}
-void HTTPClient::set_connection(const Ref<StreamPeer> &p_connection) {
- ERR_FAIL_MSG("Accessing an HTTPClient's StreamPeer is not supported for the HTML5 platform.");
+void HTTPClientJavaScript::set_connection(const Ref<StreamPeer> &p_connection) {
+ ERR_FAIL_MSG("Accessing an HTTPClientJavaScript's StreamPeer is not supported for the HTML5 platform.");
}
-Ref<StreamPeer> HTTPClient::get_connection() const {
- ERR_FAIL_V_MSG(REF(), "Accessing an HTTPClient's StreamPeer is not supported for the HTML5 platform.");
+Ref<StreamPeer> HTTPClientJavaScript::get_connection() const {
+ ERR_FAIL_V_MSG(REF(), "Accessing an HTTPClientJavaScript's StreamPeer is not supported for the HTML5 platform.");
}
-Error HTTPClient::make_request(Method p_method, const String &p_url, const Vector<String> &p_headers, const uint8_t *p_body, int p_body_len) {
+Error HTTPClientJavaScript::request(Method p_method, const String &p_url, const Vector<String> &p_headers, const uint8_t *p_body, int p_body_len) {
ERR_FAIL_INDEX_V(p_method, METHOD_MAX, ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V_MSG(p_method == METHOD_TRACE || p_method == METHOD_CONNECT, ERR_UNAVAILABLE, "HTTP methods TRACE and CONNECT are not supported for the HTML5 platform.");
ERR_FAIL_COND_V(status != STATUS_CONNECTED, ERR_INVALID_PARAMETER);
@@ -128,22 +102,7 @@ Error HTTPClient::make_request(Method p_method, const String &p_url, const Vecto
return OK;
}
-Error HTTPClient::request_raw(Method p_method, const String &p_url, const Vector<String> &p_headers, const Vector<uint8_t> &p_body) {
- if (p_body.is_empty()) {
- return make_request(p_method, p_url, p_headers, nullptr, 0);
- }
- return make_request(p_method, p_url, p_headers, p_body.ptr(), p_body.size());
-}
-
-Error HTTPClient::request(Method p_method, const String &p_url, const Vector<String> &p_headers, const String &p_body) {
- if (p_body.is_empty()) {
- return make_request(p_method, p_url, p_headers, nullptr, 0);
- }
- const CharString cs = p_body.utf8();
- return make_request(p_method, p_url, p_headers, (const uint8_t *)cs.get_data(), cs.size() - 1);
-}
-
-void HTTPClient::close() {
+void HTTPClientJavaScript::close() {
host = "";
port = -1;
use_tls = false;
@@ -157,23 +116,23 @@ void HTTPClient::close() {
}
}
-HTTPClient::Status HTTPClient::get_status() const {
+HTTPClientJavaScript::Status HTTPClientJavaScript::get_status() const {
return status;
}
-bool HTTPClient::has_response() const {
+bool HTTPClientJavaScript::has_response() const {
return response_headers.size() > 0;
}
-bool HTTPClient::is_response_chunked() const {
+bool HTTPClientJavaScript::is_response_chunked() const {
return godot_js_fetch_is_chunked(js_id);
}
-int HTTPClient::get_response_code() const {
+int HTTPClientJavaScript::get_response_code() const {
return polled_response_code;
}
-Error HTTPClient::get_response_headers(List<String> *r_response) {
+Error HTTPClientJavaScript::get_response_headers(List<String> *r_response) {
if (!response_headers.size()) {
return ERR_INVALID_PARAMETER;
}
@@ -184,11 +143,11 @@ Error HTTPClient::get_response_headers(List<String> *r_response) {
return OK;
}
-int HTTPClient::get_response_body_length() const {
+int HTTPClientJavaScript::get_response_body_length() const {
return godot_js_fetch_body_length_get(js_id);
}
-PackedByteArray HTTPClient::read_response_body_chunk() {
+PackedByteArray HTTPClientJavaScript::read_response_body_chunk() {
ERR_FAIL_COND_V(status != STATUS_BODY, PackedByteArray());
if (response_buffer.size() != read_limit) {
@@ -213,23 +172,23 @@ PackedByteArray HTTPClient::read_response_body_chunk() {
return chunk;
}
-void HTTPClient::set_blocking_mode(bool p_enable) {
- ERR_FAIL_COND_MSG(p_enable, "HTTPClient blocking mode is not supported for the HTML5 platform.");
+void HTTPClientJavaScript::set_blocking_mode(bool p_enable) {
+ ERR_FAIL_COND_MSG(p_enable, "HTTPClientJavaScript blocking mode is not supported for the HTML5 platform.");
}
-bool HTTPClient::is_blocking_mode_enabled() const {
+bool HTTPClientJavaScript::is_blocking_mode_enabled() const {
return false;
}
-void HTTPClient::set_read_chunk_size(int p_size) {
+void HTTPClientJavaScript::set_read_chunk_size(int p_size) {
read_limit = p_size;
}
-int HTTPClient::get_read_chunk_size() const {
+int HTTPClientJavaScript::get_read_chunk_size() const {
return read_limit;
}
-Error HTTPClient::poll() {
+Error HTTPClientJavaScript::poll() {
switch (status) {
case STATUS_DISCONNECTED:
return ERR_UNCONFIGURED;
@@ -263,7 +222,7 @@ Error HTTPClient::poll() {
#ifdef DEBUG_ENABLED
// forcing synchronous requests is not possible on the web
if (last_polling_frame == Engine::get_singleton()->get_process_frames()) {
- WARN_PRINT("HTTPClient polled multiple times in one frame, "
+ WARN_PRINT("HTTPClientJavaScript polled multiple times in one frame, "
"but request cannot progress more than once per "
"frame on the HTML5 platform.");
}
@@ -294,9 +253,15 @@ Error HTTPClient::poll() {
return OK;
}
-HTTPClient::HTTPClient() {
+HTTPClient *HTTPClientJavaScript::_create_func() {
+ return memnew(HTTPClientJavaScript);
+}
+
+HTTPClient *(*HTTPClient::_create)() = HTTPClientJavaScript::_create_func;
+
+HTTPClientJavaScript::HTTPClientJavaScript() {
}
-HTTPClient::~HTTPClient() {
+HTTPClientJavaScript::~HTTPClientJavaScript() {
close();
}
diff --git a/platform/javascript/http_client_javascript.h b/platform/javascript/http_client_javascript.h
new file mode 100644
index 0000000000..33f91f67b6
--- /dev/null
+++ b/platform/javascript/http_client_javascript.h
@@ -0,0 +1,108 @@
+/*************************************************************************/
+/* http_client_javascript.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef HTTP_CLIENT_JAVASCRIPT_H
+#define HTTP_CLIENT_JAVASCRIPT_H
+
+#include "core/io/http_client.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "stddef.h"
+
+typedef enum {
+ GODOT_JS_FETCH_STATE_REQUESTING = 0,
+ GODOT_JS_FETCH_STATE_BODY = 1,
+ GODOT_JS_FETCH_STATE_DONE = 2,
+ GODOT_JS_FETCH_STATE_ERROR = -1,
+} godot_js_fetch_state_t;
+
+extern int godot_js_fetch_create(const char *p_method, const char *p_url, const char **p_headers, int p_headers_len, const uint8_t *p_body, int p_body_len);
+extern int godot_js_fetch_read_headers(int p_id, void (*parse_callback)(int p_size, const char **p_headers, void *p_ref), void *p_ref);
+extern int godot_js_fetch_read_chunk(int p_id, uint8_t *p_buf, int p_buf_size);
+extern void godot_js_fetch_free(int p_id);
+extern godot_js_fetch_state_t godot_js_fetch_state_get(int p_id);
+extern int godot_js_fetch_body_length_get(int p_id);
+extern int godot_js_fetch_http_status_get(int p_id);
+extern int godot_js_fetch_is_chunked(int p_id);
+
+#ifdef __cplusplus
+}
+#endif
+
+class HTTPClientJavaScript : public HTTPClient {
+private:
+ int js_id = 0;
+ Status status = STATUS_DISCONNECTED;
+
+ // 64 KiB by default (favors fast download speeds at the cost of memory usage).
+ int read_limit = 65536;
+
+ String host;
+ int port = -1;
+ bool use_tls = false;
+
+ int polled_response_code = 0;
+ Vector<String> response_headers;
+ Vector<uint8_t> response_buffer;
+
+#ifdef DEBUG_ENABLED
+ uint64_t last_polling_frame = 0;
+#endif
+
+ static void _parse_headers(int p_len, const char **p_headers, void *p_ref);
+
+public:
+ static HTTPClient *_create_func();
+
+ Error request(Method p_method, const String &p_url, const Vector<String> &p_headers, const uint8_t *p_body, int p_body_size) override;
+
+ Error connect_to_host(const String &p_host, int p_port = -1, bool p_ssl = false, bool p_verify_host = true) override;
+ void set_connection(const Ref<StreamPeer> &p_connection) override;
+ Ref<StreamPeer> get_connection() const override;
+ void close() override;
+ Status get_status() const override;
+ bool has_response() const override;
+ bool is_response_chunked() const override;
+ int get_response_code() const override;
+ Error get_response_headers(List<String> *r_response) override;
+ int get_response_body_length() const override;
+ PackedByteArray read_response_body_chunk() override;
+ void set_blocking_mode(bool p_enable) override;
+ bool is_blocking_mode_enabled() const override;
+ void set_read_chunk_size(int p_size) override;
+ int get_read_chunk_size() const override;
+ Error poll() override;
+ HTTPClientJavaScript();
+ ~HTTPClientJavaScript();
+};
+#endif // HTTP_CLIENT_JAVASCRIPT_H
diff --git a/platform/javascript/javascript_singleton.cpp b/platform/javascript/javascript_singleton.cpp
index c441ed0517..9de2edc9a7 100644
--- a/platform/javascript/javascript_singleton.cpp
+++ b/platform/javascript/javascript_singleton.cpp
@@ -54,6 +54,7 @@ extern int godot_js_wrapper_object_setvar(int p_id, int p_key_type, godot_js_wra
extern void godot_js_wrapper_object_set(int p_id, const char *p_name, int p_type, godot_js_wrapper_ex *p_val);
extern void godot_js_wrapper_object_unref(int p_id);
extern int godot_js_wrapper_create_cb(void *p_ref, void (*p_callback)(void *p_ref, int p_arg_id, int p_argc));
+extern void godot_js_wrapper_object_set_cb_ret(int p_type, godot_js_wrapper_ex *p_val);
extern int godot_js_wrapper_create_object(const char *p_method, void **p_args, int p_argc, GodotJSWrapperVariant2JSCallback p_variant2js_callback, godot_js_wrapper_ex *p_cb_rval, void **p_lock, GodotJSWrapperFreeLockCallback p_lock_callback);
};
@@ -257,6 +258,16 @@ void JavaScriptObjectImpl::_callback(void *p_ref, int p_args_id, int p_argc) {
Callable::CallError err;
Variant ret;
obj->_callable.call(argv, 1, ret, err);
+
+ // Set return value
+ godot_js_wrapper_ex exchange;
+ void *lock = nullptr;
+ const Variant *v = &ret;
+ int type = _variant2js((const void **)&v, 0, &exchange, &lock);
+ godot_js_wrapper_object_set_cb_ret(type, &exchange);
+ if (lock) {
+ _free_lock(&lock, type);
+ }
}
Ref<JavaScriptObject> JavaScript::create_callback(const Callable &p_callable) {
diff --git a/platform/javascript/js/libs/library_godot_javascript_singleton.js b/platform/javascript/js/libs/library_godot_javascript_singleton.js
index cb80273ca8..22ce003cd2 100644
--- a/platform/javascript/js/libs/library_godot_javascript_singleton.js
+++ b/platform/javascript/js/libs/library_godot_javascript_singleton.js
@@ -34,6 +34,7 @@ const GodotJSWrapper = {
$GodotJSWrapper__postset: 'GodotJSWrapper.proxies = new Map();',
$GodotJSWrapper: {
proxies: null,
+ cb_ret: null,
MyProxy: function (val) {
const id = IDHandler.add(this);
@@ -202,15 +203,27 @@ const GodotJSWrapper = {
let id = 0;
const cb = function () {
if (!GodotJSWrapper.get_proxied_value(id)) {
- return;
+ return undefined;
}
+ // The callback will store the returned value in this variable via
+ // "godot_js_wrapper_object_set_cb_ret" upon calling the user function.
+ // This is safe! JavaScript is single threaded (and using it in threads is not a good idea anyway).
+ GodotJSWrapper.cb_ret = null;
const args = Array.from(arguments);
func(p_ref, GodotJSWrapper.get_proxied(args), args.length);
+ const ret = GodotJSWrapper.cb_ret;
+ GodotJSWrapper.cb_ret = null;
+ return ret;
};
id = GodotJSWrapper.get_proxied(cb);
return id;
},
+ godot_js_wrapper_object_set_cb_ret__sig: 'vii',
+ godot_js_wrapper_object_set_cb_ret: function (p_val_type, p_val_ex) {
+ GodotJSWrapper.cb_ret = GodotJSWrapper.variant2js(p_val_type, p_val_ex);
+ },
+
godot_js_wrapper_object_getvar__sig: 'iiii',
godot_js_wrapper_object_getvar: function (p_id, p_type, p_exchange) {
const obj = GodotJSWrapper.get_proxied_value(p_id);
diff --git a/platform/linuxbsd/SCsub b/platform/linuxbsd/SCsub
index 1751d56e71..8aebd57fd2 100644
--- a/platform/linuxbsd/SCsub
+++ b/platform/linuxbsd/SCsub
@@ -9,6 +9,7 @@ common_linuxbsd = [
"crash_handler_linuxbsd.cpp",
"os_linuxbsd.cpp",
"joypad_linux.cpp",
+ "freedesktop_screensaver.cpp",
]
if "x11" in env and env["x11"]:
diff --git a/platform/linuxbsd/detect.py b/platform/linuxbsd/detect.py
index 1487210174..eba672ddcb 100644
--- a/platform/linuxbsd/detect.py
+++ b/platform/linuxbsd/detect.py
@@ -72,6 +72,7 @@ def get_opts():
BoolVariable("use_tsan", "Use LLVM/GCC compiler thread sanitizer (TSAN)", False),
BoolVariable("use_msan", "Use LLVM compiler memory sanitizer (MSAN)", False),
BoolVariable("pulseaudio", "Detect and use PulseAudio", True),
+ BoolVariable("dbus", "Detect and use D-Bus to handle screensaver", True),
BoolVariable("udev", "Use udev for gamepad connection callbacks", True),
BoolVariable("x11", "Enable X11 display", True),
BoolVariable("debug_symbols", "Add debugging symbols to release/release_debug builds", True),
@@ -347,6 +348,14 @@ def configure(env):
else:
print("PulseAudio development libraries not found, disabling driver")
+ if env["dbus"]:
+ if os.system("pkg-config --exists dbus-1") == 0: # 0 means found
+ print("Enabling D-Bus")
+ env.Append(CPPDEFINES=["DBUS_ENABLED"])
+ env.ParseConfig("pkg-config --cflags --libs dbus-1")
+ else:
+ print("D-Bus development libraries not found, disabling dependent features")
+
if platform.system() == "Linux":
env.Append(CPPDEFINES=["JOYDEV_ENABLED"])
if env["udev"]:
diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp
index 8b6922699c..fd652c0af2 100644
--- a/platform/linuxbsd/display_server_x11.cpp
+++ b/platform/linuxbsd/display_server_x11.cpp
@@ -121,6 +121,9 @@ bool DisplayServerX11::has_feature(Feature p_feature) const {
case FEATURE_ICON:
case FEATURE_NATIVE_ICON:
case FEATURE_SWAP_BUFFERS:
+#ifdef DBUS_ENABLED
+ case FEATURE_KEEP_SCREEN_ON:
+#endif
return true;
default: {
}
@@ -450,7 +453,7 @@ Point2i DisplayServerX11::mouse_get_absolute_position() const {
return Vector2i();
}
-int DisplayServerX11::mouse_get_button_state() const {
+MouseButton DisplayServerX11::mouse_get_button_state() const {
return last_button_state;
}
@@ -822,6 +825,26 @@ bool DisplayServerX11::screen_is_touchscreen(int p_screen) const {
return DisplayServer::screen_is_touchscreen(p_screen);
}
+#ifdef DBUS_ENABLED
+void DisplayServerX11::screen_set_keep_on(bool p_enable) {
+ if (screen_is_kept_on() == p_enable) {
+ return;
+ }
+
+ if (p_enable) {
+ screensaver->inhibit();
+ } else {
+ screensaver->uninhibit();
+ }
+
+ keep_screen_on = p_enable;
+}
+
+bool DisplayServerX11::screen_is_kept_on() const {
+ return keep_screen_on;
+}
+#endif
+
Vector<DisplayServer::WindowID> DisplayServerX11::get_window_list() const {
_THREAD_SAFE_METHOD_
@@ -2172,13 +2195,13 @@ void DisplayServerX11::_get_key_modifier_state(unsigned int p_x11_state, Ref<Inp
state->set_meta_pressed((p_x11_state & Mod4Mask));
}
-unsigned int DisplayServerX11::_get_mouse_button_state(unsigned int p_x11_button, int p_x11_type) {
- unsigned int mask = 1 << (p_x11_button - 1);
+MouseButton DisplayServerX11::_get_mouse_button_state(MouseButton p_x11_button, int p_x11_type) {
+ MouseButton mask = MouseButton(1 << (p_x11_button - 1));
if (p_x11_type == ButtonPress) {
last_button_state |= mask;
} else {
- last_button_state &= ~mask;
+ last_button_state &= MouseButton(~mask);
}
return last_button_state;
@@ -2255,7 +2278,7 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event,
tmp.parse_utf8(utf8string, utf8bytes);
for (int i = 0; i < tmp.length(); i++) {
Ref<InputEventKey> k;
- k.instance();
+ k.instantiate();
if (physical_keycode == 0 && keycode == 0 && tmp[i] == 0) {
continue;
}
@@ -2346,7 +2369,7 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event,
//print_verbose("mod1: "+itos(xkeyevent->state&Mod1Mask)+" mod 5: "+itos(xkeyevent->state&Mod5Mask));
Ref<InputEventKey> k;
- k.instance();
+ k.instantiate();
k->set_window_id(p_window);
_get_key_modifier_state(xkeyevent->state, k);
@@ -2904,7 +2927,7 @@ void DisplayServerX11::process_events() {
bool is_begin = event_data->evtype == XI_TouchBegin;
Ref<InputEventScreenTouch> st;
- st.instance();
+ st.instantiate();
st->set_window_id(window_id);
st->set_index(index);
st->set_position(pos);
@@ -2938,7 +2961,7 @@ void DisplayServerX11::process_events() {
if (curr_pos_elem->value() != pos) {
Ref<InputEventScreenDrag> sd;
- sd.instance();
+ sd.instantiate();
sd->set_window_id(window_id);
sd->set_index(index);
sd->set_position(pos);
@@ -3091,7 +3114,7 @@ void DisplayServerX11::process_events() {
// Release every pointer to avoid sticky points
for (Map<int, Vector2>::Element *E = xi.state.front(); E; E = E->next()) {
Ref<InputEventScreenTouch> st;
- st.instance();
+ st.instantiate();
st->set_index(E->key());
st->set_window_id(window_id);
st->set_position(E->get());
@@ -3126,15 +3149,15 @@ void DisplayServerX11::process_events() {
}
Ref<InputEventMouseButton> mb;
- mb.instance();
+ mb.instantiate();
mb->set_window_id(window_id);
_get_key_modifier_state(event.xbutton.state, mb);
- mb->set_button_index(event.xbutton.button);
- if (mb->get_button_index() == 2) {
- mb->set_button_index(3);
- } else if (mb->get_button_index() == 3) {
- mb->set_button_index(2);
+ mb->set_button_index((MouseButton)event.xbutton.button);
+ if (mb->get_button_index() == MOUSE_BUTTON_RIGHT) {
+ mb->set_button_index(MOUSE_BUTTON_MIDDLE);
+ } else if (mb->get_button_index() == MOUSE_BUTTON_MIDDLE) {
+ mb->set_button_index(MOUSE_BUTTON_RIGHT);
}
mb->set_button_mask(_get_mouse_button_state(mb->get_button_index(), event.xbutton.type));
mb->set_position(Vector2(event.xbutton.x, event.xbutton.y));
@@ -3291,13 +3314,13 @@ void DisplayServerX11::process_events() {
}
Ref<InputEventMouseMotion> mm;
- mm.instance();
+ mm.instantiate();
mm->set_window_id(window_id);
if (xi.pressure_supported) {
mm->set_pressure(xi.pressure);
} else {
- mm->set_pressure((mouse_get_button_state() & (1 << (MOUSE_BUTTON_LEFT - 1))) ? 1.0f : 0.0f);
+ mm->set_pressure((mouse_get_button_state() & MOUSE_BUTTON_MASK_LEFT) ? 1.0f : 0.0f);
}
mm->set_tilt(xi.tilt);
@@ -3855,8 +3878,6 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
img[i] = nullptr;
}
- last_button_state = 0;
-
xmbstring = nullptr;
last_click_ms = 0;
@@ -4272,6 +4293,11 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
_update_real_mouse_position(windows[MAIN_WINDOW_ID]);
+#ifdef DBUS_ENABLED
+ screensaver = memnew(FreeDesktopScreenSaver);
+ screen_set_keep_on(GLOBAL_DEF("display/window/energy_saving/keep_screen_on", true));
+#endif
+
r_error = OK;
}
@@ -4336,6 +4362,10 @@ DisplayServerX11::~DisplayServerX11() {
if (xmbstring) {
memfree(xmbstring);
}
+
+#ifdef DBUS_ENABLED
+ memdelete(screensaver);
+#endif
}
void DisplayServerX11::register_x11_driver() {
diff --git a/platform/linuxbsd/display_server_x11.h b/platform/linuxbsd/display_server_x11.h
index 10686d8424..707775a1da 100644
--- a/platform/linuxbsd/display_server_x11.h
+++ b/platform/linuxbsd/display_server_x11.h
@@ -55,6 +55,10 @@
#include "platform/linuxbsd/vulkan_context_x11.h"
#endif
+#if defined(DBUS_ENABLED)
+#include "freedesktop_screensaver.h"
+#endif
+
#include <X11/Xcursor/Xcursor.h>
#include <X11/Xlib.h>
#include <X11/extensions/XInput2.h>
@@ -103,6 +107,11 @@ class DisplayServerX11 : public DisplayServer {
RenderingDeviceVulkan *rendering_device_vulkan;
#endif
+#if defined(DBUS_ENABLED)
+ FreeDesktopScreenSaver *screensaver;
+ bool keep_screen_on = false;
+#endif
+
struct WindowData {
Window x11_window;
::XIC xic;
@@ -162,7 +171,7 @@ class DisplayServerX11 : public DisplayServer {
Point2i last_click_pos;
uint64_t last_click_ms;
int last_click_button_index;
- uint32_t last_button_state;
+ MouseButton last_button_state = MOUSE_BUTTON_NONE;
bool app_focused = false;
uint64_t time_since_no_focus = 0;
@@ -187,7 +196,7 @@ class DisplayServerX11 : public DisplayServer {
bool _refresh_device_info();
- unsigned int _get_mouse_button_state(unsigned int p_x11_button, int p_x11_type);
+ MouseButton _get_mouse_button_state(MouseButton p_x11_button, int p_x11_type);
void _get_key_modifier_state(unsigned int p_x11_state, Ref<InputEventWithModifiers> state);
void _flush_mouse_motion();
@@ -279,7 +288,7 @@ public:
virtual void mouse_warp_to_position(const Point2i &p_to);
virtual Point2i mouse_get_position() const;
virtual Point2i mouse_get_absolute_position() const;
- virtual int mouse_get_button_state() const;
+ virtual MouseButton mouse_get_button_state() const;
virtual void clipboard_set(const String &p_text);
virtual String clipboard_get() const;
@@ -291,6 +300,11 @@ public:
virtual int screen_get_dpi(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
virtual bool screen_is_touchscreen(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
+#if defined(DBUS_ENABLED)
+ virtual void screen_set_keep_on(bool p_enable);
+ virtual bool screen_is_kept_on() const;
+#endif
+
virtual Vector<DisplayServer::WindowID> get_window_list() const;
virtual WindowID create_sub_window(WindowMode p_mode, uint32_t p_flags, const Rect2i &p_rect = Rect2i());
diff --git a/platform/linuxbsd/export/export.cpp b/platform/linuxbsd/export/export.cpp
index 3ee088dd35..5c6be2d7d4 100644
--- a/platform/linuxbsd/export/export.cpp
+++ b/platform/linuxbsd/export/export.cpp
@@ -39,11 +39,11 @@ static Error fixup_embedded_pck(const String &p_path, int64_t p_embedded_start,
void register_linuxbsd_exporter() {
Ref<EditorExportPlatformPC> platform;
- platform.instance();
+ platform.instantiate();
Ref<Image> img = memnew(Image(_linuxbsd_logo));
Ref<ImageTexture> logo;
- logo.instance();
+ logo.instantiate();
logo->create_from_image(img);
platform->set_logo(logo);
platform->set_name("Linux/X11");
diff --git a/platform/linuxbsd/freedesktop_screensaver.cpp b/platform/linuxbsd/freedesktop_screensaver.cpp
new file mode 100644
index 0000000000..23093698ba
--- /dev/null
+++ b/platform/linuxbsd/freedesktop_screensaver.cpp
@@ -0,0 +1,124 @@
+/*************************************************************************/
+/* freedesktop_screensaver.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "freedesktop_screensaver.h"
+
+#ifdef DBUS_ENABLED
+
+#include "core/config/project_settings.h"
+
+#include <dbus/dbus.h>
+
+#define BUS_OBJECT_NAME "org.freedesktop.ScreenSaver"
+#define BUS_OBJECT_PATH "/org/freedesktop/ScreenSaver"
+#define BUS_INTERFACE "org.freedesktop.ScreenSaver"
+
+void FreeDesktopScreenSaver::inhibit() {
+ if (unsupported) {
+ return;
+ }
+
+ DBusError error;
+ dbus_error_init(&error);
+
+ DBusConnection *bus = dbus_bus_get(DBUS_BUS_SESSION, &error);
+ if (dbus_error_is_set(&error)) {
+ unsupported = true;
+ return;
+ }
+
+ String app_name_string = ProjectSettings::get_singleton()->get("application/config/name");
+ const char *app_name = app_name_string.is_empty() ? "Godot Engine" : app_name_string.utf8().get_data();
+
+ const char *reason = "Running Godot Engine project";
+
+ DBusMessage *message = dbus_message_new_method_call(
+ BUS_OBJECT_NAME, BUS_OBJECT_PATH, BUS_INTERFACE,
+ "Inhibit");
+ dbus_message_append_args(
+ message,
+ DBUS_TYPE_STRING, &app_name,
+ DBUS_TYPE_STRING, &reason,
+ DBUS_TYPE_INVALID);
+
+ DBusMessage *reply = dbus_connection_send_with_reply_and_block(bus, message, 50, &error);
+ dbus_message_unref(message);
+ if (dbus_error_is_set(&error)) {
+ dbus_connection_unref(bus);
+ unsupported = false;
+ return;
+ }
+
+ DBusMessageIter reply_iter;
+ dbus_message_iter_init(reply, &reply_iter);
+ dbus_message_iter_get_basic(&reply_iter, &cookie);
+ print_verbose("FreeDesktopScreenSaver: Acquired screensaver inhibition cookie: " + uitos(cookie));
+
+ dbus_message_unref(reply);
+ dbus_connection_unref(bus);
+}
+
+void FreeDesktopScreenSaver::uninhibit() {
+ if (unsupported) {
+ return;
+ }
+
+ DBusError error;
+ dbus_error_init(&error);
+
+ DBusConnection *bus = dbus_bus_get(DBUS_BUS_SESSION, &error);
+ if (dbus_error_is_set(&error)) {
+ unsupported = true;
+ return;
+ }
+
+ DBusMessage *message = dbus_message_new_method_call(
+ BUS_OBJECT_NAME, BUS_OBJECT_PATH, BUS_INTERFACE,
+ "UnInhibit");
+ dbus_message_append_args(
+ message,
+ DBUS_TYPE_UINT32, &cookie,
+ DBUS_TYPE_INVALID);
+
+ DBusMessage *reply = dbus_connection_send_with_reply_and_block(bus, message, 50, &error);
+ if (dbus_error_is_set(&error)) {
+ dbus_connection_unref(bus);
+ unsupported = true;
+ return;
+ }
+
+ print_verbose("FreeDesktopScreenSaver: Released screensaver inhibition cookie: " + uitos(cookie));
+
+ dbus_message_unref(message);
+ dbus_message_unref(reply);
+ dbus_connection_unref(bus);
+}
+
+#endif // DBUS_ENABLED
diff --git a/platform/linuxbsd/freedesktop_screensaver.h b/platform/linuxbsd/freedesktop_screensaver.h
new file mode 100644
index 0000000000..f27e60fce4
--- /dev/null
+++ b/platform/linuxbsd/freedesktop_screensaver.h
@@ -0,0 +1,47 @@
+/*************************************************************************/
+/* freedesktop_screensaver.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifdef DBUS_ENABLED
+
+#include <dbus/dbus.h>
+#include <stdint.h>
+
+class FreeDesktopScreenSaver {
+private:
+ uint32_t cookie = 0;
+ bool unsupported = false;
+
+public:
+ FreeDesktopScreenSaver() {}
+ void inhibit();
+ void uninhibit();
+};
+
+#endif // DBUS_ENABLED
diff --git a/platform/linuxbsd/joypad_linux.cpp b/platform/linuxbsd/joypad_linux.cpp
index e8f4352dff..8b6dbc4c20 100644
--- a/platform/linuxbsd/joypad_linux.cpp
+++ b/platform/linuxbsd/joypad_linux.cpp
@@ -475,7 +475,7 @@ void JoypadLinux::process_joypads() {
switch (ev.type) {
case EV_KEY:
- input->joy_button(i, joy->key_map[ev.code], ev.value);
+ input->joy_button(i, (JoyButton)joy->key_map[ev.code], ev.value);
break;
case EV_ABS:
@@ -484,29 +484,29 @@ void JoypadLinux::process_joypads() {
case ABS_HAT0X:
if (ev.value != 0) {
if (ev.value < 0) {
- joy->dpad = (joy->dpad | Input::HAT_MASK_LEFT) & ~Input::HAT_MASK_RIGHT;
+ joy->dpad = (HatMask)((joy->dpad | HatMask::HAT_MASK_LEFT) & ~HatMask::HAT_MASK_RIGHT);
} else {
- joy->dpad = (joy->dpad | Input::HAT_MASK_RIGHT) & ~Input::HAT_MASK_LEFT;
+ joy->dpad = (HatMask)((joy->dpad | HatMask::HAT_MASK_RIGHT) & ~HatMask::HAT_MASK_LEFT);
}
} else {
- joy->dpad &= ~(Input::HAT_MASK_LEFT | Input::HAT_MASK_RIGHT);
+ joy->dpad &= ~(HatMask::HAT_MASK_LEFT | HatMask::HAT_MASK_RIGHT);
}
- input->joy_hat(i, joy->dpad);
+ input->joy_hat(i, (HatMask)joy->dpad);
break;
case ABS_HAT0Y:
if (ev.value != 0) {
if (ev.value < 0) {
- joy->dpad = (joy->dpad | Input::HAT_MASK_UP) & ~Input::HAT_MASK_DOWN;
+ joy->dpad = (HatMask)((joy->dpad | HatMask::HAT_MASK_UP) & ~HatMask::HAT_MASK_DOWN);
} else {
- joy->dpad = (joy->dpad | Input::HAT_MASK_DOWN) & ~Input::HAT_MASK_UP;
+ joy->dpad = (HatMask)((joy->dpad | HatMask::HAT_MASK_DOWN) & ~HatMask::HAT_MASK_UP);
}
} else {
- joy->dpad &= ~(Input::HAT_MASK_UP | Input::HAT_MASK_DOWN);
+ joy->dpad &= ~(HatMask::HAT_MASK_UP | HatMask::HAT_MASK_DOWN);
}
- input->joy_hat(i, joy->dpad);
+ input->joy_hat(i, (HatMask)joy->dpad);
break;
default:
@@ -526,7 +526,7 @@ void JoypadLinux::process_joypads() {
for (int j = 0; j < MAX_ABS; j++) {
int index = joy->abs_map[j];
if (index != -1) {
- input->joy_axis(i, index, joy->curr_axis[index]);
+ input->joy_axis(i, (JoyAxis)index, joy->curr_axis[index]);
}
}
if (len == 0 || (len < 0 && errno != EAGAIN)) {
diff --git a/platform/osx/display_server_osx.h b/platform/osx/display_server_osx.h
index 9fac99810b..5f7f5f84a2 100644
--- a/platform/osx/display_server_osx.h
+++ b/platform/osx/display_server_osx.h
@@ -173,7 +173,7 @@ public:
MouseMode mouse_mode;
Point2i last_mouse_pos;
- uint32_t last_button_state;
+ MouseButton last_button_state = MOUSE_BUTTON_NONE;
bool window_focused;
bool drop_events;
@@ -217,7 +217,7 @@ public:
virtual void mouse_warp_to_position(const Point2i &p_to) override;
virtual Point2i mouse_get_position() const override;
virtual Point2i mouse_get_absolute_position() const override;
- virtual int mouse_get_button_state() const override;
+ virtual MouseButton mouse_get_button_state() const override;
virtual void clipboard_set(const String &p_text) override;
virtual String clipboard_get() const override;
diff --git a/platform/osx/display_server_osx.mm b/platform/osx/display_server_osx.mm
index 408feb4db9..4a672a4b17 100644
--- a/platform/osx/display_server_osx.mm
+++ b/platform/osx/display_server_osx.mm
@@ -119,7 +119,7 @@ static NSCursor *_cursorFromSelector(SEL selector, SEL fallback = nil) {
if ([event type] == NSEventTypeKeyDown) {
if (([event modifierFlags] & NSEventModifierFlagCommand) && [event keyCode] == 0x2f) {
Ref<InputEventKey> k;
- k.instance();
+ k.instantiate();
_get_key_modifier_state([event modifierFlags], k);
k->set_window_id(DisplayServerOSX::INVALID_WINDOW_ID);
@@ -813,18 +813,18 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
DS_OSX->cursor_set_shape(p_shape);
}
-static void _mouseDownEvent(DisplayServer::WindowID window_id, NSEvent *event, int index, int mask, bool pressed) {
+static void _mouseDownEvent(DisplayServer::WindowID window_id, NSEvent *event, MouseButton index, MouseButton mask, bool pressed) {
ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
if (pressed) {
DS_OSX->last_button_state |= mask;
} else {
- DS_OSX->last_button_state &= ~mask;
+ DS_OSX->last_button_state &= (MouseButton)~mask;
}
Ref<InputEventMouseButton> mb;
- mb.instance();
+ mb.instantiate();
mb->set_window_id(window_id);
const Vector2 pos = _get_mouse_pos(wd, [event locationInWindow]);
_get_key_modifier_state([event modifierFlags], mb);
@@ -928,7 +928,7 @@ static void _mouseDownEvent(DisplayServer::WindowID window_id, NSEvent *event, i
}
Ref<InputEventMouseMotion> mm;
- mm.instance();
+ mm.instantiate();
mm->set_window_id(window_id);
mm->set_button_mask(DS_OSX->last_button_state);
@@ -1016,7 +1016,7 @@ static void _mouseDownEvent(DisplayServer::WindowID window_id, NSEvent *event, i
DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
Ref<InputEventMagnifyGesture> ev;
- ev.instance();
+ ev.instantiate();
ev->set_window_id(window_id);
_get_key_modifier_state([event modifierFlags], ev);
ev->set_position(_get_mouse_pos(wd, [event locationInWindow]));
@@ -1485,14 +1485,14 @@ static int remapKey(unsigned int key, unsigned int state) {
}
}
-inline void sendScrollEvent(DisplayServer::WindowID window_id, int button, double factor, int modifierFlags) {
+inline void sendScrollEvent(DisplayServer::WindowID window_id, MouseButton button, double factor, int modifierFlags) {
ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
- unsigned int mask = 1 << (button - 1);
+ MouseButton mask = MouseButton(1 << (button - 1));
Ref<InputEventMouseButton> sc;
- sc.instance();
+ sc.instantiate();
sc->set_window_id(window_id);
_get_key_modifier_state(modifierFlags, sc);
@@ -1501,19 +1501,19 @@ inline void sendScrollEvent(DisplayServer::WindowID window_id, int button, doubl
sc->set_pressed(true);
sc->set_position(wd.mouse_pos);
sc->set_global_position(wd.mouse_pos);
- DS_OSX->last_button_state |= mask;
+ DS_OSX->last_button_state |= (MouseButton)mask;
sc->set_button_mask(DS_OSX->last_button_state);
Input::get_singleton()->accumulate_input_event(sc);
- sc.instance();
+ sc.instantiate();
sc->set_window_id(window_id);
sc->set_button_index(button);
sc->set_factor(factor);
sc->set_pressed(false);
sc->set_position(wd.mouse_pos);
sc->set_global_position(wd.mouse_pos);
- DS_OSX->last_button_state &= ~mask;
+ DS_OSX->last_button_state &= (MouseButton)~mask;
sc->set_button_mask(DS_OSX->last_button_state);
Input::get_singleton()->accumulate_input_event(sc);
@@ -1524,7 +1524,7 @@ inline void sendPanEvent(DisplayServer::WindowID window_id, double dx, double dy
DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
Ref<InputEventPanGesture> pg;
- pg.instance();
+ pg.instantiate();
pg->set_window_id(window_id);
_get_key_modifier_state(modifierFlags, pg);
@@ -2120,6 +2120,12 @@ void DisplayServerOSX::mouse_set_mode(MouseMode p_mode) {
ignore_warp = true;
warp_events.clear();
mouse_mode = p_mode;
+
+ if (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED) {
+ CursorShape p_shape = cursor_shape;
+ cursor_shape = DisplayServer::CURSOR_MAX;
+ cursor_set_shape(p_shape);
+ }
}
DisplayServer::MouseMode DisplayServerOSX::mouse_get_mode() const {
@@ -2173,7 +2179,7 @@ Point2i DisplayServerOSX::mouse_get_absolute_position() const {
return Vector2i();
}
-int DisplayServerOSX::mouse_get_button_state() const {
+MouseButton DisplayServerOSX::mouse_get_button_state() const {
return last_button_state;
}
@@ -3375,7 +3381,7 @@ void DisplayServerOSX::_process_key_events() {
const KeyEvent &ke = key_event_buffer[i];
if (ke.raw) {
// Non IME input - no composite characters, pass events as is
- k.instance();
+ k.instantiate();
k->set_window_id(ke.window_id);
_get_key_modifier_state(ke.osx_state, k);
@@ -3389,7 +3395,7 @@ void DisplayServerOSX::_process_key_events() {
} else {
// IME input
if ((i == 0 && ke.keycode == 0) || (i > 0 && key_event_buffer[i - 1].keycode == 0)) {
- k.instance();
+ k.instantiate();
k->set_window_id(ke.window_id);
_get_key_modifier_state(ke.osx_state, k);
@@ -3402,7 +3408,7 @@ void DisplayServerOSX::_process_key_events() {
_push_input(k);
}
if (ke.keycode != 0) {
- k.instance();
+ k.instantiate();
k->set_window_id(ke.window_id);
_get_key_modifier_state(ke.osx_state, k);
@@ -3755,7 +3761,6 @@ DisplayServerOSX::DisplayServerOSX(const String &p_rendering_driver, WindowMode
key_event_pos = 0;
mouse_mode = MOUSE_MODE_VISIBLE;
- last_button_state = 0;
autoreleasePool = [[NSAutoreleasePool alloc] init];
diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp
index f52853ca9e..f68ff32012 100644
--- a/platform/osx/export/export.cpp
+++ b/platform/osx/export/export.cpp
@@ -700,7 +700,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
}
} else {
Ref<Image> icon;
- icon.instance();
+ icon.instantiate();
icon->load(iconpath);
if (!icon->is_empty()) {
_make_icon(icon, data);
@@ -1151,7 +1151,7 @@ bool EditorExportPlatformOSX::can_export(const Ref<EditorExportPreset> &p_preset
EditorExportPlatformOSX::EditorExportPlatformOSX() {
Ref<Image> img = memnew(Image(_osx_logo));
- logo.instance();
+ logo.instantiate();
logo->create_from_image(img);
}
@@ -1160,7 +1160,7 @@ EditorExportPlatformOSX::~EditorExportPlatformOSX() {
void register_osx_exporter() {
Ref<EditorExportPlatformOSX> platform;
- platform.instance();
+ platform.instantiate();
EditorExport::get_singleton()->add_export_platform(platform);
}
diff --git a/platform/osx/joypad_osx.cpp b/platform/osx/joypad_osx.cpp
index b12526915f..126ebc1908 100644
--- a/platform/osx/joypad_osx.cpp
+++ b/platform/osx/joypad_osx.cpp
@@ -390,38 +390,38 @@ bool joypad::check_ff_features() {
static int process_hat_value(int p_min, int p_max, int p_value) {
int range = (p_max - p_min + 1);
int value = p_value - p_min;
- int hat_value = Input::HAT_MASK_CENTER;
+ int hat_value = HatMask::HAT_MASK_CENTER;
if (range == 4) {
value *= 2;
}
switch (value) {
case 0:
- hat_value = Input::HAT_MASK_UP;
+ hat_value = (HatMask)HatMask::HAT_MASK_UP;
break;
case 1:
- hat_value = Input::HAT_MASK_UP | Input::HAT_MASK_RIGHT;
+ hat_value = (HatMask)(HatMask::HAT_MASK_UP | HatMask::HAT_MASK_RIGHT);
break;
case 2:
- hat_value = Input::HAT_MASK_RIGHT;
+ hat_value = (HatMask)HatMask::HAT_MASK_RIGHT;
break;
case 3:
- hat_value = Input::HAT_MASK_DOWN | Input::HAT_MASK_RIGHT;
+ hat_value = (HatMask)(HatMask::HAT_MASK_DOWN | HatMask::HAT_MASK_RIGHT);
break;
case 4:
- hat_value = Input::HAT_MASK_DOWN;
+ hat_value = (HatMask)HatMask::HAT_MASK_DOWN;
break;
case 5:
- hat_value = Input::HAT_MASK_DOWN | Input::HAT_MASK_LEFT;
+ hat_value = (HatMask)(HatMask::HAT_MASK_DOWN | HatMask::HAT_MASK_LEFT);
break;
case 6:
- hat_value = Input::HAT_MASK_LEFT;
+ hat_value = (HatMask)HatMask::HAT_MASK_LEFT;
break;
case 7:
- hat_value = Input::HAT_MASK_UP | Input::HAT_MASK_LEFT;
+ hat_value = (HatMask)(HatMask::HAT_MASK_UP | HatMask::HAT_MASK_LEFT);
break;
default:
- hat_value = Input::HAT_MASK_CENTER;
+ hat_value = (HatMask)HatMask::HAT_MASK_CENTER;
break;
}
return hat_value;
@@ -458,17 +458,17 @@ void JoypadOSX::process_joypads() {
for (int j = 0; j < joy.axis_elements.size(); j++) {
rec_element &elem = joy.axis_elements.write[j];
int value = joy.get_hid_element_state(&elem);
- input->joy_axis(joy.id, j, axis_correct(value, elem.min, elem.max));
+ input->joy_axis(joy.id, (JoyAxis)j, axis_correct(value, elem.min, elem.max));
}
for (int j = 0; j < joy.button_elements.size(); j++) {
int value = joy.get_hid_element_state(&joy.button_elements.write[j]);
- input->joy_button(joy.id, j, (value >= 1));
+ input->joy_button(joy.id, (JoyButton)j, (value >= 1));
}
for (int j = 0; j < joy.hat_elements.size(); j++) {
rec_element &elem = joy.hat_elements.write[j];
int value = joy.get_hid_element_state(&elem);
int hat_value = process_hat_value(elem.min, elem.max, value);
- input->joy_hat(joy.id, hat_value);
+ input->joy_hat(joy.id, (HatMask)hat_value);
}
if (joy.ffservice) {
diff --git a/platform/uwp/app.cpp b/platform/uwp/app.cpp
index 67f054aeaa..1da17ffc5d 100644
--- a/platform/uwp/app.cpp
+++ b/platform/uwp/app.cpp
@@ -145,7 +145,7 @@ void App::SetWindow(CoreWindow ^ p_window) {
Main::setup2();
}
-static int _get_button(Windows::UI::Input::PointerPoint ^ pt) {
+static MouseButton _get_button(Windows::UI::Input::PointerPoint ^ pt) {
using namespace Windows::UI::Input;
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
@@ -177,7 +177,7 @@ static int _get_button(Windows::UI::Input::PointerPoint ^ pt) {
}
#endif
- return 0;
+ return MOUSE_BUTTON_NONE;
};
static bool _is_touch(Windows::UI::Input::PointerPoint ^ pointerPoint) {
@@ -241,10 +241,10 @@ static int _get_finger(uint32_t p_touch_id) {
void App::pointer_event(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args, bool p_pressed, bool p_is_wheel) {
Windows::UI::Input::PointerPoint ^ point = args->CurrentPoint;
Windows::Foundation::Point pos = _get_pixel_position(window, point->Position, os);
- int but = _get_button(point);
+ MouseButton but = _get_button(point);
if (_is_touch(point)) {
Ref<InputEventScreenTouch> screen_touch;
- screen_touch.instance();
+ screen_touch.instantiate();
screen_touch->set_device(0);
screen_touch->set_pressed(p_pressed);
screen_touch->set_position(Vector2(pos.X, pos.Y));
@@ -256,7 +256,7 @@ void App::pointer_event(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Cor
os->input_event(screen_touch);
} else {
Ref<InputEventMouseButton> mouse_button;
- mouse_button.instance();
+ mouse_button.instantiate();
mouse_button->set_device(0);
mouse_button->set_pressed(p_pressed);
mouse_button->set_button_index(but);
@@ -324,7 +324,7 @@ void App::OnPointerMoved(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Co
if (_is_touch(point)) {
Ref<InputEventScreenDrag> screen_drag;
- screen_drag.instance();
+ screen_drag.instantiate();
screen_drag->set_device(0);
screen_drag->set_position(Vector2(pos.X, pos.Y));
screen_drag->set_index(_get_finger(point->PointerId));
@@ -338,7 +338,7 @@ void App::OnPointerMoved(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Co
}
Ref<InputEventMouseMotion> mouse_motion;
- mouse_motion.instance();
+ mouse_motion.instantiate();
mouse_motion->set_device(0);
mouse_motion->set_position(Vector2(pos.X, pos.Y));
mouse_motion->set_global_position(Vector2(pos.X, pos.Y));
@@ -361,7 +361,7 @@ void App::OnMouseMoved(MouseDevice ^ mouse_device, MouseEventArgs ^ args) {
pos.Y = last_mouse_pos.Y + args->MouseDelta.Y;
Ref<InputEventMouseMotion> mouse_motion;
- mouse_motion.instance();
+ mouse_motion.instantiate();
mouse_motion->set_device(0);
mouse_motion->set_position(Vector2(pos.X, pos.Y));
mouse_motion->set_global_position(Vector2(pos.X, pos.Y));
diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp
index a7edc6e6e5..1075ae38ce 100644
--- a/platform/uwp/export/export.cpp
+++ b/platform/uwp/export/export.cpp
@@ -1429,7 +1429,7 @@ public:
EditorExportPlatformUWP() {
Ref<Image> img = memnew(Image(_uwp_logo));
- logo.instance();
+ logo.instantiate();
logo->create_from_image(img);
}
};
@@ -1446,6 +1446,6 @@ void register_uwp_exporter() {
#endif // WINDOWS_ENABLED
Ref<EditorExportPlatformUWP> exporter;
- exporter.instance();
+ exporter.instantiate();
EditorExport::get_singleton()->add_export_platform(exporter);
}
diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp
index 65934b6681..e26e204f5f 100644
--- a/platform/uwp/os_uwp.cpp
+++ b/platform/uwp/os_uwp.cpp
@@ -126,8 +126,6 @@ void OS_UWP::set_keep_screen_on(bool p_enabled) {
}
void OS_UWP::initialize_core() {
- last_button_state = 0;
-
//RedirectIOToConsole();
FileAccess::make_default<FileAccessWindows>(FileAccess::ACCESS_RESOURCES);
@@ -423,7 +421,7 @@ Point2 OS_UWP::get_mouse_position() const {
return Point2(old_x, old_y);
}
-int OS_UWP::get_mouse_button_state() const {
+MouseButton OS_UWP::get_mouse_button_state() const {
return last_button_state;
}
@@ -562,7 +560,7 @@ void OS_UWP::process_key_events() {
KeyEvent &kev = key_event_buffer[i];
Ref<InputEventKey> key_event;
- key_event.instance();
+ key_event.instantiate();
key_event->set_alt_pressed(kev.alt);
key_event->set_shift_pressed(kev.shift);
key_event->set_ctrl_pressed(kev.control);
diff --git a/platform/uwp/os_uwp.h b/platform/uwp/os_uwp.h
index a4d3d6d52a..3a735889b0 100644
--- a/platform/uwp/os_uwp.h
+++ b/platform/uwp/os_uwp.h
@@ -106,7 +106,7 @@ private:
bool control_mem;
bool meta_mem;
bool force_quit;
- uint32_t last_button_state;
+ MouseButton last_button_state = MOUSE_BUTTON_NONE;
CursorShape cursor_shape;
@@ -173,7 +173,7 @@ public:
MouseMode get_mouse_mode() const;
virtual Point2 get_mouse_position() const;
- virtual int get_mouse_button_state() const;
+ virtual MouseButton get_mouse_button_state() const;
virtual void set_window_title(const String &p_title);
virtual void set_video_mode(const VideoMode &p_video_mode, int p_screen = 0);
diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp
index f16595f379..f7172598ec 100644
--- a/platform/windows/display_server_windows.cpp
+++ b/platform/windows/display_server_windows.cpp
@@ -161,7 +161,7 @@ Point2i DisplayServerWindows::mouse_get_position() const {
//return Point2(old_x, old_y);
}
-int DisplayServerWindows::mouse_get_button_state() const {
+MouseButton DisplayServerWindows::mouse_get_button_state() const {
return last_button_state;
}
@@ -1727,7 +1727,7 @@ void DisplayServerWindows::_touch_event(WindowID p_window, bool p_pressed, float
}
Ref<InputEventScreenTouch> event;
- event.instance();
+ event.instantiate();
event->set_index(idx);
event->set_window_id(p_window);
event->set_pressed(p_pressed);
@@ -1746,7 +1746,7 @@ void DisplayServerWindows::_drag_event(WindowID p_window, float p_x, float p_y,
return;
Ref<InputEventScreenDrag> event;
- event.instance();
+ event.instantiate();
event->set_window_id(p_window);
event->set_index(idx);
event->set_position(Vector2(p_x, p_y));
@@ -1965,7 +1965,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
if (raw->header.dwType == RIM_TYPEMOUSE) {
Ref<InputEventMouseMotion> mm;
- mm.instance();
+ mm.instantiate();
mm->set_window_id(window_id);
mm->set_ctrl_pressed(control_mem);
@@ -2062,7 +2062,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
break;
Ref<InputEventMouseMotion> mm;
- mm.instance();
+ mm.instantiate();
mm->set_window_id(window_id);
mm->set_ctrl_pressed(GetKeyState(VK_CONTROL) < 0);
mm->set_shift_pressed(GetKeyState(VK_SHIFT) < 0);
@@ -2196,7 +2196,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
}
Ref<InputEventMouseMotion> mm;
- mm.instance();
+ mm.instantiate();
mm->set_window_id(window_id);
if (pen_info.penMask & PEN_MASK_PRESSURE) {
@@ -2302,7 +2302,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
}
Ref<InputEventMouseMotion> mm;
- mm.instance();
+ mm.instantiate();
mm->set_window_id(window_id);
mm->set_ctrl_pressed((wParam & MK_CONTROL) != 0);
mm->set_shift_pressed((wParam & MK_SHIFT) != 0);
@@ -2385,47 +2385,47 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
case WM_XBUTTONDOWN:
case WM_XBUTTONUP: {
Ref<InputEventMouseButton> mb;
- mb.instance();
+ mb.instantiate();
mb->set_window_id(window_id);
switch (uMsg) {
case WM_LBUTTONDOWN: {
mb->set_pressed(true);
- mb->set_button_index(1);
+ mb->set_button_index(MOUSE_BUTTON_LEFT);
} break;
case WM_LBUTTONUP: {
mb->set_pressed(false);
- mb->set_button_index(1);
+ mb->set_button_index(MOUSE_BUTTON_LEFT);
} break;
case WM_MBUTTONDOWN: {
mb->set_pressed(true);
- mb->set_button_index(3);
+ mb->set_button_index(MOUSE_BUTTON_MIDDLE);
} break;
case WM_MBUTTONUP: {
mb->set_pressed(false);
- mb->set_button_index(3);
+ mb->set_button_index(MOUSE_BUTTON_MIDDLE);
} break;
case WM_RBUTTONDOWN: {
mb->set_pressed(true);
- mb->set_button_index(2);
+ mb->set_button_index(MOUSE_BUTTON_RIGHT);
} break;
case WM_RBUTTONUP: {
mb->set_pressed(false);
- mb->set_button_index(2);
+ mb->set_button_index(MOUSE_BUTTON_RIGHT);
} break;
case WM_LBUTTONDBLCLK: {
mb->set_pressed(true);
- mb->set_button_index(1);
+ mb->set_button_index(MOUSE_BUTTON_LEFT);
mb->set_double_click(true);
} break;
case WM_RBUTTONDBLCLK: {
mb->set_pressed(true);
- mb->set_button_index(2);
+ mb->set_button_index(MOUSE_BUTTON_RIGHT);
mb->set_double_click(true);
} break;
case WM_MBUTTONDBLCLK: {
mb->set_pressed(true);
- mb->set_button_index(3);
+ mb->set_button_index(MOUSE_BUTTON_MIDDLE);
mb->set_double_click(true);
} break;
case WM_MOUSEWHEEL: {
@@ -2492,9 +2492,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
mb->set_alt_pressed(alt_mem);
//mb->is_alt_pressed()=(wParam&MK_MENU)!=0;
if (mb->is_pressed()) {
- last_button_state |= (1 << (mb->get_button_index() - 1));
+ last_button_state |= MouseButton(1 << (mb->get_button_index() - 1));
} else {
- last_button_state &= ~(1 << (mb->get_button_index() - 1));
+ last_button_state &= (MouseButton) ~(1 << (mb->get_button_index() - 1));
}
mb->set_button_mask(last_button_state);
@@ -2534,7 +2534,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
//send release for mouse wheel
Ref<InputEventMouseButton> mbd = mb->duplicate();
mbd->set_window_id(window_id);
- last_button_state &= ~(1 << (mbd->get_button_index() - 1));
+ last_button_state &= (MouseButton) ~(1 << (mbd->get_button_index() - 1));
mbd->set_button_mask(last_button_state);
mbd->set_pressed(false);
Input::get_singleton()->accumulate_input_event(mbd);
@@ -2843,7 +2843,7 @@ void DisplayServerWindows::_process_key_events() {
prev_wc = 0;
}
Ref<InputEventKey> k;
- k.instance();
+ k.instantiate();
k->set_window_id(ke.window_id);
k->set_shift_pressed(ke.shift);
@@ -2870,7 +2870,7 @@ void DisplayServerWindows::_process_key_events() {
case WM_KEYUP:
case WM_KEYDOWN: {
Ref<InputEventKey> k;
- k.instance();
+ k.instantiate();
k->set_window_id(ke.window_id);
k->set_shift_pressed(ke.shift);
diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.h
index a734077e59..d71e579c67 100644
--- a/platform/windows/display_server_windows.h
+++ b/platform/windows/display_server_windows.h
@@ -408,7 +408,7 @@ class DisplayServerWindows : public DisplayServer {
bool shift_mem = false;
bool control_mem = false;
bool meta_mem = false;
- uint32_t last_button_state = 0;
+ MouseButton last_button_state = MOUSE_BUTTON_NONE;
bool use_raw_input = false;
bool drop_events = false;
bool in_dispatch_input_event = false;
@@ -449,7 +449,7 @@ public:
virtual void mouse_warp_to_position(const Point2i &p_to);
virtual Point2i mouse_get_position() const;
- virtual int mouse_get_button_state() const;
+ virtual MouseButton mouse_get_button_state() const;
virtual void clipboard_set(const String &p_text);
virtual String clipboard_get() const;
diff --git a/platform/windows/export/export.cpp b/platform/windows/export/export.cpp
index 803d9371f5..10f953f2ec 100644
--- a/platform/windows/export/export.cpp
+++ b/platform/windows/export/export.cpp
@@ -310,7 +310,7 @@ Error EditorExportPlatformWindows::_code_sign(const Ref<EditorExportPreset> &p_p
args.push_back(p_path);
#ifndef WINDOWS_ENABLED
args.push_back("-out");
- args.push_back(p_path);
+ args.push_back(p_path + "_signed");
#endif
String str;
@@ -326,6 +326,16 @@ Error EditorExportPlatformWindows::_code_sign(const Ref<EditorExportPreset> &p_p
return FAILED;
}
+#ifndef WINDOWS_ENABLED
+ DirAccessRef tmp_dir = DirAccess::create_for_path(p_path.get_base_dir());
+
+ err = tmp_dir->remove(p_path);
+ ERR_FAIL_COND_V(err != OK, err);
+
+ err = tmp_dir->rename(p_path + "_signed", p_path);
+ ERR_FAIL_COND_V(err != OK, err);
+#endif
+
return OK;
}
@@ -344,11 +354,11 @@ void register_windows_exporter() {
#endif
Ref<EditorExportPlatformWindows> platform;
- platform.instance();
+ platform.instantiate();
Ref<Image> img = memnew(Image(_windows_logo));
Ref<ImageTexture> logo;
- logo.instance();
+ logo.instantiate();
logo->create_from_image(img);
platform->set_logo(logo);
platform->set_name("Windows Desktop");
diff --git a/platform/windows/joypad_windows.cpp b/platform/windows/joypad_windows.cpp
index da36dc1f2b..94da63e49d 100644
--- a/platform/windows/joypad_windows.cpp
+++ b/platform/windows/joypad_windows.cpp
@@ -330,7 +330,7 @@ void JoypadWindows::process_joypads() {
if (joy.state.dwPacketNumber != joy.last_packet) {
int button_mask = XINPUT_GAMEPAD_DPAD_UP;
for (int j = 0; j <= 16; j++) {
- input->joy_button(joy.id, j, joy.state.Gamepad.wButtons & button_mask);
+ input->joy_button(joy.id, (JoyButton)j, joy.state.Gamepad.wButtons & button_mask);
button_mask = button_mask * 2;
}
@@ -381,12 +381,12 @@ void JoypadWindows::process_joypads() {
for (int j = 0; j < 128; j++) {
if (js.rgbButtons[j] & 0x80) {
if (!joy->last_buttons[j]) {
- input->joy_button(joy->id, j, true);
+ input->joy_button(joy->id, (JoyButton)j, true);
joy->last_buttons[j] = true;
}
} else {
if (joy->last_buttons[j]) {
- input->joy_button(joy->id, j, false);
+ input->joy_button(joy->id, (JoyButton)j, false);
joy->last_buttons[j] = false;
}
}
@@ -400,7 +400,7 @@ void JoypadWindows::process_joypads() {
for (int j = 0; j < joy->joy_axis.size(); j++) {
for (int k = 0; k < count; k++) {
if (joy->joy_axis[j] == axes[k]) {
- input->joy_axis(joy->id, j, axis_correct(values[k]));
+ input->joy_axis(joy->id, (JoyAxis)j, axis_correct(values[k]));
break;
};
};
@@ -410,38 +410,38 @@ void JoypadWindows::process_joypads() {
}
void JoypadWindows::post_hat(int p_device, DWORD p_dpad) {
- int dpad_val = 0;
+ HatMask dpad_val = (HatMask)0;
// Should be -1 when centered, but according to docs:
// "Some drivers report the centered position of the POV indicator as 65,535. Determine whether the indicator is centered as follows:
// BOOL POVCentered = (LOWORD(dwPOV) == 0xFFFF);"
// https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ee416628(v%3Dvs.85)#remarks
if (LOWORD(p_dpad) == 0xFFFF) {
- dpad_val = Input::HAT_MASK_CENTER;
+ dpad_val = (HatMask)HatMask::HAT_MASK_CENTER;
}
if (p_dpad == 0) {
- dpad_val = Input::HAT_MASK_UP;
+ dpad_val = (HatMask)HatMask::HAT_MASK_UP;
} else if (p_dpad == 4500) {
- dpad_val = (Input::HAT_MASK_UP | Input::HAT_MASK_RIGHT);
+ dpad_val = (HatMask)(HatMask::HAT_MASK_UP | HatMask::HAT_MASK_RIGHT);
} else if (p_dpad == 9000) {
- dpad_val = Input::HAT_MASK_RIGHT;
+ dpad_val = (HatMask)HatMask::HAT_MASK_RIGHT;
} else if (p_dpad == 13500) {
- dpad_val = (Input::HAT_MASK_RIGHT | Input::HAT_MASK_DOWN);
+ dpad_val = (HatMask)(HatMask::HAT_MASK_RIGHT | HatMask::HAT_MASK_DOWN);
} else if (p_dpad == 18000) {
- dpad_val = Input::HAT_MASK_DOWN;
+ dpad_val = (HatMask)HatMask::HAT_MASK_DOWN;
} else if (p_dpad == 22500) {
- dpad_val = (Input::HAT_MASK_DOWN | Input::HAT_MASK_LEFT);
+ dpad_val = (HatMask)(HatMask::HAT_MASK_DOWN | HatMask::HAT_MASK_LEFT);
} else if (p_dpad == 27000) {
- dpad_val = Input::HAT_MASK_LEFT;
+ dpad_val = (HatMask)HatMask::HAT_MASK_LEFT;
} else if (p_dpad == 31500) {
- dpad_val = (Input::HAT_MASK_LEFT | Input::HAT_MASK_UP);
+ dpad_val = (HatMask)(HatMask::HAT_MASK_LEFT | HatMask::HAT_MASK_UP);
}
input->joy_hat(p_device, dpad_val);
};
diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp
index ca4b8d72a1..926997a715 100644
--- a/scene/2d/camera_2d.cpp
+++ b/scene/2d/camera_2d.cpp
@@ -724,7 +724,7 @@ void Camera2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "rotating"), "set_rotating", "is_rotating");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "current"), "_set_current", "is_current");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "zoom"), "set_zoom", "get_zoom");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "custom_viewport", PROPERTY_HINT_RESOURCE_TYPE, "Viewport", 0), "set_custom_viewport", "get_custom_viewport");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "custom_viewport", PROPERTY_HINT_RESOURCE_TYPE, "Viewport", PROPERTY_USAGE_NONE), "set_custom_viewport", "get_custom_viewport");
ADD_PROPERTY(PropertyInfo(Variant::INT, "process_callback", PROPERTY_HINT_ENUM, "Physics,Idle"), "set_process_callback", "get_process_callback");
ADD_GROUP("Limit", "limit_");
diff --git a/scene/2d/canvas_modulate.cpp b/scene/2d/canvas_modulate.cpp
index 52eabefbcb..4de99959a3 100644
--- a/scene/2d/canvas_modulate.cpp
+++ b/scene/2d/canvas_modulate.cpp
@@ -81,7 +81,7 @@ TypedArray<String> CanvasModulate::get_configuration_warnings() const {
get_tree()->get_nodes_in_group("_canvas_modulate_" + itos(get_canvas().get_id()), &nodes);
if (nodes.size() > 1) {
- warnings.push_back(TTR("Only one visible CanvasModulate is allowed per scene (or set of instanced scenes). The first created one will work, while the rest will be ignored."));
+ warnings.push_back(TTR("Only one visible CanvasModulate is allowed per scene (or set of instantiated scenes). The first created one will work, while the rest will be ignored."));
}
}
diff --git a/scene/2d/navigation_region_2d.cpp b/scene/2d/navigation_region_2d.cpp
index d2caf5bea8..ea639ae3a3 100644
--- a/scene/2d/navigation_region_2d.cpp
+++ b/scene/2d/navigation_region_2d.cpp
@@ -169,7 +169,7 @@ Ref<NavigationMesh> NavigationPolygon::get_mesh() {
MutexLock lock(navmesh_generation);
if (navmesh.is_null()) {
- navmesh.instance();
+ navmesh.instantiate();
Vector<Vector3> verts;
{
verts.resize(get_vertices().size());
diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp
index 049d121213..9d86ec88be 100644
--- a/scene/2d/node_2d.cpp
+++ b/scene/2d/node_2d.cpp
@@ -458,13 +458,13 @@ void Node2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scale"), "set_scale", "get_scale");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "skew", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_skew", "get_skew");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "skew_degrees", PROPERTY_HINT_RANGE, "-89.9,89.9,0.1", PROPERTY_USAGE_EDITOR), "set_skew_degrees", "get_skew_degrees");
- ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "transform", PROPERTY_HINT_NONE, "", 0), "set_transform", "get_transform");
+ ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "transform", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_transform", "get_transform");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "global_position", PROPERTY_HINT_NONE, "", 0), "set_global_position", "get_global_position");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "global_rotation", PROPERTY_HINT_NONE, "", 0), "set_global_rotation", "get_global_rotation");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "global_rotation_degrees", PROPERTY_HINT_NONE, "", 0), "set_global_rotation_degrees", "get_global_rotation_degrees");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "global_scale", PROPERTY_HINT_NONE, "", 0), "set_global_scale", "get_global_scale");
- ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "global_transform", PROPERTY_HINT_NONE, "", 0), "set_global_transform", "get_global_transform");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "global_position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_global_position", "get_global_position");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "global_rotation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_global_rotation", "get_global_rotation");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "global_rotation_degrees", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_global_rotation_degrees", "get_global_rotation_degrees");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "global_scale", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_global_scale", "get_global_scale");
+ ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "global_transform", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_global_transform", "get_global_transform");
ADD_GROUP("Ordering", "");
ADD_PROPERTY(PropertyInfo(Variant::INT, "z_index", PROPERTY_HINT_RANGE, itos(RS::CANVAS_ITEM_Z_MIN) + "," + itos(RS::CANVAS_ITEM_Z_MAX) + ",1"), "set_z_index", "get_z_index");
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index 4b72043a46..6c1cdc2129 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -64,7 +64,7 @@ Ref<KinematicCollision2D> PhysicsBody2D::_move(const Vector2 &p_motion, bool p_i
if (move_and_collide(p_motion, p_infinite_inertia, result, p_margin, p_exclude_raycast_shapes, p_test_only)) {
if (motion_cache.is_null()) {
- motion_cache.instance();
+ motion_cache.instantiate();
motion_cache->owner = this;
}
@@ -856,7 +856,7 @@ void RigidBody2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Dynamic,Static,DynamicLocked,Kinematic"), "set_mode", "get_mode");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "mass", PROPERTY_HINT_EXP_RANGE, "0.01,65535,0.01"), "set_mass", "get_mass");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "inertia", PROPERTY_HINT_EXP_RANGE, "0.01,65535,0.01", 0), "set_inertia", "get_inertia");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "inertia", PROPERTY_HINT_EXP_RANGE, "0.01,65535,0.01", PROPERTY_USAGE_NONE), "set_inertia", "get_inertia");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "physics_material_override", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsMaterial"), "set_physics_material_override", "get_physics_material_override");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "gravity_scale", PROPERTY_HINT_RANGE, "-128,128,0.01"), "set_gravity_scale", "get_gravity_scale");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "custom_integrator"), "set_use_custom_integrator", "is_using_custom_integrator");
@@ -1120,7 +1120,7 @@ Ref<KinematicCollision2D> CharacterBody2D::_get_slide_collision(int p_bounce) {
}
if (slide_colliders[p_bounce].is_null()) {
- slide_colliders.write[p_bounce].instance();
+ slide_colliders.write[p_bounce].instantiate();
slide_colliders.write[p_bounce]->owner = this;
}
@@ -1352,6 +1352,10 @@ ObjectID KinematicCollision2D::get_collider_id() const {
return result.collider_id;
}
+RID KinematicCollision2D::get_collider_rid() const {
+ return result.collider;
+}
+
Object *KinematicCollision2D::get_collider_shape() const {
Object *collider = get_collider();
if (collider) {
@@ -1385,6 +1389,7 @@ void KinematicCollision2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_local_shape"), &KinematicCollision2D::get_local_shape);
ClassDB::bind_method(D_METHOD("get_collider"), &KinematicCollision2D::get_collider);
ClassDB::bind_method(D_METHOD("get_collider_id"), &KinematicCollision2D::get_collider_id);
+ ClassDB::bind_method(D_METHOD("get_collider_rid"), &KinematicCollision2D::get_collider_rid);
ClassDB::bind_method(D_METHOD("get_collider_shape"), &KinematicCollision2D::get_collider_shape);
ClassDB::bind_method(D_METHOD("get_collider_shape_index"), &KinematicCollision2D::get_collider_shape_index);
ClassDB::bind_method(D_METHOD("get_collider_velocity"), &KinematicCollision2D::get_collider_velocity);
@@ -1397,6 +1402,7 @@ void KinematicCollision2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "local_shape"), "", "get_local_shape");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "collider"), "", "get_collider");
ADD_PROPERTY(PropertyInfo(Variant::INT, "collider_id"), "", "get_collider_id");
+ ADD_PROPERTY(PropertyInfo(Variant::RID, "collider_rid"), "", "get_collider_rid");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "collider_shape"), "", "get_collider_shape");
ADD_PROPERTY(PropertyInfo(Variant::INT, "collider_shape_index"), "", "get_collider_shape_index");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "collider_velocity"), "", "get_collider_velocity");
diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h
index 423f792132..f084a247aa 100644
--- a/scene/2d/physics_body_2d.h
+++ b/scene/2d/physics_body_2d.h
@@ -357,6 +357,7 @@ public:
Object *get_local_shape() const;
Object *get_collider() const;
ObjectID get_collider_id() const;
+ RID get_collider_rid() const;
Object *get_collider_shape() const;
int get_collider_shape_index() const;
Vector2 get_collider_velocity() const;
diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp
index 21083e6a4b..860e95b51e 100644
--- a/scene/2d/polygon_2d.cpp
+++ b/scene/2d/polygon_2d.cpp
@@ -365,7 +365,7 @@ void Polygon2D::_notification(int p_what) {
arr[RS::ARRAY_INDEX] = index_array;
RS::get_singleton()->mesh_add_surface_from_arrays(mesh, RS::PRIMITIVE_TRIANGLES, arr, Array(), Dictionary(), RS::ARRAY_FLAG_USE_2D_VERTICES);
- RS::get_singleton()->canvas_item_add_mesh(get_canvas_item(), mesh, Transform2D(), Color(), texture.is_valid() ? texture->get_rid() : RID());
+ RS::get_singleton()->canvas_item_add_mesh(get_canvas_item(), mesh, Transform2D(), Color(1, 1, 1), texture.is_valid() ? texture->get_rid() : RID());
}
} break;
@@ -658,7 +658,7 @@ void Polygon2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "texture_offset"), "set_texture_offset", "get_texture_offset");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "texture_scale"), "set_texture_scale", "get_texture_scale");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "texture_rotation_degrees", PROPERTY_HINT_RANGE, "-360,360,0.1,or_lesser,or_greater"), "set_texture_rotation_degrees", "get_texture_rotation_degrees");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "texture_rotation", PROPERTY_HINT_NONE, "", 0), "set_texture_rotation", "get_texture_rotation");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "texture_rotation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_texture_rotation", "get_texture_rotation");
ADD_GROUP("Skeleton", "");
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "skeleton", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "Skeleton2D"), "set_skeleton", "get_skeleton");
diff --git a/scene/2d/touch_screen_button.cpp b/scene/2d/touch_screen_button.cpp
index 4e58984b37..0a6393551c 100644
--- a/scene/2d/touch_screen_button.cpp
+++ b/scene/2d/touch_screen_button.cpp
@@ -288,7 +288,7 @@ void TouchScreenButton::_press(int p_finger_pressed) {
if (action != StringName()) {
Input::get_singleton()->action_press(action);
Ref<InputEventAction> iea;
- iea.instance();
+ iea.instantiate();
iea->set_action(action);
iea->set_pressed(true);
get_viewport()->input(iea, true);
@@ -305,7 +305,7 @@ void TouchScreenButton::_release(bool p_exiting_tree) {
Input::get_singleton()->action_release(action);
if (!p_exiting_tree) {
Ref<InputEventAction> iea;
- iea.instance();
+ iea.instantiate();
iea->set_action(action);
iea->set_pressed(false);
get_viewport()->input(iea, true);
diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp
index 9640043031..e05f37c73c 100644
--- a/scene/3d/audio_stream_player_3d.cpp
+++ b/scene/3d/audio_stream_player_3d.cpp
@@ -997,7 +997,7 @@ void AudioStreamPlayer3D::_bind_methods() {
}
AudioStreamPlayer3D::AudioStreamPlayer3D() {
- velocity_tracker.instance();
+ velocity_tracker.instantiate();
AudioServer::get_singleton()->connect("bus_layout_changed", callable_mp(this, &AudioStreamPlayer3D::_bus_layout_changed));
set_disable_scale(true);
}
diff --git a/scene/3d/camera_3d.cpp b/scene/3d/camera_3d.cpp
index 62bbebe6e7..32006d5e7f 100644
--- a/scene/3d/camera_3d.cpp
+++ b/scene/3d/camera_3d.cpp
@@ -661,7 +661,7 @@ Camera3D::Camera3D() {
set_perspective(75.0, 0.05, 4000.0);
RenderingServer::get_singleton()->camera_set_cull_mask(camera, layers);
//active=false;
- velocity_tracker.instance();
+ velocity_tracker.instantiate();
set_notify_transform(true);
set_disable_scale(true);
}
diff --git a/scene/3d/gpu_particles_collision_3d.cpp b/scene/3d/gpu_particles_collision_3d.cpp
index 322bc60fce..c1e71b9565 100644
--- a/scene/3d/gpu_particles_collision_3d.cpp
+++ b/scene/3d/gpu_particles_collision_3d.cpp
@@ -495,7 +495,7 @@ Ref<Image> GPUParticlesCollisionSDF::bake() {
_compute_sdf(&params);
Ref<Image> ret;
- ret.instance();
+ ret.instantiate();
ret->create(sdf_size.x, sdf_size.y * sdf_size.z, false, Image::FORMAT_RF, data);
ret->convert(Image::FORMAT_RH); //convert to half, save space
ret->set_meta("depth", sdf_size.z); //hack, make sure to add to the docs of this function
diff --git a/scene/3d/light_3d.cpp b/scene/3d/light_3d.cpp
index d45749d36b..37881c3332 100644
--- a/scene/3d/light_3d.cpp
+++ b/scene/3d/light_3d.cpp
@@ -353,7 +353,7 @@ Light3D::Light3D(RenderingServer::LightType p_type) {
}
Light3D::Light3D() {
- ERR_PRINT("Light3D should not be instanced directly; use the DirectionalLight3D, OmniLight3D or SpotLight3D subtypes instead.");
+ ERR_PRINT("Light3D should not be instantiated directly; use the DirectionalLight3D, OmniLight3D or SpotLight3D subtypes instead.");
}
Light3D::~Light3D() {
diff --git a/scene/3d/lightmap_gi.cpp b/scene/3d/lightmap_gi.cpp
index a3f681e53c..74b4269169 100644
--- a/scene/3d/lightmap_gi.cpp
+++ b/scene/3d/lightmap_gi.cpp
@@ -717,7 +717,7 @@ LightmapGI::BakeError LightmapGI::bake(Node *p_from_node, String p_image_data_pa
w_albedo[i + 3] = 255;
}
- md.albedo_on_uv2.instance();
+ md.albedo_on_uv2.instantiate();
md.albedo_on_uv2->create(lightmap_size.width, lightmap_size.height, false, Image::FORMAT_RGBA8, albedom);
}
@@ -940,7 +940,7 @@ LightmapGI::BakeError LightmapGI::bake(Node *p_from_node, String p_image_data_pa
} break;
case ENVIRONMENT_MODE_CUSTOM_COLOR: {
- environment_image.instance();
+ environment_image.instantiate();
environment_image->create(128, 64, false, Image::FORMAT_RGBAF);
Color c = environment_custom_color;
c.r *= environment_custom_energy;
@@ -972,7 +972,7 @@ LightmapGI::BakeError LightmapGI::bake(Node *p_from_node, String p_image_data_pa
}
//we assume they are all the same, so let's create a large one for saving
Ref<Image> large_image;
- large_image.instance();
+ large_image.instantiate();
large_image->create(images[0]->get_width(), images[0]->get_height() * images.size(), false, images[0]->get_format());
@@ -984,7 +984,7 @@ LightmapGI::BakeError LightmapGI::bake(Node *p_from_node, String p_image_data_pa
Ref<ConfigFile> config;
- config.instance();
+ config.instantiate();
if (FileAccess::exists(base_path + ".import")) {
config->load(base_path + ".import");
}
@@ -1017,7 +1017,7 @@ LightmapGI::BakeError LightmapGI::bake(Node *p_from_node, String p_image_data_pa
set_light_data(Ref<LightmapGIData>()); //clear
data->clear();
} else {
- data.instance();
+ data.instantiate();
}
data->set_light_texture(texture);
diff --git a/scene/3d/mesh_instance_3d.cpp b/scene/3d/mesh_instance_3d.cpp
index c495f68890..08dec232ab 100644
--- a/scene/3d/mesh_instance_3d.cpp
+++ b/scene/3d/mesh_instance_3d.cpp
@@ -405,14 +405,14 @@ void MeshInstance3D::create_debug_tangents() {
if (lines.size()) {
Ref<StandardMaterial3D> sm;
- sm.instance();
+ sm.instantiate();
sm->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
sm->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true);
sm->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
Ref<ArrayMesh> am;
- am.instance();
+ am.instantiate();
Array a;
a.resize(Mesh::ARRAY_MAX);
a[Mesh::ARRAY_VERTEX] = lines;
diff --git a/scene/3d/node_3d.cpp b/scene/3d/node_3d.cpp
index e96b8ee1f9..f78a2ff14e 100644
--- a/scene/3d/node_3d.cpp
+++ b/scene/3d/node_3d.cpp
@@ -813,10 +813,10 @@ void Node3D::_bind_methods() {
//ADD_PROPERTY( PropertyInfo(Variant::TRANSFORM3D,"transform/global",PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR ), "set_global_transform", "get_global_transform") ;
ADD_GROUP("Transform", "");
- ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM3D, "global_transform", PROPERTY_HINT_NONE, "", 0), "set_global_transform", "get_global_transform");
+ ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM3D, "global_transform", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_global_transform", "get_global_transform");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_position", "get_position");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation_degrees", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_rotation_degrees", "get_rotation_degrees");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation", PROPERTY_HINT_NONE, "", 0), "set_rotation", "get_rotation");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_rotation", "get_rotation");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "scale", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_scale", "get_scale");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "top_level"), "set_as_top_level", "is_set_as_top_level");
ADD_GROUP("Matrix", "");
@@ -824,7 +824,7 @@ void Node3D::_bind_methods() {
ADD_GROUP("Visibility", "");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "visible"), "set_visible", "is_visible");
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "visibility_parent", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "GeometryInstance3D"), "set_visibility_parent", "get_visibility_parent");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "gizmo", PROPERTY_HINT_RESOURCE_TYPE, "Node3DGizmo", 0), "set_gizmo", "get_gizmo");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "gizmo", PROPERTY_HINT_RESOURCE_TYPE, "Node3DGizmo", PROPERTY_USAGE_NONE), "set_gizmo", "get_gizmo");
ADD_SIGNAL(MethodInfo("visibility_changed"));
}
diff --git a/scene/3d/occluder_instance_3d.cpp b/scene/3d/occluder_instance_3d.cpp
index 429e1d4b98..b0b9668fd2 100644
--- a/scene/3d/occluder_instance_3d.cpp
+++ b/scene/3d/occluder_instance_3d.cpp
@@ -114,7 +114,7 @@ Ref<ArrayMesh> Occluder3D::get_debug_mesh() const {
arrays[Mesh::ARRAY_VERTEX] = vertices;
arrays[Mesh::ARRAY_INDEX] = indices;
- debug_mesh.instance();
+ debug_mesh.instantiate();
debug_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, arrays);
return debug_mesh;
}
@@ -303,7 +303,7 @@ OccluderInstance3D::BakeError OccluderInstance3D::bake(Node *p_from_node, String
if (get_occluder().is_valid()) {
occ = get_occluder();
} else {
- occ.instance();
+ occ.instantiate();
occ->set_path(p_occluder_path);
}
diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp
index 25c7c3d798..8e10a37afb 100644
--- a/scene/3d/physics_body_3d.cpp
+++ b/scene/3d/physics_body_3d.cpp
@@ -106,7 +106,7 @@ Ref<KinematicCollision3D> PhysicsBody3D::_move(const Vector3 &p_motion, bool p_i
PhysicsServer3D::MotionResult result;
if (move_and_collide(p_motion, p_infinite_inertia, result, p_margin, p_exclude_raycast_shapes, p_test_only)) {
if (motion_cache.is_null()) {
- motion_cache.instance();
+ motion_cache.instantiate();
motion_cache->owner = this;
}
@@ -1168,7 +1168,7 @@ Ref<KinematicCollision3D> CharacterBody3D::_get_slide_collision(int p_bounce) {
}
if (slide_colliders[p_bounce].is_null()) {
- slide_colliders.write[p_bounce].instance();
+ slide_colliders.write[p_bounce].instantiate();
slide_colliders.write[p_bounce]->owner = this;
}
@@ -1337,6 +1337,10 @@ ObjectID KinematicCollision3D::get_collider_id() const {
return result.collider_id;
}
+RID KinematicCollision3D::get_collider_rid() const {
+ return result.collider;
+}
+
Object *KinematicCollision3D::get_collider_shape() const {
Object *collider = get_collider();
if (collider) {
@@ -1370,6 +1374,7 @@ void KinematicCollision3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_local_shape"), &KinematicCollision3D::get_local_shape);
ClassDB::bind_method(D_METHOD("get_collider"), &KinematicCollision3D::get_collider);
ClassDB::bind_method(D_METHOD("get_collider_id"), &KinematicCollision3D::get_collider_id);
+ ClassDB::bind_method(D_METHOD("get_collider_rid"), &KinematicCollision3D::get_collider_rid);
ClassDB::bind_method(D_METHOD("get_collider_shape"), &KinematicCollision3D::get_collider_shape);
ClassDB::bind_method(D_METHOD("get_collider_shape_index"), &KinematicCollision3D::get_collider_shape_index);
ClassDB::bind_method(D_METHOD("get_collider_velocity"), &KinematicCollision3D::get_collider_velocity);
@@ -1382,6 +1387,7 @@ void KinematicCollision3D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "local_shape"), "", "get_local_shape");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "collider"), "", "get_collider");
ADD_PROPERTY(PropertyInfo(Variant::INT, "collider_id"), "", "get_collider_id");
+ ADD_PROPERTY(PropertyInfo(Variant::RID, "collider_rid"), "", "get_collider_rid");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "collider_shape"), "", "get_collider_shape");
ADD_PROPERTY(PropertyInfo(Variant::INT, "collider_shape_index"), "", "get_collider_shape_index");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "collider_velocity"), "", "get_collider_velocity");
@@ -2187,7 +2193,7 @@ void PhysicalBone3D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "joint_type", PROPERTY_HINT_ENUM, "None,PinJoint,ConeJoint,HingeJoint,SliderJoint,6DOFJoint"), "set_joint_type", "get_joint_type");
ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM3D, "joint_offset"), "set_joint_offset", "get_joint_offset");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "joint_rotation_degrees", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_joint_rotation_degrees", "get_joint_rotation_degrees");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "joint_rotation", PROPERTY_HINT_NONE, "", 0), "set_joint_rotation", "get_joint_rotation");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "joint_rotation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_joint_rotation", "get_joint_rotation");
ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM3D, "body_offset"), "set_body_offset", "get_body_offset");
diff --git a/scene/3d/physics_body_3d.h b/scene/3d/physics_body_3d.h
index 8df3635be0..7d7adf1624 100644
--- a/scene/3d/physics_body_3d.h
+++ b/scene/3d/physics_body_3d.h
@@ -358,6 +358,7 @@ public:
Object *get_local_shape() const;
Object *get_collider() const;
ObjectID get_collider_id() const;
+ RID get_collider_rid() const;
Object *get_collider_shape() const;
int get_collider_shape_index() const;
Vector3 get_collider_velocity() const;
diff --git a/scene/3d/ray_cast_3d.cpp b/scene/3d/ray_cast_3d.cpp
index db841101e5..dfab3d4a17 100644
--- a/scene/3d/ray_cast_3d.cpp
+++ b/scene/3d/ray_cast_3d.cpp
@@ -419,6 +419,8 @@ void RayCast3D::_update_debug_shape_material(bool p_check_collision) {
debug_material = material;
material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
+ // Use double-sided rendering so that the RayCast can be seen if the camera is inside.
+ material->set_cull_mode(BaseMaterial3D::CULL_DISABLED);
material->set_transparency(BaseMaterial3D::TRANSPARENCY_ALPHA);
}
diff --git a/scene/3d/reflection_probe.h b/scene/3d/reflection_probe.h
index 15c2da3ae0..4bf20c89c5 100644
--- a/scene/3d/reflection_probe.h
+++ b/scene/3d/reflection_probe.h
@@ -55,7 +55,7 @@ private:
RID probe;
float intensity = 1.0;
float max_distance = 0.0;
- Vector3 extents = Vector3(1, 1, 1);
+ Vector3 extents = Vector3(10, 10, 10);
Vector3 origin_offset = Vector3(0, 0, 0);
bool box_projection = false;
bool enable_shadows = false;
diff --git a/scene/3d/skeleton_3d.cpp b/scene/3d/skeleton_3d.cpp
index f9d613a4bb..fa3b16935c 100644
--- a/scene/3d/skeleton_3d.cpp
+++ b/scene/3d/skeleton_3d.cpp
@@ -797,7 +797,7 @@ Ref<SkinReference> Skeleton3D::register_skin(const Ref<Skin> &p_skin) {
//when skeletons did not support skins. It is also used by gizmo
//to display the skeleton.
- skin.instance();
+ skin.instantiate();
skin->set_bind_count(bones.size());
_update_process_order(); //just in case
@@ -826,7 +826,7 @@ Ref<SkinReference> Skeleton3D::register_skin(const Ref<Skin> &p_skin) {
ERR_FAIL_COND_V(skin.is_null(), Ref<SkinReference>());
Ref<SkinReference> skin_ref;
- skin_ref.instance();
+ skin_ref.instantiate();
skin_ref->skeleton_node = this;
skin_ref->bind_count = 0;
diff --git a/scene/3d/soft_body_3d.cpp b/scene/3d/soft_body_3d.cpp
index df5474d03e..9592fe5849 100644
--- a/scene/3d/soft_body_3d.cpp
+++ b/scene/3d/soft_body_3d.cpp
@@ -465,7 +465,7 @@ void SoftBody3D::become_mesh_owner() {
surface_format |= Mesh::ARRAY_FLAG_USE_DYNAMIC_UPDATE;
Ref<ArrayMesh> soft_mesh;
- soft_mesh.instance();
+ soft_mesh.instantiate();
soft_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, surface_arrays, surface_blend_arrays, surface_lods, surface_format);
soft_mesh->surface_set_material(0, mesh->surface_get_material(0));
diff --git a/scene/3d/voxel_gi.cpp b/scene/3d/voxel_gi.cpp
index e00be9204c..5558930df8 100644
--- a/scene/3d/voxel_gi.cpp
+++ b/scene/3d/voxel_gi.cpp
@@ -55,7 +55,7 @@ void VoxelGIData::_set_data(const Dictionary &p_data) {
} else if (p_data.has("octree_df_png")) {
Vector<uint8_t> octree_df_png = p_data["octree_df_png"];
Ref<Image> img;
- img.instance();
+ img.instantiate();
Error err = img->load_png_from_buffer(octree_df_png);
ERR_FAIL_COND(err != OK);
ERR_FAIL_COND(img->get_format() != Image::FORMAT_L8);
@@ -76,7 +76,7 @@ Dictionary VoxelGIData::_get_data() const {
d["octree_data"] = get_data_cells();
if (otsize != Vector3i()) {
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create(otsize.x * otsize.y, otsize.z, false, Image::FORMAT_L8, get_distance_field());
Vector<uint8_t> df_png = img->save_png_to_buffer();
ERR_FAIL_COND_V(df_png.size() == 0, Dictionary());
@@ -467,7 +467,7 @@ void VoxelGI::bake(Node *p_from_node, bool p_create_visual_debug) {
Ref<VoxelGIData> probe_data = get_probe_data();
if (probe_data.is_null()) {
- probe_data.instance();
+ probe_data.instantiate();
}
if (bake_step_function) {
diff --git a/scene/3d/voxelizer.cpp b/scene/3d/voxelizer.cpp
index ee0c3fe9b6..12f055c01d 100644
--- a/scene/3d/voxelizer.cpp
+++ b/scene/3d/voxelizer.cpp
@@ -931,14 +931,14 @@ void Voxelizer::_debug_mesh(int p_idx, int p_level, const AABB &p_aabb, Ref<Mult
Ref<MultiMesh> Voxelizer::create_debug_multimesh() {
Ref<MultiMesh> mm;
- mm.instance();
+ mm.instantiate();
mm->set_transform_format(MultiMesh::TRANSFORM_3D);
mm->set_use_colors(true);
mm->set_instance_count(leaf_voxel_count);
Ref<ArrayMesh> mesh;
- mesh.instance();
+ mesh.instantiate();
{
Array arr;
@@ -985,7 +985,7 @@ Ref<MultiMesh> Voxelizer::create_debug_multimesh() {
{
Ref<StandardMaterial3D> fsm;
- fsm.instance();
+ fsm.instantiate();
fsm->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true);
fsm->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
fsm->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
diff --git a/scene/3d/world_environment.cpp b/scene/3d/world_environment.cpp
index 829ecc5ec2..352bef072f 100644
--- a/scene/3d/world_environment.cpp
+++ b/scene/3d/world_environment.cpp
@@ -145,7 +145,7 @@ TypedArray<String> WorldEnvironment::get_configuration_warnings() const {
}
if (camera_effects.is_valid() && get_viewport()->find_world_3d()->get_camera_effects() != camera_effects) {
- warnings.push_back(TTR("Only one WorldEnvironment is allowed per scene (or set of instanced scenes)."));
+ warnings.push_back(TTR("Only one WorldEnvironment is allowed per scene (or set of instantiated scenes)."));
}
return warnings;
diff --git a/scene/3d/xr_nodes.cpp b/scene/3d/xr_nodes.cpp
index 4f2c816934..a91e712b0b 100644
--- a/scene/3d/xr_nodes.cpp
+++ b/scene/3d/xr_nodes.cpp
@@ -204,7 +204,7 @@ void XRController3D::_notification(int p_what) {
// check button states
for (int i = 0; i < 16; i++) {
bool was_pressed = (button_states & mask) == mask;
- bool is_pressed = Input::get_singleton()->is_joy_button_pressed(joy_id, i);
+ bool is_pressed = Input::get_singleton()->is_joy_button_pressed(joy_id, (JoyButton)i);
if (!was_pressed && is_pressed) {
emit_signal("button_pressed", i);
@@ -304,7 +304,7 @@ bool XRController3D::is_button_pressed(int p_button) const {
return false;
};
- return Input::get_singleton()->is_joy_button_pressed(joy_id, p_button);
+ return Input::get_singleton()->is_joy_button_pressed(joy_id, (JoyButton)p_button);
};
float XRController3D::get_joystick_axis(int p_axis) const {
@@ -313,7 +313,7 @@ float XRController3D::get_joystick_axis(int p_axis) const {
return 0.0;
};
- return Input::get_singleton()->get_joy_axis(joy_id, p_axis);
+ return Input::get_singleton()->get_joy_axis(joy_id, (JoyAxis)p_axis);
};
real_t XRController3D::get_rumble() const {
diff --git a/scene/animation/animation_blend_tree.cpp b/scene/animation/animation_blend_tree.cpp
index 79a1dc1ac0..ad6115fa16 100644
--- a/scene/animation/animation_blend_tree.cpp
+++ b/scene/animation/animation_blend_tree.cpp
@@ -1164,7 +1164,7 @@ void AnimationNodeBlendTree::_bind_methods() {
AnimationNodeBlendTree::AnimationNodeBlendTree() {
Ref<AnimationNodeOutput> output;
- output.instance();
+ output.instantiate();
Node n;
n.node = output;
n.position = Vector2(300, 150);
diff --git a/scene/animation/animation_node_state_machine.cpp b/scene/animation/animation_node_state_machine.cpp
index 65918a2989..f494f5c163 100644
--- a/scene/animation/animation_node_state_machine.cpp
+++ b/scene/animation/animation_node_state_machine.cpp
@@ -496,7 +496,7 @@ void AnimationNodeStateMachinePlayback::_bind_methods() {
}
AnimationNodeStateMachinePlayback::AnimationNodeStateMachinePlayback() {
- set_local_to_scene(true); //only one per instanced scene
+ set_local_to_scene(true); //only one per instantiated scene
}
///////////////////////////////////////////////////////
@@ -520,7 +520,7 @@ void AnimationNodeStateMachine::get_parameter_list(List<PropertyInfo> *r_list) c
Variant AnimationNodeStateMachine::get_parameter_default_value(const StringName &p_parameter) const {
if (p_parameter == playback) {
Ref<AnimationNodeStateMachinePlayback> p;
- p.instance();
+ p.instantiate();
return p;
} else {
return false; //advance condition
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index 2d565fc47a..799c81c2ab 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -1511,7 +1511,7 @@ Ref<AnimatedValuesBackup> AnimationPlayer::backup_animated_values(Node *p_root_o
_ensure_node_caches(playback.current.from, p_root_override);
- backup.instance();
+ backup.instantiate();
for (int i = 0; i < playback.current.from->node_cache.size(); i++) {
TrackNodeCache *nc = playback.current.from->node_cache[i];
if (!nc) {
@@ -1657,16 +1657,16 @@ void AnimationPlayer::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "root_node"), "set_root", "get_root");
ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "current_animation", PROPERTY_HINT_ENUM, "", PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_ANIMATE_AS_TRIGGER), "set_current_animation", "get_current_animation");
- ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "assigned_animation", PROPERTY_HINT_NONE, "", 0), "set_assigned_animation", "get_assigned_animation");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "assigned_animation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_assigned_animation", "get_assigned_animation");
ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "autoplay", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_autoplay", "get_autoplay");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "reset_on_save", PROPERTY_HINT_NONE, ""), "set_reset_on_save_enabled", "is_reset_on_save_enabled");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "current_animation_length", PROPERTY_HINT_NONE, "", 0), "", "get_current_animation_length");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "current_animation_position", PROPERTY_HINT_NONE, "", 0), "", "get_current_animation_position");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "current_animation_length", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_current_animation_length");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "current_animation_position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_current_animation_position");
ADD_GROUP("Playback Options", "playback_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "playback_process_mode", PROPERTY_HINT_ENUM, "Physics,Idle,Manual"), "set_process_callback", "get_process_callback");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "playback_default_blend_time", PROPERTY_HINT_RANGE, "0,4096,0.01"), "set_default_blend_time", "get_default_blend_time");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "playback_active", PROPERTY_HINT_NONE, "", 0), "set_active", "is_active");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "playback_active", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_active", "is_active");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "playback_speed", PROPERTY_HINT_RANGE, "-64,64,0.01"), "set_speed_scale", "get_speed_scale");
ADD_PROPERTY(PropertyInfo(Variant::INT, "method_call_mode", PROPERTY_HINT_ENUM, "Deferred,Immediate"), "set_method_call_mode", "get_method_call_mode");
diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp
index b4e597f75e..7bf616e602 100644
--- a/scene/animation/tween.cpp
+++ b/scene/animation/tween.cpp
@@ -30,535 +30,407 @@
#include "tween.h"
-void Tween::_add_pending_command(StringName p_key, const Variant &p_arg1, const Variant &p_arg2, const Variant &p_arg3, const Variant &p_arg4, const Variant &p_arg5, const Variant &p_arg6, const Variant &p_arg7, const Variant &p_arg8, const Variant &p_arg9, const Variant &p_arg10) {
- // Add a new pending command and reference it
- pending_commands.push_back(PendingCommand());
- PendingCommand &cmd = pending_commands.back()->get();
-
- // Update the command with the target key
- cmd.key = p_key;
-
- // Determine command argument count
- int &count = cmd.args;
- if (p_arg10.get_type() != Variant::NIL) {
- count = 10;
- } else if (p_arg9.get_type() != Variant::NIL) {
- count = 9;
- } else if (p_arg8.get_type() != Variant::NIL) {
- count = 8;
- } else if (p_arg7.get_type() != Variant::NIL) {
- count = 7;
- } else if (p_arg6.get_type() != Variant::NIL) {
- count = 6;
- } else if (p_arg5.get_type() != Variant::NIL) {
- count = 5;
- } else if (p_arg4.get_type() != Variant::NIL) {
- count = 4;
- } else if (p_arg3.get_type() != Variant::NIL) {
- count = 3;
- } else if (p_arg2.get_type() != Variant::NIL) {
- count = 2;
- } else if (p_arg1.get_type() != Variant::NIL) {
- count = 1;
- } else {
- count = 0;
- }
+#include "scene/main/node.h"
- // Add the specified arguments to the command
- if (count > 0) {
- cmd.arg[0] = p_arg1;
- }
- if (count > 1) {
- cmd.arg[1] = p_arg2;
- }
- if (count > 2) {
- cmd.arg[2] = p_arg3;
- }
- if (count > 3) {
- cmd.arg[3] = p_arg4;
- }
- if (count > 4) {
- cmd.arg[4] = p_arg5;
- }
- if (count > 5) {
- cmd.arg[5] = p_arg6;
- }
- if (count > 6) {
- cmd.arg[6] = p_arg7;
- }
- if (count > 7) {
- cmd.arg[7] = p_arg8;
- }
- if (count > 8) {
- cmd.arg[8] = p_arg9;
+void Tweener::set_tween(Ref<Tween> p_tween) {
+ tween = p_tween;
+}
+
+void Tweener::_bind_methods() {
+ ADD_SIGNAL(MethodInfo("finished"));
+}
+
+void Tween::start_tweeners() {
+ if (tweeners.is_empty()) {
+ dead = true;
+ ERR_FAIL_MSG("Tween without commands, aborting.");
}
- if (count > 9) {
- cmd.arg[9] = p_arg10;
+
+ for (List<Ref<Tweener>>::Element *E = tweeners.write[current_step].front(); E; E = E->next()) {
+ E->get()->start();
}
}
-void Tween::_process_pending_commands() {
- // For each pending command...
- for (List<PendingCommand>::Element *E = pending_commands.front(); E; E = E->next()) {
- // Get the command
- PendingCommand &cmd = E->get();
- Callable::CallError err;
-
- // Grab all of the arguments for the command
- Variant *arg[10] = {
- &cmd.arg[0],
- &cmd.arg[1],
- &cmd.arg[2],
- &cmd.arg[3],
- &cmd.arg[4],
- &cmd.arg[5],
- &cmd.arg[6],
- &cmd.arg[7],
- &cmd.arg[8],
- &cmd.arg[9],
- };
-
- // Execute the command (and retrieve any errors)
- this->call(cmd.key, (const Variant **)arg, cmd.args, err);
- }
+Ref<PropertyTweener> Tween::tween_property(Object *p_target, NodePath p_property, Variant p_to, float p_duration) {
+ ERR_FAIL_NULL_V(p_target, nullptr);
+ ERR_FAIL_COND_V_MSG(invalid, nullptr, "Tween was created outside the scene tree, can't use Tweeners.");
+ ERR_FAIL_COND_V_MSG(started, nullptr, "Can't append to a Tween that has started. Use stop() first.");
- // Clear the pending commands
- pending_commands.clear();
+ Ref<PropertyTweener> tweener = memnew(PropertyTweener(p_target, p_property, p_to, p_duration));
+ append(tweener);
+ return tweener;
}
-bool Tween::_set(const StringName &p_name, const Variant &p_value) {
- // Set the correct attribute based on the given name
- String name = p_name;
- if (name == "playback/speed" || name == "speed") { // Backwards compatibility
- set_speed_scale(p_value);
- return true;
+Ref<IntervalTweener> Tween::tween_interval(float p_time) {
+ ERR_FAIL_COND_V_MSG(invalid, nullptr, "Tween was created outside the scene tree, can't use Tweeners.");
+ ERR_FAIL_COND_V_MSG(started, nullptr, "Can't append to a Tween that has started. Use stop() first.");
- } else if (name == "playback/active") {
- set_active(p_value);
- return true;
+ Ref<IntervalTweener> tweener = memnew(IntervalTweener(p_time));
+ append(tweener);
+ return tweener;
+}
- } else if (name == "playback/repeat") {
- set_repeat(p_value);
- return true;
- }
- return false;
+Ref<CallbackTweener> Tween::tween_callback(Callable p_callback) {
+ ERR_FAIL_COND_V_MSG(invalid, nullptr, "Tween was created outside the scene tree, can't use Tweeners.");
+ ERR_FAIL_COND_V_MSG(started, nullptr, "Can't append to a Tween that has started. Use stop() first.");
+
+ Ref<CallbackTweener> tweener = memnew(CallbackTweener(p_callback));
+ append(tweener);
+ return tweener;
}
-bool Tween::_get(const StringName &p_name, Variant &r_ret) const {
- // Get the correct attribute based on the given name
- String name = p_name;
- if (name == "playback/speed") { // Backwards compatibility
- r_ret = speed_scale;
- return true;
+Ref<MethodTweener> Tween::tween_method(Callable p_callback, float p_from, float p_to, float p_duration) {
+ ERR_FAIL_COND_V_MSG(invalid, nullptr, "Tween was created outside the scene tree, can't use Tweeners.");
+ ERR_FAIL_COND_V_MSG(started, nullptr, "Can't append to a Tween that has started. Use stop() first.");
- } else if (name == "playback/active") {
- r_ret = is_active();
- return true;
+ Ref<MethodTweener> tweener = memnew(MethodTweener(p_callback, p_from, p_to, p_duration));
+ append(tweener);
+ return tweener;
+}
- } else if (name == "playback/repeat") {
- r_ret = is_repeat();
- return true;
+Ref<Tween> Tween::append(Ref<Tweener> p_tweener) {
+ ERR_FAIL_COND_V_MSG(invalid, nullptr, "Tween was created outside the scene tree, can't use Tweeners.");
+ ERR_FAIL_COND_V_MSG(started, nullptr, "Can't append to a Tween that has started. Use stop() first.");
+ p_tweener->set_tween(this);
+
+ if (parallel_enabled) {
+ current_step = MAX(current_step, 0);
+ } else {
+ current_step++;
}
- return false;
-}
-
-void Tween::_get_property_list(List<PropertyInfo> *p_list) const {
- // Add the property info for the Tween object
- p_list->push_back(PropertyInfo(Variant::BOOL, "playback/active", PROPERTY_HINT_NONE, ""));
- p_list->push_back(PropertyInfo(Variant::BOOL, "playback/repeat", PROPERTY_HINT_NONE, ""));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "playback/speed", PROPERTY_HINT_RANGE, "-64,64,0.01"));
-}
-
-void Tween::_notification(int p_what) {
- // What notification did we receive?
- switch (p_what) {
- case NOTIFICATION_ENTER_TREE: {
- // Are we not already active?
- if (!is_active()) {
- // Make sure that a previous process state was not saved
- // Only process if "processing" is set
- set_physics_process_internal(false);
- set_process_internal(false);
- }
- } break;
+ parallel_enabled = default_parallel;
- case NOTIFICATION_READY: {
- // Do nothing
- } break;
+ tweeners.resize(current_step + 1);
+ tweeners.write[current_step].push_back(p_tweener);
- case NOTIFICATION_INTERNAL_PROCESS: {
- // Are we processing during physics time?
- if (tween_process_mode == TWEEN_PROCESS_PHYSICS) {
- // Do nothing since we aren't aligned with physics when we should be
- break;
- }
+ return this;
+}
- // Should we update?
- if (is_active()) {
- // Update the tweens
- _tween_process(get_process_delta_time());
- }
- } break;
+void Tween::stop() {
+ started = false;
+ running = false;
+ dead = false;
+}
- case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
- // Are we processing during 'regular' time?
- if (tween_process_mode == TWEEN_PROCESS_IDLE) {
- // Do nothing since we would only process during idle time
- break;
- }
+void Tween::pause() {
+ running = false;
+}
- // Should we update?
- if (is_active()) {
- // Update the tweens
- _tween_process(get_physics_process_delta_time());
- }
- } break;
+void Tween::play() {
+ ERR_FAIL_COND_MSG(invalid, "Tween invalid, can't play.");
+ ERR_FAIL_COND_MSG(dead, "Can't play finished Tween, use stop() first to reset its state.");
+ running = true;
+}
- case NOTIFICATION_EXIT_TREE: {
- // We've left the tree. Stop all tweens
- stop_all();
- } break;
- }
+void Tween::kill() {
+ running = false; // For the sake of is_running().
+ dead = true;
}
-void Tween::_bind_methods() {
- // Bind getters and setters
- ClassDB::bind_method(D_METHOD("is_active"), &Tween::is_active);
- ClassDB::bind_method(D_METHOD("set_active", "active"), &Tween::set_active);
+bool Tween::is_running() {
+ return running;
+}
- ClassDB::bind_method(D_METHOD("is_repeat"), &Tween::is_repeat);
- ClassDB::bind_method(D_METHOD("set_repeat", "repeat"), &Tween::set_repeat);
+void Tween::set_valid(bool p_valid) {
+ invalid = !p_valid;
+}
- ClassDB::bind_method(D_METHOD("set_speed_scale", "speed"), &Tween::set_speed_scale);
- ClassDB::bind_method(D_METHOD("get_speed_scale"), &Tween::get_speed_scale);
-
- ClassDB::bind_method(D_METHOD("set_tween_process_mode", "mode"), &Tween::set_tween_process_mode);
- ClassDB::bind_method(D_METHOD("get_tween_process_mode"), &Tween::get_tween_process_mode);
-
- // Bind the various Tween control methods
- ClassDB::bind_method(D_METHOD("start"), &Tween::start);
- ClassDB::bind_method(D_METHOD("reset", "object", "key"), &Tween::reset, DEFVAL(""));
- ClassDB::bind_method(D_METHOD("reset_all"), &Tween::reset_all);
- ClassDB::bind_method(D_METHOD("stop", "object", "key"), &Tween::stop, DEFVAL(""));
- ClassDB::bind_method(D_METHOD("stop_all"), &Tween::stop_all);
- ClassDB::bind_method(D_METHOD("resume", "object", "key"), &Tween::resume, DEFVAL(""));
- ClassDB::bind_method(D_METHOD("resume_all"), &Tween::resume_all);
- ClassDB::bind_method(D_METHOD("remove", "object", "key"), &Tween::remove, DEFVAL(""));
- ClassDB::bind_method(D_METHOD("_remove_by_uid", "uid"), &Tween::_remove_by_uid);
- ClassDB::bind_method(D_METHOD("remove_all"), &Tween::remove_all);
- ClassDB::bind_method(D_METHOD("seek", "time"), &Tween::seek);
- ClassDB::bind_method(D_METHOD("tell"), &Tween::tell);
- ClassDB::bind_method(D_METHOD("get_runtime"), &Tween::get_runtime);
-
- // Bind interpolation and follow methods
- ClassDB::bind_method(D_METHOD("interpolate_property", "object", "property", "initial_val", "final_val", "duration", "trans_type", "ease_type", "delay"), &Tween::interpolate_property, DEFVAL(TRANS_LINEAR), DEFVAL(EASE_IN_OUT), DEFVAL(0));
- ClassDB::bind_method(D_METHOD("interpolate_method", "object", "method", "initial_val", "final_val", "duration", "trans_type", "ease_type", "delay"), &Tween::interpolate_method, DEFVAL(TRANS_LINEAR), DEFVAL(EASE_IN_OUT), DEFVAL(0));
- ClassDB::bind_method(D_METHOD("interpolate_callback", "object", "duration", "callback", "arg1", "arg2", "arg3", "arg4", "arg5"), &Tween::interpolate_callback, DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()));
- ClassDB::bind_method(D_METHOD("interpolate_deferred_callback", "object", "duration", "callback", "arg1", "arg2", "arg3", "arg4", "arg5"), &Tween::interpolate_deferred_callback, DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()));
- ClassDB::bind_method(D_METHOD("follow_property", "object", "property", "initial_val", "target", "target_property", "duration", "trans_type", "ease_type", "delay"), &Tween::follow_property, DEFVAL(TRANS_LINEAR), DEFVAL(EASE_IN_OUT), DEFVAL(0));
- ClassDB::bind_method(D_METHOD("follow_method", "object", "method", "initial_val", "target", "target_method", "duration", "trans_type", "ease_type", "delay"), &Tween::follow_method, DEFVAL(TRANS_LINEAR), DEFVAL(EASE_IN_OUT), DEFVAL(0));
- ClassDB::bind_method(D_METHOD("targeting_property", "object", "property", "initial", "initial_val", "final_val", "duration", "trans_type", "ease_type", "delay"), &Tween::targeting_property, DEFVAL(TRANS_LINEAR), DEFVAL(EASE_IN_OUT), DEFVAL(0));
- ClassDB::bind_method(D_METHOD("targeting_method", "object", "method", "initial", "initial_method", "final_val", "duration", "trans_type", "ease_type", "delay"), &Tween::targeting_method, DEFVAL(TRANS_LINEAR), DEFVAL(EASE_IN_OUT), DEFVAL(0));
-
- // Add the Tween signals
- ADD_SIGNAL(MethodInfo("tween_started", PropertyInfo(Variant::OBJECT, "object"), PropertyInfo(Variant::NODE_PATH, "key")));
- ADD_SIGNAL(MethodInfo("tween_step", PropertyInfo(Variant::OBJECT, "object"), PropertyInfo(Variant::NODE_PATH, "key"), PropertyInfo(Variant::FLOAT, "elapsed"), PropertyInfo(Variant::OBJECT, "value")));
- ADD_SIGNAL(MethodInfo("tween_completed", PropertyInfo(Variant::OBJECT, "object"), PropertyInfo(Variant::NODE_PATH, "key")));
- ADD_SIGNAL(MethodInfo("tween_all_completed"));
-
- // Add the properties and tie them to the getters and setters
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "repeat"), "set_repeat", "is_repeat");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "playback_process_mode", PROPERTY_HINT_ENUM, "Physics,Idle"), "set_tween_process_mode", "get_tween_process_mode");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "playback_speed", PROPERTY_HINT_RANGE, "-64,64,0.01"), "set_speed_scale", "get_speed_scale");
-
- // Bind Idle vs Physics process
- BIND_ENUM_CONSTANT(TWEEN_PROCESS_PHYSICS);
- BIND_ENUM_CONSTANT(TWEEN_PROCESS_IDLE);
+bool Tween::is_valid() {
+ return invalid;
+}
- // Bind the Transition type constants
- BIND_ENUM_CONSTANT(TRANS_LINEAR);
- BIND_ENUM_CONSTANT(TRANS_SINE);
- BIND_ENUM_CONSTANT(TRANS_QUINT);
- BIND_ENUM_CONSTANT(TRANS_QUART);
- BIND_ENUM_CONSTANT(TRANS_QUAD);
- BIND_ENUM_CONSTANT(TRANS_EXPO);
- BIND_ENUM_CONSTANT(TRANS_ELASTIC);
- BIND_ENUM_CONSTANT(TRANS_CUBIC);
- BIND_ENUM_CONSTANT(TRANS_CIRC);
- BIND_ENUM_CONSTANT(TRANS_BOUNCE);
- BIND_ENUM_CONSTANT(TRANS_BACK);
+Ref<Tween> Tween::bind_node(Node *p_node) {
+ bound_node = p_node->get_instance_id();
+ is_bound = true;
+ return this;
+}
- // Bind the easing constants
- BIND_ENUM_CONSTANT(EASE_IN);
- BIND_ENUM_CONSTANT(EASE_OUT);
- BIND_ENUM_CONSTANT(EASE_IN_OUT);
- BIND_ENUM_CONSTANT(EASE_OUT_IN);
+Ref<Tween> Tween::set_process_mode(TweenProcessMode p_mode) {
+ process_mode = p_mode;
+ return this;
}
-Variant Tween::_get_initial_val(const InterpolateData &p_data) const {
- // What type of data are we interpolating?
- switch (p_data.type) {
- case INTER_PROPERTY:
- case INTER_METHOD:
- case FOLLOW_PROPERTY:
- case FOLLOW_METHOD:
- // Simply use the given initial value
- return p_data.initial_val;
-
- case TARGETING_PROPERTY:
- case TARGETING_METHOD: {
- // Get the object that is being targeted
- Object *object = ObjectDB::get_instance(p_data.target_id);
- ERR_FAIL_COND_V(object == nullptr, p_data.initial_val);
-
- // Are we targeting a property or a method?
- Variant initial_val;
- if (p_data.type == TARGETING_PROPERTY) {
- // Get the property from the target object
- bool valid = false;
- initial_val = object->get_indexed(p_data.target_key, &valid);
- ERR_FAIL_COND_V(!valid, p_data.initial_val);
- } else {
- // Call the method and get the initial value from it
- Callable::CallError error;
- initial_val = object->call(p_data.target_key[0], nullptr, 0, error);
- ERR_FAIL_COND_V(error.error != Callable::CallError::CALL_OK, p_data.initial_val);
- }
- return initial_val;
- }
+Tween::TweenProcessMode Tween::get_process_mode() {
+ return process_mode;
+}
+
+Ref<Tween> Tween::set_pause_mode(TweenPauseMode p_mode) {
+ pause_mode = p_mode;
+ return this;
+}
+
+Tween::TweenPauseMode Tween::get_pause_mode() {
+ return pause_mode;
+}
+
+Ref<Tween> Tween::set_parallel(bool p_parallel) {
+ default_parallel = p_parallel;
+ parallel_enabled = p_parallel;
+ return this;
+}
+
+Ref<Tween> Tween::set_loops(int p_loops) {
+ loops = p_loops;
+ return this;
+}
+
+Ref<Tween> Tween::set_speed_scale(float p_speed) {
+ speed_scale = p_speed;
+ return this;
+}
+
+Ref<Tween> Tween::set_trans(TransitionType p_trans) {
+ default_transition = p_trans;
+ return this;
+}
- case INTER_CALLBACK:
- // Callback does not have a special initial value
- break;
+Tween::TransitionType Tween::get_trans() {
+ return default_transition;
+}
+
+Ref<Tween> Tween::set_ease(EaseType p_ease) {
+ default_ease = p_ease;
+ return this;
+}
+
+Tween::EaseType Tween::get_ease() {
+ return default_ease;
+}
+
+Ref<Tween> Tween::parallel() {
+ parallel_enabled = true;
+ return this;
+}
+
+Ref<Tween> Tween::chain() {
+ parallel_enabled = false;
+ return this;
+}
+
+bool Tween::custom_step(float p_delta) {
+ bool r = running;
+ running = true;
+ bool ret = step(p_delta);
+ running = running && r; // Running might turn false when Tween finished.
+ return ret;
+}
+
+bool Tween::step(float p_delta) {
+ ERR_FAIL_COND_V_MSG(tweeners.is_empty(), false, "Tween started, but has no Tweeners.");
+
+ if (dead) {
+ return false;
}
- // If we've made it here, just return the delta value as the initial value
- return p_data.delta_val;
-}
-
-Variant Tween::_get_final_val(const InterpolateData &p_data) const {
- switch (p_data.type) {
- case FOLLOW_PROPERTY:
- case FOLLOW_METHOD: {
- // Get the object that is being followed
- Object *target = ObjectDB::get_instance(p_data.target_id);
- ERR_FAIL_COND_V(target == nullptr, p_data.initial_val);
-
- // We want to figure out the final value
- Variant final_val;
- if (p_data.type == FOLLOW_PROPERTY) {
- // Read the property as-is
- bool valid = false;
- final_val = target->get_indexed(p_data.target_key, &valid);
- ERR_FAIL_COND_V(!valid, p_data.initial_val);
- } else {
- // We're looking at a method. Call the method on the target object
- Callable::CallError error;
- final_val = target->call(p_data.target_key[0], nullptr, 0, error);
- ERR_FAIL_COND_V(error.error != Callable::CallError::CALL_OK, p_data.initial_val);
- }
- // If we're looking at an INT value, instead convert it to a FLOAT
- // This is better for interpolation
- if (final_val.get_type() == Variant::INT) {
- final_val = final_val.operator real_t();
- }
+ if (!running) {
+ return true;
+ }
- return final_val;
- }
- default: {
- // If we're not following a final value/method, use the final value from the data
- return p_data.final_val;
+ if (is_bound) {
+ Object *bound_instance = ObjectDB::get_instance(bound_node);
+ if (bound_instance) {
+ Node *bound_node = Object::cast_to<Node>(bound_instance);
+ // This can't by anything else than Node, so we can omit checking if casting succeeded.
+ if (!bound_node->is_inside_tree()) {
+ return true;
+ }
+ } else {
+ return false;
}
}
-}
-Variant &Tween::_get_delta_val(InterpolateData &p_data) {
- // What kind of data are we interpolating?
- switch (p_data.type) {
- case INTER_PROPERTY:
- case INTER_METHOD:
- // Simply return the given delta value
- return p_data.delta_val;
-
- case FOLLOW_PROPERTY:
- case FOLLOW_METHOD: {
- // We're following an object, so grab that instance
- Object *target = ObjectDB::get_instance(p_data.target_id);
- ERR_FAIL_COND_V(target == nullptr, p_data.initial_val);
-
- // We want to figure out the final value
- Variant final_val;
- if (p_data.type == FOLLOW_PROPERTY) {
- // Read the property as-is
- bool valid = false;
- final_val = target->get_indexed(p_data.target_key, &valid);
- ERR_FAIL_COND_V(!valid, p_data.initial_val);
- } else {
- // We're looking at a method. Call the method on the target object
- Callable::CallError error;
- final_val = target->call(p_data.target_key[0], nullptr, 0, error);
- ERR_FAIL_COND_V(error.error != Callable::CallError::CALL_OK, p_data.initial_val);
- }
+ if (!started) {
+ current_step = 0;
+ loops_done = 0;
+ start_tweeners();
+ started = true;
+ }
- // If we're looking at an INT value, instead convert it to a FLOAT
- // This is better for interpolation
- if (final_val.get_type() == Variant::INT) {
- final_val = final_val.operator real_t();
- }
+ float rem_delta = p_delta * speed_scale;
+ bool step_active = false;
- // Calculate the delta based on the initial value and the final value
- _calc_delta_val(p_data.initial_val, final_val, p_data.delta_val);
- return p_data.delta_val;
+ while (rem_delta > 0 && running) {
+ float step_delta = rem_delta;
+ step_active = false;
+
+ for (List<Ref<Tweener>>::Element *E = tweeners.write[current_step].front(); E; E = E->next()) {
+ // Modified inside Tweener.step().
+ float temp_delta = rem_delta;
+ // Turns to true if any Tweener returns true (i.e. is still not finished).
+ step_active = E->get()->step(temp_delta) || step_active;
+ step_delta = MIN(temp_delta, rem_delta);
}
- case TARGETING_PROPERTY:
- case TARGETING_METHOD: {
- // Grab the initial value from the data to calculate delta
- Variant initial_val = _get_initial_val(p_data);
+ rem_delta = step_delta;
- // If we're looking at an INT value, instead convert it to a FLOAT
- // This is better for interpolation
- if (initial_val.get_type() == Variant::INT) {
- initial_val = initial_val.operator real_t();
- }
+ if (!step_active) {
+ emit_signal("step_finished", current_step);
+ current_step++;
- // Calculate the delta based on the initial value and the final value
- _calc_delta_val(initial_val, p_data.final_val, p_data.delta_val);
- return p_data.delta_val;
+ if (current_step == tweeners.size()) {
+ loops_done++;
+ if (loops_done == loops) {
+ running = false;
+ dead = true;
+ emit_signal("finished");
+ } else {
+ emit_signal("loop_finished", loops_done);
+ current_step = 0;
+ start_tweeners();
+ }
+ } else {
+ start_tweeners();
+ }
}
+ }
+
+ return true;
+}
- case INTER_CALLBACK:
- // Callbacks have no special delta
- break;
+bool Tween::should_pause() {
+ if (is_bound && pause_mode == TWEEN_PAUSE_BOUND) {
+ Object *bound_instance = ObjectDB::get_instance(bound_node);
+ if (bound_instance) {
+ Node *bound_node = Object::cast_to<Node>(bound_instance);
+ return !bound_node->can_process();
+ }
}
- // If we've made it here, use the initial value as the delta
- return p_data.initial_val;
+
+ return pause_mode != TWEEN_PAUSE_PROCESS;
}
-Variant Tween::_run_equation(InterpolateData &p_data) {
- // Get the initial and delta values from the data
- Variant initial_val = _get_initial_val(p_data);
- Variant &delta_val = _get_delta_val(p_data);
- Variant result;
+Variant Tween::interpolate_variant(Variant p_initial_val, Variant p_delta_val, float p_time, float p_duration, TransitionType p_trans, EaseType p_ease) {
+ ERR_FAIL_INDEX_V(p_trans, TransitionType::TRANS_MAX, Variant());
+ ERR_FAIL_INDEX_V(p_ease, EaseType::EASE_MAX, Variant());
+// Helper macro to run equation on sub-elements of the value (e.g. x and y of Vector2).
#define APPLY_EQUATION(element) \
- r.element = _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, i.element, d.element, p_data.duration);
+ r.element = run_equation(p_trans, p_ease, p_time, i.element, d.element, p_duration);
- // What type of data are we interpolating?
- switch (initial_val.get_type()) {
- case Variant::BOOL:
- // Run the boolean specific equation (checking if it is at least 0.5)
- result = (_run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, initial_val, delta_val, p_data.duration)) >= 0.5;
- break;
+ switch (p_initial_val.get_type()) {
+ case Variant::BOOL: {
+ return (run_equation(p_trans, p_ease, p_time, p_initial_val, p_delta_val, p_duration)) >= 0.5;
+ }
- case Variant::INT:
- // Run the integer specific equation
- result = (int)_run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, (int)initial_val, (int)delta_val, p_data.duration);
- break;
+ case Variant::INT: {
+ return (int)run_equation(p_trans, p_ease, p_time, (int)p_initial_val, (int)p_delta_val, p_duration);
+ }
- case Variant::FLOAT:
- // Run the FLOAT specific equation
- result = _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, (real_t)initial_val, (real_t)delta_val, p_data.duration);
- break;
+ case Variant::FLOAT: {
+ return run_equation(p_trans, p_ease, p_time, (real_t)p_initial_val, (real_t)p_delta_val, p_duration);
+ }
case Variant::VECTOR2: {
- // Get vectors for initial and delta values
- Vector2 i = initial_val;
- Vector2 d = delta_val;
+ Vector2 i = p_initial_val;
+ Vector2 d = p_delta_val;
Vector2 r;
- // Execute the equation and mutate the r vector
- // This uses the custom APPLY_EQUATION macro defined above
APPLY_EQUATION(x);
APPLY_EQUATION(y);
- result = r;
- } break;
+ return r;
+ }
+
+ case Variant::VECTOR2I: {
+ Vector2i i = p_initial_val;
+ Vector2i d = p_delta_val;
+ Vector2i r;
+
+ APPLY_EQUATION(x);
+ APPLY_EQUATION(y);
+ return r;
+ }
case Variant::RECT2: {
- // Get the Rect2 for initial and delta value
- Rect2 i = initial_val;
- Rect2 d = delta_val;
+ Rect2 i = p_initial_val;
+ Rect2 d = p_delta_val;
Rect2 r;
- // Execute the equation for the position and size of Rect2
APPLY_EQUATION(position.x);
APPLY_EQUATION(position.y);
APPLY_EQUATION(size.x);
APPLY_EQUATION(size.y);
- result = r;
- } break;
+ return r;
+ }
+
+ case Variant::RECT2I: {
+ Rect2i i = p_initial_val;
+ Rect2i d = p_delta_val;
+ Rect2i r;
+
+ APPLY_EQUATION(position.x);
+ APPLY_EQUATION(position.y);
+ APPLY_EQUATION(size.x);
+ APPLY_EQUATION(size.y);
+ return r;
+ }
case Variant::VECTOR3: {
- // Get vectors for initial and delta values
- Vector3 i = initial_val;
- Vector3 d = delta_val;
+ Vector3 i = p_initial_val;
+ Vector3 d = p_delta_val;
Vector3 r;
- // Execute the equation and mutate the r vector
- // This uses the custom APPLY_EQUATION macro defined above
APPLY_EQUATION(x);
APPLY_EQUATION(y);
APPLY_EQUATION(z);
- result = r;
- } break;
+ return r;
+ }
+
+ case Variant::VECTOR3I: {
+ Vector3i i = p_initial_val;
+ Vector3i d = p_delta_val;
+ Vector3i r;
+
+ APPLY_EQUATION(x);
+ APPLY_EQUATION(y);
+ APPLY_EQUATION(z);
+ return r;
+ }
case Variant::TRANSFORM2D: {
- // Get the transforms for initial and delta values
- Transform2D i = initial_val;
- Transform2D d = delta_val;
+ Transform2D i = p_initial_val;
+ Transform2D d = p_delta_val;
Transform2D r;
- // Execute the equation on the transforms and mutate the r transform
- // This uses the custom APPLY_EQUATION macro defined above
APPLY_EQUATION(elements[0][0]);
APPLY_EQUATION(elements[0][1]);
APPLY_EQUATION(elements[1][0]);
APPLY_EQUATION(elements[1][1]);
APPLY_EQUATION(elements[2][0]);
APPLY_EQUATION(elements[2][1]);
- result = r;
- } break;
+ return r;
+ }
case Variant::QUATERNION: {
- // Get the quaternian for the initial and delta values
- Quaternion i = initial_val;
- Quaternion d = delta_val;
+ Quaternion i = p_initial_val;
+ Quaternion d = p_delta_val;
Quaternion r;
- // Execute the equation on the quaternian values and mutate the r quaternian
- // This uses the custom APPLY_EQUATION macro defined above
APPLY_EQUATION(x);
APPLY_EQUATION(y);
APPLY_EQUATION(z);
APPLY_EQUATION(w);
- result = r;
- } break;
+ return r;
+ }
case Variant::AABB: {
- // Get the AABB's for the initial and delta values
- AABB i = initial_val;
- AABB d = delta_val;
+ AABB i = p_initial_val;
+ AABB d = p_delta_val;
AABB r;
- // Execute the equation for the position and size of the AABB's and mutate the r AABB
- // This uses the custom APPLY_EQUATION macro defined above
APPLY_EQUATION(position.x);
APPLY_EQUATION(position.y);
APPLY_EQUATION(position.z);
APPLY_EQUATION(size.x);
APPLY_EQUATION(size.y);
APPLY_EQUATION(size.z);
- result = r;
- } break;
+ return r;
+ }
case Variant::BASIS: {
- // Get the basis for initial and delta values
- Basis i = initial_val;
- Basis d = delta_val;
+ Basis i = p_initial_val;
+ Basis d = p_delta_val;
Basis r;
- // Execute the equation on all the basis and mutate the r basis
- // This uses the custom APPLY_EQUATION macro defined above
APPLY_EQUATION(elements[0][0]);
APPLY_EQUATION(elements[0][1]);
APPLY_EQUATION(elements[0][2]);
@@ -568,17 +440,14 @@ Variant Tween::_run_equation(InterpolateData &p_data) {
APPLY_EQUATION(elements[2][0]);
APPLY_EQUATION(elements[2][1]);
APPLY_EQUATION(elements[2][2]);
- result = r;
- } break;
+ return r;
+ }
case Variant::TRANSFORM3D: {
- // Get the transforms for the initial and delta values
- Transform3D i = initial_val;
- Transform3D d = delta_val;
+ Transform3D i = p_initial_val;
+ Transform3D d = p_delta_val;
Transform3D r;
- // Execute the equation for each of the transforms and their origin and mutate the r transform
- // This uses the custom APPLY_EQUATION macro defined above
APPLY_EQUATION(basis.elements[0][0]);
APPLY_EQUATION(basis.elements[0][1]);
APPLY_EQUATION(basis.elements[0][2]);
@@ -591,634 +460,67 @@ Variant Tween::_run_equation(InterpolateData &p_data) {
APPLY_EQUATION(origin.x);
APPLY_EQUATION(origin.y);
APPLY_EQUATION(origin.z);
- result = r;
- } break;
+ return r;
+ }
case Variant::COLOR: {
- // Get the Color for initial and delta value
- Color i = initial_val;
- Color d = delta_val;
+ Color i = p_initial_val;
+ Color d = p_delta_val;
Color r;
- // Apply the equation on the Color RGBA, and mutate the r color
- // This uses the custom APPLY_EQUATION macro defined above
APPLY_EQUATION(r);
APPLY_EQUATION(g);
APPLY_EQUATION(b);
APPLY_EQUATION(a);
- result = r;
- } break;
-
- default: {
- // If unknown, just return the initial value
- result = initial_val;
- } break;
- };
-#undef APPLY_EQUATION
- // Return the result that was computed
- return result;
-}
-
-bool Tween::_apply_tween_value(InterpolateData &p_data, Variant &value) {
- // Get the object we want to apply the new value to
- Object *object = ObjectDB::get_instance(p_data.id);
- ERR_FAIL_COND_V(object == nullptr, false);
-
- // What kind of data are we mutating?
- switch (p_data.type) {
- case INTER_PROPERTY:
- case FOLLOW_PROPERTY:
- case TARGETING_PROPERTY: {
- // Simply set the property on the object
- bool valid = false;
- object->set_indexed(p_data.key, value, &valid);
- return valid;
+ return r;
}
- case INTER_METHOD:
- case FOLLOW_METHOD:
- case TARGETING_METHOD: {
- // We want to call the method on the target object
- Callable::CallError error;
-
- // Do we have a non-nil value passed in?
- if (value.get_type() != Variant::NIL) {
- // Pass it as an argument to the function call
- Variant *arg[1] = { &value };
- object->call(p_data.key[0], (const Variant **)arg, 1, error);
- } else {
- // Don't pass any argument
- object->call(p_data.key[0], nullptr, 0, error);
- }
-
- // Did we get an error from the function call?
- return error.error == Callable::CallError::CALL_OK;
+ default: {
+ return p_initial_val;
}
-
- case INTER_CALLBACK:
- // Nothing to apply for a callback
- break;
};
- // No issues found!
- return true;
-}
-
-void Tween::_tween_process(float p_delta) {
- // Process all of the pending commands
- _process_pending_commands();
-
- // If the scale is 0, make no progress on the tweens
- if (speed_scale == 0) {
- return;
- }
-
- // Update the delta and whether we are pending an update
- p_delta *= speed_scale;
- pending_update++;
-
- // Are we repeating the interpolations?
- if (repeat) {
- // For each interpolation...
- bool repeats_finished = true;
- for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
- // Get the data from it
- InterpolateData &data = E->get();
-
- // Is not finished?
- if (!data.finish) {
- // We aren't finished yet, no need to check the rest
- repeats_finished = false;
- break;
- }
- }
-
- // If we are all finished, we can reset all of the tweens
- if (repeats_finished) {
- reset_all();
- }
- }
-
- // Are all of the tweens complete?
- int any_unfinished = 0;
-
- // For each tween we wish to interpolate...
- for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
- // Get the data from it
- InterpolateData &data = E->get();
-
- // Is the data not active or already finished? No need to go any further
- if (!data.active || data.finish) {
- continue;
- }
-
- // Track if we hit one that isn't finished yet
- any_unfinished++;
-
- // Get the target object for this interpolation
- Object *object = ObjectDB::get_instance(data.id);
- if (object == nullptr) {
- continue;
- }
-
- // Are we still delaying this tween?
- bool prev_delaying = data.elapsed <= data.delay;
- data.elapsed += p_delta;
- if (data.elapsed < data.delay) {
- continue;
- } else if (prev_delaying) {
- // We can apply the tween's value to the data and emit that the tween has started
- _apply_tween_value(data, data.initial_val);
- emit_signal("tween_started", object, NodePath(Vector<StringName>(), data.key, false));
- }
-
- // Are we at the end of the tween?
- if (data.elapsed > (data.delay + data.duration)) {
- // Set the elapsed time to the end and mark this one as finished
- data.elapsed = data.delay + data.duration;
- data.finish = true;
- }
-
- // Are we interpolating a callback?
- if (data.type == INTER_CALLBACK) {
- // Is the tween completed?
- if (data.finish) {
- // Are we calling this callback deferred or immediately?
- if (data.call_deferred) {
- // Run the deferred function callback, applying the correct number of arguments
- switch (data.args) {
- case 0:
- object->call_deferred(data.key[0]);
- break;
- case 1:
- object->call_deferred(data.key[0], data.arg[0]);
- break;
- case 2:
- object->call_deferred(data.key[0], data.arg[0], data.arg[1]);
- break;
- case 3:
- object->call_deferred(data.key[0], data.arg[0], data.arg[1], data.arg[2]);
- break;
- case 4:
- object->call_deferred(data.key[0], data.arg[0], data.arg[1], data.arg[2], data.arg[3]);
- break;
- case 5:
- object->call_deferred(data.key[0], data.arg[0], data.arg[1], data.arg[2], data.arg[3], data.arg[4]);
- break;
- }
- } else {
- // Call the function directly with the arguments
- Callable::CallError error;
- Variant *arg[5] = {
- &data.arg[0],
- &data.arg[1],
- &data.arg[2],
- &data.arg[3],
- &data.arg[4],
- };
- object->call(data.key[0], (const Variant **)arg, data.args, error);
- }
- }
- } else {
- // We can apply the value directly
- Variant result = _run_equation(data);
- _apply_tween_value(data, result);
-
- // Emit that the tween has taken a step
- emit_signal("tween_step", object, NodePath(Vector<StringName>(), data.key, false), data.elapsed, result);
- }
-
- // Is the tween now finished?
- if (data.finish) {
- // Set it to the final value directly
- Variant final_val = _get_final_val(data);
- _apply_tween_value(data, final_val);
-
- // Mark the tween as completed and emit the signal
- data.elapsed = 0;
- emit_signal("tween_completed", object, NodePath(Vector<StringName>(), data.key, false));
-
- // If we are not repeating the tween, remove it
- if (!repeat) {
- call_deferred("_remove_by_uid", data.uid);
- any_unfinished--;
- }
- }
- }
- // One less update left to go
- pending_update--;
-
- // If all tweens are completed, we no longer need to be active
- if (any_unfinished == 0) {
- set_active(false);
- emit_signal("tween_all_completed");
- }
-}
-
-void Tween::set_tween_process_mode(TweenProcessMode p_mode) {
- tween_process_mode = p_mode;
-}
-
-Tween::TweenProcessMode Tween::get_tween_process_mode() const {
- return tween_process_mode;
-}
-
-bool Tween::is_active() const {
- return is_processing_internal() || is_physics_processing_internal();
-}
-
-void Tween::set_active(bool p_active) {
- // Do nothing if it's the same active mode that we currently are
- if (is_active() == p_active) {
- return;
- }
-
- // Depending on physics or idle, set processing
- switch (tween_process_mode) {
- case TWEEN_PROCESS_IDLE:
- set_process_internal(p_active);
- break;
- case TWEEN_PROCESS_PHYSICS:
- set_physics_process_internal(p_active);
- break;
- }
-}
-
-bool Tween::is_repeat() const {
- return repeat;
-}
-
-void Tween::set_repeat(bool p_repeat) {
- repeat = p_repeat;
-}
-
-void Tween::set_speed_scale(float p_speed) {
- speed_scale = p_speed;
-}
-
-float Tween::get_speed_scale() const {
- return speed_scale;
-}
-
-void Tween::start() {
- ERR_FAIL_COND_MSG(!is_inside_tree(), "Tween was not added to the SceneTree!");
-
- // Are there any pending updates?
- if (pending_update != 0) {
- // Start the tweens after deferring
- call_deferred("start");
- return;
- }
-
- pending_update++;
- for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
- InterpolateData &data = E->get();
- data.active = true;
- }
- pending_update--;
-
- // We want to be activated
- set_active(true);
-
- // Don't resume from current position if stop_all() function has been used
- if (was_stopped) {
- seek(0);
- }
- was_stopped = false;
-}
-
-void Tween::reset(Object *p_object, StringName p_key) {
- // Find all interpolations that use the same object and target string
- pending_update++;
- for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
- // Get the target object
- InterpolateData &data = E->get();
- Object *object = ObjectDB::get_instance(data.id);
- if (object == nullptr) {
- continue;
- }
-
- // Do we have the correct object and key?
- if (object == p_object && (data.concatenated_key == p_key || p_key == "")) {
- // Reset the tween to the initial state
- data.elapsed = 0;
- data.finish = false;
-
- // Also apply the initial state if there isn't a delay
- if (data.delay == 0) {
- _apply_tween_value(data, data.initial_val);
- }
- }
- }
- pending_update--;
-}
-
-void Tween::reset_all() {
- // Go through all interpolations
- pending_update++;
- for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
- // Get the target data and set it back to the initial state
- InterpolateData &data = E->get();
- data.elapsed = 0;
- data.finish = false;
-
- // If there isn't a delay, apply the value to the object
- if (data.delay == 0) {
- _apply_tween_value(data, data.initial_val);
- }
- }
- pending_update--;
-}
-
-void Tween::stop(Object *p_object, StringName p_key) {
- // Find the tween that has the given target object and string key
- pending_update++;
- for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
- // Get the object the tween is targeting
- InterpolateData &data = E->get();
- Object *object = ObjectDB::get_instance(data.id);
- if (object == nullptr) {
- continue;
- }
-
- // Is this the correct object and does it have the given key?
- if (object == p_object && (data.concatenated_key == p_key || p_key == "")) {
- // Disable the tween
- data.active = false;
- }
- }
- pending_update--;
-}
-
-void Tween::stop_all() {
- // We no longer need to be active since all tweens have been stopped
- set_active(false);
- was_stopped = true;
- // For each interpolation...
- pending_update++;
- for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
- // Simply set it inactive
- InterpolateData &data = E->get();
- data.active = false;
- }
- pending_update--;
-}
-
-void Tween::resume(Object *p_object, StringName p_key) {
- // We need to be activated
- // TODO: What if no tween is found??
- set_active(true);
-
- // Find the tween that uses the given target object and string key
- pending_update++;
- for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
- // Grab the object
- InterpolateData &data = E->get();
- Object *object = ObjectDB::get_instance(data.id);
- if (object == nullptr) {
- continue;
- }
-
- // If the object and string key match, activate it
- if (object == p_object && (data.concatenated_key == p_key || p_key == "")) {
- data.active = true;
- }
- }
- pending_update--;
-}
-
-void Tween::resume_all() {
- // Set ourselves active so we can process tweens
- // TODO: What if there are no tweens? We get set to active for no reason!
- set_active(true);
-
- // For each interpolation...
- pending_update++;
- for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
- // Simply grab it and set it to active
- InterpolateData &data = E->get();
- data.active = true;
- }
- pending_update--;
-}
-
-void Tween::remove(Object *p_object, StringName p_key) {
- // If we are still updating, call this function again later
- if (pending_update != 0) {
- call_deferred("remove", p_object, p_key);
- return;
- }
-
- // For each interpolation...
- List<List<InterpolateData>::Element *> for_removal;
- for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
- // Get the target object
- InterpolateData &data = E->get();
- Object *object = ObjectDB::get_instance(data.id);
- if (object == nullptr) {
- continue;
- }
-
- // If the target object and string key match, queue it for removal
- if (object == p_object && (data.concatenated_key == p_key || p_key == "")) {
- for_removal.push_back(E);
- }
- }
-
- // For each interpolation we wish to remove...
- for (List<List<InterpolateData>::Element *>::Element *E = for_removal.front(); E; E = E->next()) {
- // Erase it
- interpolates.erase(E->get());
- }
-}
-
-void Tween::_remove_by_uid(int uid) {
- // If we are still updating, call this function again later
- if (pending_update != 0) {
- call_deferred("_remove_by_uid", uid);
- return;
- }
-
- // Find the interpolation that matches the given UID
- for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
- if (uid == E->get().uid) {
- // It matches, erase it and stop looking
- E->erase();
- break;
- }
- }
-}
-
-void Tween::_push_interpolate_data(InterpolateData &p_data) {
- pending_update++;
-
- // Add the new interpolation
- p_data.uid = ++uid;
- interpolates.push_back(p_data);
-
- pending_update--;
+#undef APPLY_EQUATION
}
-void Tween::remove_all() {
- // If we are still updating, call this function again later
- if (pending_update != 0) {
- call_deferred("remove_all");
- return;
- }
- // We no longer need to be active
- set_active(false);
-
- // Clear out all interpolations and reset the uid
- interpolates.clear();
- uid = 0;
-}
-
-void Tween::seek(real_t p_time) {
- // Go through each interpolation...
- pending_update++;
- for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
- // Get the target data
- InterpolateData &data = E->get();
-
- // Update the elapsed data to be set to the target time
- data.elapsed = p_time;
-
- // Are we at the end?
- if (data.elapsed < data.delay) {
- // There is still time left to go
- data.finish = false;
- continue;
- } else if (data.elapsed >= (data.delay + data.duration)) {
- // We are past the end of it, set the elapsed time to the end and mark as finished
- data.elapsed = (data.delay + data.duration);
- data.finish = true;
- } else {
- // We are not finished with this interpolation yet
- data.finish = false;
+Variant Tween::calculate_delta_value(Variant p_intial_val, Variant p_final_val) {
+ switch (p_intial_val.get_type()) {
+ case Variant::BOOL: {
+ return (int)p_final_val - (int)p_intial_val;
}
- // If we are a callback, do nothing special
- if (data.type == INTER_CALLBACK) {
- continue;
+ case Variant::RECT2: {
+ Rect2 i = p_intial_val;
+ Rect2 f = p_final_val;
+ return Rect2(f.position - i.position, f.size - i.size);
}
- // Run the equation on the data and apply the value
- Variant result = _run_equation(data);
- _apply_tween_value(data, result);
- }
- pending_update--;
-}
-
-real_t Tween::tell() const {
- // We want to grab the position of the furthest along tween
- pending_update++;
- real_t pos = 0.0;
-
- // For each interpolation...
- for (const List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
- // Get the data and figure out if its position is further along than the previous ones
- const InterpolateData &data = E->get();
- if (data.elapsed > pos) {
- // Save it if so
- pos = data.elapsed;
+ case Variant::RECT2I: {
+ Rect2i i = p_intial_val;
+ Rect2i f = p_final_val;
+ return Rect2i(f.position - i.position, f.size - i.size);
}
- }
- pending_update--;
- return pos;
-}
-
-real_t Tween::get_runtime() const {
- // If the tween isn't moving, it'll last forever
- if (speed_scale == 0) {
- return INFINITY;
- }
-
- pending_update++;
-
- // For each interpolation...
- real_t runtime = 0.0;
- for (const List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
- // Get the tween data and see if it's runtime is greater than the previous tweens
- const InterpolateData &data = E->get();
- real_t t = data.delay + data.duration;
- if (t > runtime) {
- // This is the longest running tween
- runtime = t;
- }
- }
- pending_update--;
-
- // Adjust the runtime for the current speed scale
- return runtime / speed_scale;
-}
-
-bool Tween::_calc_delta_val(const Variant &p_initial_val, const Variant &p_final_val, Variant &p_delta_val) {
- // Get the initial, final, and delta values
- const Variant &initial_val = p_initial_val;
- const Variant &final_val = p_final_val;
- Variant &delta_val = p_delta_val;
-
- // What kind of data are we interpolating?
- switch (initial_val.get_type()) {
- case Variant::BOOL:
- // We'll treat booleans just like integers
- case Variant::INT:
- // Compute the integer delta
- delta_val = (int)final_val - (int)initial_val;
- break;
-
- case Variant::FLOAT:
- // Convert to FLOAT and find the delta
- delta_val = (real_t)final_val - (real_t)initial_val;
- break;
-
- case Variant::VECTOR2:
- // Convert to Vectors and find the delta
- delta_val = final_val.operator Vector2() - initial_val.operator Vector2();
- break;
-
- case Variant::RECT2: {
- // Build a new Rect2 and use the new position and sizes to make a delta
- Rect2 i = initial_val;
- Rect2 f = final_val;
- delta_val = Rect2(f.position - i.position, f.size - i.size);
- } break;
-
- case Variant::VECTOR3:
- // Convert to Vectors and find the delta
- delta_val = final_val.operator Vector3() - initial_val.operator Vector3();
- break;
case Variant::TRANSFORM2D: {
- // Build a new transform which is the difference between the initial and final values
- Transform2D i = initial_val;
- Transform2D f = final_val;
- Transform2D d = Transform2D();
- d[0][0] = f.elements[0][0] - i.elements[0][0];
- d[0][1] = f.elements[0][1] - i.elements[0][1];
- d[1][0] = f.elements[1][0] - i.elements[1][0];
- d[1][1] = f.elements[1][1] - i.elements[1][1];
- d[2][0] = f.elements[2][0] - i.elements[2][0];
- d[2][1] = f.elements[2][1] - i.elements[2][1];
- delta_val = d;
- } break;
-
- case Variant::QUATERNION:
- // Convert to quaternianls and find the delta
- delta_val = final_val.operator Quaternion() - initial_val.operator Quaternion();
- break;
+ Transform2D i = p_intial_val;
+ Transform2D f = p_final_val;
+ return Transform2D(f.elements[0][0] - i.elements[0][0],
+ f.elements[0][1] - i.elements[0][1],
+ f.elements[1][0] - i.elements[1][0],
+ f.elements[1][1] - i.elements[1][1],
+ f.elements[2][0] - i.elements[2][0],
+ f.elements[2][1] - i.elements[2][1]);
+ }
case Variant::AABB: {
- // Build a new AABB and use the new position and sizes to make a delta
- AABB i = initial_val;
- AABB f = final_val;
- delta_val = AABB(f.position - i.position, f.size - i.size);
- } break;
+ AABB i = p_intial_val;
+ AABB f = p_final_val;
+ return AABB(f.position - i.position, f.size - i.size);
+ }
case Variant::BASIS: {
- // Build a new basis which is the delta between the initial and final values
- Basis i = initial_val;
- Basis f = final_val;
- delta_val = Basis(f.elements[0][0] - i.elements[0][0],
+ Basis i = p_intial_val;
+ Basis f = p_final_val;
+ return Basis(f.elements[0][0] - i.elements[0][0],
f.elements[0][1] - i.elements[0][1],
f.elements[0][2] - i.elements[0][2],
f.elements[1][0] - i.elements[1][0],
@@ -1227,14 +529,12 @@ bool Tween::_calc_delta_val(const Variant &p_initial_val, const Variant &p_final
f.elements[2][0] - i.elements[2][0],
f.elements[2][1] - i.elements[2][1],
f.elements[2][2] - i.elements[2][2]);
- } break;
+ }
case Variant::TRANSFORM3D: {
- // Build a new transform which is the difference between the initial and final values
- Transform3D i = initial_val;
- Transform3D f = final_val;
- Transform3D d;
- d.set(f.basis.elements[0][0] - i.basis.elements[0][0],
+ Transform3D i = p_intial_val;
+ Transform3D f = p_final_val;
+ return Transform3D(f.basis.elements[0][0] - i.basis.elements[0][0],
f.basis.elements[0][1] - i.basis.elements[0][1],
f.basis.elements[0][2] - i.basis.elements[0][2],
f.basis.elements[1][0] - i.basis.elements[1][0],
@@ -1246,569 +546,342 @@ bool Tween::_calc_delta_val(const Variant &p_initial_val, const Variant &p_final
f.origin.x - i.origin.x,
f.origin.y - i.origin.y,
f.origin.z - i.origin.z);
-
- delta_val = d;
- } break;
-
- case Variant::COLOR: {
- // Make a new color which is the difference between each the color's RGBA attributes
- Color i = initial_val;
- Color f = final_val;
- delta_val = Color(f.r - i.r, f.g - i.g, f.b - i.b, f.a - i.a);
- } break;
+ }
default: {
- static Variant::Type supported_types[] = {
- Variant::BOOL,
- Variant::INT,
- Variant::FLOAT,
- Variant::VECTOR2,
- Variant::RECT2,
- Variant::VECTOR3,
- Variant::TRANSFORM2D,
- Variant::QUATERNION,
- Variant::AABB,
- Variant::BASIS,
- Variant::TRANSFORM3D,
- Variant::COLOR,
- };
-
- int length = *(&supported_types + 1) - supported_types;
- String error_msg = "Invalid parameter type. Supported types are: ";
- for (int i = 0; i < length; i++) {
- if (i != 0) {
- error_msg += ", ";
- }
- error_msg += Variant::get_type_name(supported_types[i]);
- }
- error_msg += ".";
- ERR_PRINT(error_msg);
- return false;
+ return Variant::evaluate(Variant::OP_SUBTRACT, p_final_val, p_intial_val);
}
};
- return true;
}
-void Tween::_build_interpolation(InterpolateType p_interpolation_type, Object *p_object, NodePath *p_property, StringName *p_method, Variant p_initial_val, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) {
- // TODO: Add initialization+implementation for remaining interpolation types
- // TODO: Fix this method's organization to take advantage of the type
-
- // Make a new interpolation data
- InterpolateData data;
- data.active = true;
- data.type = p_interpolation_type;
- data.finish = false;
- data.elapsed = 0;
+void Tween::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("tween_property", "object", "property", "final_val", "duration"), &Tween::tween_property);
+ ClassDB::bind_method(D_METHOD("tween_interval", "time"), &Tween::tween_interval);
+ ClassDB::bind_method(D_METHOD("tween_callback", "callback"), &Tween::tween_callback);
+ ClassDB::bind_method(D_METHOD("tween_method", "method", "from", "to", "duration"), &Tween::tween_method);
+
+ ClassDB::bind_method(D_METHOD("custom_step", "delta"), &Tween::custom_step);
+ ClassDB::bind_method(D_METHOD("stop"), &Tween::stop);
+ ClassDB::bind_method(D_METHOD("pause"), &Tween::pause);
+ ClassDB::bind_method(D_METHOD("play"), &Tween::play);
+ ClassDB::bind_method(D_METHOD("kill"), &Tween::kill);
+
+ ClassDB::bind_method(D_METHOD("is_running"), &Tween::is_running);
+ ClassDB::bind_method(D_METHOD("is_valid"), &Tween::is_valid);
+ ClassDB::bind_method(D_METHOD("bind_node", "node"), &Tween::bind_node);
+ ClassDB::bind_method(D_METHOD("set_process_mode", "mode"), &Tween::set_process_mode);
+ ClassDB::bind_method(D_METHOD("set_pause_mode", "mode"), &Tween::set_pause_mode);
+
+ ClassDB::bind_method(D_METHOD("set_parallel", "parallel"), &Tween::set_parallel, DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("set_loops", "loops"), &Tween::set_loops, DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("set_speed_scale", "speed"), &Tween::set_speed_scale);
+ ClassDB::bind_method(D_METHOD("set_trans", "trans"), &Tween::set_trans);
+ ClassDB::bind_method(D_METHOD("set_ease", "ease"), &Tween::set_ease);
- // Validate and apply interpolation data
+ ClassDB::bind_method(D_METHOD("parallel"), &Tween::parallel);
+ ClassDB::bind_method(D_METHOD("chain"), &Tween::chain);
- // Give it the object
- ERR_FAIL_COND_MSG(p_object == nullptr, "Invalid object provided to Tween.");
- data.id = p_object->get_instance_id();
+ ClassDB::bind_method(D_METHOD("interpolate_value", "trans_type", "ease_type", "elapsed_time", "initial_value", "delta_value", "duration"), &Tween::interpolate_variant);
- // Validate the initial and final values
- ERR_FAIL_COND_MSG(p_initial_val.get_type() != p_final_val.get_type(), "Initial value type '" + Variant::get_type_name(p_initial_val.get_type()) + "' does not match final value type '" + Variant::get_type_name(p_final_val.get_type()) + "'.");
- data.initial_val = p_initial_val;
- data.final_val = p_final_val;
+ ADD_SIGNAL(MethodInfo("step_finished", PropertyInfo(Variant::INT, "idx")));
+ ADD_SIGNAL(MethodInfo("loop_finished", PropertyInfo(Variant::INT, "loop_count")));
+ ADD_SIGNAL(MethodInfo("finished"));
- // Check the Duration
- ERR_FAIL_COND_MSG(p_duration < 0, "Only non-negative duration values allowed in Tweens.");
- data.duration = p_duration;
+ BIND_ENUM_CONSTANT(TWEEN_PROCESS_PHYSICS);
+ BIND_ENUM_CONSTANT(TWEEN_PROCESS_IDLE);
- // Tween Delay
- ERR_FAIL_COND_MSG(p_delay < 0, "Only non-negative delay values allowed in Tweens.");
- data.delay = p_delay;
+ BIND_ENUM_CONSTANT(TWEEN_PAUSE_BOUND);
+ BIND_ENUM_CONSTANT(TWEEN_PAUSE_STOP);
+ BIND_ENUM_CONSTANT(TWEEN_PAUSE_PROCESS);
- // Transition type
- ERR_FAIL_COND_MSG(p_trans_type < 0 || p_trans_type >= TRANS_COUNT, "Invalid transition type provided to Tween.");
- data.trans_type = p_trans_type;
+ BIND_ENUM_CONSTANT(TRANS_LINEAR);
+ BIND_ENUM_CONSTANT(TRANS_SINE);
+ BIND_ENUM_CONSTANT(TRANS_QUINT);
+ BIND_ENUM_CONSTANT(TRANS_QUART);
+ BIND_ENUM_CONSTANT(TRANS_QUAD);
+ BIND_ENUM_CONSTANT(TRANS_EXPO);
+ BIND_ENUM_CONSTANT(TRANS_ELASTIC);
+ BIND_ENUM_CONSTANT(TRANS_CUBIC);
+ BIND_ENUM_CONSTANT(TRANS_CIRC);
+ BIND_ENUM_CONSTANT(TRANS_BOUNCE);
+ BIND_ENUM_CONSTANT(TRANS_BACK);
- // Easing type
- ERR_FAIL_COND_MSG(p_ease_type < 0 || p_ease_type >= EASE_COUNT, "Invalid easing type provided to Tween.");
- data.ease_type = p_ease_type;
+ BIND_ENUM_CONSTANT(EASE_IN);
+ BIND_ENUM_CONSTANT(EASE_OUT);
+ BIND_ENUM_CONSTANT(EASE_IN_OUT);
+ BIND_ENUM_CONSTANT(EASE_OUT_IN);
+}
- // Is the property defined?
- if (p_property) {
- // Check that the object actually contains the given property
- bool prop_valid = false;
- p_object->get_indexed(p_property->get_subnames(), &prop_valid);
- ERR_FAIL_COND_MSG(!prop_valid, "Tween target object has no property named: " + p_property->get_concatenated_subnames() + ".");
+Ref<PropertyTweener> PropertyTweener::from(Variant p_value) {
+ initial_val = p_value;
+ do_continue = false;
+ return this;
+}
- data.key = p_property->get_subnames();
- data.concatenated_key = p_property->get_concatenated_subnames();
- }
+Ref<PropertyTweener> PropertyTweener::from_current() {
+ do_continue = false;
+ return this;
+}
- // Is the method defined?
- if (p_method) {
- // Does the object even have the requested method?
- ERR_FAIL_COND_MSG(!p_object->has_method(*p_method), "Tween target object has no method named: " + *p_method + ".");
+Ref<PropertyTweener> PropertyTweener::as_relative() {
+ relative = true;
+ return this;
+}
- data.key.push_back(*p_method);
- data.concatenated_key = *p_method;
- }
+Ref<PropertyTweener> PropertyTweener::set_trans(Tween::TransitionType p_trans) {
+ trans_type = p_trans;
+ return this;
+}
- // Is there not a valid delta?
- if (!_calc_delta_val(data.initial_val, data.final_val, data.delta_val)) {
- return;
- }
+Ref<PropertyTweener> PropertyTweener::set_ease(Tween::EaseType p_ease) {
+ ease_type = p_ease;
+ return this;
+}
- // Add this interpolation to the total
- _push_interpolate_data(data);
+Ref<PropertyTweener> PropertyTweener::set_delay(float p_delay) {
+ delay = p_delay;
+ return this;
}
-void Tween::interpolate_property(Object *p_object, NodePath p_property, Variant p_initial_val, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) {
- // If we are busy updating, call this function again later
- if (pending_update != 0) {
- _add_pending_command("interpolate_property", p_object, p_property, p_initial_val, p_final_val, p_duration, p_trans_type, p_ease_type, p_delay);
+void PropertyTweener::start() {
+ elapsed_time = 0;
+ finished = false;
+
+ Object *target_instance = ObjectDB::get_instance(target);
+ if (!target_instance) {
+ WARN_PRINT("Target object freed before starting, aborting Tweener.");
return;
}
- // Check that the target object is valid
- ERR_FAIL_COND_MSG(p_object == nullptr, vformat("The Tween \"%s\"'s target node is `null`. Is the node reference correct?", get_name()));
-
- // Get the property from the node path
- p_property = p_property.get_as_property_path();
-
- // If no initial value given, grab the initial value from the object
- // TODO: Is this documented? This is very useful and removes a lot of clutter from tweens!
- if (p_initial_val.get_type() == Variant::NIL) {
- p_initial_val = p_object->get_indexed(p_property.get_subnames());
+ if (do_continue) {
+ initial_val = target_instance->get_indexed(property);
}
- // Convert any integers into REALs as they are better for interpolation
- if (p_initial_val.get_type() == Variant::INT) {
- p_initial_val = p_initial_val.operator real_t();
- }
- if (p_final_val.get_type() == Variant::INT) {
- p_final_val = p_final_val.operator real_t();
+ if (relative) {
+ final_val = Variant::evaluate(Variant::Operator::OP_ADD, initial_val, base_final_val);
}
- // Build the interpolation data
- _build_interpolation(INTER_PROPERTY, p_object, &p_property, nullptr, p_initial_val, p_final_val, p_duration, p_trans_type, p_ease_type, p_delay);
+ delta_val = tween->calculate_delta_value(initial_val, final_val);
}
-void Tween::interpolate_method(Object *p_object, StringName p_method, Variant p_initial_val, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) {
- // If we are busy updating, call this function again later
- if (pending_update != 0) {
- _add_pending_command("interpolate_method", p_object, p_method, p_initial_val, p_final_val, p_duration, p_trans_type, p_ease_type, p_delay);
- return;
+bool PropertyTweener::step(float &r_delta) {
+ if (finished) {
+ // This is needed in case there's a parallel Tweener with longer duration.
+ return false;
}
- // Check that the target object is valid
- ERR_FAIL_COND_MSG(p_object == nullptr, vformat("The Tween \"%s\"'s target node is `null`. Is the node reference correct?", get_name()));
-
- // Convert any integers into REALs as they are better for interpolation
- if (p_initial_val.get_type() == Variant::INT) {
- p_initial_val = p_initial_val.operator real_t();
- }
- if (p_final_val.get_type() == Variant::INT) {
- p_final_val = p_final_val.operator real_t();
+ Object *target_instance = ObjectDB::get_instance(target);
+ if (!target_instance) {
+ return false;
}
+ elapsed_time += r_delta;
- // Build the interpolation data
- _build_interpolation(INTER_METHOD, p_object, nullptr, &p_method, p_initial_val, p_final_val, p_duration, p_trans_type, p_ease_type, p_delay);
-}
-
-void Tween::interpolate_callback(Object *p_object, real_t p_duration, String p_callback, VARIANT_ARG_DECLARE) {
- // If we are already updating, call this function again later
- if (pending_update != 0) {
- _add_pending_command("interpolate_callback", p_object, p_duration, p_callback, p_arg1, p_arg2, p_arg3, p_arg4, p_arg5);
- return;
+ if (elapsed_time < delay) {
+ r_delta = 0;
+ return true;
}
- // Check that the target object is valid
- ERR_FAIL_COND(p_object == nullptr);
-
- // Duration cannot be negative
- ERR_FAIL_COND(p_duration < 0);
-
- // Check whether the object even has the callback
- ERR_FAIL_COND_MSG(!p_object->has_method(p_callback), "Object has no callback named: " + p_callback + ".");
-
- // Build a new InterpolationData
- InterpolateData data;
- data.active = true;
- data.type = INTER_CALLBACK;
- data.finish = false;
- data.call_deferred = false;
- data.elapsed = 0;
-
- // Give the data it's configuration
- data.id = p_object->get_instance_id();
- data.key.push_back(p_callback);
- data.concatenated_key = p_callback;
- data.duration = p_duration;
- data.delay = 0;
-
- // Add arguments to the interpolation
- int args = 0;
- if (p_arg5.get_type() != Variant::NIL) {
- args = 5;
- } else if (p_arg4.get_type() != Variant::NIL) {
- args = 4;
- } else if (p_arg3.get_type() != Variant::NIL) {
- args = 3;
- } else if (p_arg2.get_type() != Variant::NIL) {
- args = 2;
- } else if (p_arg1.get_type() != Variant::NIL) {
- args = 1;
+ float time = MIN(elapsed_time - delay, duration);
+ target_instance->set_indexed(property, tween->interpolate_variant(initial_val, delta_val, time, duration, trans_type, ease_type));
+
+ if (time < duration) {
+ r_delta = 0;
+ return true;
} else {
- args = 0;
+ finished = true;
+ r_delta = elapsed_time - delay - duration;
+ emit_signal("finished");
+ return false;
}
-
- data.args = args;
- data.arg[0] = p_arg1;
- data.arg[1] = p_arg2;
- data.arg[2] = p_arg3;
- data.arg[3] = p_arg4;
- data.arg[4] = p_arg5;
-
- // Add the new interpolation
- _push_interpolate_data(data);
}
-void Tween::interpolate_deferred_callback(Object *p_object, real_t p_duration, String p_callback, VARIANT_ARG_DECLARE) {
- // If we are already updating, call this function again later
- if (pending_update != 0) {
- _add_pending_command("interpolate_deferred_callback", p_object, p_duration, p_callback, p_arg1, p_arg2, p_arg3, p_arg4, p_arg5);
- return;
+void PropertyTweener::set_tween(Ref<Tween> p_tween) {
+ tween = p_tween;
+ if (trans_type == Tween::TRANS_MAX) {
+ trans_type = tween->get_trans();
}
-
- // Check that the target object is valid
- ERR_FAIL_COND(p_object == nullptr);
-
- // No negative durations allowed
- ERR_FAIL_COND(p_duration < 0);
-
- // Confirm the callback exists on the object
- ERR_FAIL_COND_MSG(!p_object->has_method(p_callback), "Object has no callback named: " + p_callback + ".");
-
- // Create a new InterpolateData for the callback
- InterpolateData data;
- data.active = true;
- data.type = INTER_CALLBACK;
- data.finish = false;
- data.call_deferred = true;
- data.elapsed = 0;
-
- // Give the data it's configuration
- data.id = p_object->get_instance_id();
- data.key.push_back(p_callback);
- data.concatenated_key = p_callback;
- data.duration = p_duration;
- data.delay = 0;
-
- // Collect arguments for the callback
- int args = 0;
- if (p_arg5.get_type() != Variant::NIL) {
- args = 5;
- } else if (p_arg4.get_type() != Variant::NIL) {
- args = 4;
- } else if (p_arg3.get_type() != Variant::NIL) {
- args = 3;
- } else if (p_arg2.get_type() != Variant::NIL) {
- args = 2;
- } else if (p_arg1.get_type() != Variant::NIL) {
- args = 1;
- } else {
- args = 0;
+ if (ease_type == Tween::EASE_MAX) {
+ ease_type = tween->get_ease();
}
+}
- data.args = args;
- data.arg[0] = p_arg1;
- data.arg[1] = p_arg2;
- data.arg[2] = p_arg3;
- data.arg[3] = p_arg4;
- data.arg[4] = p_arg5;
+void PropertyTweener::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("from", "value"), &PropertyTweener::from);
+ ClassDB::bind_method(D_METHOD("from_current"), &PropertyTweener::from_current);
+ ClassDB::bind_method(D_METHOD("as_relative"), &PropertyTweener::as_relative);
+ ClassDB::bind_method(D_METHOD("set_trans", "trans"), &PropertyTweener::set_trans);
+ ClassDB::bind_method(D_METHOD("set_ease", "ease"), &PropertyTweener::set_ease);
+ ClassDB::bind_method(D_METHOD("set_delay", "delay"), &PropertyTweener::set_delay);
+}
- // Add the new interpolation
- _push_interpolate_data(data);
+PropertyTweener::PropertyTweener(Object *p_target, NodePath p_property, Variant p_to, float p_duration) {
+ target = p_target->get_instance_id();
+ property = p_property.get_as_property_path().get_subnames();
+ initial_val = p_target->get_indexed(property);
+ base_final_val = p_to;
+ final_val = base_final_val;
+ duration = p_duration;
}
-void Tween::follow_property(Object *p_object, NodePath p_property, Variant p_initial_val, Object *p_target, NodePath p_target_property, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) {
- // If we are already updating, call this function again later
- if (pending_update != 0) {
- _add_pending_command("follow_property", p_object, p_property, p_initial_val, p_target, p_target_property, p_duration, p_trans_type, p_ease_type, p_delay);
- return;
- }
+PropertyTweener::PropertyTweener() {
+ ERR_FAIL_MSG("Can't create empty PropertyTweener. Use get_tree().tween_property() or tween_property() instead.");
+}
- // Get the two properties from their paths
- p_property = p_property.get_as_property_path();
- p_target_property = p_target_property.get_as_property_path();
+void IntervalTweener::start() {
+ elapsed_time = 0;
+ finished = false;
+}
- // If no initial value is given, grab it from the source object
- // TODO: Is this documented? It's really helpful for decluttering tweens
- if (p_initial_val.get_type() == Variant::NIL) {
- p_initial_val = p_object->get_indexed(p_property.get_subnames());
+bool IntervalTweener::step(float &r_delta) {
+ if (finished) {
+ return false;
}
- // Convert initial INT values to FLOAT as they are better for interpolation
- if (p_initial_val.get_type() == Variant::INT) {
- p_initial_val = p_initial_val.operator real_t();
+ elapsed_time += r_delta;
+
+ if (elapsed_time < duration) {
+ r_delta = 0;
+ return true;
+ } else {
+ finished = true;
+ r_delta = elapsed_time - duration;
+ emit_signal("finished");
+ return false;
}
+}
- // Confirm the source and target objects are valid
- ERR_FAIL_COND(p_object == nullptr);
- ERR_FAIL_COND(p_target == nullptr);
+IntervalTweener::IntervalTweener(float p_time) {
+ duration = p_time;
+}
- // No negative durations
- ERR_FAIL_COND(p_duration < 0);
+IntervalTweener::IntervalTweener() {
+ ERR_FAIL_MSG("Can't create empty IntervalTweener. Use get_tree().tween_interval() instead.");
+}
- // Ensure transition and easing types are valid
- ERR_FAIL_COND(p_trans_type < 0 || p_trans_type >= TRANS_COUNT);
- ERR_FAIL_COND(p_ease_type < 0 || p_ease_type >= EASE_COUNT);
+Ref<CallbackTweener> CallbackTweener::set_delay(float p_delay) {
+ delay = p_delay;
+ return this;
+}
- // No negative delays
- ERR_FAIL_COND(p_delay < 0);
+void CallbackTweener::start() {
+ elapsed_time = 0;
+ finished = false;
+}
- // Confirm the source and target objects have the desired properties
- bool prop_valid = false;
- p_object->get_indexed(p_property.get_subnames(), &prop_valid);
- ERR_FAIL_COND(!prop_valid);
+bool CallbackTweener::step(float &r_delta) {
+ if (finished) {
+ return false;
+ }
- bool target_prop_valid = false;
- Variant target_val = p_target->get_indexed(p_target_property.get_subnames(), &target_prop_valid);
- ERR_FAIL_COND(!target_prop_valid);
+ elapsed_time += r_delta;
+ if (elapsed_time >= delay) {
+ Variant result;
+ Callable::CallError ce;
+ callback.call(nullptr, 0, result, ce);
+ if (ce.error != Callable::CallError::CALL_OK) {
+ ERR_FAIL_V_MSG(false, "Error calling method from CallbackTweener: " + Variant::get_call_error_text(this, callback.get_method(), nullptr, 0, ce));
+ }
- // Convert target INT to FLOAT since it is better for interpolation
- if (target_val.get_type() == Variant::INT) {
- target_val = target_val.operator real_t();
+ finished = true;
+ r_delta = elapsed_time - delay;
+ emit_signal("finished");
+ return false;
}
- // Verify that the target value and initial value are the same type
- ERR_FAIL_COND(target_val.get_type() != p_initial_val.get_type());
-
- // Create a new InterpolateData
- InterpolateData data;
- data.active = true;
- data.type = FOLLOW_PROPERTY;
- data.finish = false;
- data.elapsed = 0;
-
- // Give the InterpolateData it's configuration
- data.id = p_object->get_instance_id();
- data.key = p_property.get_subnames();
- data.concatenated_key = p_property.get_concatenated_subnames();
- data.initial_val = p_initial_val;
- data.target_id = p_target->get_instance_id();
- data.target_key = p_target_property.get_subnames();
- data.duration = p_duration;
- data.trans_type = p_trans_type;
- data.ease_type = p_ease_type;
- data.delay = p_delay;
-
- // Add the interpolation
- _push_interpolate_data(data);
-}
-
-void Tween::follow_method(Object *p_object, StringName p_method, Variant p_initial_val, Object *p_target, StringName p_target_method, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) {
- // If we are currently updating, call this function again later
- if (pending_update != 0) {
- _add_pending_command("follow_method", p_object, p_method, p_initial_val, p_target, p_target_method, p_duration, p_trans_type, p_ease_type, p_delay);
- return;
- }
- // Convert initial INT values to FLOAT as they are better for interpolation
- if (p_initial_val.get_type() == Variant::INT) {
- p_initial_val = p_initial_val.operator real_t();
- }
+ r_delta = 0;
+ return true;
+}
- // Verify the source and target objects are valid
- ERR_FAIL_COND(p_object == nullptr);
- ERR_FAIL_COND(p_target == nullptr);
+void CallbackTweener::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_delay", "delay"), &CallbackTweener::set_delay);
+}
- // No negative durations
- ERR_FAIL_COND(p_duration < 0);
+CallbackTweener::CallbackTweener(Callable p_callback) {
+ callback = p_callback;
+}
- // Ensure that the transition and ease types are valid
- ERR_FAIL_COND(p_trans_type < 0 || p_trans_type >= TRANS_COUNT);
- ERR_FAIL_COND(p_ease_type < 0 || p_ease_type >= EASE_COUNT);
+CallbackTweener::CallbackTweener() {
+ ERR_FAIL_MSG("Can't create empty CallbackTweener. Use get_tree().tween_callback() instead.");
+}
- // No negative delays
- ERR_FAIL_COND(p_delay < 0);
+Ref<MethodTweener> MethodTweener::set_delay(float p_delay) {
+ delay = p_delay;
+ return this;
+}
- // Confirm both objects have the target methods
- ERR_FAIL_COND_MSG(!p_object->has_method(p_method), "Object has no method named: " + p_method + ".");
- ERR_FAIL_COND_MSG(!p_target->has_method(p_target_method), "Target has no method named: " + p_target_method + ".");
+Ref<MethodTweener> MethodTweener::set_trans(Tween::TransitionType p_trans) {
+ trans_type = p_trans;
+ return this;
+}
- // Call the method to get the target value
- Callable::CallError error;
- Variant target_val = p_target->call(p_target_method, nullptr, 0, error);
- ERR_FAIL_COND(error.error != Callable::CallError::CALL_OK);
+Ref<MethodTweener> MethodTweener::set_ease(Tween::EaseType p_ease) {
+ ease_type = p_ease;
+ return this;
+}
- // Convert target INT values to FLOAT as they are better for interpolation
- if (target_val.get_type() == Variant::INT) {
- target_val = target_val.operator real_t();
- }
- ERR_FAIL_COND(target_val.get_type() != p_initial_val.get_type());
-
- // Make the new InterpolateData for the method follow
- InterpolateData data;
- data.active = true;
- data.type = FOLLOW_METHOD;
- data.finish = false;
- data.elapsed = 0;
-
- // Give the data it's configuration
- data.id = p_object->get_instance_id();
- data.key.push_back(p_method);
- data.concatenated_key = p_method;
- data.initial_val = p_initial_val;
- data.target_id = p_target->get_instance_id();
- data.target_key.push_back(p_target_method);
- data.duration = p_duration;
- data.trans_type = p_trans_type;
- data.ease_type = p_ease_type;
- data.delay = p_delay;
-
- // Add the new interpolation
- _push_interpolate_data(data);
-}
-
-void Tween::targeting_property(Object *p_object, NodePath p_property, Object *p_initial, NodePath p_initial_property, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) {
- // If we are currently updating, call this function again later
- if (pending_update != 0) {
- _add_pending_command("targeting_property", p_object, p_property, p_initial, p_initial_property, p_final_val, p_duration, p_trans_type, p_ease_type, p_delay);
- return;
- }
- // Grab the target property and the target property
- p_property = p_property.get_as_property_path();
- p_initial_property = p_initial_property.get_as_property_path();
+void MethodTweener::start() {
+ elapsed_time = 0;
+ finished = false;
+}
- // Convert the initial INT values to FLOAT as they are better for Interpolation
- if (p_final_val.get_type() == Variant::INT) {
- p_final_val = p_final_val.operator real_t();
+bool MethodTweener::step(float &r_delta) {
+ if (finished) {
+ return false;
}
- // Verify both objects are valid
- ERR_FAIL_COND(p_object == nullptr);
- ERR_FAIL_COND(p_initial == nullptr);
-
- // No negative durations
- ERR_FAIL_COND(p_duration < 0);
-
- // Ensure transition and easing types are valid
- ERR_FAIL_COND(p_trans_type < 0 || p_trans_type >= TRANS_COUNT);
- ERR_FAIL_COND(p_ease_type < 0 || p_ease_type >= EASE_COUNT);
-
- // No negative delays
- ERR_FAIL_COND(p_delay < 0);
-
- // Ensure the initial and target properties exist on their objects
- bool prop_valid = false;
- p_object->get_indexed(p_property.get_subnames(), &prop_valid);
- ERR_FAIL_COND(!prop_valid);
+ elapsed_time += r_delta;
- bool initial_prop_valid = false;
- Variant initial_val = p_initial->get_indexed(p_initial_property.get_subnames(), &initial_prop_valid);
- ERR_FAIL_COND(!initial_prop_valid);
-
- // Convert the initial INT value to FLOAT as it is better for interpolation
- if (initial_val.get_type() == Variant::INT) {
- initial_val = initial_val.operator real_t();
- }
- ERR_FAIL_COND(initial_val.get_type() != p_final_val.get_type());
-
- // Build the InterpolateData object
- InterpolateData data;
- data.active = true;
- data.type = TARGETING_PROPERTY;
- data.finish = false;
- data.elapsed = 0;
-
- // Give the data it's configuration
- data.id = p_object->get_instance_id();
- data.key = p_property.get_subnames();
- data.concatenated_key = p_property.get_concatenated_subnames();
- data.target_id = p_initial->get_instance_id();
- data.target_key = p_initial_property.get_subnames();
- data.initial_val = initial_val;
- data.final_val = p_final_val;
- data.duration = p_duration;
- data.trans_type = p_trans_type;
- data.ease_type = p_ease_type;
- data.delay = p_delay;
-
- // Ensure there is a valid delta
- if (!_calc_delta_val(data.initial_val, data.final_val, data.delta_val)) {
- return;
+ if (elapsed_time < delay) {
+ r_delta = 0;
+ return true;
}
- // Add the interpolation
- _push_interpolate_data(data);
-}
+ float time = MIN(elapsed_time - delay, duration);
+ Variant current_val = tween->interpolate_variant(initial_val, delta_val, time, duration, trans_type, ease_type);
+ const Variant **argptr = (const Variant **)alloca(sizeof(Variant *));
+ argptr[0] = &current_val;
-void Tween::targeting_method(Object *p_object, StringName p_method, Object *p_initial, StringName p_initial_method, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) {
- // If we are currently updating, call this function again later
- if (pending_update != 0) {
- _add_pending_command("targeting_method", p_object, p_method, p_initial, p_initial_method, p_final_val, p_duration, p_trans_type, p_ease_type, p_delay);
- return;
+ Variant result;
+ Callable::CallError ce;
+ callback.call(argptr, 1, result, ce);
+ if (ce.error != Callable::CallError::CALL_OK) {
+ ERR_FAIL_V_MSG(false, "Error calling method from MethodTweener: " + Variant::get_call_error_text(this, callback.get_method(), argptr, 1, ce));
}
- // Convert final INT values to FLOAT as they are better for interpolation
- if (p_final_val.get_type() == Variant::INT) {
- p_final_val = p_final_val.operator real_t();
+ if (time < duration) {
+ r_delta = 0;
+ return true;
+ } else {
+ finished = true;
+ r_delta = elapsed_time - delay - duration;
+ emit_signal("finished");
+ return false;
}
+}
- // Make sure the given objects are valid
- ERR_FAIL_COND(p_object == nullptr);
- ERR_FAIL_COND(p_initial == nullptr);
-
- // No negative durations
- ERR_FAIL_COND(p_duration < 0);
-
- // Ensure transition and easing types are valid
- ERR_FAIL_COND(p_trans_type < 0 || p_trans_type >= TRANS_COUNT);
- ERR_FAIL_COND(p_ease_type < 0 || p_ease_type >= EASE_COUNT);
-
- // No negative delays
- ERR_FAIL_COND(p_delay < 0);
-
- // Make sure both objects have the given method
- ERR_FAIL_COND_MSG(!p_object->has_method(p_method), "Object has no method named: " + p_method + ".");
- ERR_FAIL_COND_MSG(!p_initial->has_method(p_initial_method), "Initial Object has no method named: " + p_initial_method + ".");
-
- // Call the method to get the initial value
- Callable::CallError error;
- Variant initial_val = p_initial->call(p_initial_method, nullptr, 0, error);
- ERR_FAIL_COND(error.error != Callable::CallError::CALL_OK);
-
- // Convert initial INT values to FLOAT as they aer better for interpolation
- if (initial_val.get_type() == Variant::INT) {
- initial_val = initial_val.operator real_t();
+void MethodTweener::set_tween(Ref<Tween> p_tween) {
+ tween = p_tween;
+ if (trans_type == Tween::TRANS_MAX) {
+ trans_type = tween->get_trans();
}
- ERR_FAIL_COND(initial_val.get_type() != p_final_val.get_type());
-
- // Build the new InterpolateData object
- InterpolateData data;
- data.active = true;
- data.type = TARGETING_METHOD;
- data.finish = false;
- data.elapsed = 0;
-
- // Configure the data
- data.id = p_object->get_instance_id();
- data.key.push_back(p_method);
- data.concatenated_key = p_method;
- data.target_id = p_initial->get_instance_id();
- data.target_key.push_back(p_initial_method);
- data.initial_val = initial_val;
- data.final_val = p_final_val;
- data.duration = p_duration;
- data.trans_type = p_trans_type;
- data.ease_type = p_ease_type;
- data.delay = p_delay;
-
- // Ensure there is a valid delta
- if (!_calc_delta_val(data.initial_val, data.final_val, data.delta_val)) {
- return;
+ if (ease_type == Tween::EASE_MAX) {
+ ease_type = tween->get_ease();
}
+}
- // Add the interpolation
- _push_interpolate_data(data);
+void MethodTweener::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_delay", "delay"), &MethodTweener::set_delay);
+ ClassDB::bind_method(D_METHOD("set_trans", "trans"), &MethodTweener::set_trans);
+ ClassDB::bind_method(D_METHOD("set_ease", "ease"), &MethodTweener::set_ease);
}
-Tween::Tween() {
+MethodTweener::MethodTweener(Callable p_callback, float p_from, float p_to, float p_duration) {
+ callback = p_callback;
+ initial_val = p_from;
+ delta_val = tween->calculate_delta_value(p_from, p_to);
+ duration = p_duration;
}
-Tween::~Tween() {
+MethodTweener::MethodTweener() {
+ ERR_FAIL_MSG("Can't create empty MethodTweener. Use get_tree().tween_method() instead.");
}
diff --git a/scene/animation/tween.h b/scene/animation/tween.h
index 142c0c65e0..947cdb7c2d 100644
--- a/scene/animation/tween.h
+++ b/scene/animation/tween.h
@@ -31,10 +31,33 @@
#ifndef TWEEN_H
#define TWEEN_H
-#include "scene/main/node.h"
+#include "core/object/ref_counted.h"
-class Tween : public Node {
- GDCLASS(Tween, Node);
+class Tween;
+class Node;
+
+class Tweener : public RefCounted {
+ GDCLASS(Tweener, RefCounted);
+
+public:
+ virtual void set_tween(Ref<Tween> p_tween);
+ virtual void start() = 0;
+ virtual bool step(float &r_delta) = 0;
+
+protected:
+ static void _bind_methods();
+ Ref<Tween> tween;
+ float elapsed_time = 0;
+ bool finished = false;
+};
+
+class PropertyTweener;
+class IntervalTweener;
+class CallbackTweener;
+class MethodTweener;
+
+class Tween : public RefCounted {
+ GDCLASS(Tween, RefCounted);
public:
enum TweenProcessMode {
@@ -42,6 +65,12 @@ public:
TWEEN_PROCESS_IDLE,
};
+ enum TweenPauseMode {
+ TWEEN_PAUSE_BOUND,
+ TWEEN_PAUSE_STOP,
+ TWEEN_PAUSE_PROCESS,
+ };
+
enum TransitionType {
TRANS_LINEAR,
TRANS_SINE,
@@ -54,8 +83,7 @@ public:
TRANS_CIRC,
TRANS_BOUNCE,
TRANS_BACK,
-
- TRANS_COUNT,
+ TRANS_MAX
};
enum EaseType {
@@ -63,130 +91,187 @@ public:
EASE_OUT,
EASE_IN_OUT,
EASE_OUT_IN,
-
- EASE_COUNT,
+ EASE_MAX
};
private:
- enum InterpolateType {
- INTER_PROPERTY,
- INTER_METHOD,
- FOLLOW_PROPERTY,
- FOLLOW_METHOD,
- TARGETING_PROPERTY,
- TARGETING_METHOD,
- INTER_CALLBACK,
- };
+ TweenProcessMode process_mode = TweenProcessMode::TWEEN_PROCESS_IDLE;
+ TweenPauseMode pause_mode = TweenPauseMode::TWEEN_PAUSE_STOP;
+ TransitionType default_transition = TransitionType::TRANS_LINEAR;
+ EaseType default_ease = EaseType::EASE_IN_OUT;
+ ObjectID bound_node;
- struct InterpolateData {
- bool active = false;
- InterpolateType type = INTER_CALLBACK;
- bool finish = false;
- bool call_deferred = false;
- real_t elapsed = 0.0;
- ObjectID id;
- Vector<StringName> key;
- StringName concatenated_key;
- Variant initial_val;
- Variant delta_val;
- Variant final_val;
- ObjectID target_id;
- Vector<StringName> target_key;
- real_t duration = 0.0;
- TransitionType trans_type = TransitionType::TRANS_BACK;
- EaseType ease_type = EaseType::EASE_COUNT;
- real_t delay = 0.0;
- int args = 0;
- Variant arg[5];
- int uid = 0;
- };
+ Vector<List<Ref<Tweener>>> tweeners;
+ int current_step = -1;
+ int loops = 1;
+ int loops_done = 0;
+ float speed_scale = 1;
- String autoplay;
- TweenProcessMode tween_process_mode = TWEEN_PROCESS_IDLE;
- bool repeat = false;
- float speed_scale = 1.0;
- mutable int pending_update = 0;
- int uid = 0;
- bool was_stopped = false;
+ bool is_bound = false;
+ bool started = false;
+ bool running = true;
+ bool dead = false;
+ bool invalid = true;
+ bool default_parallel = false;
+ bool parallel_enabled = false;
- List<InterpolateData> interpolates;
+ typedef real_t (*interpolater)(real_t t, real_t b, real_t c, real_t d);
+ static interpolater interpolaters[TRANS_MAX][EASE_MAX];
- struct PendingCommand {
- StringName key;
- int args = 0;
- Variant arg[10];
- };
- List<PendingCommand> pending_commands;
+ void start_tweeners();
- void _add_pending_command(StringName p_key, const Variant &p_arg1 = Variant(), const Variant &p_arg2 = Variant(), const Variant &p_arg3 = Variant(), const Variant &p_arg4 = Variant(), const Variant &p_arg5 = Variant(), const Variant &p_arg6 = Variant(), const Variant &p_arg7 = Variant(), const Variant &p_arg8 = Variant(), const Variant &p_arg9 = Variant(), const Variant &p_arg10 = Variant());
- void _process_pending_commands();
+protected:
+ static void _bind_methods();
- typedef real_t (*interpolater)(real_t t, real_t b, real_t c, real_t d);
- static interpolater interpolaters[TRANS_COUNT][EASE_COUNT];
+public:
+ Ref<PropertyTweener> tween_property(Object *p_target, NodePath p_property, Variant p_to, float p_duration);
+ Ref<IntervalTweener> tween_interval(float p_time);
+ Ref<CallbackTweener> tween_callback(Callable p_callback);
+ Ref<MethodTweener> tween_method(Callable p_callback, float p_from, float p_to, float p_duration);
+ Ref<Tween> append(Ref<Tweener> p_tweener);
- real_t _run_equation(TransitionType p_trans_type, EaseType p_ease_type, real_t t, real_t b, real_t c, real_t d);
- Variant &_get_delta_val(InterpolateData &p_data);
- Variant _get_initial_val(const InterpolateData &p_data) const;
- Variant _get_final_val(const InterpolateData &p_data) const;
- Variant _run_equation(InterpolateData &p_data);
- bool _calc_delta_val(const Variant &p_initial_val, const Variant &p_final_val, Variant &p_delta_val);
- bool _apply_tween_value(InterpolateData &p_data, Variant &value);
+ bool custom_step(float p_delta);
+ void stop();
+ void pause();
+ void play();
+ void kill();
- void _tween_process(float p_delta);
- void _remove_by_uid(int uid);
- void _push_interpolate_data(InterpolateData &p_data);
- void _build_interpolation(InterpolateType p_interpolation_type, Object *p_object, NodePath *p_property, StringName *p_method, Variant p_initial_val, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay);
+ bool is_running();
+ void set_valid(bool p_valid);
+ bool is_valid();
-protected:
- bool _set(const StringName &p_name, const Variant &p_value);
- bool _get(const StringName &p_name, Variant &r_ret) const;
- void _get_property_list(List<PropertyInfo> *p_list) const;
- void _notification(int p_what);
+ Ref<Tween> bind_node(Node *p_node);
+ Ref<Tween> set_process_mode(TweenProcessMode p_mode);
+ TweenProcessMode get_process_mode();
+ Ref<Tween> set_pause_mode(TweenPauseMode p_mode);
+ TweenPauseMode get_pause_mode();
- static void _bind_methods();
+ Ref<Tween> set_parallel(bool p_parallel);
+ Ref<Tween> set_loops(int p_loops);
+ Ref<Tween> set_speed_scale(float p_speed);
+ Ref<Tween> set_trans(TransitionType p_trans);
+ TransitionType get_trans();
+ Ref<Tween> set_ease(EaseType p_ease);
+ EaseType get_ease();
-public:
- bool is_active() const;
- void set_active(bool p_active);
-
- bool is_repeat() const;
- void set_repeat(bool p_repeat);
-
- void set_tween_process_mode(TweenProcessMode p_mode);
- TweenProcessMode get_tween_process_mode() const;
-
- void set_speed_scale(float p_speed);
- float get_speed_scale() const;
-
- void start();
- void reset(Object *p_object, StringName p_key);
- void reset_all();
- void stop(Object *p_object, StringName p_key);
- void stop_all();
- void resume(Object *p_object, StringName p_key);
- void resume_all();
- void remove(Object *p_object, StringName p_key);
- void remove_all();
-
- void seek(real_t p_time);
- real_t tell() const;
- real_t get_runtime() const;
-
- void interpolate_property(Object *p_object, NodePath p_property, Variant p_initial_val, Variant p_final_val, real_t p_duration, TransitionType p_trans_type = TRANS_LINEAR, EaseType p_ease_type = EASE_IN_OUT, real_t p_delay = 0);
- void interpolate_method(Object *p_object, StringName p_method, Variant p_initial_val, Variant p_final_val, real_t p_duration, TransitionType p_trans_type = TRANS_LINEAR, EaseType p_ease_type = EASE_IN_OUT, real_t p_delay = 0);
- void interpolate_callback(Object *p_object, real_t p_duration, String p_callback, VARIANT_ARG_DECLARE);
- void interpolate_deferred_callback(Object *p_object, real_t p_duration, String p_callback, VARIANT_ARG_DECLARE);
- void follow_property(Object *p_object, NodePath p_property, Variant p_initial_val, Object *p_target, NodePath p_target_property, real_t p_duration, TransitionType p_trans_type = TRANS_LINEAR, EaseType p_ease_type = EASE_IN_OUT, real_t p_delay = 0);
- void follow_method(Object *p_object, StringName p_method, Variant p_initial_val, Object *p_target, StringName p_target_method, real_t p_duration, TransitionType p_trans_type = TRANS_LINEAR, EaseType p_ease_type = EASE_IN_OUT, real_t p_delay = 0);
- void targeting_property(Object *p_object, NodePath p_property, Object *p_initial, NodePath p_initial_property, Variant p_final_val, real_t p_duration, TransitionType p_trans_type = TRANS_LINEAR, EaseType p_ease_type = EASE_IN_OUT, real_t p_delay = 0);
- void targeting_method(Object *p_object, StringName p_method, Object *p_initial, StringName p_initial_method, Variant p_final_val, real_t p_duration, TransitionType p_trans_type = TRANS_LINEAR, EaseType p_ease_type = EASE_IN_OUT, real_t p_delay = 0);
-
- Tween();
- ~Tween();
+ Ref<Tween> parallel();
+ Ref<Tween> chain();
+
+ real_t run_equation(TransitionType p_trans_type, EaseType p_ease_type, real_t t, real_t b, real_t c, real_t d);
+ Variant interpolate_variant(Variant p_initial_val, Variant p_delta_val, float p_time, float p_duration, Tween::TransitionType p_trans, Tween::EaseType p_ease);
+ Variant calculate_delta_value(Variant p_intial_val, Variant p_final_val);
+
+ bool step(float p_delta);
+ bool should_pause();
+
+ Tween() {}
};
+VARIANT_ENUM_CAST(Tween::TweenPauseMode);
VARIANT_ENUM_CAST(Tween::TweenProcessMode);
VARIANT_ENUM_CAST(Tween::TransitionType);
VARIANT_ENUM_CAST(Tween::EaseType);
+class PropertyTweener : public Tweener {
+ GDCLASS(PropertyTweener, Tweener);
+
+public:
+ Ref<PropertyTweener> from(Variant p_value);
+ Ref<PropertyTweener> from_current();
+ Ref<PropertyTweener> as_relative();
+ Ref<PropertyTweener> set_trans(Tween::TransitionType p_trans);
+ Ref<PropertyTweener> set_ease(Tween::EaseType p_ease);
+ Ref<PropertyTweener> set_delay(float p_delay);
+
+ void set_tween(Ref<Tween> p_tween) override;
+ void start() override;
+ bool step(float &r_delta) override;
+
+ PropertyTweener(Object *p_target, NodePath p_property, Variant p_to, float p_duration);
+ PropertyTweener();
+
+protected:
+ static void _bind_methods();
+
+private:
+ ObjectID target;
+ Vector<StringName> property;
+ Variant initial_val;
+ Variant base_final_val;
+ Variant final_val;
+ Variant delta_val;
+
+ float duration = 0;
+ Tween::TransitionType trans_type = Tween::TRANS_MAX; // This is set inside set_tween();
+ Tween::EaseType ease_type = Tween::EASE_MAX;
+
+ float delay = 0;
+ bool do_continue = true;
+ bool relative = false;
+};
+
+class IntervalTweener : public Tweener {
+ GDCLASS(IntervalTweener, Tweener);
+
+public:
+ void start() override;
+ bool step(float &r_delta) override;
+
+ IntervalTweener(float p_time);
+ IntervalTweener();
+
+private:
+ float duration = 0;
+};
+
+class CallbackTweener : public Tweener {
+ GDCLASS(CallbackTweener, Tweener);
+
+public:
+ Ref<CallbackTweener> set_delay(float p_delay);
+
+ void start() override;
+ bool step(float &r_delta) override;
+
+ CallbackTweener(Callable p_callback);
+ CallbackTweener();
+
+protected:
+ static void _bind_methods();
+
+private:
+ Callable callback;
+ float delay = 0;
+};
+
+class MethodTweener : public Tweener {
+ GDCLASS(MethodTweener, Tweener);
+
+public:
+ Ref<MethodTweener> set_trans(Tween::TransitionType p_trans);
+ Ref<MethodTweener> set_ease(Tween::EaseType p_ease);
+ Ref<MethodTweener> set_delay(float p_delay);
+
+ void set_tween(Ref<Tween> p_tween) override;
+ void start() override;
+ bool step(float &r_delta) override;
+
+ MethodTweener(Callable p_callback, float p_from, float p_to, float p_duration);
+ MethodTweener();
+
+protected:
+ static void _bind_methods();
+
+private:
+ float duration = 0;
+ float delay = 0;
+ Tween::TransitionType trans_type = Tween::TRANS_MAX;
+ Tween::EaseType ease_type = Tween::EASE_MAX;
+
+ Ref<Tween> tween;
+ Variant initial_val;
+ Variant delta_val;
+ Callable callback;
+};
+
#endif
diff --git a/scene/debugger/scene_debugger.cpp b/scene/debugger/scene_debugger.cpp
index 5cf44c9afd..1e121ab6e5 100644
--- a/scene/debugger/scene_debugger.cpp
+++ b/scene/debugger/scene_debugger.cpp
@@ -661,7 +661,7 @@ void LiveEditor::_create_node_func(const NodePath &p_parent, const String &p_typ
}
Node *n2 = n->get_node(p_parent);
- Node *no = Object::cast_to<Node>(ClassDB::instance(p_type));
+ Node *no = Object::cast_to<Node>(ClassDB::instantiate(p_type));
if (!no) {
continue;
}
@@ -705,7 +705,7 @@ void LiveEditor::_instance_node_func(const NodePath &p_parent, const String &p_p
}
Node *n2 = n->get_node(p_parent);
- Node *no = ps->instance();
+ Node *no = ps->instantiate();
if (!no) {
continue;
}
diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp
index c0df5271b4..595d712eb8 100644
--- a/scene/gui/button.cpp
+++ b/scene/gui/button.cpp
@@ -543,7 +543,7 @@ void Button::_bind_methods() {
}
Button::Button(const String &p_text) {
- text_buf.instance();
+ text_buf.instantiate();
text_buf->set_flags(TextServer::BREAK_MANDATORY);
set_mouse_filter(MOUSE_FILTER_STOP);
diff --git a/scene/gui/code_edit.cpp b/scene/gui/code_edit.cpp
index 5b720945b8..ba1534ed5c 100644
--- a/scene/gui/code_edit.cpp
+++ b/scene/gui/code_edit.cpp
@@ -122,7 +122,7 @@ void CodeEdit::_notification(int p_what) {
ERR_CONTINUE(l < 0 || l >= code_completion_options_count);
Ref<TextLine> tl;
- tl.instance();
+ tl.instantiate();
tl->add_string(code_completion_options[l].display, cache.font, cache.font_size);
int yofs = (row_height - tl->get_size().y) / 2;
@@ -248,6 +248,8 @@ void CodeEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
update();
} break;
+ default:
+ break;
}
return;
}
@@ -358,7 +360,7 @@ void CodeEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
return;
}
if (k->is_action("ui_text_backspace", true)) {
- backspace_at_cursor();
+ backspace();
_filter_code_completion_candidates();
accept_event();
return;
@@ -385,14 +387,34 @@ void CodeEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
set_code_hint("");
}
- /* Override input to unfold lines where needed. */
- if (!is_readonly()) {
- if (k->is_action("ui_text_newline_above", true) || k->is_action("ui_text_newline_blank", true) || k->is_action("ui_text_newline", true)) {
- unfold_line(cursor_get_line());
- }
- if (cursor_get_line() > 0 && k->is_action("ui_text_backspace", true)) {
- unfold_line(cursor_get_line() - 1);
- }
+ /* Indentation */
+ if (k->is_action("ui_text_indent", true)) {
+ do_indent();
+ accept_event();
+ return;
+ }
+
+ if (k->is_action("ui_text_dedent", true)) {
+ do_unindent();
+ accept_event();
+ return;
+ }
+
+ // Override new line actions, for auto indent
+ if (k->is_action("ui_text_newline_above", true)) {
+ _new_line(false, true);
+ accept_event();
+ return;
+ }
+ if (k->is_action("ui_text_newline_blank", true)) {
+ _new_line(false);
+ accept_event();
+ return;
+ }
+ if (k->is_action("ui_text_newline", true)) {
+ _new_line();
+ accept_event();
+ return;
}
/* Remove shift otherwise actions will not match. */
@@ -437,6 +459,443 @@ Control::CursorShape CodeEdit::get_cursor_shape(const Point2 &p_pos) const {
return TextEdit::get_cursor_shape(p_pos);
}
+/* Indent management */
+void CodeEdit::set_indent_size(const int p_size) {
+ ERR_FAIL_COND_MSG(p_size <= 0, "Indend size must be greater than 0.");
+ if (indent_size == p_size) {
+ return;
+ }
+
+ indent_size = p_size;
+ if (indent_using_spaces) {
+ indent_text = String(" ").repeat(p_size);
+ } else {
+ indent_text = "\t";
+ }
+ set_tab_size(p_size);
+}
+
+int CodeEdit::get_indent_size() const {
+ return indent_size;
+}
+
+void CodeEdit::set_indent_using_spaces(const bool p_use_spaces) {
+ indent_using_spaces = p_use_spaces;
+ if (indent_using_spaces) {
+ indent_text = String(" ").repeat(indent_size);
+ } else {
+ indent_text = "\t";
+ }
+}
+
+bool CodeEdit::is_indent_using_spaces() const {
+ return indent_using_spaces;
+}
+
+void CodeEdit::set_auto_indent_enabled(bool p_enabled) {
+ auto_indent = p_enabled;
+}
+
+bool CodeEdit::is_auto_indent_enabled() const {
+ return auto_indent;
+}
+
+void CodeEdit::set_auto_indent_prefixes(const TypedArray<String> &p_prefixes) {
+ auto_indent_prefixes.clear();
+ for (int i = 0; i < p_prefixes.size(); i++) {
+ const String prefix = p_prefixes[i];
+ auto_indent_prefixes.insert(prefix[0]);
+ }
+}
+
+TypedArray<String> CodeEdit::get_auto_indent_prefixes() const {
+ TypedArray<String> prefixes;
+ for (const Set<char32_t>::Element *E = auto_indent_prefixes.front(); E; E = E->next()) {
+ prefixes.push_back(String::chr(E->get()));
+ }
+ return prefixes;
+}
+
+void CodeEdit::do_indent() {
+ if (is_readonly()) {
+ return;
+ }
+
+ if (is_selection_active()) {
+ indent_lines();
+ return;
+ }
+
+ if (!indent_using_spaces) {
+ _insert_text_at_cursor("\t");
+ return;
+ }
+
+ int spaces_to_add = _calculate_spaces_till_next_right_indent(cursor_get_column());
+ if (spaces_to_add > 0) {
+ _insert_text_at_cursor(String(" ").repeat(spaces_to_add));
+ }
+}
+
+void CodeEdit::indent_lines() {
+ if (is_readonly()) {
+ return;
+ }
+
+ begin_complex_operation();
+
+ /* This value informs us by how much we changed selection position by indenting right. */
+ /* Default is 1 for tab indentation. */
+ int selection_offset = 1;
+
+ int start_line = cursor_get_line();
+ int end_line = start_line;
+ if (is_selection_active()) {
+ start_line = get_selection_from_line();
+ end_line = get_selection_to_line();
+
+ /* Ignore the last line if the selection is not past the first column. */
+ if (get_selection_to_column() == 0) {
+ selection_offset = 0;
+ end_line--;
+ }
+ }
+
+ for (int i = start_line; i <= end_line; i++) {
+ const String line_text = get_line(i);
+ if (line_text.size() == 0 && is_selection_active()) {
+ continue;
+ }
+
+ if (!indent_using_spaces) {
+ set_line(i, '\t' + line_text);
+ continue;
+ }
+
+ /* We don't really care where selection is - we just need to know indentation level at the beginning of the line. */
+ /* Since we will add this many spaces, we want to move the whole selection and caret by this much. */
+ int spaces_to_add = _calculate_spaces_till_next_right_indent(get_first_non_whitespace_column(i));
+ set_line(i, String(" ").repeat(spaces_to_add) + line_text);
+ selection_offset = spaces_to_add;
+ }
+
+ /* Fix selection and caret being off after shifting selection right.*/
+ if (is_selection_active()) {
+ select(start_line, get_selection_from_column() + selection_offset, get_selection_to_line(), get_selection_to_column() + selection_offset);
+ }
+ cursor_set_column(cursor_get_column() + selection_offset, false);
+
+ end_complex_operation();
+}
+
+void CodeEdit::do_unindent() {
+ if (is_readonly()) {
+ return;
+ }
+
+ int cc = cursor_get_column();
+
+ if (is_selection_active() || cc <= 0) {
+ unindent_lines();
+ return;
+ }
+
+ int cl = cursor_get_line();
+ const String &line = get_line(cl);
+
+ if (line[cc - 1] == '\t') {
+ _remove_text(cl, cc - 1, cl, cc);
+ cursor_set_column(MAX(0, cc - 1));
+ return;
+ }
+
+ if (line[cc - 1] != ' ') {
+ return;
+ }
+
+ int spaces_to_remove = _calculate_spaces_till_next_left_indent(cc);
+ if (spaces_to_remove > 0) {
+ for (int i = 1; i <= spaces_to_remove; i++) {
+ if (line[cc - i] != ' ') {
+ spaces_to_remove = i - 1;
+ break;
+ }
+ }
+ _remove_text(cl, cc - spaces_to_remove, cl, cc);
+ cursor_set_column(MAX(0, cc - spaces_to_remove));
+ }
+}
+
+void CodeEdit::unindent_lines() {
+ if (is_readonly()) {
+ return;
+ }
+
+ begin_complex_operation();
+
+ /* Moving caret and selection after unindenting can get tricky because */
+ /* changing content of line can move caret and selection on its own (if new line ends before previous position of either), */
+ /* therefore we just remember initial values and at the end of the operation offset them by number of removed characters. */
+ int removed_characters = 0;
+ int initial_selection_end_column = 0;
+ int initial_cursor_column = cursor_get_column();
+
+ int start_line = cursor_get_line();
+ int end_line = start_line;
+ if (is_selection_active()) {
+ start_line = get_selection_from_line();
+ end_line = get_selection_to_line();
+
+ /* Ignore the last line if the selection is not past the first column. */
+ initial_selection_end_column = get_selection_to_column();
+ if (initial_selection_end_column == 0) {
+ end_line--;
+ }
+ }
+
+ bool first_line_edited = false;
+ bool last_line_edited = false;
+
+ for (int i = start_line; i <= end_line; i++) {
+ String line_text = get_line(i);
+
+ if (line_text.begins_with("\t")) {
+ line_text = line_text.substr(1, line_text.length());
+
+ set_line(i, line_text);
+ removed_characters = 1;
+
+ first_line_edited = (i == start_line) ? true : first_line_edited;
+ last_line_edited = (i == end_line) ? true : last_line_edited;
+ continue;
+ }
+
+ if (line_text.begins_with(" ")) {
+ /* When unindenting we aim to remove spaces before line that has selection no matter what is selected, */
+ /* Here we remove only enough spaces to align text to nearest full multiple of indentation_size. */
+ /* In case where selection begins at the start of indentation_size multiple we remove whole indentation level. */
+ int spaces_to_remove = _calculate_spaces_till_next_left_indent(get_first_non_whitespace_column(i));
+ line_text = line_text.substr(spaces_to_remove, line_text.length());
+
+ set_line(i, line_text);
+ removed_characters = spaces_to_remove;
+
+ first_line_edited = (i == start_line) ? true : first_line_edited;
+ last_line_edited = (i == end_line) ? true : last_line_edited;
+ }
+ }
+
+ if (is_selection_active()) {
+ /* Fix selection being off by one on the first line. */
+ if (first_line_edited) {
+ select(get_selection_from_line(), get_selection_from_column() - removed_characters, get_selection_to_line(), initial_selection_end_column);
+ }
+
+ /* Fix selection being off by one on the last line. */
+ if (last_line_edited) {
+ select(get_selection_from_line(), get_selection_from_column(), get_selection_to_line(), initial_selection_end_column - removed_characters);
+ }
+ }
+ cursor_set_column(initial_cursor_column - removed_characters, false);
+
+ end_complex_operation();
+}
+
+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) {
+ spaces_till_indent = indent_size;
+ }
+ return spaces_till_indent;
+}
+
+int CodeEdit::_calculate_spaces_till_next_right_indent(int p_column) const {
+ return indent_size - p_column % indent_size;
+}
+
+/* TODO: remove once brace completion is refactored. */
+static char32_t _get_right_pair_symbol(char32_t c) {
+ if (c == '"') {
+ return '"';
+ }
+ if (c == '\'') {
+ return '\'';
+ }
+ if (c == '(') {
+ return ')';
+ }
+ if (c == '[') {
+ return ']';
+ }
+ if (c == '{') {
+ return '}';
+ }
+ return 0;
+}
+
+static bool _is_pair_left_symbol(char32_t c) {
+ return c == '"' ||
+ c == '\'' ||
+ c == '(' ||
+ c == '[' ||
+ c == '{';
+}
+
+void CodeEdit::_new_line(bool p_split_current_line, bool p_above) {
+ if (is_readonly()) {
+ return;
+ }
+
+ const int cc = cursor_get_column();
+ const int cl = cursor_get_line();
+ const String line = get_line(cl);
+
+ String ins = "\n";
+
+ /* Append current indentation. */
+ int space_count = 0;
+ int line_col = 0;
+ for (; line_col < cc; line_col++) {
+ if (line[line_col] == '\t') {
+ ins += indent_text;
+ space_count = 0;
+ continue;
+ }
+
+ if (line[line_col] == ' ') {
+ space_count++;
+
+ if (space_count == indent_size) {
+ ins += indent_text;
+ space_count = 0;
+ }
+ continue;
+ }
+ break;
+ }
+
+ if (is_line_folded(cl)) {
+ unfold_line(cl);
+ }
+
+ /* Indent once again if the previous line needs it, ie ':'. */
+ /* Then add an addition new line for any closing pairs aka '()'. */
+ /* Skip this in comments or if we are going above. */
+ bool brace_indent = false;
+ if (auto_indent && !p_above && cc > 0 && is_in_comment(cl) == -1) {
+ bool should_indent = false;
+ char32_t indent_char = ' ';
+
+ for (; line_col < cc; line_col++) {
+ char32_t c = line[line_col];
+ if (auto_indent_prefixes.has(c)) {
+ should_indent = true;
+ indent_char = c;
+ continue;
+ }
+
+ /* Make sure this is the last char, trailing whitespace or comments are okay. */
+ if (should_indent && (!_is_whitespace(c) && is_in_comment(cl, cc) == -1)) {
+ should_indent = false;
+ }
+ }
+
+ if (should_indent) {
+ ins += indent_text;
+
+ /* TODO: Change when brace completion is refactored. */
+ char32_t closing_char = _get_right_pair_symbol(indent_char);
+ if (closing_char != 0 && closing_char == line[cc]) {
+ /* No need to move the brace below if we are not taking the text with us. */
+ if (p_split_current_line) {
+ brace_indent = true;
+ ins += "\n" + ins.substr(1, ins.length() - 2);
+ } else {
+ brace_indent = false;
+ ins = "\n" + ins.substr(1, ins.length() - 2);
+ }
+ }
+ }
+ }
+
+ begin_complex_operation();
+
+ bool first_line = false;
+ if (!p_split_current_line) {
+ if (p_above) {
+ if (cl > 0) {
+ cursor_set_line(cl - 1, false);
+ cursor_set_column(get_line(cursor_get_line()).length());
+ } else {
+ cursor_set_column(0);
+ first_line = true;
+ }
+ } else {
+ cursor_set_column(line.length());
+ }
+ }
+
+ insert_text_at_cursor(ins);
+
+ if (first_line) {
+ cursor_set_line(0);
+ } else if (brace_indent) {
+ cursor_set_line(cursor_get_line() - 1, false);
+ cursor_set_column(get_line(cursor_get_line()).length());
+ }
+
+ end_complex_operation();
+}
+
+void CodeEdit::backspace() {
+ if (is_readonly()) {
+ return;
+ }
+
+ int cc = cursor_get_column();
+ int cl = cursor_get_line();
+
+ if (cc == 0 && cl == 0) {
+ return;
+ }
+
+ if (is_selection_active()) {
+ delete_selection();
+ return;
+ }
+
+ if (cl > 0 && is_line_hidden(cl - 1)) {
+ unfold_line(cursor_get_line() - 1);
+ }
+
+ int prev_line = cc ? cl : cl - 1;
+ int prev_column = cc ? (cc - 1) : (get_line(cl - 1).length());
+
+ merge_gutters(cl, prev_line);
+
+ /* TODO: Change when brace completion is refactored. */
+ if (auto_brace_completion_enabled && cc > 0 && _is_pair_left_symbol(get_line(cl)[cc - 1])) {
+ _consume_backspace_for_pair_symbol(prev_line, prev_column);
+ cursor_set_line(prev_line, false, true);
+ cursor_set_column(prev_column);
+ return;
+ }
+
+ /* For space indentation we need to do a simple unindent if there are no chars to the left, acting in the */
+ /* same way as tabs. */
+ if (indent_using_spaces && cc != 0) {
+ if (get_first_non_whitespace_column(cl) > cc) {
+ prev_column = cc - _calculate_spaces_till_next_left_indent(cc);
+ prev_line = cl;
+ }
+ }
+
+ _remove_text(prev_line, prev_column, cl, cc);
+
+ cursor_set_line(prev_line, false, true);
+ cursor_set_column(prev_column);
+}
+
/* Main Gutter */
void CodeEdit::_update_draw_main_gutter() {
set_gutter_draw(main_gutter, draw_breakpoints || draw_bookmarks || draw_executing_lines);
@@ -615,7 +1074,7 @@ bool CodeEdit::is_line_numbers_zero_padded() const {
void CodeEdit::_line_number_draw_callback(int p_line, int p_gutter, const Rect2 &p_region) {
String fc = TS->format_number(String::num(p_line + 1).lpad(line_number_digits, line_number_padding));
Ref<TextLine> tl;
- tl.instance();
+ tl.instantiate();
tl->add_string(fc, cache.font, cache.font_size);
int yofs = p_region.position.y + (get_row_height() - tl->get_size().y) / 2;
Color number_color = get_line_gutter_item_color(p_line, line_number_gutter);
@@ -1284,6 +1743,25 @@ void CodeEdit::cancel_code_completion() {
}
void CodeEdit::_bind_methods() {
+ /* Indent management */
+ ClassDB::bind_method(D_METHOD("set_indent_size", "size"), &CodeEdit::set_indent_size);
+ ClassDB::bind_method(D_METHOD("get_indent_size"), &CodeEdit::get_indent_size);
+
+ ClassDB::bind_method(D_METHOD("set_indent_using_spaces", "use_spaces"), &CodeEdit::set_indent_using_spaces);
+ ClassDB::bind_method(D_METHOD("is_indent_using_spaces"), &CodeEdit::is_indent_using_spaces);
+
+ ClassDB::bind_method(D_METHOD("set_auto_indent_enabled", "enable"), &CodeEdit::set_auto_indent_enabled);
+ ClassDB::bind_method(D_METHOD("is_auto_indent_enabled"), &CodeEdit::is_auto_indent_enabled);
+
+ ClassDB::bind_method(D_METHOD("set_auto_indent_prefixes", "prefixes"), &CodeEdit::set_auto_indent_prefixes);
+ ClassDB::bind_method(D_METHOD("get_auto_indent_prefixes"), &CodeEdit::get_auto_indent_prefixes);
+
+ ClassDB::bind_method(D_METHOD("do_indent"), &CodeEdit::do_indent);
+ ClassDB::bind_method(D_METHOD("do_unindent"), &CodeEdit::do_unindent);
+
+ ClassDB::bind_method(D_METHOD("indent_lines"), &CodeEdit::indent_lines);
+ ClassDB::bind_method(D_METHOD("unindent_lines"), &CodeEdit::unindent_lines);
+
/* Main Gutter */
ClassDB::bind_method(D_METHOD("_main_gutter_draw_callback"), &CodeEdit::_main_gutter_draw_callback);
@@ -1434,6 +1912,12 @@ void CodeEdit::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "code_completion_enabled"), "set_code_completion_enabled", "is_code_completion_enabled");
ADD_PROPERTY(PropertyInfo(Variant::PACKED_STRING_ARRAY, "code_completion_prefixes"), "set_code_completion_prefixes", "get_code_comletion_prefixes");
+ ADD_GROUP("Indentation", "indent_");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "indent_size"), "set_indent_size", "get_indent_size");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "indent_use_spaces"), "set_indent_using_spaces", "is_indent_using_spaces");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "indent_automatic"), "set_auto_indent_enabled", "is_auto_indent_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::PACKED_STRING_ARRAY, "indent_automatic_prefixes"), "set_auto_indent_prefixes", "get_auto_indent_prefixes");
+
/* Signals */
ADD_SIGNAL(MethodInfo("breakpoint_toggled", PropertyInfo(Variant::INT, "line")));
ADD_SIGNAL(MethodInfo("request_code_completion"));
@@ -2060,6 +2544,12 @@ void CodeEdit::_lines_edited_from(int p_from_line, int p_to_line) {
}
CodeEdit::CodeEdit() {
+ /* Indent management */
+ auto_indent_prefixes.insert(':');
+ auto_indent_prefixes.insert('{');
+ auto_indent_prefixes.insert('[');
+ auto_indent_prefixes.insert('(');
+
/* Text Direction */
set_layout_direction(LAYOUT_DIRECTION_LTR);
set_text_direction(TEXT_DIRECTION_LTR);
diff --git a/scene/gui/code_edit.h b/scene/gui/code_edit.h
index 52b3f52a03..25b518402b 100644
--- a/scene/gui/code_edit.h
+++ b/scene/gui/code_edit.h
@@ -53,6 +53,19 @@ public:
};
private:
+ /* Indent management */
+ int indent_size = 4;
+ String indent_text = "\t";
+
+ bool auto_indent = false;
+ Set<char32_t> auto_indent_prefixes;
+
+ bool indent_using_spaces = false;
+ int _calculate_spaces_till_next_left_indent(int p_column) const;
+ int _calculate_spaces_till_next_right_indent(int p_column) const;
+
+ void _new_line(bool p_split_current_line = true, bool p_above = false);
+
/* Main Gutter */
enum MainGutterType {
MAIN_GUTTER_BREAKPOINT = 0x01,
@@ -206,6 +219,27 @@ protected:
public:
virtual CursorShape get_cursor_shape(const Point2 &p_pos = Point2i()) const override;
+ /* Indent management */
+ void set_indent_size(const int p_size);
+ int get_indent_size() const;
+
+ void set_indent_using_spaces(const bool p_use_spaces);
+ bool is_indent_using_spaces() const;
+
+ void set_auto_indent_enabled(bool p_enabled);
+ bool is_auto_indent_enabled() const;
+
+ void set_auto_indent_prefixes(const TypedArray<String> &p_prefixes);
+ TypedArray<String> get_auto_indent_prefixes() const;
+
+ void do_indent();
+ void do_unindent();
+
+ void indent_lines();
+ void unindent_lines();
+
+ virtual void backspace() override;
+
/* Main Gutter */
void set_draw_breakpoints_gutter(bool p_draw);
bool is_drawing_breakpoints_gutter() const;
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index f394b9e3a5..049de4c8c5 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -88,7 +88,7 @@ Ref<Shader> ColorPicker::wheel_shader;
Ref<Shader> ColorPicker::circle_shader;
void ColorPicker::init_shaders() {
- wheel_shader.instance();
+ wheel_shader.instantiate();
wheel_shader->set_code(
"shader_type canvas_item;"
"void fragment() {"
@@ -107,7 +107,7 @@ void ColorPicker::init_shaders() {
" COLOR = vec4(clamp((abs(fract(((a - TAU) / TAU) + vec3(3.0, 2.0, 1.0) / 3.0) * 6.0 - 3.0) - 1.0), 0.0, 1.0), (b + b2 + b3 + b4) / 4.00);"
"}");
- circle_shader.instance();
+ circle_shader.instantiate();
circle_shader->set_code(
"shader_type canvas_item;"
"uniform float v = 1.0;"
@@ -1213,9 +1213,9 @@ ColorPicker::ColorPicker() :
wheel_edit->set_custom_minimum_size(Size2(get_theme_constant("sv_width"), get_theme_constant("sv_height")));
hb_edit->add_child(wheel_edit);
- wheel_mat.instance();
+ wheel_mat.instantiate();
wheel_mat->set_shader(wheel_shader);
- circle_mat.instance();
+ circle_mat.instantiate();
circle_mat->set_shader(circle_shader);
MarginContainer *wheel_margin(memnew(MarginContainer));
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index bb2a8302c4..1bfdff1134 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -650,27 +650,11 @@ void Control::_notification(int p_notification) {
}
}
-bool Control::clips_input() const {
- if (get_script_instance()) {
- return get_script_instance()->call(SceneStringNames::get_singleton()->_clips_input);
- }
- return false;
-}
-
bool Control::has_point(const Point2 &p_point) const {
- if (get_script_instance()) {
- Variant v = p_point;
- const Variant *p = &v;
- Callable::CallError ce;
- Variant ret = get_script_instance()->call(SceneStringNames::get_singleton()->_has_point, &p, 1, ce);
- if (ce.error == Callable::CallError::CALL_OK) {
- return ret;
- }
+ bool ret;
+ if (GDVIRTUAL_CALL(_has_point, p_point, ret)) {
+ return ret;
}
- /*if (has_stylebox("mask")) {
- Ref<StyleBox> mask = get_stylebox("mask");
- return mask->test_mask(p_point,Rect2(Point2(),get_size()));
- }*/
return Rect2(Point2(), get_size()).has_point(p_point);
}
@@ -2784,7 +2768,6 @@ void Control::_bind_methods() {
BIND_VMETHOD(MethodInfo(
PropertyInfo(Variant::OBJECT, "control", PROPERTY_HINT_RESOURCE_TYPE, "Control"),
"_make_custom_tooltip", PropertyInfo(Variant::STRING, "for_text")));
- BIND_VMETHOD(MethodInfo(Variant::BOOL, "_clips_input"));
ADD_GROUP("Anchor", "anchor_");
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "anchor_left", PROPERTY_HINT_RANGE, "0,1,0.001,or_lesser,or_greater"), "_set_anchor", "get_anchor", SIDE_LEFT);
@@ -2807,7 +2790,7 @@ void Control::_bind_methods() {
ADD_GROUP("Rect", "rect_");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "rect_position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_position", "get_position");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "rect_global_position", PROPERTY_HINT_NONE, "", 0), "_set_global_position", "get_global_position");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "rect_global_position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "_set_global_position", "get_global_position");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "rect_size", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_size", "get_size");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "rect_min_size"), "set_custom_minimum_size", "get_custom_minimum_size");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rect_rotation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_rotation", "get_rotation");
@@ -2940,5 +2923,5 @@ void Control::_bind_methods() {
ADD_SIGNAL(MethodInfo("minimum_size_changed"));
ADD_SIGNAL(MethodInfo("theme_changed"));
- BIND_VMETHOD(MethodInfo(Variant::BOOL, "_has_point", PropertyInfo(Variant::VECTOR2, "point")));
+ GDVIRTUAL_BIND(_has_point);
}
diff --git a/scene/gui/control.h b/scene/gui/control.h
index a05025c32d..87fad96571 100644
--- a/scene/gui/control.h
+++ b/scene/gui/control.h
@@ -32,6 +32,7 @@
#define CONTROL_H
#include "core/math/transform_2d.h"
+#include "core/object/gdvirtual.gen.inc"
#include "core/templates/rid.h"
#include "scene/gui/shortcut.h"
#include "scene/main/canvas_item.h"
@@ -264,6 +265,7 @@ private:
static bool has_theme_item_in_types(Control *p_theme_owner, Window *p_theme_owner_window, Theme::DataType p_data_type, const StringName &p_name, List<StringName> p_theme_types);
_FORCE_INLINE_ void _get_theme_type_dependencies(const StringName &p_theme_type, List<StringName> *p_list) const;
+ GDVIRTUAL1RC(bool, _has_point, Vector2)
protected:
virtual void add_child_notify(Node *p_child) override;
virtual void remove_child_notify(Node *p_child) override;
@@ -329,7 +331,6 @@ public:
virtual Size2 get_minimum_size() const;
virtual Size2 get_combined_minimum_size() const;
virtual bool has_point(const Point2 &p_point) const;
- virtual bool clips_input() const;
virtual void set_drag_forwarding(Control *p_target);
virtual Variant get_drag_data(const Point2 &p_point);
virtual bool can_drop_data(const Point2 &p_point, const Variant &p_data) const;
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index 5ef89e38f0..39aa6749e7 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -239,10 +239,6 @@ void GraphEdit::disconnect_node(const StringName &p_from, int p_from_port, const
}
}
-bool GraphEdit::clips_input() const {
- return true;
-}
-
void GraphEdit::get_connection_list(List<Connection> *r_connections) const {
*r_connections = connections;
}
diff --git a/scene/gui/graph_edit.h b/scene/gui/graph_edit.h
index e8300f901c..5251de1722 100644
--- a/scene/gui/graph_edit.h
+++ b/scene/gui/graph_edit.h
@@ -235,7 +235,6 @@ protected:
virtual void add_child_notify(Node *p_child) override;
virtual void remove_child_notify(Node *p_child) override;
void _notification(int p_what);
- virtual bool clips_input() const override;
public:
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 77c502cf8d..93f1fe9e8e 100644
--- a/scene/gui/graph_node.cpp
+++ b/scene/gui/graph_node.cpp
@@ -1021,6 +1021,6 @@ void GraphNode::_bind_methods() {
}
GraphNode::GraphNode() {
- title_buf.instance();
+ title_buf.instantiate();
set_mouse_filter(MOUSE_FILTER_STOP);
}
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index 150980b2e9..b0d54bf8c9 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -57,7 +57,7 @@ int ItemList::add_item(const String &p_item, const Ref<Texture2D> &p_texture, bo
item.icon_region = Rect2i();
item.icon_modulate = Color(1, 1, 1, 1);
item.text = p_item;
- item.text_buf.instance();
+ item.text_buf.instantiate();
item.selectable = p_selectable;
item.selected = false;
item.disabled = false;
@@ -80,7 +80,7 @@ int ItemList::add_icon_item(const Ref<Texture2D> &p_item, bool p_selectable) {
item.icon_region = Rect2i();
item.icon_modulate = Color(1, 1, 1, 1);
//item.text=p_item;
- item.text_buf.instance();
+ item.text_buf.instantiate();
item.selectable = p_selectable;
item.selected = false;
item.disabled = false;
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index 0ce0130ad5..6580d794d1 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -453,6 +453,7 @@ void Label::set_text(const String &p_string) {
visible_chars = get_total_character_count() * percent_visible;
}
update();
+ minimum_size_changed();
}
void Label::set_text_direction(Control::TextDirection p_text_direction) {
diff --git a/scene/gui/link_button.cpp b/scene/gui/link_button.cpp
index d45ffde715..ee0618a991 100644
--- a/scene/gui/link_button.cpp
+++ b/scene/gui/link_button.cpp
@@ -301,7 +301,7 @@ void LinkButton::_bind_methods() {
}
LinkButton::LinkButton() {
- text_buf.instance();
+ text_buf.instantiate();
set_focus_mode(FOCUS_NONE);
set_default_cursor_shape(CURSOR_POINTING_HAND);
}
diff --git a/scene/gui/popup_menu.h b/scene/gui/popup_menu.h
index e4cbe984c9..74718395d3 100644
--- a/scene/gui/popup_menu.h
+++ b/scene/gui/popup_menu.h
@@ -80,8 +80,8 @@ class PopupMenu : public Popup {
}
Item() {
- text_buf.instance();
- accel_text_buf.instance();
+ text_buf.instantiate();
+ accel_text_buf.instantiate();
checkable_type = CHECKABLE_TYPE_NONE;
}
};
diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp
index adc1ed67ca..4ea1e1eb9f 100644
--- a/scene/gui/range.cpp
+++ b/scene/gui/range.cpp
@@ -265,7 +265,7 @@ void Range::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "step"), "set_step", "get_step");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "page"), "set_page", "get_page");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "value"), "set_value", "get_value");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ratio", PROPERTY_HINT_RANGE, "0,1,0.01", 0), "set_as_ratio", "get_as_ratio");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ratio", PROPERTY_HINT_RANGE, "0,1,0.01", PROPERTY_USAGE_NONE), "set_as_ratio", "get_as_ratio");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "exp_edit"), "set_exp_ratio", "is_ratio_exp");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "rounded"), "set_use_rounded_values", "is_using_rounded_values");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_greater"), "set_allow_greater", "is_greater_allowed");
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 987d05bf71..f32ad2144a 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -934,6 +934,11 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o
}
}
+ Vector2 fbg_line_off = off + p_ofs;
+ // Draw background color box
+ Vector2i chr_range = TS->shaped_text_get_range(rid);
+ _draw_fbg_boxes(ci, rid, fbg_line_off, it_from, it_to, chr_range.x, chr_range.y, 0);
+
// Draw main text.
Color selection_fg = get_theme_color("font_selected_color");
Color selection_bg = get_theme_color("selection_color");
@@ -1079,6 +1084,9 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o
off.x += glyphs[i].advance;
}
}
+ // Draw foreground color box
+ _draw_fbg_boxes(ci, rid, fbg_line_off, it_from, it_to, chr_range.x, chr_range.y, 1);
+
off.y += TS->shaped_text_get_descent(rid) + l.text_buf->get_spacing_bottom();
}
@@ -2036,6 +2044,36 @@ bool RichTextLabel::_find_meta(Item *p_item, Variant *r_meta, ItemMeta **r_item)
return false;
}
+Color RichTextLabel::_find_bgcolor(Item *p_item) {
+ Item *item = p_item;
+
+ while (item) {
+ if (item->type == ITEM_BGCOLOR) {
+ ItemBGColor *color = static_cast<ItemBGColor *>(item);
+ return color->color;
+ }
+
+ item = item->parent;
+ }
+
+ return Color(0, 0, 0, 0);
+}
+
+Color RichTextLabel::_find_fgcolor(Item *p_item) {
+ Item *item = p_item;
+
+ while (item) {
+ if (item->type == ITEM_FGCOLOR) {
+ ItemFGColor *color = static_cast<ItemFGColor *>(item);
+ return color->color;
+ }
+
+ item = item->parent;
+ }
+
+ return Color(0, 0, 0, 0);
+}
+
bool RichTextLabel::_find_layout_subitem(Item *from, Item *to) {
if (from && from != to) {
if (from->type != ITEM_FONT && from->type != ITEM_COLOR && from->type != ITEM_UNDERLINE && from->type != ITEM_STRIKETHROUGH) {
@@ -2546,6 +2584,22 @@ void RichTextLabel::push_rainbow(float p_saturation, float p_value, float p_freq
_add_item(item, true);
}
+void RichTextLabel::push_bgcolor(const Color &p_color) {
+ ERR_FAIL_COND(current->type == ITEM_TABLE);
+ ItemBGColor *item = memnew(ItemBGColor);
+
+ item->color = p_color;
+ _add_item(item, true);
+}
+
+void RichTextLabel::push_fgcolor(const Color &p_color) {
+ ERR_FAIL_COND(current->type == ITEM_TABLE);
+ ItemFGColor *item = memnew(ItemFGColor);
+
+ item->color = p_color;
+ _add_item(item, true);
+}
+
void RichTextLabel::push_customfx(Ref<RichTextEffect> p_custom_effect, Dictionary p_environment) {
ItemCustomFX *item = memnew(ItemCustomFX);
item->custom_effect = p_custom_effect;
@@ -3352,6 +3406,23 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
pos = brk_end + 1;
tag_stack.push_front("rainbow");
set_process_internal(true);
+
+ } else if (tag.begins_with("bgcolor=")) {
+ String color_str = tag.substr(8, tag.length());
+ Color color = Color::from_string(color_str, base_color);
+
+ push_bgcolor(color);
+ pos = brk_end + 1;
+ tag_stack.push_front("bgcolor");
+
+ } else if (tag.begins_with("fgcolor=")) {
+ String color_str = tag.substr(8, tag.length());
+ Color color = Color::from_string(color_str, base_color);
+
+ push_fgcolor(color);
+ pos = brk_end + 1;
+ tag_stack.push_front("fgcolor");
+
} else {
Vector<String> &expr = split_tag_block;
if (expr.size() < 1) {
@@ -3918,6 +3989,8 @@ void RichTextLabel::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_cell_size_override", "min_size", "max_size"), &RichTextLabel::set_cell_size_override);
ClassDB::bind_method(D_METHOD("set_cell_padding", "padding"), &RichTextLabel::set_cell_padding);
ClassDB::bind_method(D_METHOD("push_cell"), &RichTextLabel::push_cell);
+ ClassDB::bind_method(D_METHOD("push_fgcolor", "fgcolor"), &RichTextLabel::push_fgcolor);
+ ClassDB::bind_method(D_METHOD("push_bgcolor", "bgcolor"), &RichTextLabel::push_bgcolor);
ClassDB::bind_method(D_METHOD("pop"), &RichTextLabel::pop);
ClassDB::bind_method(D_METHOD("clear"), &RichTextLabel::clear);
@@ -4012,7 +4085,7 @@ void RichTextLabel::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "selection_enabled"), "set_selection_enabled", "is_selection_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "override_selected_font_color"), "set_override_selected_font_color", "is_overriding_selected_font_color");
- ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "custom_effects", PROPERTY_HINT_ARRAY_TYPE, "RichTextEffect", (PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_SCRIPT_VARIABLE)), "set_effects", "get_effects");
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "custom_effects", PROPERTY_HINT_ARRAY_TYPE, vformat("%s/%s:%s", Variant::OBJECT, PROPERTY_HINT_RESOURCE_TYPE, "RichTextEffect"), (PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_SCRIPT_VARIABLE)), "set_effects", "get_effects");
ADD_PROPERTY(PropertyInfo(Variant::INT, "text_direction", PROPERTY_HINT_ENUM, "Auto,Left-to-Right,Right-to-Left,Inherited"), "set_text_direction", "get_text_direction");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "language"), "set_language", "get_language");
@@ -4056,6 +4129,8 @@ void RichTextLabel::_bind_methods() {
BIND_ENUM_CONSTANT(ITEM_WAVE);
BIND_ENUM_CONSTANT(ITEM_TORNADO);
BIND_ENUM_CONSTANT(ITEM_RAINBOW);
+ BIND_ENUM_CONSTANT(ITEM_BGCOLOR);
+ BIND_ENUM_CONSTANT(ITEM_FGCOLOR);
BIND_ENUM_CONSTANT(ITEM_META);
BIND_ENUM_CONSTANT(ITEM_DROPCAP);
BIND_ENUM_CONSTANT(ITEM_CUSTOMFX);
@@ -4108,6 +4183,65 @@ Size2 RichTextLabel::get_minimum_size() const {
return size;
}
+void RichTextLabel::_draw_fbg_boxes(RID p_ci, RID p_rid, Vector2 line_off, Item *it_from, Item *it_to, int start, int end, int fbg_flag) {
+ Vector2i fbg_index = Vector2i(end, start);
+ Color last_color = Color(0, 0, 0, 0);
+ bool draw_box = false;
+ // Draw a box based on color tags associated with glyphs
+ for (int i = start; i < end; i++) {
+ Item *it = _get_item_at_pos(it_from, it_to, i);
+ Color color = Color(0, 0, 0, 0);
+
+ if (fbg_flag == 0) {
+ color = _find_bgcolor(it);
+ } else {
+ color = _find_fgcolor(it);
+ }
+
+ bool change_to_color = ((color.a > 0) && ((last_color.a - 0.0) < 0.01));
+ bool change_from_color = (((color.a - 0.0) < 0.01) && (last_color.a > 0.0));
+ bool change_color = (((color.a > 0) == (last_color.a > 0)) && (color != last_color));
+
+ if (change_to_color) {
+ fbg_index.x = MIN(i, fbg_index.x);
+ fbg_index.y = MAX(i, fbg_index.y);
+ }
+
+ if (change_from_color || change_color) {
+ fbg_index.x = MIN(i, fbg_index.x);
+ fbg_index.y = MAX(i, fbg_index.y);
+ draw_box = true;
+ }
+
+ if (draw_box) {
+ Vector<Vector2> sel = TS->shaped_text_get_selection(p_rid, fbg_index.x, fbg_index.y);
+ for (int j = 0; j < sel.size(); j++) {
+ Vector2 rect_off = line_off + Vector2(sel[j].x, -TS->shaped_text_get_ascent(p_rid));
+ Vector2 rect_size = Vector2(sel[j].y - sel[j].x, TS->shaped_text_get_size(p_rid).y);
+ RenderingServer::get_singleton()->canvas_item_add_rect(p_ci, Rect2(rect_off, rect_size), last_color);
+ }
+ fbg_index = Vector2i(end, start);
+ draw_box = false;
+ }
+
+ if (change_color) {
+ fbg_index.x = MIN(i, fbg_index.x);
+ fbg_index.y = MAX(i, fbg_index.y);
+ }
+
+ last_color = color;
+ }
+
+ if (last_color.a > 0) {
+ Vector<Vector2> sel = TS->shaped_text_get_selection(p_rid, fbg_index.x, end);
+ for (int i = 0; i < sel.size(); i++) {
+ Vector2 rect_off = line_off + Vector2(sel[i].x, -TS->shaped_text_get_ascent(p_rid));
+ Vector2 rect_size = Vector2(sel[i].y - sel[i].x, TS->shaped_text_get_size(p_rid).y);
+ RenderingServer::get_singleton()->canvas_item_add_rect(p_ci, Rect2(rect_off, rect_size), last_color);
+ }
+ }
+}
+
Ref<RichTextEffect> RichTextLabel::_get_custom_effect_by_code(String p_bbcode_identifier) {
for (int i = 0; i < custom_effects.size(); i++) {
if (!custom_effects[i].is_valid()) {
diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h
index 9cf94b0cd7..999d8b05fd 100644
--- a/scene/gui/rich_text_label.h
+++ b/scene/gui/rich_text_label.h
@@ -75,6 +75,8 @@ public:
ITEM_WAVE,
ITEM_TORNADO,
ITEM_RAINBOW,
+ ITEM_BGCOLOR,
+ ITEM_FGCOLOR,
ITEM_META,
ITEM_DROPCAP,
ITEM_CUSTOMFX
@@ -100,7 +102,7 @@ private:
int char_offset = 0;
int char_count = 0;
- Line() { text_buf.instance(); }
+ Line() { text_buf.instantiate(); }
};
struct Item {
@@ -307,13 +309,23 @@ private:
ItemRainbow() { type = ITEM_RAINBOW; }
};
+ struct ItemBGColor : public Item {
+ Color color;
+ ItemBGColor() { type = ITEM_BGCOLOR; }
+ };
+
+ struct ItemFGColor : public Item {
+ Color color;
+ ItemFGColor() { type = ITEM_FGCOLOR; }
+ };
+
struct ItemCustomFX : public ItemFX {
Ref<CharFXTransform> char_fx_transform;
Ref<RichTextEffect> custom_effect;
ItemCustomFX() {
type = ITEM_CUSTOMFX;
- char_fx_transform.instance();
+ char_fx_transform.instantiate();
}
virtual ~ItemCustomFX() {
@@ -422,6 +434,8 @@ private:
bool _find_underline(Item *p_item);
bool _find_strikethrough(Item *p_item);
bool _find_meta(Item *p_item, Variant *r_meta, ItemMeta **r_item = nullptr);
+ Color _find_bgcolor(Item *p_item);
+ Color _find_fgcolor(Item *p_item);
bool _find_layout_subitem(Item *from, Item *to);
void _fetch_item_fx_stack(Item *p_item, Vector<ItemFX *> &r_stack);
@@ -437,6 +451,8 @@ private:
Ref<RichTextEffect> _get_custom_effect_by_code(String p_bbcode_identifier);
virtual Dictionary parse_expressions_for_values(Vector<String> p_expressions);
+ void _draw_fbg_boxes(RID p_ci, RID p_rid, Vector2 line_off, Item *it_from, Item *it_to, int start, int end, int fbg_flag);
+
bool use_bbcode = false;
String bbcode;
@@ -474,6 +490,8 @@ public:
void push_wave(float p_frequency, float p_amplitude);
void push_tornado(float p_frequency, float p_radius);
void push_rainbow(float p_saturation, float p_value, float p_frequency);
+ void push_bgcolor(const Color &p_color);
+ void push_fgcolor(const Color &p_color);
void push_customfx(Ref<RichTextEffect> p_custom_effect, Dictionary p_environment);
void set_table_column_expand(int p_column, bool p_expand, int p_ratio = 1);
void set_cell_row_background_color(const Color &p_odd_row_bg, const Color &p_even_row_bg);
diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp
index 28d1260458..177f146b6a 100644
--- a/scene/gui/scroll_container.cpp
+++ b/scene/gui/scroll_container.cpp
@@ -32,10 +32,6 @@
#include "core/os/os.h"
#include "scene/main/window.h"
-bool ScrollContainer::clips_input() const {
- return true;
-}
-
Size2 ScrollContainer::get_minimum_size() const {
Ref<StyleBox> sb = get_theme_stylebox("bg");
Size2 min_size;
diff --git a/scene/gui/scroll_container.h b/scene/gui/scroll_container.h
index c77a0d62f5..4733fdabca 100644
--- a/scene/gui/scroll_container.h
+++ b/scene/gui/scroll_container.h
@@ -108,8 +108,6 @@ public:
VScrollBar *get_v_scrollbar();
void ensure_control_visible(Control *p_control);
- virtual bool clips_input() const override;
-
TypedArray<String> get_configuration_warnings() const override;
ScrollContainer();
diff --git a/scene/gui/shortcut.cpp b/scene/gui/shortcut.cpp
index cbbcf9e069..962c6dcc60 100644
--- a/scene/gui/shortcut.cpp
+++ b/scene/gui/shortcut.cpp
@@ -42,7 +42,7 @@ Ref<InputEvent> Shortcut::get_shortcut() const {
}
bool Shortcut::is_shortcut(const Ref<InputEvent> &p_event) const {
- return shortcut.is_valid() && shortcut->shortcut_match(p_event);
+ return shortcut.is_valid() && shortcut->is_match(p_event, true);
}
String Shortcut::get_as_text() const {
diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp
index 4ac73ae6b5..941dd30057 100644
--- a/scene/gui/spin_box.cpp
+++ b/scene/gui/spin_box.cpp
@@ -52,7 +52,7 @@ void SpinBox::_value_changed(double) {
void SpinBox::_text_submitted(const String &p_string) {
Ref<Expression> expr;
- expr.instance();
+ expr.instantiate();
String num = TS->parse_number(p_string);
// Ignore the prefix and suffix in the expression
@@ -140,6 +140,8 @@ void SpinBox::_gui_input(const Ref<InputEvent> &p_event) {
accept_event();
}
} break;
+ default:
+ break;
}
}
diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp
index acf0641005..133966013b 100644
--- a/scene/gui/tab_container.cpp
+++ b/scene/gui/tab_container.cpp
@@ -586,7 +586,7 @@ void TabContainer::_refresh_texts() {
Control *control = Object::cast_to<Control>(tabs[i]);
String text = control->has_meta("_tab_name") ? String(tr(String(control->get_meta("_tab_name")))) : String(tr(control->get_name()));
Ref<TextLine> name;
- name.instance();
+ name.instantiate();
name->set_direction(rtl ? TextServer::DIRECTION_RTL : TextServer::DIRECTION_LTR);
name->add_string(text, font, font_size, Dictionary(), TranslationServer::get_singleton()->get_tool_locale());
text_buf.push_back(name);
diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp
index 11096e7976..6f1cff9ec8 100644
--- a/scene/gui/tabs.cpp
+++ b/scene/gui/tabs.cpp
@@ -743,7 +743,7 @@ void Tabs::add_tab(const String &p_str, const Ref<Texture2D> &p_icon) {
Tab t;
t.text = p_str;
t.xl_text = tr(p_str);
- t.text_buf.instance();
+ t.text_buf.instantiate();
t.text_buf->set_direction(is_layout_rtl() ? TextServer::DIRECTION_RTL : TextServer::DIRECTION_LTR);
t.text_buf->add_string(t.xl_text, get_theme_font("font"), get_theme_font_size("font_size"), Dictionary(), TranslationServer::get_singleton()->get_tool_locale());
t.icon = p_icon;
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 6f78d586f1..370fdd8b88 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -102,14 +102,6 @@ static char32_t _get_right_pair_symbol(char32_t c) {
return 0;
}
-static int _find_first_non_whitespace_column_of_line(const String &line) {
- int left = 0;
- while (left < line.length() && _is_whitespace(line[left])) {
- left++;
- }
- return left;
-}
-
///////////////////////////////////////////////////////////////////////////////
void TextEdit::Text::set_font(const Ref<Font> &p_font) {
@@ -120,8 +112,12 @@ void TextEdit::Text::set_font_size(int p_font_size) {
font_size = p_font_size;
}
-void TextEdit::Text::set_indent_size(int p_indent_size) {
- indent_size = p_indent_size;
+void TextEdit::Text::set_tab_size(int p_tab_size) {
+ tab_size = p_tab_size;
+}
+
+int TextEdit::Text::get_tab_size() const {
+ return tab_size;
}
void TextEdit::Text::set_font_features(const Dictionary &p_features) {
@@ -204,9 +200,9 @@ void TextEdit::Text::invalidate_cache(int p_line, int p_column, const String &p_
}
// Apply tab align.
- if (indent_size > 0) {
+ if (tab_size > 0) {
Vector<float> tabs;
- tabs.push_back(font->get_char_size(' ', 0, font_size).width * indent_size);
+ tabs.push_back(font->get_char_size(' ', 0, font_size).width * tab_size);
text.write[p_line].data_buf->tab_align(tabs);
}
}
@@ -214,9 +210,9 @@ void TextEdit::Text::invalidate_cache(int p_line, int p_column, const String &p_
void TextEdit::Text::invalidate_all_lines() {
for (int i = 0; i < text.size(); i++) {
text.write[i].data_buf->set_width(width);
- if (indent_size > 0) {
+ if (tab_size > 0) {
Vector<float> tabs;
- tabs.push_back(font->get_char_size(' ', 0, font_size).width * indent_size);
+ tabs.push_back(font->get_char_size(' ', 0, font_size).width * tab_size);
text.write[i].data_buf->tab_align(tabs);
}
}
@@ -822,7 +818,7 @@ void TextEdit::_notification(int p_what) {
if (draw_minimap) {
int minimap_visible_lines = _get_minimap_visible_rows();
int minimap_line_height = (minimap_char_size.y + minimap_line_spacing);
- int minimap_tab_size = minimap_char_size.x * indent_size;
+ int minimap_tab_size = minimap_char_size.x * text.get_tab_size();
// calculate viewport size and y offset
int viewport_height = (draw_amount - 1) * minimap_line_height;
@@ -1114,7 +1110,7 @@ void TextEdit::_notification(int p_what) {
}
Ref<TextLine> tl;
- tl.instance();
+ tl.instantiate();
tl->add_string(text, cache.font, cache.font_size);
int yofs = ofs_y + (row_height - tl->get_size().y) / 2;
@@ -1695,7 +1691,13 @@ void TextEdit::_consume_backspace_for_pair_symbol(int prev_line, int prev_column
}
}
-void TextEdit::backspace_at_cursor() {
+void TextEdit::backspace() {
+ ScriptInstance *si = get_script_instance();
+ if (si && si->has_method("_backspace")) {
+ si->call("_backspace");
+ return;
+ }
+
if (readonly) {
return;
}
@@ -1704,34 +1706,15 @@ void TextEdit::backspace_at_cursor() {
return;
}
+ if (is_selection_active()) {
+ delete_selection();
+ return;
+ }
+
int prev_line = cursor.column ? cursor.line : cursor.line - 1;
int prev_column = cursor.column ? (cursor.column - 1) : (text[cursor.line - 1].length());
- if (cursor.line != prev_line) {
- for (int i = 0; i < gutters.size(); i++) {
- if (!gutters[i].overwritable) {
- continue;
- }
-
- if (text.get_line_gutter_text(cursor.line, i) != "") {
- text.set_line_gutter_text(prev_line, i, text.get_line_gutter_text(cursor.line, i));
- text.set_line_gutter_item_color(prev_line, i, text.get_line_gutter_item_color(cursor.line, i));
- }
-
- if (text.get_line_gutter_icon(cursor.line, i).is_valid()) {
- text.set_line_gutter_icon(prev_line, i, text.get_line_gutter_icon(cursor.line, i));
- text.set_line_gutter_item_color(prev_line, i, text.get_line_gutter_item_color(cursor.line, i));
- }
-
- if (text.get_line_gutter_metadata(cursor.line, i) != "") {
- text.set_line_gutter_metadata(prev_line, i, text.get_line_gutter_metadata(cursor.line, i));
- }
-
- if (text.is_line_gutter_clickable(cursor.line, i)) {
- text.set_line_gutter_clickable(prev_line, i, true);
- }
- }
- }
+ merge_gutters(cursor.line, prev_line);
if (is_line_hidden(cursor.line)) {
set_line_as_hidden(prev_line, true);
@@ -1742,168 +1725,13 @@ void TextEdit::backspace_at_cursor() {
_is_pair_left_symbol(text[cursor.line][cursor.column - 1])) {
_consume_backspace_for_pair_symbol(prev_line, prev_column);
} else {
- // Handle space indentation.
- if (cursor.column != 0 && indent_using_spaces) {
- // Check if there are no other chars before cursor, just indentation.
- bool unindent = true;
- int i = 0;
- while (i < cursor.column && i < text[cursor.line].length()) {
- if (!_is_whitespace(text[cursor.line][i])) {
- unindent = false;
- break;
- }
- i++;
- }
-
- // Then we can remove all spaces as a single character.
- if (unindent) {
- // We want to remove spaces up to closest indent, or whole indent if cursor is pointing at it.
- int spaces_to_delete = _calculate_spaces_till_next_left_indent(cursor.column);
- prev_column = cursor.column - spaces_to_delete;
- _remove_text(cursor.line, prev_column, cursor.line, cursor.column);
- } else {
- _remove_text(prev_line, prev_column, cursor.line, cursor.column);
- }
- } else {
- _remove_text(prev_line, prev_column, cursor.line, cursor.column);
- }
+ _remove_text(prev_line, prev_column, cursor.line, cursor.column);
}
cursor_set_line(prev_line, false, true);
cursor_set_column(prev_column);
}
-void TextEdit::indent_selected_lines_right() {
- int start_line;
- int end_line;
-
- // This value informs us by how much we changed selection position by indenting right.
- // Default is 1 for tab indentation.
- int selection_offset = 1;
- begin_complex_operation();
-
- if (is_selection_active()) {
- start_line = get_selection_from_line();
- end_line = get_selection_to_line();
- } else {
- start_line = cursor.line;
- end_line = start_line;
- }
-
- // Ignore if the cursor is not past the first column.
- if (is_selection_active() && get_selection_to_column() == 0) {
- selection_offset = 0;
- end_line--;
- }
-
- for (int i = start_line; i <= end_line; i++) {
- String line_text = get_line(i);
- if (line_text.size() == 0 && is_selection_active()) {
- continue;
- }
- if (indent_using_spaces) {
- // We don't really care where selection is - we just need to know indentation level at the beginning of the line.
- int left = _find_first_non_whitespace_column_of_line(line_text);
- int spaces_to_add = _calculate_spaces_till_next_right_indent(left);
- // Since we will add these many spaces, we want to move the whole selection and cursor by this much.
- selection_offset = spaces_to_add;
- for (int j = 0; j < spaces_to_add; j++) {
- line_text = ' ' + line_text;
- }
- } else {
- line_text = '\t' + line_text;
- }
- set_line(i, line_text);
- }
-
- // Fix selection and cursor being off after shifting selection right.
- if (is_selection_active()) {
- select(selection.from_line, selection.from_column + selection_offset, selection.to_line, selection.to_column + selection_offset);
- }
- cursor_set_column(cursor.column + selection_offset, false);
- end_complex_operation();
- update();
-}
-
-void TextEdit::indent_selected_lines_left() {
- int start_line;
- int end_line;
-
- // Moving cursor and selection after unindenting can get tricky because
- // changing content of line can move cursor and selection on its own (if new line ends before previous position of either),
- // therefore we just remember initial values and at the end of the operation offset them by number of removed characters.
- int removed_characters = 0;
- int initial_selection_end_column = selection.to_column;
- int initial_cursor_column = cursor.column;
-
- begin_complex_operation();
-
- if (is_selection_active()) {
- start_line = get_selection_from_line();
- end_line = get_selection_to_line();
- } else {
- start_line = cursor.line;
- end_line = start_line;
- }
-
- // Ignore if the cursor is not past the first column.
- if (is_selection_active() && get_selection_to_column() == 0) {
- end_line--;
- }
- String first_line_text = get_line(start_line);
- String last_line_text = get_line(end_line);
-
- for (int i = start_line; i <= end_line; i++) {
- String line_text = get_line(i);
-
- if (line_text.begins_with("\t")) {
- line_text = line_text.substr(1, line_text.length());
- set_line(i, line_text);
- removed_characters = 1;
- } else if (line_text.begins_with(" ")) {
- // When unindenting we aim to remove spaces before line that has selection no matter what is selected,
- // so we start of by finding first non whitespace character of line
- int left = _find_first_non_whitespace_column_of_line(line_text);
-
- // Here we remove only enough spaces to align text to nearest full multiple of indentation_size.
- // In case where selection begins at the start of indentation_size multiple we remove whole indentation level.
- int spaces_to_remove = _calculate_spaces_till_next_left_indent(left);
-
- line_text = line_text.substr(spaces_to_remove, line_text.length());
- set_line(i, line_text);
- removed_characters = spaces_to_remove;
- }
- }
-
- if (is_selection_active()) {
- // Fix selection being off by one on the first line.
- if (first_line_text != get_line(start_line)) {
- select(selection.from_line, selection.from_column - removed_characters,
- selection.to_line, initial_selection_end_column);
- }
- // Fix selection being off by one on the last line.
- if (last_line_text != get_line(end_line)) {
- select(selection.from_line, selection.from_column,
- selection.to_line, initial_selection_end_column - removed_characters);
- }
- }
- cursor_set_column(initial_cursor_column - removed_characters, false);
- end_complex_operation();
- update();
-}
-
-int TextEdit::_calculate_spaces_till_next_left_indent(int column) {
- int spaces_till_indent = column % indent_size;
- if (spaces_till_indent == 0) {
- spaces_till_indent = indent_size;
- }
- return spaces_till_indent;
-}
-
-int TextEdit::_calculate_spaces_till_next_right_indent(int column) {
- return indent_size - column % indent_size;
-}
-
void TextEdit::_swap_current_input_direction() {
if (input_direction == TEXT_DIRECTION_LTR) {
input_direction = TEXT_DIRECTION_RTL;
@@ -1919,90 +1747,8 @@ void TextEdit::_new_line(bool p_split_current_line, bool p_above) {
return;
}
- String ins = "\n";
-
- // Keep indentation.
- int space_count = 0;
- for (int i = 0; i < cursor.column; i++) {
- if (text[cursor.line][i] == '\t') {
- if (indent_using_spaces) {
- ins += space_indent;
- } else {
- ins += "\t";
- }
- space_count = 0;
- } else if (text[cursor.line][i] == ' ') {
- space_count++;
-
- if (space_count == indent_size) {
- if (indent_using_spaces) {
- ins += space_indent;
- } else {
- ins += "\t";
- }
- space_count = 0;
- }
- } else {
- break;
- }
- }
-
- bool brace_indent = false;
-
- // No need to indent if we are going upwards.
- if (auto_indent && !p_above) {
- // Indent once again if previous line will end with ':','{','[','(' and the line is not a comment
- // (i.e. colon/brace precedes current cursor position).
- if (cursor.column > 0) {
- bool indent_char_found = false;
- bool should_indent = false;
- char indent_char = ':';
- char c = text[cursor.line][cursor.column];
-
- for (int i = 0; i < cursor.column; i++) {
- c = text[cursor.line][i];
- switch (c) {
- case ':':
- case '{':
- case '[':
- case '(':
- indent_char_found = true;
- should_indent = true;
- indent_char = c;
- continue;
- }
-
- if (indent_char_found && is_line_comment(cursor.line)) {
- should_indent = true;
- break;
- } else if (indent_char_found && !_is_whitespace(c)) {
- should_indent = false;
- indent_char_found = false;
- }
- }
-
- if (!is_line_comment(cursor.line) && should_indent) {
- if (indent_using_spaces) {
- ins += space_indent;
- } else {
- ins += "\t";
- }
-
- // No need to move the brace below if we are not taking the text with us.
- char32_t closing_char = _get_right_pair_symbol(indent_char);
- if ((closing_char != 0) && (closing_char == text[cursor.line][cursor.column])) {
- if (p_split_current_line) {
- brace_indent = true;
- ins += "\n" + ins.substr(1, ins.length() - 2);
- } else {
- brace_indent = false;
- ins = "\n" + ins.substr(1, ins.length() - 2);
- }
- }
- }
- }
- }
begin_complex_operation();
+
bool first_line = false;
if (!p_split_current_line) {
if (p_above) {
@@ -2018,83 +1764,13 @@ void TextEdit::_new_line(bool p_split_current_line, bool p_above) {
}
}
- insert_text_at_cursor(ins);
+ insert_text_at_cursor("\n");
if (first_line) {
cursor_set_line(0);
- } else if (brace_indent) {
- cursor_set_line(cursor.line - 1, false);
- cursor_set_column(text[cursor.line].length());
- }
- end_complex_operation();
-}
-
-void TextEdit::_indent_right() {
- if (readonly) {
- return;
- }
-
- if (is_selection_active()) {
- indent_selected_lines_right();
- } else {
- // Simple indent.
- if (indent_using_spaces) {
- // Insert only as much spaces as needed till next indentation level.
- int spaces_to_add = _calculate_spaces_till_next_right_indent(cursor.column);
- String indent_to_insert = String();
- for (int i = 0; i < spaces_to_add; i++) {
- indent_to_insert = ' ' + indent_to_insert;
- }
- _insert_text_at_cursor(indent_to_insert);
- } else {
- _insert_text_at_cursor("\t");
- }
- }
-}
-
-void TextEdit::_indent_left() {
- if (readonly) {
- return;
}
- if (is_selection_active()) {
- indent_selected_lines_left();
- } else {
- // Simple unindent.
- int cc = cursor.column;
- const String &line = text[cursor.line];
-
- int left = _find_first_non_whitespace_column_of_line(line);
- cc = MIN(cc, left);
-
- while (cc < indent_size && cc < left && line[cc] == ' ') {
- cc++;
- }
-
- if (cc > 0 && cc <= text[cursor.line].length()) {
- if (text[cursor.line][cc - 1] == '\t') {
- // Tabs unindentation.
- _remove_text(cursor.line, cc - 1, cursor.line, cc);
- if (cursor.column >= left) {
- cursor_set_column(MAX(0, cursor.column - 1));
- }
- update();
- } else {
- // Spaces unindentation.
- int spaces_to_remove = _calculate_spaces_till_next_left_indent(cc);
- if (spaces_to_remove > 0) {
- _remove_text(cursor.line, cc - spaces_to_remove, cursor.line, cc);
- if (cursor.column > left - spaces_to_remove) { // Inside text?
- cursor_set_column(MAX(0, cursor.column - spaces_to_remove));
- }
- update();
- }
- }
- } else if (cc == 0 && line.length() > 0 && line[0] == '\t') {
- _remove_text(cursor.line, 0, cursor.line, 1);
- update();
- }
- }
+ end_complex_operation();
}
void TextEdit::_move_cursor_left(bool p_select, bool p_move_by_word) {
@@ -2331,20 +2007,24 @@ void TextEdit::_move_cursor_page_down(bool p_select) {
}
}
-void TextEdit::_backspace(bool p_word, bool p_all_to_left) {
+void TextEdit::_do_backspace(bool p_word, bool p_all_to_left) {
if (readonly) {
return;
}
- if (is_selection_active()) {
- _delete_selection();
+ if (is_selection_active() || (!p_all_to_left && !p_word)) {
+ backspace();
return;
}
+
if (p_all_to_left) {
int cursor_current_column = cursor.column;
cursor.column = 0;
_remove_text(cursor.line, 0, cursor.line, cursor_current_column);
- } else if (p_word) {
+ return;
+ }
+
+ if (p_word) {
int line = cursor.line;
int column = cursor.column;
@@ -2360,8 +2040,7 @@ void TextEdit::_backspace(bool p_word, bool p_all_to_left) {
cursor_set_line(line, false);
cursor_set_column(column);
- } else {
- backspace_at_cursor();
+ return;
}
}
@@ -2371,7 +2050,7 @@ void TextEdit::_delete(bool p_word, bool p_all_to_right) {
}
if (is_selection_active()) {
- _delete_selection();
+ delete_selection();
return;
}
int curline_len = text[cursor.line].length();
@@ -2416,15 +2095,16 @@ void TextEdit::_delete(bool p_word, bool p_all_to_right) {
update();
}
-void TextEdit::_delete_selection() {
- if (is_selection_active()) {
- selection.active = false;
- update();
- _remove_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column);
- cursor_set_line(selection.from_line, false, false);
- cursor_set_column(selection.from_column);
- update();
+void TextEdit::delete_selection() {
+ if (!is_selection_active()) {
+ return;
}
+
+ selection.active = false;
+ _remove_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column);
+ cursor_set_line(selection.from_line, false, false);
+ cursor_set_column(selection.from_column);
+ update();
}
void TextEdit::_move_cursor_document_start(bool p_select) {
@@ -2459,7 +2139,7 @@ void TextEdit::_move_cursor_document_end(bool p_select) {
void TextEdit::_handle_unicode_character(uint32_t unicode, bool p_had_selection) {
if (p_had_selection) {
- _delete_selection();
+ delete_selection();
}
// Remove the old character if in insert mode and no selection.
@@ -2942,31 +2622,19 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
return;
}
- // INDENTATION.
- if (k->is_action("ui_text_dedent", true)) {
- _indent_left();
- accept_event();
- return;
- }
- if (k->is_action("ui_text_indent", true)) {
- _indent_right();
- accept_event();
- return;
- }
-
// BACKSPACE AND DELETE.
if (k->is_action("ui_text_backspace_all_to_left", true)) {
- _backspace(false, true);
+ _do_backspace(false, true);
accept_event();
return;
}
if (k->is_action("ui_text_backspace_word", true)) {
- _backspace(true);
+ _do_backspace(true);
accept_event();
return;
}
if (k->is_action("ui_text_backspace", true)) {
- _backspace();
+ _do_backspace();
accept_event();
return;
}
@@ -4540,6 +4208,39 @@ bool TextEdit::is_gutter_overwritable(int p_gutter) const {
return gutters[p_gutter].overwritable;
}
+void TextEdit::merge_gutters(int p_from_line, int p_to_line) {
+ ERR_FAIL_INDEX(p_from_line, text.size());
+ ERR_FAIL_INDEX(p_to_line, text.size());
+ if (p_from_line == p_to_line) {
+ return;
+ }
+
+ for (int i = 0; i < gutters.size(); i++) {
+ if (!gutters[i].overwritable) {
+ continue;
+ }
+
+ if (text.get_line_gutter_text(p_from_line, i) != "") {
+ text.set_line_gutter_text(p_to_line, i, text.get_line_gutter_text(p_from_line, i));
+ text.set_line_gutter_item_color(p_to_line, i, text.get_line_gutter_item_color(p_from_line, i));
+ }
+
+ if (text.get_line_gutter_icon(p_from_line, i).is_valid()) {
+ text.set_line_gutter_icon(p_to_line, i, text.get_line_gutter_icon(p_from_line, i));
+ text.set_line_gutter_item_color(p_to_line, i, text.get_line_gutter_item_color(p_from_line, i));
+ }
+
+ if (text.get_line_gutter_metadata(p_from_line, i) != "") {
+ text.set_line_gutter_metadata(p_to_line, i, text.get_line_gutter_metadata(p_from_line, i));
+ }
+
+ if (text.is_line_gutter_clickable(p_from_line, i)) {
+ text.set_line_gutter_clickable(p_to_line, i, true);
+ }
+ }
+ update();
+}
+
void TextEdit::set_gutter_custom_draw(int p_gutter, Object *p_object, const StringName &p_callback) {
ERR_FAIL_INDEX(p_gutter, gutters.size());
ERR_FAIL_NULL(p_object);
@@ -4625,18 +4326,6 @@ Color TextEdit::get_line_background_color(int p_line) {
return text.get_line_background_color(p_line);
}
-void TextEdit::add_keyword(const String &p_keyword) {
- keywords.insert(p_keyword);
-}
-
-void TextEdit::clear_keywords() {
- keywords.clear();
-}
-
-void TextEdit::set_auto_indent(bool p_auto_indent) {
- auto_indent = p_auto_indent;
-}
-
void TextEdit::cut() {
if (readonly) {
return;
@@ -4652,7 +4341,7 @@ void TextEdit::cut() {
_remove_text(cursor.line, 0, cursor.line + 1, 0);
} else {
_remove_text(cursor.line, 0, cursor.line, text[cursor.line].length());
- backspace_at_cursor();
+ backspace();
cursor_set_line(cursor.line + 1);
}
@@ -5199,7 +4888,6 @@ int TextEdit::get_last_unhidden_line() const {
int TextEdit::get_indent_level(int p_line) const {
ERR_FAIL_INDEX_V(p_line, text.size(), 0);
- // Counts number of tabs and spaces before line starts.
int tab_count = 0;
int whitespace_count = 0;
int line_length = text[p_line].size();
@@ -5212,28 +4900,17 @@ int TextEdit::get_indent_level(int p_line) const {
break;
}
}
- return tab_count * indent_size + whitespace_count;
+ return tab_count * text.get_tab_size() + whitespace_count;
}
-bool TextEdit::is_line_comment(int p_line) const {
- // Checks to see if this line is the start of a comment.
- ERR_FAIL_INDEX_V(p_line, text.size(), false);
+int TextEdit::get_first_non_whitespace_column(int p_line) const {
+ ERR_FAIL_INDEX_V(p_line, text.size(), 0);
- int line_length = text[p_line].size();
- for (int i = 0; i < line_length - 1; i++) {
- if (_is_whitespace(text[p_line][i])) {
- continue;
- }
- if (_is_symbol(text[p_line][i])) {
- if (text[p_line][i] == '\\') {
- i++; // Skip quoted anything.
- continue;
- }
- return text[p_line][i] == '#' || (i + 1 < line_length && text[p_line][i] == '/' && text[p_line][i + 1] == '/');
- }
- break;
+ int col = 0;
+ while (col < text[p_line].length() && _is_whitespace(text[p_line][col])) {
+ col++;
}
- return false;
+ return col;
}
int TextEdit::get_line_count() const {
@@ -5409,32 +5086,18 @@ void TextEdit::_push_current_op() {
}
}
-void TextEdit::set_indent_using_spaces(const bool p_use_spaces) {
- indent_using_spaces = p_use_spaces;
-}
-
-bool TextEdit::is_indent_using_spaces() const {
- return indent_using_spaces;
-}
-
-void TextEdit::set_indent_size(const int p_size) {
- ERR_FAIL_COND_MSG(p_size <= 0, "Indend size must be greater than 0.");
- if (indent_size != p_size) {
- indent_size = p_size;
- text.set_indent_size(p_size);
- text.invalidate_all_lines();
- }
-
- space_indent = "";
- for (int i = 0; i < p_size; i++) {
- space_indent += " ";
+void TextEdit::set_tab_size(const int p_size) {
+ ERR_FAIL_COND_MSG(p_size <= 0, "Tab size must be greater than 0.");
+ if (p_size == text.get_tab_size()) {
+ return;
}
-
+ text.set_tab_size(p_size);
+ text.invalidate_all_lines();
update();
}
-int TextEdit::get_indent_size() {
- return indent_size;
+int TextEdit::get_tab_size() const {
+ return text.get_tab_size();
}
void TextEdit::set_draw_tabs(bool p_draw) {
@@ -6027,6 +5690,11 @@ void TextEdit::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_language", "language"), &TextEdit::set_language);
ClassDB::bind_method(D_METHOD("get_language"), &TextEdit::get_language);
+ ClassDB::bind_method(D_METHOD("get_first_non_whitespace_column", "line"), &TextEdit::get_first_non_whitespace_column);
+ ClassDB::bind_method(D_METHOD("get_indent_level", "line"), &TextEdit::get_indent_level);
+ ClassDB::bind_method(D_METHOD("set_tab_size", "size"), &TextEdit::set_tab_size);
+ ClassDB::bind_method(D_METHOD("get_tab_size"), &TextEdit::get_tab_size);
+
ClassDB::bind_method(D_METHOD("set_text", "text"), &TextEdit::set_text);
ClassDB::bind_method(D_METHOD("insert_text_at_cursor", "text"), &TextEdit::insert_text_at_cursor);
@@ -6081,6 +5749,10 @@ void TextEdit::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_selecting_enabled", "enable"), &TextEdit::set_selecting_enabled);
ClassDB::bind_method(D_METHOD("is_selecting_enabled"), &TextEdit::is_selecting_enabled);
+ ClassDB::bind_method(D_METHOD("delete_selection"), &TextEdit::delete_selection);
+ ClassDB::bind_method(D_METHOD("backspace"), &TextEdit::backspace);
+ BIND_VMETHOD(MethodInfo("_backspace"));
+
ClassDB::bind_method(D_METHOD("cut"), &TextEdit::cut);
ClassDB::bind_method(D_METHOD("copy"), &TextEdit::copy);
ClassDB::bind_method(D_METHOD("paste"), &TextEdit::paste);
@@ -6136,6 +5808,7 @@ void TextEdit::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_gutter_clickable", "gutter"), &TextEdit::is_gutter_clickable);
ClassDB::bind_method(D_METHOD("set_gutter_overwritable", "gutter", "overwritable"), &TextEdit::set_gutter_overwritable);
ClassDB::bind_method(D_METHOD("is_gutter_overwritable", "gutter"), &TextEdit::is_gutter_overwritable);
+ ClassDB::bind_method(D_METHOD("merge_gutters", "from_line", "to_line"), &TextEdit::merge_gutters);
ClassDB::bind_method(D_METHOD("set_gutter_custom_draw", "column", "object", "callback"), &TextEdit::set_gutter_custom_draw);
// Line gutters.
@@ -6262,7 +5935,7 @@ TextEdit::TextEdit() {
_update_caches();
set_default_cursor_shape(CURSOR_IBEAM);
- text.set_indent_size(indent_size);
+ text.set_tab_size(text.get_tab_size());
text.clear();
h_scroll = memnew(HScrollBar);
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index c04d758abb..146de50275 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -96,7 +96,7 @@ private:
bool hidden = false;
Line() {
- data_buf.instance();
+ data_buf.instantiate();
}
};
@@ -112,11 +112,12 @@ private:
int width = -1;
- int indent_size = 4;
+ int tab_size = 4;
int gutter_count = 0;
public:
- void set_indent_size(int p_indent_size);
+ void set_tab_size(int p_tab_size);
+ int get_tab_size() const;
void set_font(const Ref<Font> &p_font);
void set_font_size(int p_font_size);
void set_font_features(const Dictionary &p_features);
@@ -259,9 +260,6 @@ private:
int max_chars = 0;
bool readonly = true; // Initialise to opposite first, so we get past the early-out in set_readonly.
- bool indent_using_spaces = false;
- int indent_size = 4;
- String space_indent = " ";
Timer *caret_blink_timer;
bool caret_blink_enabled = false;
@@ -296,7 +294,6 @@ private:
bool scroll_past_end_of_file_enabled = false;
bool brace_matching_enabled = false;
bool highlight_current_line = false;
- bool auto_indent = false;
String cut_copy_line;
bool insert_mode = false;
@@ -420,14 +417,9 @@ private:
void _clear();
- int _calculate_spaces_till_next_left_indent(int column);
- int _calculate_spaces_till_next_right_indent(int column);
-
// Methods used in shortcuts
void _swap_current_input_direction();
void _new_line(bool p_split_current = true, bool p_above = false);
- void _indent_right();
- void _indent_left();
void _move_cursor_left(bool p_select, bool p_move_by_word = false);
void _move_cursor_right(bool p_select, bool p_move_by_word = false);
void _move_cursor_up(bool p_select);
@@ -436,9 +428,8 @@ private:
void _move_cursor_to_line_end(bool p_select);
void _move_cursor_page_up(bool p_select);
void _move_cursor_page_down(bool p_select);
- void _backspace(bool p_word = false, bool p_all_to_left = false);
+ void _do_backspace(bool p_word = false, bool p_all_to_left = false);
void _delete(bool p_word = false, bool p_all_to_right = false);
- void _delete_selection();
void _move_cursor_document_start(bool p_select);
void _move_cursor_document_end(bool p_select);
void _handle_unicode_character(uint32_t unicode, bool p_had_selection);
@@ -522,6 +513,8 @@ public:
void set_gutter_overwritable(int p_gutter, bool p_overwritable);
bool is_gutter_overwritable(int p_gutter) const;
+ void merge_gutters(int p_from_line, int p_to_line);
+
void set_gutter_custom_draw(int p_gutter, Object *p_object, const StringName &p_callback);
// Line gutters.
@@ -635,12 +628,9 @@ public:
bool has_ime_text() const;
void set_line(int line, String new_text);
int get_row_height() const;
- void backspace_at_cursor();
- void indent_selected_lines_left();
- void indent_selected_lines_right();
int get_indent_level(int p_line) const;
- bool is_line_comment(int p_line) const;
+ int get_first_non_whitespace_column(int p_line) const;
inline void set_scroll_pass_end_of_file(bool p_enabled) {
scroll_past_end_of_file_enabled = p_enabled;
@@ -653,7 +643,6 @@ public:
brace_matching_enabled = p_enabled;
update();
}
- void set_auto_indent(bool p_auto_indent);
void center_viewport_to_cursor();
@@ -699,6 +688,9 @@ public:
void clear();
+ void delete_selection();
+
+ virtual void backspace();
void cut();
void copy();
void paste();
@@ -730,10 +722,8 @@ public:
void redo();
void clear_undo_history();
- void set_indent_using_spaces(const bool p_use_spaces);
- bool is_indent_using_spaces() const;
- void set_indent_size(const int p_size);
- int get_indent_size();
+ void set_tab_size(const int p_size);
+ int get_tab_size() const;
void set_draw_tabs(bool p_draw);
bool is_drawing_tabs() const;
void set_draw_spaces(bool p_draw);
@@ -744,9 +734,6 @@ public:
void set_insert_mode(bool p_enabled);
bool is_insert_mode() const;
- void add_keyword(const String &p_keyword);
- void clear_keywords();
-
double get_v_scroll() const;
void set_v_scroll(double p_scroll);
diff --git a/scene/gui/texture_progress_bar.cpp b/scene/gui/texture_progress_bar.cpp
index 46ce9d5ca9..5e5dec3579 100644
--- a/scene/gui/texture_progress_bar.cpp
+++ b/scene/gui/texture_progress_bar.cpp
@@ -221,43 +221,87 @@ void TextureProgressBar::draw_nine_patch_stretched(const Ref<Texture2D> &p_textu
double width_texture = 0.0;
double first_section_size = 0.0;
double last_section_size = 0.0;
- switch (mode) {
- case FILL_LEFT_TO_RIGHT:
- case FILL_RIGHT_TO_LEFT: {
+ switch (p_mode) {
+ case FILL_LEFT_TO_RIGHT: {
width_total = dst_rect.size.x;
width_texture = texture_size.x;
first_section_size = topleft.x;
last_section_size = bottomright.x;
} break;
- case FILL_TOP_TO_BOTTOM:
- case FILL_BOTTOM_TO_TOP: {
+ case FILL_RIGHT_TO_LEFT: {
+ width_total = dst_rect.size.x;
+ width_texture = texture_size.x;
+ // In contrast to `FILL_LEFT_TO_RIGHT`, `first_section_size` and `last_section_size` should switch value.
+ first_section_size = bottomright.x;
+ last_section_size = topleft.x;
+ } break;
+ case FILL_TOP_TO_BOTTOM: {
width_total = dst_rect.size.y;
width_texture = texture_size.y;
first_section_size = topleft.y;
last_section_size = bottomright.y;
} break;
+ case FILL_BOTTOM_TO_TOP: {
+ width_total = dst_rect.size.y;
+ width_texture = texture_size.y;
+ // Similar to `FILL_RIGHT_TO_LEFT`.
+ first_section_size = bottomright.y;
+ last_section_size = topleft.y;
+ } break;
case FILL_BILINEAR_LEFT_AND_RIGHT: {
- // TODO: Implement
+ width_total = dst_rect.size.x;
+ width_texture = texture_size.x;
+ first_section_size = topleft.x;
+ last_section_size = bottomright.x;
} break;
case FILL_BILINEAR_TOP_AND_BOTTOM: {
- // TODO: Implement
+ width_total = dst_rect.size.y;
+ width_texture = texture_size.y;
+ first_section_size = topleft.y;
+ last_section_size = bottomright.y;
} break;
case FILL_CLOCKWISE:
case FILL_CLOCKWISE_AND_COUNTER_CLOCKWISE:
case FILL_COUNTER_CLOCKWISE: {
- // Those modes are circular, not relevant for nine patch
+ // Those modes are circular, not relevant for nine patch.
} break;
+ case FILL_MODE_MAX:
+ break;
}
double width_filled = width_total * p_ratio;
double middle_section_size = MAX(0.0, width_texture - first_section_size - last_section_size);
- middle_section_size *= MIN(1.0, (MAX(0.0, width_filled - first_section_size) / MAX(1.0, width_total - first_section_size - last_section_size)));
- last_section_size = MAX(0.0, last_section_size - (width_total - width_filled));
- first_section_size = MIN(first_section_size, width_filled);
- width_texture = MIN(width_texture, first_section_size + middle_section_size + last_section_size);
+ // Maximum middle texture size.
+ double max_middle_texture_size = middle_section_size;
+
+ // Maximum real middle texture size.
+ double max_middle_real_size = MAX(0.0, width_total - (first_section_size + last_section_size));
+
+ switch (p_mode) {
+ case FILL_BILINEAR_LEFT_AND_RIGHT:
+ case FILL_BILINEAR_TOP_AND_BOTTOM: {
+ last_section_size = MAX(0.0, last_section_size - (width_total - width_filled) * 0.5);
+ first_section_size = MAX(0.0, first_section_size - (width_total - width_filled) * 0.5);
+
+ // When `width_filled` increases, `middle_section_size` only increases when either of `first_section_size` and `last_section_size` is zero.
+ // Also, it should always be smaller than or equal to `(width_total - (first_section_size + last_section_size))`.
+ double real_middle_size = width_filled - first_section_size - last_section_size;
+ middle_section_size *= MIN(max_middle_real_size, real_middle_size) / max_middle_real_size;
+
+ width_texture = MIN(width_texture, first_section_size + middle_section_size + last_section_size);
+ } break;
+ case FILL_MODE_MAX:
+ break;
+ default: {
+ middle_section_size *= MIN(1.0, (MAX(0.0, width_filled - first_section_size) / MAX(1.0, width_total - first_section_size - last_section_size)));
+ last_section_size = MAX(0.0, last_section_size - (width_total - width_filled));
+ first_section_size = MIN(first_section_size, width_filled);
+ width_texture = MIN(width_texture, first_section_size + middle_section_size + last_section_size);
+ }
+ }
- switch (mode) {
+ switch (p_mode) {
case FILL_LEFT_TO_RIGHT: {
src_rect.size.x = width_texture;
dst_rect.size.x = width_filled;
@@ -287,16 +331,32 @@ void TextureProgressBar::draw_nine_patch_stretched(const Ref<Texture2D> &p_textu
bottomright.y = first_section_size;
} break;
case FILL_BILINEAR_LEFT_AND_RIGHT: {
- // TODO: Implement
+ double center_mapped_from_real_width = (width_total * 0.5 - topleft.x) / max_middle_real_size * max_middle_texture_size + topleft.x;
+ double drift_from_unscaled_center = (src_rect.size.x * 0.5 - center_mapped_from_real_width) * (last_section_size - first_section_size) / (bottomright.x - topleft.x);
+ src_rect.position.x += center_mapped_from_real_width + drift_from_unscaled_center - width_texture * 0.5;
+ src_rect.size.x = width_texture;
+ dst_rect.position.x += (width_total - width_filled) * 0.5;
+ dst_rect.size.x = width_filled;
+ topleft.x = first_section_size;
+ bottomright.x = last_section_size;
} break;
case FILL_BILINEAR_TOP_AND_BOTTOM: {
- // TODO: Implement
+ double center_mapped_from_real_width = (width_total * 0.5 - topleft.y) / max_middle_real_size * max_middle_texture_size + topleft.y;
+ double drift_from_unscaled_center = (src_rect.size.y * 0.5 - center_mapped_from_real_width) * (last_section_size - first_section_size) / (bottomright.y - topleft.y);
+ src_rect.position.y += center_mapped_from_real_width + drift_from_unscaled_center - width_texture * 0.5;
+ src_rect.size.y = width_texture;
+ dst_rect.position.y += (width_total - width_filled) * 0.5;
+ dst_rect.size.y = width_filled;
+ topleft.y = first_section_size;
+ bottomright.y = last_section_size;
} break;
case FILL_CLOCKWISE:
case FILL_CLOCKWISE_AND_COUNTER_CLOCKWISE:
case FILL_COUNTER_CLOCKWISE: {
- // Those modes are circular, not relevant for nine patch
+ // Those modes are circular, not relevant for nine patch.
} break;
+ case FILL_MODE_MAX:
+ break;
}
}
@@ -310,19 +370,34 @@ void TextureProgressBar::_notification(int p_what) {
const float corners[12] = { -0.125, -0.375, -0.625, -0.875, 0.125, 0.375, 0.625, 0.875, 1.125, 1.375, 1.625, 1.875 };
switch (p_what) {
case NOTIFICATION_DRAW: {
- if (nine_patch_stretch && (mode == FILL_LEFT_TO_RIGHT || mode == FILL_RIGHT_TO_LEFT || mode == FILL_TOP_TO_BOTTOM || mode == FILL_BOTTOM_TO_TOP)) {
+ if (nine_patch_stretch && (mode == FILL_LEFT_TO_RIGHT || mode == FILL_RIGHT_TO_LEFT || mode == FILL_TOP_TO_BOTTOM || mode == FILL_BOTTOM_TO_TOP || mode == FILL_BILINEAR_LEFT_AND_RIGHT || mode == FILL_BILINEAR_TOP_AND_BOTTOM)) {
if (under.is_valid()) {
- draw_nine_patch_stretched(under, FILL_LEFT_TO_RIGHT, 1.0, tint_under);
+ draw_nine_patch_stretched(under, mode, 1.0, tint_under);
}
if (progress.is_valid()) {
draw_nine_patch_stretched(progress, mode, get_as_ratio(), tint_progress);
}
if (over.is_valid()) {
- draw_nine_patch_stretched(over, FILL_LEFT_TO_RIGHT, 1.0, tint_over);
+ draw_nine_patch_stretched(over, mode, 1.0, tint_over);
}
} else {
if (under.is_valid()) {
- draw_texture(under, Point2(), tint_under);
+ switch (mode) {
+ case FILL_CLOCKWISE:
+ case FILL_COUNTER_CLOCKWISE:
+ case FILL_CLOCKWISE_AND_COUNTER_CLOCKWISE: {
+ if (nine_patch_stretch) {
+ Rect2 region = Rect2(Point2(), get_size());
+ draw_texture_rect(under, region, false, tint_under);
+ } else {
+ draw_texture(under, Point2(), tint_under);
+ }
+ } break;
+ case FILL_MODE_MAX:
+ break;
+ default:
+ draw_texture(under, Point2(), tint_under);
+ }
}
if (progress.is_valid()) {
Size2 s = progress->get_size();
@@ -353,7 +428,7 @@ void TextureProgressBar::_notification(int p_what) {
float val = get_as_ratio() * rad_max_degrees / 360;
if (val == 1) {
Rect2 region = Rect2(Point2(), s);
- draw_texture_rect_region(progress, region, region, tint_progress);
+ draw_texture_rect(progress, region, false, tint_progress);
} else if (val != 0) {
Array pts;
float direction = mode == FILL_COUNTER_CLOCKWISE ? -1 : 1;
@@ -416,12 +491,29 @@ void TextureProgressBar::_notification(int p_what) {
Rect2 region = Rect2(Point2(0, s.y / 2 - s.y * get_as_ratio() / 2), Size2(s.x, s.y * get_as_ratio()));
draw_texture_rect_region(progress, region, region, tint_progress);
} break;
+ case FILL_MODE_MAX:
+ break;
default:
draw_texture_rect_region(progress, Rect2(Point2(), Size2(s.x * get_as_ratio(), s.y)), Rect2(Point2(), Size2(s.x * get_as_ratio(), s.y)), tint_progress);
}
}
if (over.is_valid()) {
- draw_texture(over, Point2(), tint_over);
+ switch (mode) {
+ case FILL_CLOCKWISE:
+ case FILL_COUNTER_CLOCKWISE:
+ case FILL_CLOCKWISE_AND_COUNTER_CLOCKWISE: {
+ if (nine_patch_stretch) {
+ Rect2 region = Rect2(Point2(), get_size());
+ draw_texture_rect(over, region, false, tint_over);
+ } else {
+ draw_texture(over, Point2(), tint_over);
+ }
+ } break;
+ case FILL_MODE_MAX:
+ break;
+ default:
+ draw_texture(over, Point2(), tint_over);
+ }
}
}
} break;
@@ -429,7 +521,7 @@ void TextureProgressBar::_notification(int p_what) {
}
void TextureProgressBar::set_fill_mode(int p_fill) {
- ERR_FAIL_INDEX(p_fill, 9);
+ ERR_FAIL_INDEX(p_fill, FILL_MODE_MAX);
mode = (FillMode)p_fill;
update();
}
@@ -512,7 +604,7 @@ void TextureProgressBar::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_under", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_under_texture", "get_under_texture");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_over", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_over_texture", "get_over_texture");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_progress", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_progress_texture", "get_progress_texture");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "fill_mode", PROPERTY_HINT_ENUM, "Left to Right,Right to Left,Top to Bottom,Bottom to Top,Clockwise,Counter Clockwise,Bilinear (Left and Right),Bilinear (Top and Bottom), Clockwise and Counter Clockwise"), "set_fill_mode", "get_fill_mode");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "fill_mode", PROPERTY_HINT_ENUM, "Left to Right,Right to Left,Top to Bottom,Bottom to Top,Clockwise,Counter Clockwise,Bilinear (Left and Right),Bilinear (Top and Bottom),Clockwise and Counter Clockwise"), "set_fill_mode", "get_fill_mode");
ADD_GROUP("Tint", "tint_");
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "tint_under"), "set_tint_under", "get_tint_under");
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "tint_over"), "set_tint_over", "get_tint_over");
diff --git a/scene/gui/texture_progress_bar.h b/scene/gui/texture_progress_bar.h
index a3883a7017..d147c43a26 100644
--- a/scene/gui/texture_progress_bar.h
+++ b/scene/gui/texture_progress_bar.h
@@ -54,7 +54,8 @@ public:
FILL_COUNTER_CLOCKWISE,
FILL_BILINEAR_LEFT_AND_RIGHT,
FILL_BILINEAR_TOP_AND_BOTTOM,
- FILL_CLOCKWISE_AND_COUNTER_CLOCKWISE
+ FILL_CLOCKWISE_AND_COUNTER_CLOCKWISE,
+ FILL_MODE_MAX,
};
void set_fill_mode(int p_fill);
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 26d881955b..aac15cd9a5 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -489,11 +489,11 @@ TreeItem *TreeItem::create_child(int p_idx) {
return ti;
}
-Tree *TreeItem::get_tree() {
+Tree *TreeItem::get_tree() const {
return tree;
}
-TreeItem *TreeItem::get_next() {
+TreeItem *TreeItem::get_next() const {
return next;
}
@@ -516,11 +516,11 @@ TreeItem *TreeItem::get_prev() {
return prev;
}
-TreeItem *TreeItem::get_parent() {
+TreeItem *TreeItem::get_parent() const {
return parent;
}
-TreeItem *TreeItem::get_first_child() {
+TreeItem *TreeItem::get_first_child() const {
return first_child;
}
@@ -953,6 +953,53 @@ bool TreeItem::is_folding_disabled() const {
return disable_folding;
}
+Size2 TreeItem::get_minimum_size(int p_column) {
+ ERR_FAIL_INDEX_V(p_column, cells.size(), Size2());
+ Tree *tree = get_tree();
+ ERR_FAIL_COND_V(!tree, Size2());
+
+ Size2 size;
+
+ // Default offset?
+ //size.width += (disable_folding || tree->hide_folding) ? tree->cache.hseparation : tree->cache.item_margin;
+
+ // Text.
+ const TreeItem::Cell &cell = cells[p_column];
+ if (!cell.text.is_empty()) {
+ if (cell.dirty) {
+ tree->update_item_cell(this, p_column);
+ }
+ Size2 text_size = cell.text_buf->get_size();
+ size.width += text_size.width;
+ size.height = MAX(size.height, text_size.height);
+ }
+
+ // Icon.
+ if (cell.icon.is_valid()) {
+ Size2i icon_size = cell.get_icon_size();
+ if (cell.icon_max_w > 0 && icon_size.width > cell.icon_max_w) {
+ icon_size.width = cell.icon_max_w;
+ }
+ size.width += icon_size.width + tree->cache.hseparation;
+ size.height = MAX(size.height, icon_size.height);
+ }
+
+ // Buttons.
+ for (int i = 0; i < cell.buttons.size(); i++) {
+ Ref<Texture2D> texture = cell.buttons[i].texture;
+ if (texture.is_valid()) {
+ Size2 button_size = texture->get_size() + tree->cache.button_pressed->get_minimum_size();
+ size.width += button_size.width;
+ size.height = MAX(size.height, button_size.height);
+ }
+ }
+ if (cell.buttons.size() >= 2) {
+ size.width += (cell.buttons.size() - 1) * tree->cache.button_margin;
+ }
+
+ return size;
+}
+
Variant TreeItem::_call_recursive_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
if (p_argcount < 1) {
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
@@ -1846,78 +1893,76 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
int prev_hl_ofs = base_ofs;
while (c) {
- if (cache.draw_relationship_lines > 0 && (!hide_root || c->parent != root)) {
- int root_ofs = children_pos.x + ((p_item->disable_folding || hide_folding) ? cache.hseparation : cache.item_margin);
- int parent_ofs = p_pos.x + cache.item_margin;
- Point2i root_pos = Point2i(root_ofs, children_pos.y + label_h / 2) - cache.offset + p_draw_ofs;
+ if (htotal >= 0) {
+ int child_h = draw_item(children_pos, p_draw_ofs, p_draw_size, c);
- if (c->get_first_child() != nullptr) {
- root_pos -= Point2i(cache.arrow->get_width(), 0);
- }
+ // Draw relationship lines.
+ if (cache.draw_relationship_lines > 0 && (!hide_root || c->parent != root)) {
+ int root_ofs = children_pos.x + ((p_item->disable_folding || hide_folding) ? cache.hseparation : cache.item_margin);
+ int parent_ofs = p_pos.x + cache.item_margin;
+ Point2i root_pos = Point2i(root_ofs, children_pos.y + label_h / 2) - cache.offset + p_draw_ofs;
+
+ if (c->get_first_child() != nullptr) {
+ root_pos -= Point2i(cache.arrow->get_width(), 0);
+ }
- float line_width = cache.relationship_line_width;
- float parent_line_width = cache.parent_hl_line_width;
- float children_line_width = cache.children_hl_line_width;
+ float line_width = cache.relationship_line_width;
+ float parent_line_width = cache.parent_hl_line_width;
+ float children_line_width = cache.children_hl_line_width;
#ifdef TOOLS_ENABLED
- line_width *= Math::round(EDSCALE);
- parent_line_width *= Math::round(EDSCALE);
- children_line_width *= Math::round(EDSCALE);
+ line_width *= Math::round(EDSCALE);
+ parent_line_width *= Math::round(EDSCALE);
+ children_line_width *= Math::round(EDSCALE);
#endif
- Point2i parent_pos = Point2i(parent_ofs - cache.arrow->get_width() / 2, p_pos.y + label_h / 2 + cache.arrow->get_height() / 2) - cache.offset + p_draw_ofs;
+ Point2i parent_pos = Point2i(parent_ofs - cache.arrow->get_width() / 2, p_pos.y + label_h / 2 + cache.arrow->get_height() / 2) - cache.offset + p_draw_ofs;
- int more_prev_ofs = 0;
+ int more_prev_ofs = 0;
- if (root_pos.y + line_width >= 0) {
- if (rtl) {
- root_pos.x = get_size().width - root_pos.x;
- parent_pos.x = get_size().width - parent_pos.x;
- }
+ if (root_pos.y + line_width >= 0) {
+ if (rtl) {
+ root_pos.x = get_size().width - root_pos.x;
+ parent_pos.x = get_size().width - parent_pos.x;
+ }
- // Order of parts on this bend: the horizontal line first, then the vertical line.
- if (_is_branch_selected(c)) {
- // If this item or one of its children is selected, we draw the line using parent highlight style.
- RenderingServer::get_singleton()->canvas_item_add_line(ci, root_pos, Point2i(parent_pos.x + Math::floor(parent_line_width / 2), root_pos.y), cache.parent_hl_line_color, parent_line_width);
- RenderingServer::get_singleton()->canvas_item_add_line(ci, Point2i(parent_pos.x, root_pos.y + Math::floor(parent_line_width / 2)), Point2i(parent_pos.x, prev_hl_ofs), cache.parent_hl_line_color, parent_line_width);
-
- more_prev_ofs = cache.parent_hl_line_margin;
- prev_hl_ofs = root_pos.y + Math::floor(parent_line_width / 2);
- } else if (p_item->is_selected(0)) {
- // If parent item is selected (but this item is not), we draw the line using children highlight style.
- // Siblings of the selected branch can be drawn with a slight offset and their vertical line must appear as highlighted.
- if (_is_sibling_branch_selected(c)) {
- RenderingServer::get_singleton()->canvas_item_add_line(ci, root_pos, Point2i(parent_pos.x + Math::floor(parent_line_width / 2), root_pos.y), cache.children_hl_line_color, children_line_width);
+ // Order of parts on this bend: the horizontal line first, then the vertical line.
+ if (_is_branch_selected(c)) {
+ // If this item or one of its children is selected, we draw the line using parent highlight style.
+ RenderingServer::get_singleton()->canvas_item_add_line(ci, root_pos, Point2i(parent_pos.x + Math::floor(parent_line_width / 2), root_pos.y), cache.parent_hl_line_color, parent_line_width);
RenderingServer::get_singleton()->canvas_item_add_line(ci, Point2i(parent_pos.x, root_pos.y + Math::floor(parent_line_width / 2)), Point2i(parent_pos.x, prev_hl_ofs), cache.parent_hl_line_color, parent_line_width);
+ more_prev_ofs = cache.parent_hl_line_margin;
prev_hl_ofs = root_pos.y + Math::floor(parent_line_width / 2);
+ } else if (p_item->is_selected(0)) {
+ // If parent item is selected (but this item is not), we draw the line using children highlight style.
+ // Siblings of the selected branch can be drawn with a slight offset and their vertical line must appear as highlighted.
+ if (_is_sibling_branch_selected(c)) {
+ RenderingServer::get_singleton()->canvas_item_add_line(ci, root_pos, Point2i(parent_pos.x + Math::floor(parent_line_width / 2), root_pos.y), cache.children_hl_line_color, children_line_width);
+ RenderingServer::get_singleton()->canvas_item_add_line(ci, Point2i(parent_pos.x, root_pos.y + Math::floor(parent_line_width / 2)), Point2i(parent_pos.x, prev_hl_ofs), cache.parent_hl_line_color, parent_line_width);
+
+ prev_hl_ofs = root_pos.y + Math::floor(parent_line_width / 2);
+ } else {
+ RenderingServer::get_singleton()->canvas_item_add_line(ci, root_pos, Point2i(parent_pos.x + Math::floor(children_line_width / 2), root_pos.y), cache.children_hl_line_color, children_line_width);
+ RenderingServer::get_singleton()->canvas_item_add_line(ci, Point2i(parent_pos.x, root_pos.y + Math::floor(children_line_width / 2)), Point2i(parent_pos.x, prev_ofs + Math::floor(children_line_width / 2)), cache.children_hl_line_color, children_line_width);
+ }
} else {
- RenderingServer::get_singleton()->canvas_item_add_line(ci, root_pos, Point2i(parent_pos.x + Math::floor(children_line_width / 2), root_pos.y), cache.children_hl_line_color, children_line_width);
- RenderingServer::get_singleton()->canvas_item_add_line(ci, Point2i(parent_pos.x, root_pos.y + Math::floor(children_line_width / 2)), Point2i(parent_pos.x, prev_ofs + Math::floor(children_line_width / 2)), cache.children_hl_line_color, children_line_width);
- }
- } else {
- // If nothing of the above is true, we draw the line using normal style.
- // Siblings of the selected branch can be drawn with a slight offset and their vertical line must appear as highlighted.
- if (_is_sibling_branch_selected(c)) {
- RenderingServer::get_singleton()->canvas_item_add_line(ci, root_pos, Point2i(parent_pos.x + cache.parent_hl_line_margin, root_pos.y), cache.relationship_line_color, line_width);
- RenderingServer::get_singleton()->canvas_item_add_line(ci, Point2i(parent_pos.x, root_pos.y + Math::floor(parent_line_width / 2)), Point2i(parent_pos.x, prev_hl_ofs), cache.parent_hl_line_color, parent_line_width);
+ // If nothing of the above is true, we draw the line using normal style.
+ // Siblings of the selected branch can be drawn with a slight offset and their vertical line must appear as highlighted.
+ if (_is_sibling_branch_selected(c)) {
+ RenderingServer::get_singleton()->canvas_item_add_line(ci, root_pos, Point2i(parent_pos.x + cache.parent_hl_line_margin, root_pos.y), cache.relationship_line_color, line_width);
+ RenderingServer::get_singleton()->canvas_item_add_line(ci, Point2i(parent_pos.x, root_pos.y + Math::floor(parent_line_width / 2)), Point2i(parent_pos.x, prev_hl_ofs), cache.parent_hl_line_color, parent_line_width);
- prev_hl_ofs = root_pos.y + Math::floor(parent_line_width / 2);
- } else {
- RenderingServer::get_singleton()->canvas_item_add_line(ci, root_pos, Point2i(parent_pos.x + Math::floor(line_width / 2), root_pos.y), cache.relationship_line_color, line_width);
- RenderingServer::get_singleton()->canvas_item_add_line(ci, Point2i(parent_pos.x, root_pos.y + Math::floor(line_width / 2)), Point2i(parent_pos.x, prev_ofs + Math::floor(line_width / 2)), cache.relationship_line_color, line_width);
+ prev_hl_ofs = root_pos.y + Math::floor(parent_line_width / 2);
+ } else {
+ RenderingServer::get_singleton()->canvas_item_add_line(ci, root_pos, Point2i(parent_pos.x + Math::floor(line_width / 2), root_pos.y), cache.relationship_line_color, line_width);
+ RenderingServer::get_singleton()->canvas_item_add_line(ci, Point2i(parent_pos.x, root_pos.y + Math::floor(line_width / 2)), Point2i(parent_pos.x, prev_ofs + Math::floor(line_width / 2)), cache.relationship_line_color, line_width);
+ }
}
}
- }
- if (htotal < 0) {
- return -1;
+ prev_ofs = root_pos.y + more_prev_ofs;
}
- prev_ofs = root_pos.y + more_prev_ofs;
- }
-
- if (htotal >= 0) {
- int child_h = draw_item(children_pos, p_draw_ofs, p_draw_size, c);
if (child_h < 0) {
if (cache.draw_relationship_lines == 0) {
@@ -2092,7 +2137,7 @@ void Tree::_range_click_timeout() {
click_handled = false;
Ref<InputEventMouseButton> mb;
- mb.instance();
+ mb.instantiate();
propagate_mouse_activated = false; // done from outside, so signal handler can't clear the tree in the middle of emit (which is a common case)
blocked++;
@@ -3161,6 +3206,8 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
}
} break;
+ default:
+ break;
}
}
@@ -3276,7 +3323,7 @@ Size2 Tree::get_internal_min_size() const {
size.height += get_item_height(root);
}
for (int i = 0; i < columns.size(); i++) {
- size.width += columns[i].min_width;
+ size.width += get_column_minimum_width(i);
}
return size;
@@ -3300,26 +3347,38 @@ void Tree::update_scrollbars() {
h_scroll->set_begin(Point2(0, size.height - hmin.height));
h_scroll->set_end(Point2(size.width - vmin.width, size.height));
- Size2 min = get_internal_min_size();
+ Size2 internal_min_size = get_internal_min_size();
- if (min.height < size.height - hmin.height) {
- v_scroll->hide();
- cache.offset.y = 0;
- } else {
+ bool display_vscroll = internal_min_size.height + cache.bg->get_margin(SIDE_TOP) > size.height;
+ bool display_hscroll = internal_min_size.width + cache.bg->get_margin(SIDE_LEFT) > size.width;
+ for (int i = 0; i < 2; i++) {
+ // Check twice, as both values are dependent on each other.
+ if (display_hscroll) {
+ display_vscroll = internal_min_size.height + cache.bg->get_margin(SIDE_TOP) + hmin.height > size.height;
+ }
+ if (display_vscroll) {
+ display_hscroll = internal_min_size.width + cache.bg->get_margin(SIDE_LEFT) + vmin.width > size.width;
+ }
+ }
+
+ if (display_vscroll) {
v_scroll->show();
- v_scroll->set_max(min.height);
+ v_scroll->set_max(internal_min_size.height);
v_scroll->set_page(size.height - hmin.height - tbh);
cache.offset.y = v_scroll->get_value();
+ } else {
+ v_scroll->hide();
+ cache.offset.y = 0;
}
- if (min.width < size.width - vmin.width) {
- h_scroll->hide();
- cache.offset.x = 0;
- } else {
+ if (display_hscroll) {
h_scroll->show();
- h_scroll->set_max(min.width);
+ h_scroll->set_max(internal_min_size.width);
h_scroll->set_page(size.width - vmin.width);
cache.offset.x = h_scroll->get_value();
+ } else {
+ h_scroll->hide();
+ cache.offset.x = 0;
}
}
@@ -3445,7 +3504,7 @@ void Tree::_notification(int p_what) {
draw_ofs.y += tbh;
draw_size.y -= tbh;
- if (root) {
+ if (root && get_size().x > 0 && get_size().y > 0) {
draw_item(Point2(), draw_ofs, draw_size, root);
}
@@ -3513,7 +3572,17 @@ void Tree::_update_all() {
}
Size2 Tree::get_minimum_size() const {
- return Size2(1, 1);
+ if (h_scroll_enabled && v_scroll_enabled) {
+ return Size2();
+ } else {
+ Vector2 min_size = get_internal_min_size();
+ Ref<StyleBox> bg = cache.bg;
+ if (bg.is_valid()) {
+ min_size.x += bg->get_margin(SIDE_LEFT) + bg->get_margin(SIDE_RIGHT);
+ min_size.y += bg->get_margin(SIDE_TOP) + bg->get_margin(SIDE_BOTTOM);
+ }
+ return Vector2(h_scroll_enabled ? 0 : min_size.x, v_scroll_enabled ? 0 : min_size.y);
+ }
}
TreeItem *Tree::create_item(TreeItem *p_parent, int p_idx) {
@@ -3541,11 +3610,11 @@ TreeItem *Tree::create_item(TreeItem *p_parent, int p_idx) {
return ti;
}
-TreeItem *Tree::get_root() {
+TreeItem *Tree::get_root() const {
return root;
}
-TreeItem *Tree::get_last_item() {
+TreeItem *Tree::get_last_item() const {
TreeItem *last = root;
while (last) {
@@ -3675,13 +3744,13 @@ bool Tree::is_root_hidden() const {
return hide_root;
}
-void Tree::set_column_min_width(int p_column, int p_min_width) {
+void Tree::set_column_custom_minimum_width(int p_column, int p_min_width) {
ERR_FAIL_INDEX(p_column, columns.size());
- if (p_min_width < 1) {
+ if (p_min_width < 0) {
return;
}
- columns.write[p_column].min_width = p_min_width;
+ columns.write[p_column].custom_min_width = p_min_width;
update();
}
@@ -3748,44 +3817,82 @@ TreeItem *Tree::get_next_selected(TreeItem *p_item) {
return nullptr;
}
-int Tree::get_column_width(int p_column) const {
+int Tree::get_column_minimum_width(int p_column) const {
ERR_FAIL_INDEX_V(p_column, columns.size(), -1);
- if (!columns[p_column].expand) {
- return columns[p_column].min_width;
- }
+ if (columns[p_column].custom_min_width != 0) {
+ return columns[p_column].custom_min_width;
+ } else {
+ int depth = 0;
+ int min_width = 0;
+ TreeItem *next;
+ for (TreeItem *item = get_root(); item; item = next) {
+ next = item->get_next_visible();
+ // Compute the depth in tree.
+ if (next && p_column == 0) {
+ if (next->get_parent() == item) {
+ depth += 1;
+ } else {
+ TreeItem *common_parent = item->get_parent();
+ while (common_parent != next->get_parent()) {
+ common_parent = common_parent->get_parent();
+ depth -= 1;
+ }
+ }
+ }
- int expand_area = get_size().width;
+ // Get the item minimum size.
+ Size2 item_size = item->get_minimum_size(p_column);
+ if (p_column == 0) {
+ item_size.width += cache.item_margin * depth;
+ }
+ min_width = MAX(min_width, item_size.width);
+ }
+ return min_width;
+ }
+}
- Ref<StyleBox> bg = cache.bg;
+int Tree::get_column_width(int p_column) const {
+ ERR_FAIL_INDEX_V(p_column, columns.size(), -1);
- if (bg.is_valid()) {
- expand_area -= bg->get_margin(SIDE_LEFT) + bg->get_margin(SIDE_RIGHT);
- }
+ if (columns[p_column].expand) {
+ int expand_area = get_size().width;
- if (v_scroll->is_visible_in_tree()) {
- expand_area -= v_scroll->get_combined_minimum_size().width;
- }
+ Ref<StyleBox> bg = cache.bg;
- int expanding_columns = 0;
- int expanding_total = 0;
+ if (bg.is_valid()) {
+ expand_area -= bg->get_margin(SIDE_LEFT) + bg->get_margin(SIDE_RIGHT);
+ }
- for (int i = 0; i < columns.size(); i++) {
- if (!columns[i].expand) {
- expand_area -= columns[i].min_width;
- } else {
- expanding_total += columns[i].min_width;
- expanding_columns++;
+ if (v_scroll->is_visible_in_tree()) {
+ expand_area -= v_scroll->get_combined_minimum_size().width;
}
- }
- if (expand_area < expanding_total) {
- return columns[p_column].min_width;
- }
+ int expanding_columns = 0;
+ int expanding_total = 0;
- ERR_FAIL_COND_V(expanding_columns == 0, -1); // shouldn't happen
+ for (int i = 0; i < columns.size(); i++) {
+ if (!columns[i].expand) {
+ expand_area -= get_column_minimum_width(i);
+ } else {
+ expanding_total += get_column_minimum_width(i);
+ expanding_columns++;
+ }
+ }
- return expand_area * columns[p_column].min_width / expanding_total;
+ if (expand_area < expanding_total) {
+ return get_column_minimum_width(p_column);
+ }
+
+ ERR_FAIL_COND_V(expanding_columns == 0, -1); // shouldn't happen
+ if (expanding_total == 0) {
+ return 0;
+ } else {
+ return expand_area * get_column_minimum_width(p_column) / expanding_total;
+ }
+ } else {
+ return get_column_minimum_width(p_column);
+ }
}
void Tree::propagate_set_columns(TreeItem *p_item) {
@@ -4047,6 +4154,24 @@ void Tree::scroll_to_item(TreeItem *p_item) {
}
}
+void Tree::set_h_scroll_enabled(bool p_enable) {
+ h_scroll_enabled = p_enable;
+ minimum_size_changed();
+}
+
+bool Tree::is_h_scroll_enabled() const {
+ return h_scroll_enabled;
+}
+
+void Tree::set_v_scroll_enabled(bool p_enable) {
+ v_scroll_enabled = p_enable;
+ minimum_size_changed();
+}
+
+bool Tree::is_v_scroll_enabled() const {
+ return v_scroll_enabled;
+}
+
TreeItem *Tree::_search_item_text(TreeItem *p_at, const String &p_find, int *r_col, bool p_selectable, bool p_backwards) {
TreeItem *from = p_at;
TreeItem *loop = nullptr; // Safe-guard against infinite loop.
@@ -4422,7 +4547,7 @@ void Tree::_bind_methods() {
ClassDB::bind_method(D_METHOD("create_item", "parent", "idx"), &Tree::_create_item, DEFVAL(Variant()), DEFVAL(-1));
ClassDB::bind_method(D_METHOD("get_root"), &Tree::get_root);
- ClassDB::bind_method(D_METHOD("set_column_min_width", "column", "min_width"), &Tree::set_column_min_width);
+ ClassDB::bind_method(D_METHOD("set_column_custom_minimum_width", "column", "min_width"), &Tree::set_column_custom_minimum_width);
ClassDB::bind_method(D_METHOD("set_column_expand", "column", "expand"), &Tree::set_column_expand);
ClassDB::bind_method(D_METHOD("get_column_width", "column"), &Tree::get_column_width);
@@ -4468,6 +4593,12 @@ void Tree::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_scroll"), &Tree::get_scroll);
ClassDB::bind_method(D_METHOD("scroll_to_item", "item"), &Tree::_scroll_to_item);
+ ClassDB::bind_method(D_METHOD("set_h_scroll_enabled", "h_scroll"), &Tree::set_h_scroll_enabled);
+ ClassDB::bind_method(D_METHOD("is_h_scroll_enabled"), &Tree::is_h_scroll_enabled);
+
+ ClassDB::bind_method(D_METHOD("set_v_scroll_enabled", "h_scroll"), &Tree::set_v_scroll_enabled);
+ ClassDB::bind_method(D_METHOD("is_v_scroll_enabled"), &Tree::is_v_scroll_enabled);
+
ClassDB::bind_method(D_METHOD("set_hide_folding", "hide"), &Tree::set_hide_folding);
ClassDB::bind_method(D_METHOD("is_folding_hidden"), &Tree::is_folding_hidden);
@@ -4487,6 +4618,8 @@ void Tree::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "hide_root"), "set_hide_root", "is_root_hidden");
ADD_PROPERTY(PropertyInfo(Variant::INT, "drop_mode_flags", PROPERTY_HINT_FLAGS, "On Item,In Between"), "set_drop_mode_flags", "get_drop_mode_flags");
ADD_PROPERTY(PropertyInfo(Variant::INT, "select_mode", PROPERTY_HINT_ENUM, "Single,Row,Multi"), "set_select_mode", "get_select_mode");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "scroll_horizontal_enabled"), "set_h_scroll_enabled", "is_h_scroll_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "scroll_vertical_enabled"), "set_v_scroll_enabled", "is_v_scroll_enabled");
ADD_SIGNAL(MethodInfo("item_selected"));
ADD_SIGNAL(MethodInfo("cell_selected"));
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index 0571a605a5..fd5fcd7838 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -115,7 +115,7 @@ private:
Ref<Font> custom_font;
Cell() {
- text_buf.instance();
+ text_buf.instantiate();
}
Size2 get_icon_size() const;
@@ -315,16 +315,18 @@ public:
void set_disable_folding(bool p_disable);
bool is_folding_disabled() const;
+ Size2 get_minimum_size(int p_column);
+
/* Item manipulation */
TreeItem *create_child(int p_idx = -1);
- Tree *get_tree();
+ Tree *get_tree() const;
TreeItem *get_prev();
- TreeItem *get_next();
- TreeItem *get_parent();
- TreeItem *get_first_child();
+ TreeItem *get_next() const;
+ TreeItem *get_parent() const;
+ TreeItem *get_first_child() const;
TreeItem *get_prev_visible(bool p_wrap = false);
TreeItem *get_next_visible(bool p_wrap = false);
@@ -408,7 +410,7 @@ private:
int drop_mode_flags = 0;
struct ColumnInfo {
- int min_width = 1;
+ int custom_min_width = 0;
bool expand = true;
String title;
Ref<TextLine> text_buf;
@@ -416,7 +418,7 @@ private:
String language;
Control::TextDirection text_direction = Control::TEXT_DIRECTION_INHERITED;
ColumnInfo() {
- text_buf.instance();
+ text_buf.instantiate();
}
};
@@ -545,6 +547,8 @@ private:
void _scroll_moved(float p_value);
HScrollBar *h_scroll;
VScrollBar *v_scroll;
+ bool h_scroll_enabled = true;
+ bool v_scroll_enabled = true;
Size2 get_internal_min_size() const;
void update_cache();
@@ -623,11 +627,12 @@ public:
void clear();
TreeItem *create_item(TreeItem *p_parent = nullptr, int p_idx = -1);
- TreeItem *get_root();
- TreeItem *get_last_item();
+ TreeItem *get_root() const;
+ TreeItem *get_last_item() const;
- void set_column_min_width(int p_column, int p_min_width);
+ void set_column_custom_minimum_width(int p_column, int p_min_width);
void set_column_expand(int p_column, bool p_expand);
+ int get_column_minimum_width(int p_column) const;
int get_column_width(int p_column) const;
void set_hide_root(bool p_enabled);
@@ -679,6 +684,10 @@ public:
Point2 get_scroll() const;
void scroll_to_item(TreeItem *p_item);
+ void set_h_scroll_enabled(bool p_enable);
+ bool is_h_scroll_enabled() const;
+ void set_v_scroll_enabled(bool p_enable);
+ bool is_v_scroll_enabled() const;
void set_cursor_can_exit_tree(bool p_enable);
diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp
index 0590ae2415..ed3c0b7a56 100644
--- a/scene/gui/video_player.cpp
+++ b/scene/gui/video_player.cpp
@@ -452,12 +452,12 @@ void VideoPlayer::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE, "VideoStream"), "set_stream", "get_stream");
//ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/loop"), "set_loop", "has_loop") ;
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "volume_db", PROPERTY_HINT_RANGE, "-80,24,0.01"), "set_volume_db", "get_volume_db");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "volume", PROPERTY_HINT_EXP_RANGE, "0,15,0.01", 0), "set_volume", "get_volume");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "volume", PROPERTY_HINT_EXP_RANGE, "0,15,0.01", PROPERTY_USAGE_NONE), "set_volume", "get_volume");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "autoplay"), "set_autoplay", "has_autoplay");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "paused"), "set_paused", "is_paused");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "expand"), "set_expand", "has_expand");
ADD_PROPERTY(PropertyInfo(Variant::INT, "buffering_msec", PROPERTY_HINT_RANGE, "10,1000"), "set_buffering_msec", "get_buffering_msec");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "stream_position", PROPERTY_HINT_RANGE, "0,1280000,0.1", 0), "set_stream_position", "get_stream_position");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "stream_position", PROPERTY_HINT_RANGE, "0,1280000,0.1", PROPERTY_USAGE_NONE), "set_stream_position", "get_stream_position");
ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "bus", PROPERTY_HINT_ENUM, ""), "set_bus", "get_bus");
}
diff --git a/scene/main/canvas_item.cpp b/scene/main/canvas_item.cpp
index a4393d682f..361f584a5d 100644
--- a/scene/main/canvas_item.cpp
+++ b/scene/main/canvas_item.cpp
@@ -1218,7 +1218,7 @@ void CanvasItem::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "self_modulate"), "set_self_modulate", "get_self_modulate");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_behind_parent"), "set_draw_behind_parent", "is_draw_behind_parent_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "top_level"), "set_as_top_level", "is_set_as_top_level");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_on_top", PROPERTY_HINT_NONE, "", 0), "_set_on_top", "_is_on_top"); //compatibility
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_on_top", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "_set_on_top", "_is_on_top"); //compatibility
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "clip_children"), "set_clip_children", "is_clipping_children");
ADD_PROPERTY(PropertyInfo(Variant::INT, "light_mask", PROPERTY_HINT_LAYERS_2D_RENDER), "set_light_mask", "get_light_mask");
diff --git a/scene/main/canvas_layer.cpp b/scene/main/canvas_layer.cpp
index 85d7edd64b..f699e68715 100644
--- a/scene/main/canvas_layer.cpp
+++ b/scene/main/canvas_layer.cpp
@@ -303,7 +303,7 @@ void CanvasLayer::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scale"), "set_scale", "get_scale");
ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "transform"), "set_transform", "get_transform");
ADD_GROUP("", "");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "custom_viewport", PROPERTY_HINT_RESOURCE_TYPE, "Viewport", 0), "set_custom_viewport", "get_custom_viewport");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "custom_viewport", PROPERTY_HINT_RESOURCE_TYPE, "Viewport", PROPERTY_USAGE_NONE), "set_custom_viewport", "get_custom_viewport");
ADD_GROUP("Follow Viewport", "follow_viewport");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "follow_viewport_enable"), "set_follow_viewport", "is_following_viewport");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "follow_viewport_scale", PROPERTY_HINT_RANGE, "0.001,1000,0.001,or_greater,or_lesser"), "set_follow_viewport_scale", "get_follow_viewport_scale");
diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp
index 927b114fbc..775dfa4c46 100644
--- a/scene/main/http_request.cpp
+++ b/scene/main/http_request.cpp
@@ -322,7 +322,8 @@ bool HTTPRequest::_update_connection() {
} else {
// Did not request yet, do request
- Error err = client->request_raw(method, request_string, headers, request_data);
+ int size = request_data.size();
+ Error err = client->request(method, request_string, headers, size > 0 ? request_data.ptr() : nullptr, size);
if (err != OK) {
call_deferred("_request_done", RESULT_CONNECTION_ERROR, 0, PackedStringArray(), PackedByteArray());
return true;
@@ -627,7 +628,7 @@ void HTTPRequest::_bind_methods() {
}
HTTPRequest::HTTPRequest() {
- client.instance();
+ client = Ref<HTTPClient>(HTTPClient::create());
timer = memnew(Timer);
timer->set_one_shot(true);
timer->connect("timeout", callable_mp(this, &HTTPRequest::_timeout));
diff --git a/scene/main/instance_placeholder.cpp b/scene/main/instance_placeholder.cpp
index 1661984e30..89dac5f5a8 100644
--- a/scene/main/instance_placeholder.cpp
+++ b/scene/main/instance_placeholder.cpp
@@ -88,7 +88,7 @@ Node *InstancePlaceholder::create_instance(bool p_replace, const Ref<PackedScene
if (!ps.is_valid()) {
return nullptr;
}
- Node *scene = ps->instance();
+ Node *scene = ps->instantiate();
if (!scene) {
return nullptr;
}
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 8cf2aa24fb..9479b1339d 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -35,6 +35,7 @@
#include "core/object/message_queue.h"
#include "core/string/print_string.h"
#include "instance_placeholder.h"
+#include "scene/animation/tween.h"
#include "scene/debugger/scene_debugger.h"
#include "scene/resources/packed_scene.h"
#include "scene/scene_string_names.h"
@@ -1686,6 +1687,13 @@ int Node::get_index() const {
return data.pos;
}
+Ref<Tween> Node::create_tween() {
+ ERR_FAIL_COND_V_MSG(!data.tree, nullptr, "Can't create Tween when not inside scene tree.");
+ Ref<Tween> tween = get_tree()->create_tween();
+ tween->bind_node(this);
+ return tween;
+}
+
void Node::remove_and_skip() {
ERR_FAIL_COND(!data.parent);
@@ -1805,7 +1813,7 @@ bool Node::get_scene_instance_load_placeholder() const {
Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const {
Node *node = nullptr;
- bool instanced = false;
+ bool instantiated = false;
if (Object::cast_to<InstancePlaceholder>(this)) {
const InstancePlaceholder *ip = Object::cast_to<const InstancePlaceholder>(this);
@@ -1822,13 +1830,13 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const
ges = PackedScene::GEN_EDIT_STATE_INSTANCE;
}
#endif
- node = res->instance(ges);
+ node = res->instantiate(ges);
ERR_FAIL_COND_V(!node, nullptr);
- instanced = true;
+ instantiated = true;
} else {
- Object *obj = ClassDB::instance(get_class());
+ Object *obj = ClassDB::instantiate(get_class());
ERR_FAIL_COND_V(!obj, nullptr);
node = Object::cast_to<Node>(obj);
if (!node) {
@@ -1848,9 +1856,9 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const
List<const Node *> node_tree;
node_tree.push_front(this);
- if (instanced) {
- // Since nodes in the instanced hierarchy won't be duplicated explicitly, we need to make an inventory
- // of all the nodes in the tree of the instanced scene in order to transfer the values of the properties
+ if (instantiated) {
+ // Since nodes in the instantiated hierarchy won't be duplicated explicitly, we need to make an inventory
+ // of all the nodes in the tree of the instantiated scene in order to transfer the values of the properties
Vector<const Node *> instance_roots;
instance_roots.push_back(this);
@@ -1858,8 +1866,8 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const
for (List<const Node *>::Element *N = node_tree.front(); N; N = N->next()) {
for (int i = 0; i < N->get()->get_child_count(); ++i) {
Node *descendant = N->get()->get_child(i);
- // Skip nodes not really belonging to the instanced hierarchy; they'll be processed normally later
- // but remember non-instanced nodes that are hidden below instanced ones
+ // Skip nodes not really belonging to the instantiated hierarchy; they'll be processed normally later
+ // but remember non-instantiated nodes that are hidden below instantiated ones
if (!instance_roots.has(descendant->get_owner())) {
if (descendant->get_parent() && descendant->get_parent() != this && descendant->data.owner != descendant->get_parent()) {
hidden_roots.push_back(descendant);
@@ -1942,7 +1950,7 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const
if (get_child(i)->data.parent_owned) {
continue;
}
- if (instanced && get_child(i)->data.owner == this) {
+ if (instantiated && get_child(i)->data.owner == this) {
continue; //part of instance
}
@@ -2555,6 +2563,7 @@ void Node::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_physics_processing_internal"), &Node::is_physics_processing_internal);
ClassDB::bind_method(D_METHOD("get_tree"), &Node::get_tree);
+ ClassDB::bind_method(D_METHOD("create_tween"), &Node::create_tween);
ClassDB::bind_method(D_METHOD("duplicate", "flags"), &Node::duplicate, DEFVAL(DUPLICATE_USE_INSTANCING | DUPLICATE_SIGNALS | DUPLICATE_GROUPS | DUPLICATE_SCRIPTS));
ClassDB::bind_method(D_METHOD("replace_by", "node", "keep_groups"), &Node::replace_by, DEFVAL(false));
@@ -2658,11 +2667,11 @@ void Node::_bind_methods() {
ADD_SIGNAL(MethodInfo("tree_exiting"));
ADD_SIGNAL(MethodInfo("tree_exited"));
- ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "name", PROPERTY_HINT_NONE, "", 0), "set_name", "get_name");
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "filename", PROPERTY_HINT_NONE, "", 0), "set_filename", "get_filename");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "owner", PROPERTY_HINT_RESOURCE_TYPE, "Node", 0), "set_owner", "get_owner");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "multiplayer", PROPERTY_HINT_RESOURCE_TYPE, "MultiplayerAPI", 0), "", "get_multiplayer");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "custom_multiplayer", PROPERTY_HINT_RESOURCE_TYPE, "MultiplayerAPI", 0), "set_custom_multiplayer", "get_custom_multiplayer");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_name", "get_name");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "filename", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_filename", "get_filename");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "owner", PROPERTY_HINT_RESOURCE_TYPE, "Node", PROPERTY_USAGE_NONE), "set_owner", "get_owner");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "multiplayer", PROPERTY_HINT_RESOURCE_TYPE, "MultiplayerAPI", PROPERTY_USAGE_NONE), "", "get_multiplayer");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "custom_multiplayer", PROPERTY_HINT_RESOURCE_TYPE, "MultiplayerAPI", PROPERTY_USAGE_NONE), "set_custom_multiplayer", "get_custom_multiplayer");
ADD_GROUP("Process", "process_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "process_mode", PROPERTY_HINT_ENUM, "Inherit,Pausable,When Paused,Always,Disabled"), "set_process_mode", "get_process_mode");
diff --git a/scene/main/node.h b/scene/main/node.h
index d088508f9e..f685eac86a 100644
--- a/scene/main/node.h
+++ b/scene/main/node.h
@@ -41,6 +41,9 @@
class Viewport;
class SceneState;
+class Tween;
+class PropertyTweener;
+
class Node : public Object {
GDCLASS(Node, Object);
OBJ_CATEGORY("Nodes");
@@ -308,6 +311,8 @@ public:
void remove_and_skip();
int get_index() const;
+ Ref<Tween> create_tween();
+
void print_tree();
void print_tree_pretty();
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index 7f6163ab0c..4b52c4e99f 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -41,6 +41,7 @@
#include "core/os/os.h"
#include "core/string/print_string.h"
#include "node.h"
+#include "scene/animation/tween.h"
#include "scene/debugger/scene_debugger.h"
#include "scene/resources/font.h"
#include "scene/resources/material.h"
@@ -412,6 +413,9 @@ bool SceneTree::physics_process(float p_time) {
_notify_group_pause("physics_process", Node::NOTIFICATION_PHYSICS_PROCESS);
_flush_ugc();
MessageQueue::get_singleton()->flush(); //small little hack
+
+ process_tweens(p_time, true);
+
flush_transform_notifications();
root_lock--;
@@ -476,6 +480,8 @@ bool SceneTree::process(float p_time) {
E = N;
}
+ process_tweens(p_time, false);
+
flush_transform_notifications(); //additional transforms after timers update
_call_idle_callbacks();
@@ -510,6 +516,32 @@ bool SceneTree::process(float p_time) {
return _quit;
}
+void SceneTree::process_tweens(float p_delta, bool p_physics) {
+ // This methods works similarly to how SceneTreeTimers are handled.
+ List<Ref<Tween>>::Element *L = tweens.back();
+
+ for (List<Ref<Tween>>::Element *E = tweens.front(); E;) {
+ List<Ref<Tween>>::Element *N = E->next();
+ // Don't process if paused or process mode doesn't match.
+ if ((paused && E->get()->should_pause()) || (p_physics == (E->get()->get_process_mode() == Tween::TWEEN_PROCESS_IDLE))) {
+ if (E == L) {
+ break;
+ }
+ E = N;
+ continue;
+ }
+
+ if (!E->get()->step(p_delta)) {
+ E->get()->set_valid(false);
+ tweens.erase(E);
+ }
+ if (E == L) {
+ break;
+ }
+ E = N;
+ }
+}
+
void SceneTree::finalize() {
_flush_delete_queue();
@@ -1061,7 +1093,7 @@ Error SceneTree::change_scene(const String &p_path) {
Error SceneTree::change_scene_to(const Ref<PackedScene> &p_scene) {
Node *new_scene = nullptr;
if (p_scene.is_valid()) {
- new_scene = p_scene->instance();
+ new_scene = p_scene->instantiate();
ERR_FAIL_COND_V(!new_scene, ERR_CANT_CREATE);
}
@@ -1082,13 +1114,34 @@ void SceneTree::add_current_scene(Node *p_current) {
Ref<SceneTreeTimer> SceneTree::create_timer(float p_delay_sec, bool p_process_always) {
Ref<SceneTreeTimer> stt;
- stt.instance();
+ stt.instantiate();
stt->set_process_always(p_process_always);
stt->set_time_left(p_delay_sec);
timers.push_back(stt);
return stt;
}
+Ref<Tween> SceneTree::create_tween() {
+ Ref<Tween> tween;
+ tween.instantiate();
+ tween->set_valid(true);
+ tweens.push_back(tween);
+ return tween;
+}
+
+Array SceneTree::get_processed_tweens() {
+ Array ret;
+ ret.resize(tweens.size());
+
+ int i = 0;
+ for (List<Ref<Tween>>::Element *E = tweens.front(); E; E = E->next()) {
+ ret[i] = E->get();
+ i++;
+ }
+
+ return ret;
+}
+
void SceneTree::_network_peer_connected(int p_id) {
emit_signal("network_peer_connected", p_id);
}
@@ -1197,6 +1250,8 @@ void SceneTree::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_paused"), &SceneTree::is_paused);
ClassDB::bind_method(D_METHOD("create_timer", "time_sec", "process_always"), &SceneTree::create_timer, DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("create_tween"), &SceneTree::create_tween);
+ ClassDB::bind_method(D_METHOD("get_processed_tweens"), &SceneTree::get_processed_tweens);
ClassDB::bind_method(D_METHOD("get_node_count"), &SceneTree::get_node_count);
ClassDB::bind_method(D_METHOD("get_frame"), &SceneTree::get_frame);
@@ -1257,11 +1312,11 @@ void SceneTree::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "paused"), "set_pause", "is_paused");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "refuse_new_network_connections"), "set_refuse_new_network_connections", "is_refusing_new_network_connections");
ADD_PROPERTY_DEFAULT("refuse_new_network_connections", false);
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "edited_scene_root", PROPERTY_HINT_RESOURCE_TYPE, "Node", 0), "set_edited_scene_root", "get_edited_scene_root");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "current_scene", PROPERTY_HINT_RESOURCE_TYPE, "Node", 0), "set_current_scene", "get_current_scene");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "network_peer", PROPERTY_HINT_RESOURCE_TYPE, "NetworkedMultiplayerPeer", 0), "set_network_peer", "get_network_peer");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "root", PROPERTY_HINT_RESOURCE_TYPE, "Node", 0), "", "get_root");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "multiplayer", PROPERTY_HINT_RESOURCE_TYPE, "MultiplayerAPI", 0), "set_multiplayer", "get_multiplayer");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "edited_scene_root", PROPERTY_HINT_RESOURCE_TYPE, "Node", PROPERTY_USAGE_NONE), "set_edited_scene_root", "get_edited_scene_root");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "current_scene", PROPERTY_HINT_RESOURCE_TYPE, "Node", PROPERTY_USAGE_NONE), "set_current_scene", "get_current_scene");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "network_peer", PROPERTY_HINT_RESOURCE_TYPE, "NetworkedMultiplayerPeer", PROPERTY_USAGE_NONE), "set_network_peer", "get_network_peer");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "root", PROPERTY_HINT_RESOURCE_TYPE, "Node", PROPERTY_USAGE_NONE), "", "get_root");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "multiplayer", PROPERTY_HINT_RESOURCE_TYPE, "MultiplayerAPI", PROPERTY_USAGE_NONE), "set_multiplayer", "get_multiplayer");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "multiplayer_poll"), "set_multiplayer_poll_enabled", "is_multiplayer_poll_enabled");
ADD_SIGNAL(MethodInfo("tree_changed"));
diff --git a/scene/main/scene_tree.h b/scene/main/scene_tree.h
index 78c4c14e97..0e9ffb0f5f 100644
--- a/scene/main/scene_tree.h
+++ b/scene/main/scene_tree.h
@@ -47,6 +47,7 @@ class Window;
class Material;
class Mesh;
class SceneDebugger;
+class Tween;
class SceneTreeTimer : public RefCounted {
GDCLASS(SceneTreeTimer, RefCounted);
@@ -151,6 +152,7 @@ private:
//void _call_group(uint32_t p_call_flags,const StringName& p_group,const StringName& p_function,const Variant& p_arg1,const Variant& p_arg2);
List<Ref<SceneTreeTimer>> timers;
+ List<Ref<Tween>> tweens;
///network///
@@ -171,6 +173,7 @@ private:
void node_added(Node *p_node);
void node_removed(Node *p_node);
void node_renamed(Node *p_node);
+ void process_tweens(float p_delta, bool p_physics_frame);
Group *add_to_group(const StringName &p_group, Node *p_node);
void remove_from_group(const StringName &p_group, Node *p_node);
@@ -318,6 +321,8 @@ public:
Error reload_current_scene();
Ref<SceneTreeTimer> create_timer(float p_delay_sec, bool p_process_always = true);
+ Ref<Tween> create_tween();
+ Array get_processed_tweens();
//used by Main::start, don't use otherwise
void add_current_scene(Node *p_current);
diff --git a/scene/main/timer.cpp b/scene/main/timer.cpp
index d88956e56d..ea9f51aa5d 100644
--- a/scene/main/timer.cpp
+++ b/scene/main/timer.cpp
@@ -210,8 +210,8 @@ void Timer::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "wait_time", PROPERTY_HINT_EXP_RANGE, "0.001,4096,0.001,or_greater"), "set_wait_time", "get_wait_time");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "one_shot"), "set_one_shot", "is_one_shot");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "autostart"), "set_autostart", "has_autostart");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "paused", PROPERTY_HINT_NONE, "", 0), "set_paused", "is_paused");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "time_left", PROPERTY_HINT_NONE, "", 0), "", "get_time_left");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "paused", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_paused", "is_paused");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "time_left", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_time_left");
BIND_ENUM_CONSTANT(TIMER_PROCESS_PHYSICS);
BIND_ENUM_CONSTANT(TIMER_PROCESS_IDLE);
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 9dd2172bfc..cc56d6a49e 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -594,7 +594,7 @@ void Viewport::_process_picking() {
if (!has_mouse_event) {
Ref<InputEventMouseMotion> mm;
- mm.instance();
+ mm.instantiate();
mm->set_device(InputEvent::DEVICE_ID_INTERNAL);
mm->set_global_position(physics_last_mousepos);
@@ -644,9 +644,9 @@ void Viewport::_process_picking() {
physics_last_mouse_state.meta = mb->is_meta_pressed();
if (mb->is_pressed()) {
- physics_last_mouse_state.mouse_mask |= (1 << (mb->get_button_index() - 1));
+ physics_last_mouse_state.mouse_mask |= (MouseButton)(1 << (mb->get_button_index() - 1));
} else {
- physics_last_mouse_state.mouse_mask &= ~(1 << (mb->get_button_index() - 1));
+ physics_last_mouse_state.mouse_mask &= (MouseButton) ~(1 << (mb->get_button_index() - 1));
// If touch mouse raised, assume we don't know last mouse pos until new events come
if (mb->get_device() == InputEvent::DEVICE_ID_TOUCH_MOUSE) {
@@ -1746,7 +1746,7 @@ Control *Viewport::_gui_find_control_at_pos(CanvasItem *p_node, const Point2 &p_
Control *c = Object::cast_to<Control>(p_node);
- if (!c || !c->clips_input() || c->has_point(matrix.affine_inverse().xform(p_global))) {
+ if (!c || !c->is_clipping_contents() || c->has_point(matrix.affine_inverse().xform(p_global))) {
for (int i = p_node->get_child_count() - 1; i >= 0; i--) {
CanvasItem *ci = Object::cast_to<CanvasItem>(p_node->get_child(i));
if (!ci || ci->is_set_as_top_level()) {
@@ -2585,10 +2585,10 @@ void Viewport::_drop_mouse_focus() {
for (int i = 0; i < 3; i++) {
if (mask & (1 << i)) {
Ref<InputEventMouseButton> mb;
- mb.instance();
+ mb.instantiate();
mb->set_position(c->get_local_mouse_position());
mb->set_global_position(c->get_local_mouse_position());
- mb->set_button_index(i + 1);
+ mb->set_button_index(MouseButton(i + 1));
mb->set_pressed(false);
c->call(SceneStringNames::get_singleton()->_gui_input, mb);
}
@@ -2661,12 +2661,12 @@ void Viewport::_post_gui_grab_click_focus() {
for (int i = 0; i < 3; i++) {
if (mask & (1 << i)) {
Ref<InputEventMouseButton> mb;
- mb.instance();
+ mb.instantiate();
//send unclick
mb->set_position(click);
- mb->set_button_index(i + 1);
+ mb->set_button_index(MouseButton(i + 1));
mb->set_pressed(false);
gui.mouse_focus->call(SceneStringNames::get_singleton()->_gui_input, mb);
}
@@ -2679,12 +2679,12 @@ void Viewport::_post_gui_grab_click_focus() {
for (int i = 0; i < 3; i++) {
if (mask & (1 << i)) {
Ref<InputEventMouseButton> mb;
- mb.instance();
+ mb.instantiate();
//send click
mb->set_position(click);
- mb->set_button_index(i + 1);
+ mb->set_button_index(MouseButton(i + 1));
mb->set_pressed(true);
gui.mouse_focus->call_deferred(SceneStringNames::get_singleton()->_gui_input, mb);
}
@@ -3576,7 +3576,7 @@ void Viewport::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_xr"), "set_use_xr", "is_using_xr");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "own_world_3d"), "set_use_own_world_3d", "is_using_own_world_3d");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "world_3d", PROPERTY_HINT_RESOURCE_TYPE, "World3D"), "set_world_3d", "get_world_3d");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "world_2d", PROPERTY_HINT_RESOURCE_TYPE, "World2D", 0), "set_world_2d", "get_world_2d");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "world_2d", PROPERTY_HINT_RESOURCE_TYPE, "World2D", PROPERTY_USAGE_NONE), "set_world_2d", "get_world_2d");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "transparent_bg"), "set_transparent_background", "has_transparent_background");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "handle_input_locally"), "set_handle_input_locally", "is_handling_input_locally");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_2d_transforms_to_pixel"), "set_snap_2d_transforms_to_pixel", "is_snap_2d_transforms_to_pixel_enabled");
@@ -3610,8 +3610,8 @@ void Viewport::_bind_methods() {
ADD_PROPERTYI(PropertyInfo(Variant::INT, "shadow_atlas_quad_1", PROPERTY_HINT_ENUM, "Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"), "set_shadow_atlas_quadrant_subdiv", "get_shadow_atlas_quadrant_subdiv", 1);
ADD_PROPERTYI(PropertyInfo(Variant::INT, "shadow_atlas_quad_2", PROPERTY_HINT_ENUM, "Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"), "set_shadow_atlas_quadrant_subdiv", "get_shadow_atlas_quadrant_subdiv", 2);
ADD_PROPERTYI(PropertyInfo(Variant::INT, "shadow_atlas_quad_3", PROPERTY_HINT_ENUM, "Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"), "set_shadow_atlas_quadrant_subdiv", "get_shadow_atlas_quadrant_subdiv", 3);
- ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "canvas_transform", PROPERTY_HINT_NONE, "", 0), "set_canvas_transform", "get_canvas_transform");
- ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "global_canvas_transform", PROPERTY_HINT_NONE, "", 0), "set_global_canvas_transform", "get_global_canvas_transform");
+ ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "canvas_transform", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_canvas_transform", "get_canvas_transform");
+ ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "global_canvas_transform", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_global_canvas_transform", "get_global_canvas_transform");
ADD_SIGNAL(MethodInfo("size_changed"));
ADD_SIGNAL(MethodInfo("gui_focus_changed", PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
@@ -3698,7 +3698,7 @@ Viewport::Viewport() {
viewport = RenderingServer::get_singleton()->viewport_create();
texture_rid = RenderingServer::get_singleton()->viewport_get_texture(viewport);
- default_texture.instance();
+ default_texture.instantiate();
default_texture->vp = const_cast<Viewport *>(this);
viewport_textures.insert(default_texture.ptr());
default_texture->proxy = RS::get_singleton()->texture_proxy_create(texture_rid);
diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp
index 2a97ae3acf..8d0283d536 100644
--- a/scene/register_scene_types.cpp
+++ b/scene/register_scene_types.cpp
@@ -31,6 +31,7 @@
#include "register_scene_types.h"
#include "core/config/project_settings.h"
+#include "core/extension/native_extension_manager.h"
#include "core/object/class_db.h"
#include "core/os/os.h"
#include "scene/2d/animated_sprite_2d.h"
@@ -260,33 +261,33 @@ void register_scene_types() {
Node::init_node_hrcr();
- resource_loader_font.instance();
+ resource_loader_font.instantiate();
ResourceLoader::add_resource_format_loader(resource_loader_font);
#ifndef DISABLE_DEPRECATED
- resource_loader_compat_font.instance();
+ resource_loader_compat_font.instantiate();
ResourceLoader::add_resource_format_loader(resource_loader_compat_font);
#endif /* DISABLE_DEPRECATED */
- resource_loader_stream_texture.instance();
+ resource_loader_stream_texture.instantiate();
ResourceLoader::add_resource_format_loader(resource_loader_stream_texture);
- resource_loader_texture_layered.instance();
+ resource_loader_texture_layered.instantiate();
ResourceLoader::add_resource_format_loader(resource_loader_texture_layered);
- resource_loader_texture_3d.instance();
+ resource_loader_texture_3d.instantiate();
ResourceLoader::add_resource_format_loader(resource_loader_texture_3d);
- resource_saver_text.instance();
+ resource_saver_text.instantiate();
ResourceSaver::add_resource_format_saver(resource_saver_text, true);
- resource_loader_text.instance();
+ resource_loader_text.instantiate();
ResourceLoader::add_resource_format_loader(resource_loader_text, true);
- resource_saver_shader.instance();
+ resource_saver_shader.instantiate();
ResourceSaver::add_resource_format_saver(resource_saver_shader, true);
- resource_loader_shader.instance();
+ resource_loader_shader.instantiate();
ResourceLoader::add_resource_format_loader(resource_loader_shader, true);
OS::get_singleton()->yield(); //may take time to init
@@ -407,6 +408,11 @@ void register_scene_types() {
ClassDB::register_class<AnimationPlayer>();
ClassDB::register_class<Tween>();
+ ClassDB::register_virtual_class<Tweener>();
+ ClassDB::register_class<PropertyTweener>();
+ ClassDB::register_class<IntervalTweener>();
+ ClassDB::register_class<CallbackTweener>();
+ ClassDB::register_class<MethodTweener>();
ClassDB::register_class<AnimationTree>();
ClassDB::register_class<AnimationNode>();
@@ -1035,9 +1041,13 @@ void register_scene_types() {
}
}
SceneDebugger::initialize();
+
+ NativeExtensionManager::get_singleton()->initialize_extensions(NativeExtension::INITIALIZATION_LEVEL_SCENE);
}
void unregister_scene_types() {
+ NativeExtensionManager::get_singleton()->deinitialize_extensions(NativeExtension::INITIALIZATION_LEVEL_SCENE);
+
SceneDebugger::deinitialize();
clear_default_theme();
diff --git a/scene/resources/audio_stream_sample.cpp b/scene/resources/audio_stream_sample.cpp
index 81062feb46..8ffd2df112 100644
--- a/scene/resources/audio_stream_sample.cpp
+++ b/scene/resources/audio_stream_sample.cpp
@@ -596,7 +596,7 @@ Error AudioStreamSample::save_to_wav(const String &p_path) {
Ref<AudioStreamPlayback> AudioStreamSample::instance_playback() {
Ref<AudioStreamPlaybackSample> sample;
- sample.instance();
+ sample.instantiate();
sample->base = Ref<AudioStreamSample>(this);
return sample;
}
diff --git a/scene/resources/bit_map.cpp b/scene/resources/bit_map.cpp
index 0ffeb8a5bf..de557494c3 100644
--- a/scene/resources/bit_map.cpp
+++ b/scene/resources/bit_map.cpp
@@ -487,7 +487,7 @@ Vector<Vector<Vector2>> BitMap::clip_opaque_to_polygons(const Rect2 &p_rect, flo
Point2i from;
Ref<BitMap> fill;
- fill.instance();
+ fill.instantiate();
fill->create(get_size());
Vector<Vector<Vector2>> polygons;
@@ -525,7 +525,7 @@ void BitMap::grow_mask(int p_pixels, const Rect2 &p_rect) {
Rect2i r = Rect2i(0, 0, width, height).intersection(p_rect);
Ref<BitMap> copy;
- copy.instance();
+ copy.instantiate();
copy->create(get_size());
copy->bitmask = bitmask;
@@ -604,7 +604,7 @@ Array BitMap::_opaque_to_polygons_bind(const Rect2 &p_rect, float p_epsilon) con
void BitMap::resize(const Size2 &p_new_size) {
Ref<BitMap> new_bitmap;
- new_bitmap.instance();
+ new_bitmap.instantiate();
new_bitmap->create(p_new_size);
int lw = MIN(width, p_new_size.width);
int lh = MIN(height, p_new_size.height);
@@ -621,7 +621,7 @@ void BitMap::resize(const Size2 &p_new_size) {
Ref<Image> BitMap::convert_to_image() const {
Ref<Image> image;
- image.instance();
+ image.instantiate();
image->create(width, height, false, Image::FORMAT_L8);
for (int i = 0; i < width; i++) {
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index a4228d48b4..5464a46df4 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -559,7 +559,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
// ScrollContainer
Ref<StyleBoxEmpty> empty;
- empty.instance();
+ empty.instantiate();
theme->set_stylebox("bg", "ScrollContainer", empty);
// WindowDialog
@@ -979,7 +979,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
void make_default_theme(bool p_hidpi, Ref<Font> p_font) {
Ref<Theme> t;
- t.instance();
+ t.instantiate();
Ref<StyleBox> default_style;
Ref<Texture2D> default_icon;
@@ -993,10 +993,10 @@ void make_default_theme(bool p_hidpi, Ref<Font> p_font) {
// The default DynamicFont is chosen to have a small file size since it's
// embedded in both editor and export template binaries.
Ref<Font> dynamic_font;
- dynamic_font.instance();
+ dynamic_font.instantiate();
Ref<FontData> dynamic_font_data;
- dynamic_font_data.instance();
+ dynamic_font_data.instantiate();
dynamic_font_data->load_memory(_font_OpenSans_SemiBold, _font_OpenSans_SemiBold_size, "ttf", default_font_size);
dynamic_font->add_data(dynamic_font_data);
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp
index 6f87c524d8..032171847d 100644
--- a/scene/resources/font.cpp
+++ b/scene/resources/font.cpp
@@ -813,7 +813,7 @@ Size2 Font::get_string_size(const String &p_text, int p_size) const {
if (cache.has(hash)) {
buffer = cache.get(hash);
} else {
- buffer.instance();
+ buffer.instantiate();
int size = p_size <= 0 ? data[0]->get_base_size() : p_size;
buffer->add_string(p_text, Ref<Font>(this), size, Dictionary(), TranslationServer::get_singleton()->get_tool_locale());
cache.insert(hash, buffer);
@@ -838,7 +838,7 @@ Size2 Font::get_multiline_string_size(const String &p_text, float p_width, int p
if (cache_wrap.has(wrp_hash)) {
lines_buffer = cache_wrap.get(wrp_hash);
} else {
- lines_buffer.instance();
+ lines_buffer.instantiate();
int size = p_size <= 0 ? data[0]->get_base_size() : p_size;
lines_buffer->add_string(p_text, Ref<Font>(this), size, Dictionary(), TranslationServer::get_singleton()->get_tool_locale());
lines_buffer->set_width(p_width);
@@ -870,7 +870,7 @@ void Font::draw_string(RID p_canvas_item, const Point2 &p_pos, const String &p_t
if (cache.has(hash)) {
buffer = cache.get(hash);
} else {
- buffer.instance();
+ buffer.instantiate();
int size = p_size <= 0 ? data[0]->get_base_size() : p_size;
buffer->add_string(p_text, Ref<Font>(this), size, Dictionary(), TranslationServer::get_singleton()->get_tool_locale());
cache.insert(hash, buffer);
@@ -905,7 +905,7 @@ void Font::draw_multiline_string(RID p_canvas_item, const Point2 &p_pos, const S
if (cache_wrap.has(wrp_hash)) {
lines_buffer = cache_wrap.get(wrp_hash);
} else {
- lines_buffer.instance();
+ lines_buffer.instantiate();
int size = p_size <= 0 ? data[0]->get_base_size() : p_size;
lines_buffer->add_string(p_text, Ref<Font>(this), size, Dictionary(), TranslationServer::get_singleton()->get_tool_locale());
lines_buffer->set_width(p_width);
@@ -1041,7 +1041,7 @@ RES ResourceFormatLoaderFont::load(const String &p_path, const String &p_origina
}
Ref<FontData> dfont;
- dfont.instance();
+ dfont.instantiate();
dfont->load_resource(p_path);
if (r_error) {
@@ -1096,11 +1096,11 @@ RES ResourceFormatLoaderCompatFont::load(const String &p_path, const String &p_o
}
Ref<FontData> dfont;
- dfont.instance();
+ dfont.instantiate();
dfont->load_resource(p_path);
Ref<Font> font;
- font.instance();
+ font.instantiate();
font->add_data(dfont);
if (r_error) {
diff --git a/scene/resources/line_shape_2d.h b/scene/resources/line_shape_2d.h
index 9f0405ad29..210a1aa9e6 100644
--- a/scene/resources/line_shape_2d.h
+++ b/scene/resources/line_shape_2d.h
@@ -36,7 +36,8 @@
class LineShape2D : public Shape2D {
GDCLASS(LineShape2D, Shape2D);
- Vector2 normal = Vector2(0, 1);
+ // LineShape2D is often used for one-way platforms, where the normal pointing up makes sense.
+ Vector2 normal = Vector2(0, -1);
real_t distance = 0.0;
void _update_shape();
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index 2c5634e6ef..cb66d5724d 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -822,9 +822,9 @@ void BaseMaterial3D::_update_shader() {
code += "\tTANGENT+= vec3(1.0,0.0,0.0) * abs(NORMAL.z);\n";
code += "\tTANGENT = normalize(TANGENT);\n";
- code += "\tBINORMAL = vec3(0.0,-1.0,0.0) * abs(NORMAL.x);\n";
- code += "\tBINORMAL+= vec3(0.0,0.0,1.0) * abs(NORMAL.y);\n";
- code += "\tBINORMAL+= vec3(0.0,-1.0,0.0) * abs(NORMAL.z);\n";
+ code += "\tBINORMAL = vec3(0.0,1.0,0.0) * abs(NORMAL.x);\n";
+ code += "\tBINORMAL+= vec3(0.0,0.0,-1.0) * abs(NORMAL.y);\n";
+ code += "\tBINORMAL+= vec3(0.0,1.0,0.0) * abs(NORMAL.z);\n";
code += "\tBINORMAL = normalize(BINORMAL);\n";
}
@@ -878,6 +878,20 @@ void BaseMaterial3D::_update_shader() {
code += "\tvec2 base_uv2 = UV2;\n";
}
+ if (features[FEATURE_HEIGHT_MAPPING] && flags[FLAG_UV1_USE_TRIPLANAR]) {
+ // Display both resource name and albedo texture name.
+ // Materials are often built-in to scenes, so displaying the resource name alone may not be meaningful.
+ // On the other hand, albedo textures are almost always external to the scene.
+ if (textures[TEXTURE_ALBEDO].is_valid()) {
+ WARN_PRINT(vformat("%s (albedo %s): Height mapping is not supported on triplanar materials. Ignoring height mapping in favor of triplanar mapping.", get_path(), textures[TEXTURE_ALBEDO]->get_path()));
+ } else if (!get_path().is_empty()) {
+ WARN_PRINT(vformat("%s: Height mapping is not supported on triplanar materials. Ignoring height mapping in favor of triplanar mapping.", get_path()));
+ } else {
+ // Resource wasn't saved yet.
+ WARN_PRINT("Height mapping is not supported on triplanar materials. Ignoring height mapping in favor of triplanar mapping.");
+ }
+ }
+
if (!RenderingServer::get_singleton()->is_low_end() && features[FEATURE_HEIGHT_MAPPING] && !flags[FLAG_UV1_USE_TRIPLANAR]) { //heightmap not supported with triplanar
code += "\t{\n";
code += "\t\tvec3 view_dir = normalize(normalize(-VERTEX)*mat3(TANGENT*heightmap_flip.x,-BINORMAL*heightmap_flip.y,NORMAL));\n"; // binormal is negative due to mikktspace, flip 'unflips' it ;-)
@@ -2092,7 +2106,7 @@ RID BaseMaterial3D::get_material_rid_for_2d(bool p_shaded, bool p_transparent, b
}
Ref<StandardMaterial3D> material;
- material.instance();
+ material.instantiate();
material->set_shading_mode(p_shaded ? SHADING_MODE_PER_PIXEL : SHADING_MODE_UNSHADED);
material->set_transparency(p_transparent ? (p_opaque_prepass ? TRANSPARENCY_ALPHA_DEPTH_PRE_PASS : (p_cut_alpha ? TRANSPARENCY_ALPHA_SCISSOR : TRANSPARENCY_ALPHA)) : TRANSPARENCY_DISABLED);
diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp
index 5e8e77c730..cf59c6fa22 100644
--- a/scene/resources/mesh.cpp
+++ b/scene/resources/mesh.cpp
@@ -571,7 +571,7 @@ Vector<Ref<Shape3D>> Mesh::convex_decompose() const {
}
Ref<ConvexPolygonShape3D> shape;
- shape.instance();
+ shape.instantiate();
shape->set_points(convex_points);
ret.push_back(shape);
}
@@ -1537,7 +1537,7 @@ Error ArrayMesh::lightmap_unwrap_cached(const Transform3D &p_base_transform, flo
for (int i = 0; i < lightmap_surfaces.size(); i++) {
Ref<SurfaceTool> st;
- st.instance();
+ st.instantiate();
st->begin(Mesh::PRIMITIVE_TRIANGLES);
st->set_material(lightmap_surfaces[i].material);
surfaces_tools.push_back(st); //stay there
diff --git a/scene/resources/multimesh.cpp b/scene/resources/multimesh.cpp
index dea5c4e7d3..8894f0bb11 100644
--- a/scene/resources/multimesh.cpp
+++ b/scene/resources/multimesh.cpp
@@ -349,10 +349,10 @@ void MultiMesh::_bind_methods() {
ClassDB::bind_method(D_METHOD("_set_custom_data_array"), &MultiMesh::_set_custom_data_array);
ClassDB::bind_method(D_METHOD("_get_custom_data_array"), &MultiMesh::_get_custom_data_array);
- ADD_PROPERTY(PropertyInfo(Variant::PACKED_VECTOR3_ARRAY, "transform_array", PROPERTY_HINT_NONE, "", 0), "_set_transform_array", "_get_transform_array");
- ADD_PROPERTY(PropertyInfo(Variant::PACKED_VECTOR2_ARRAY, "transform_2d_array", PROPERTY_HINT_NONE, "", 0), "_set_transform_2d_array", "_get_transform_2d_array");
- ADD_PROPERTY(PropertyInfo(Variant::PACKED_COLOR_ARRAY, "color_array", PROPERTY_HINT_NONE, "", 0), "_set_color_array", "_get_color_array");
- ADD_PROPERTY(PropertyInfo(Variant::PACKED_COLOR_ARRAY, "custom_data_array", PROPERTY_HINT_NONE, "", 0), "_set_custom_data_array", "_get_custom_data_array");
+ ADD_PROPERTY(PropertyInfo(Variant::PACKED_VECTOR3_ARRAY, "transform_array", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "_set_transform_array", "_get_transform_array");
+ ADD_PROPERTY(PropertyInfo(Variant::PACKED_VECTOR2_ARRAY, "transform_2d_array", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "_set_transform_2d_array", "_get_transform_2d_array");
+ ADD_PROPERTY(PropertyInfo(Variant::PACKED_COLOR_ARRAY, "color_array", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "_set_color_array", "_get_color_array");
+ ADD_PROPERTY(PropertyInfo(Variant::PACKED_COLOR_ARRAY, "custom_data_array", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "_set_custom_data_array", "_get_custom_data_array");
#endif
BIND_ENUM_CONSTANT(TRANSFORM_2D);
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp
index ab8a4b7934..913f1ca376 100644
--- a/scene/resources/packed_scene.cpp
+++ b/scene/resources/packed_scene.cpp
@@ -41,11 +41,11 @@
#define PACKED_SCENE_VERSION 2
-bool SceneState::can_instance() const {
+bool SceneState::can_instantiate() const {
return nodes.size() > 0;
}
-Node *SceneState::instance(GenEditState p_edit_state) const {
+Node *SceneState::instantiate(GenEditState p_edit_state) const {
// nodes where instancing failed (because something is missing)
List<Node *> stray_instances;
@@ -109,7 +109,7 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
//scene inheritance on root node
Ref<PackedScene> sdata = props[base_scene_idx];
ERR_FAIL_COND_V(!sdata.is_valid(), nullptr);
- node = sdata->instance(p_edit_state == GEN_EDIT_STATE_DISABLED ? PackedScene::GEN_EDIT_STATE_DISABLED : PackedScene::GEN_EDIT_STATE_INSTANCE); //only main gets main edit state
+ node = sdata->instantiate(p_edit_state == GEN_EDIT_STATE_DISABLED ? PackedScene::GEN_EDIT_STATE_DISABLED : PackedScene::GEN_EDIT_STATE_INSTANCE); //only main gets main edit state
ERR_FAIL_COND_V(!node, nullptr);
if (p_edit_state != GEN_EDIT_STATE_DISABLED) {
node->set_scene_inherited_state(sdata->get_state());
@@ -122,7 +122,7 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
if (disable_placeholders) {
Ref<PackedScene> sdata = ResourceLoader::load(path, "PackedScene");
ERR_FAIL_COND_V(!sdata.is_valid(), nullptr);
- node = sdata->instance(p_edit_state == GEN_EDIT_STATE_DISABLED ? PackedScene::GEN_EDIT_STATE_DISABLED : PackedScene::GEN_EDIT_STATE_INSTANCE);
+ node = sdata->instantiate(p_edit_state == GEN_EDIT_STATE_DISABLED ? PackedScene::GEN_EDIT_STATE_DISABLED : PackedScene::GEN_EDIT_STATE_INSTANCE);
ERR_FAIL_COND_V(!node, nullptr);
} else {
InstancePlaceholder *ip = memnew(InstancePlaceholder);
@@ -133,7 +133,7 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
} else {
Ref<PackedScene> sdata = props[n.instance & FLAG_MASK];
ERR_FAIL_COND_V(!sdata.is_valid(), nullptr);
- node = sdata->instance(p_edit_state == GEN_EDIT_STATE_DISABLED ? PackedScene::GEN_EDIT_STATE_DISABLED : PackedScene::GEN_EDIT_STATE_INSTANCE);
+ node = sdata->instantiate(p_edit_state == GEN_EDIT_STATE_DISABLED ? PackedScene::GEN_EDIT_STATE_DISABLED : PackedScene::GEN_EDIT_STATE_INSTANCE);
ERR_FAIL_COND_V(!node, nullptr);
}
@@ -152,7 +152,7 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
if (ClassDB::is_class_enabled(snames[n.type])) {
//node belongs to this scene and must be created
- obj = ClassDB::instance(snames[n.type]);
+ obj = ClassDB::instantiate(snames[n.type]);
}
if (!Object::cast_to<Node>(obj)) {
@@ -180,7 +180,7 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
}
if (node) {
- // may not have found the node (part of instanced scene and removed)
+ // may not have found the node (part of instantiated scene and removed)
// if found all is good, otherwise ignore
//properties
@@ -266,7 +266,7 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
parent->move_child(node, n.index);
}
} else {
- //it may be possible that an instanced scene has changed
+ //it may be possible that an instantiated scene has changed
//and the node has nowhere to go anymore
stray_instances.push_back(node); //can't be added, go to stray list
}
@@ -368,7 +368,7 @@ static int _vm_get_variant(const Variant &p_variant, HashMap<Variant, int, Varia
Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map<StringName, int> &name_map, HashMap<Variant, int, VariantHasher, VariantComparator> &variant_map, Map<Node *, int> &node_map, Map<Node *, int> &nodepath_map) {
// this function handles all the work related to properly packing scenes, be it
- // instanced or inherited.
+ // instantiated or inherited.
// given the complexity of this process, an attempt will be made to properly
// document it. if you fail to understand something, please ask!
@@ -377,7 +377,7 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map
return OK;
}
- // save the child instanced scenes that are chosen as editable, so they can be restored
+ // save the child instantiated scenes that are chosen as editable, so they can be restored
// upon load back
if (p_node != p_owner && p_node->get_filename() != String() && p_owner->is_editable_instance(p_node)) {
editable_instances.push_back(p_owner->get_path_to(p_node));
@@ -386,7 +386,7 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map
NodeData nd;
nd.name = _nm_get_string(p_node->get_name(), name_map);
- nd.instance = -1; //not instanced by default
+ nd.instance = -1; //not instantiated by default
//really convoluted condition, but it basically checks that index is only saved when part of an inherited scene OR the node parent is from the edited scene
if (p_owner->get_scene_inherited_state().is_null() && (p_node == p_owner || (p_node->get_owner() == p_owner && (p_node->get_parent() == p_owner || p_node->get_parent()->get_owner() == p_owner)))) {
@@ -396,18 +396,18 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map
//This (hopefully) happens if the node is a scene root, so its index is irrelevant.
nd.index = -1;
} else {
- //part of an inherited scene, or parent is from an instanced scene
+ //part of an inherited scene, or parent is from an instantiated scene
nd.index = p_node->get_index();
}
- // if this node is part of an instanced scene or sub-instanced scene
+ // if this node is part of an instantiated scene or sub-instantiated scene
// we need to get the corresponding instance states.
// with the instance states, we can query for identical properties/groups
// and only save what has changed
List<PackState> pack_state_stack;
- bool instanced_by_owner = true;
+ bool instantiated_by_owner = true;
{
Node *n = p_node;
@@ -423,11 +423,11 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map
ps.node = node;
ps.state = state;
pack_state_stack.push_back(ps);
- instanced_by_owner = false;
+ instantiated_by_owner = false;
}
}
- if (p_node->get_filename() != String() && p_node->get_owner() == p_owner && instanced_by_owner) {
+ if (p_node->get_filename() != String() && p_node->get_owner() == p_owner && instantiated_by_owner) {
if (p_node->get_scene_instance_load_placeholder()) {
//it's a placeholder, use the placeholder path
nd.instance = _vm_get_variant(p_node->get_filename(), variant_map);
@@ -500,8 +500,8 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map
// }
if (pack_state_stack.size()) {
- // we are on part of an instanced subscene
- // or part of instanced scene.
+ // we are on part of an instantiated subscene
+ // or part of instantiated scene.
// only save what has been changed
// only save changed properties in instance
@@ -571,7 +571,7 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map
}
/*
if (instance_state_node>=0 && instance_state->is_node_in_group(instance_state_node,gi.name))
- continue; //group was instanced, don't add here
+ continue; //group was instantiated, don't add here
*/
bool skip = false;
@@ -594,7 +594,7 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map
// save the right owner
// for the saved scene root this is -1
// for nodes of the saved scene this is 0
- // for nodes of instanced scenes this is >0
+ // for nodes of instantiated scenes this is >0
if (p_node == p_owner) {
//saved scene root
@@ -612,20 +612,20 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map
//this node is not part of an instancing process, so save the type
nd.type = _nm_get_string(p_node->get_class(), name_map);
} else {
- // this node is part of an instanced process, so do not save the type.
- // instead, save that it was instanced
+ // this node is part of an instantiated process, so do not save the type.
+ // instead, save that it was instantiated
nd.type = TYPE_INSTANCED;
}
// determine whether to save this node or not
- // if this node is part of an instanced sub-scene, we can skip storing it if basically
+ // if this node is part of an instantiated sub-scene, we can skip storing it if basically
// no properties changed and no groups were added to it.
// below condition is true for all nodes of the scene being saved, and ones in subscenes
// that hold changes
bool save_node = nd.properties.size() || nd.groups.size(); // some local properties or groups exist
save_node = save_node || p_node == p_owner; // owner is always saved
- save_node = save_node || (p_node->get_owner() == p_owner && instanced_by_owner); //part of scene and not instanced
+ save_node = save_node || (p_node->get_owner() == p_owner && instantiated_by_owner); //part of scene and not instantiated
int idx = nodes.size();
int parent_node = NO_PARENT_SAVED;
@@ -893,6 +893,13 @@ Error SceneState::pack(Node *p_scene) {
node_paths.write[E->get()] = scene->get_path_to(E->key());
}
+ if (Engine::get_singleton()->is_editor_hint()) {
+ // Build node path cache
+ for (Map<Node *, int>::Element *E = node_map.front(); E; E = E->next()) {
+ node_path_cache[scene->get_path_to(E->key())] = E->get();
+ }
+ }
+
return OK;
}
@@ -927,10 +934,12 @@ Ref<SceneState> SceneState::_get_base_scene_state() const {
}
int SceneState::find_node_by_path(const NodePath &p_node) const {
+ ERR_FAIL_COND_V_MSG(node_path_cache.size() == 0, -1, "This operation requires the node cache to have been built.");
+
if (!node_path_cache.has(p_node)) {
if (_get_base_scene_state().is_valid()) {
int idx = _get_base_scene_state()->find_node_by_path(p_node);
- if (idx >= 0) {
+ if (idx != -1) {
int rkey = _find_base_scene_node_remap_key(idx);
if (rkey == -1) {
rkey = nodes.size() + base_scene_node_remap.size();
@@ -946,7 +955,7 @@ int SceneState::find_node_by_path(const NodePath &p_node) const {
if (_get_base_scene_state().is_valid() && !base_scene_node_remap.has(nid)) {
//for nodes that _do_ exist in current scene, still try to look for
- //the node in the instanced scene, as a property may be missing
+ //the node in the instantiated scene, as a property may be missing
//from the local one
int idx = _get_base_scene_state()->find_node_by_path(p_node);
if (idx != -1) {
@@ -1614,16 +1623,16 @@ void PackedScene::clear() {
state->clear();
}
-bool PackedScene::can_instance() const {
- return state->can_instance();
+bool PackedScene::can_instantiate() const {
+ return state->can_instantiate();
}
-Node *PackedScene::instance(GenEditState p_edit_state) const {
+Node *PackedScene::instantiate(GenEditState p_edit_state) const {
#ifndef TOOLS_ENABLED
ERR_FAIL_COND_V_MSG(p_edit_state != GEN_EDIT_STATE_DISABLED, nullptr, "Edit state is only for editors, does not work without tools compiled.");
#endif
- Node *s = state->instance((SceneState::GenEditState)p_edit_state);
+ Node *s = state->instantiate((SceneState::GenEditState)p_edit_state);
if (!s) {
return nullptr;
}
@@ -1671,8 +1680,8 @@ void PackedScene::reset_state() {
}
void PackedScene::_bind_methods() {
ClassDB::bind_method(D_METHOD("pack", "path"), &PackedScene::pack);
- ClassDB::bind_method(D_METHOD("instance", "edit_state"), &PackedScene::instance, DEFVAL(GEN_EDIT_STATE_DISABLED));
- ClassDB::bind_method(D_METHOD("can_instance"), &PackedScene::can_instance);
+ ClassDB::bind_method(D_METHOD("instantiate", "edit_state"), &PackedScene::instantiate, DEFVAL(GEN_EDIT_STATE_DISABLED));
+ ClassDB::bind_method(D_METHOD("can_instantiate"), &PackedScene::can_instantiate);
ClassDB::bind_method(D_METHOD("_set_bundled_scene"), &PackedScene::_set_bundled_scene);
ClassDB::bind_method(D_METHOD("_get_bundled_scene"), &PackedScene::_get_bundled_scene);
ClassDB::bind_method(D_METHOD("get_state"), &PackedScene::get_state);
diff --git a/scene/resources/packed_scene.h b/scene/resources/packed_scene.h
index e85b933439..55708f7914 100644
--- a/scene/resources/packed_scene.h
+++ b/scene/resources/packed_scene.h
@@ -136,8 +136,8 @@ public:
void clear();
- bool can_instance() const;
- Node *instance(GenEditState p_edit_state) const;
+ bool can_instantiate() const;
+ Node *instantiate(GenEditState p_edit_state) const;
//unbuild API
@@ -213,8 +213,8 @@ public:
void clear();
- bool can_instance() const;
- Node *instance(GenEditState p_edit_state = GEN_EDIT_STATE_DISABLED) const;
+ bool can_instantiate() const;
+ Node *instantiate(GenEditState p_edit_state = GEN_EDIT_STATE_DISABLED) const;
void recreate_state();
void replace_state(Ref<SceneState> p_by);
diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp
index a745df522b..2b2ebb5c16 100644
--- a/scene/resources/primitive_meshes.cpp
+++ b/scene/resources/primitive_meshes.cpp
@@ -866,9 +866,9 @@ void CylinderMesh::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_rings", "rings"), &CylinderMesh::set_rings);
ClassDB::bind_method(D_METHOD("get_rings"), &CylinderMesh::get_rings);
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "top_radius", PROPERTY_HINT_RANGE, "0.001,100.0,0.001,or_greater"), "set_top_radius", "get_top_radius");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "bottom_radius", PROPERTY_HINT_RANGE, "0.001,100.0,0.001,or_greater"), "set_bottom_radius", "get_bottom_radius");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "height", PROPERTY_HINT_RANGE, "0.001,100.0,0.001,or_greater"), "set_height", "get_height");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "top_radius", PROPERTY_HINT_RANGE, "0,100,0.001,or_greater"), "set_top_radius", "get_top_radius");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "bottom_radius", PROPERTY_HINT_RANGE, "0,100,0.001,or_greater"), "set_bottom_radius", "get_bottom_radius");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "height", PROPERTY_HINT_RANGE, "0.001,100,0.001,or_greater"), "set_height", "get_height");
ADD_PROPERTY(PropertyInfo(Variant::INT, "radial_segments", PROPERTY_HINT_RANGE, "1,100,1,or_greater"), "set_radial_segments", "get_radial_segments");
ADD_PROPERTY(PropertyInfo(Variant::INT, "rings", PROPERTY_HINT_RANGE, "1,100,1,or_greater"), "set_rings", "get_rings");
}
diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp
index 27f0c50a79..ee61e64ed3 100644
--- a/scene/resources/resource_format_text.cpp
+++ b/scene/resources/resource_format_text.cpp
@@ -65,7 +65,7 @@ Error ResourceLoaderText::_parse_sub_resource_dummy(DummyReadData *p_data, Varia
if (!p_data->resource_map.has(index)) {
Ref<DummyResource> dr;
- dr.instance();
+ dr.instantiate();
dr->set_subindex(index);
p_data->resource_map[index] = dr;
p_data->resource_set.insert(dr);
@@ -183,7 +183,7 @@ Error ResourceLoaderText::_parse_ext_resource(VariantParser::Stream *p_stream, R
Ref<PackedScene> ResourceLoaderText::_parse_node_tag(VariantParser::ResourceParser &parser) {
Ref<PackedScene> packed_scene;
- packed_scene.instance();
+ packed_scene.instantiate();
while (true) {
if (next_tag.name == "node") {
@@ -208,7 +208,7 @@ Ref<PackedScene> ResourceLoaderText::_parse_node_tag(VariantParser::ResourcePars
if (next_tag.fields.has("type")) {
type = packed_scene->get_state()->add_name(next_tag.fields["type"]);
} else {
- type = SceneState::TYPE_INSTANCED; //no type? assume this was instanced
+ type = SceneState::TYPE_INSTANCED; //no type? assume this was instantiated
}
if (next_tag.fields.has("instance")) {
@@ -522,7 +522,7 @@ Error ResourceLoaderText::load() {
} else {
//create
- Object *obj = ClassDB::instance(type);
+ Object *obj = ClassDB::instantiate(type);
if (!obj) {
error_text += "Can't create sub resource of type: " + type;
_printerr();
@@ -604,7 +604,7 @@ Error ResourceLoaderText::load() {
}
if (!resource.is_valid()) {
- Object *obj = ClassDB::instance(res_type);
+ Object *obj = ClassDB::instantiate(res_type);
if (!obj) {
error_text += "Can't create sub resource of type: " + res_type;
_printerr();
@@ -1022,7 +1022,7 @@ Error ResourceLoaderText::save_as_binary(FileAccess *p_f, const String &p_path)
int lindex = dummy_read.external_resources.size();
Ref<DummyResource> dr;
- dr.instance();
+ dr.instantiate();
dr->set_path("res://dummy" + itos(lindex)); //anything is good to detect it for saving as external
dummy_read.external_resources[dr] = lindex;
dummy_read.rev_external_resources[index] = dr;
diff --git a/scene/resources/shader.cpp b/scene/resources/shader.cpp
index cbd44315b7..f19d08dbb1 100644
--- a/scene/resources/shader.cpp
+++ b/scene/resources/shader.cpp
@@ -167,7 +167,7 @@ RES ResourceFormatLoaderShader::load(const String &p_path, const String &p_origi
}
Ref<Shader> shader;
- shader.instance();
+ shader.instantiate();
Vector<uint8_t> buffer = FileAccess::get_file_as_array(p_path);
diff --git a/scene/resources/sprite_frames.cpp b/scene/resources/sprite_frames.cpp
index 90c702081b..df80084c5c 100644
--- a/scene/resources/sprite_frames.cpp
+++ b/scene/resources/sprite_frames.cpp
@@ -228,7 +228,7 @@ void SpriteFrames::_bind_methods() {
ClassDB::bind_method(D_METHOD("_set_frames"), &SpriteFrames::_set_frames);
ClassDB::bind_method(D_METHOD("_get_frames"), &SpriteFrames::_get_frames);
- ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "frames", PROPERTY_HINT_NONE, "", 0), "_set_frames", "_get_frames"); //compatibility
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "frames", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "_set_frames", "_get_frames"); //compatibility
ClassDB::bind_method(D_METHOD("_set_animations"), &SpriteFrames::_set_animations);
ClassDB::bind_method(D_METHOD("_get_animations"), &SpriteFrames::_get_animations);
diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp
index fee9f92ad7..9f8c35b668 100644
--- a/scene/resources/surface_tool.cpp
+++ b/scene/resources/surface_tool.cpp
@@ -607,7 +607,7 @@ Ref<ArrayMesh> SurfaceTool::commit(const Ref<ArrayMesh> &p_existing, uint32_t p_
if (p_existing.is_valid()) {
mesh = p_existing;
} else {
- mesh.instance();
+ mesh.instantiate();
}
int varr_len = vertex_array.size();
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index 064563d4b5..acc85cf7df 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -88,7 +88,7 @@ void ImageTexture::reload_from_file() {
}
Ref<Image> img;
- img.instance();
+ img.instantiate();
if (ImageLoader::load_image(path, img) == OK) {
create_from_image(img);
@@ -138,7 +138,7 @@ void ImageTexture::_reload_hook(const RID &p_hook) {
}
Ref<Image> img;
- img.instance();
+ img.instantiate();
Error err = ImageLoader::load_image(path, img);
ERR_FAIL_COND_MSG(err != OK, "Cannot load image from path '" + path + "'.");
@@ -258,7 +258,7 @@ bool ImageTexture::is_pixel_opaque(int p_x, int p_y) const {
decom->decompress();
img = decom;
}
- alpha_cache.instance();
+ alpha_cache.instantiate();
alpha_cache->create_from_image_alpha(img);
}
}
@@ -390,7 +390,7 @@ Ref<Image> StreamTexture2D::load_image_from_file(FileAccess *f, int p_size_limit
//print_line("mipmap read total: " + itos(mipmap_images.size()));
Ref<Image> image;
- image.instance();
+ image.instantiate();
if (mipmap_images.size() == 1) {
//only one image (which will most likely be the case anyway for this format)
@@ -442,7 +442,7 @@ Ref<Image> StreamTexture2D::load_image_from_file(FileAccess *f, int p_size_limit
}
Ref<Image> image;
- image.instance();
+ image.instantiate();
image->create(tw, th, mipmaps - i ? true : false, format, data);
@@ -553,7 +553,7 @@ Error StreamTexture2D::_load_data(const String &p_path, int &r_width, int &r_hei
Error StreamTexture2D::load(const String &p_path) {
int lw, lh;
Ref<Image> image;
- image.instance();
+ image.instantiate();
bool request_3d;
bool request_normal;
@@ -679,7 +679,7 @@ bool StreamTexture2D::is_pixel_opaque(int p_x, int p_y) const {
img = decom;
}
- alpha_cache.instance();
+ alpha_cache.instantiate();
alpha_cache->create_from_image_alpha(img);
}
}
@@ -738,7 +738,7 @@ StreamTexture2D::~StreamTexture2D() {
RES ResourceFormatLoaderStreamTexture2D::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_cache_mode) {
Ref<StreamTexture2D> st;
- st.instance();
+ st.instantiate();
Error err = st->load(p_path);
if (r_error) {
*r_error = err;
@@ -1036,7 +1036,7 @@ StreamTexture3D::~StreamTexture3D() {
RES ResourceFormatLoaderStreamTexture3D::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_cache_mode) {
Ref<StreamTexture3D> st;
- st.instance();
+ st.instantiate();
Error err = st->load(p_path);
if (r_error) {
*r_error = err;
@@ -1595,6 +1595,7 @@ void GradientTexture::_update() {
}
void GradientTexture::set_width(int p_width) {
+ ERR_FAIL_COND(p_width <= 0);
width = p_width;
_queue_update();
}
@@ -1904,7 +1905,7 @@ void AnimatedTexture::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_frame_delay", "frame"), &AnimatedTexture::get_frame_delay);
ADD_PROPERTY(PropertyInfo(Variant::INT, "frames", PROPERTY_HINT_RANGE, "1," + itos(MAX_FRAMES), PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), "set_frames", "get_frames");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "current_frame", PROPERTY_HINT_NONE, "", 0), "set_current_frame", "get_current_frame");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "current_frame", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_current_frame", "get_current_frame");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pause"), "set_pause", "get_pause");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "oneshot"), "set_oneshot", "get_oneshot");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fps", PROPERTY_HINT_RANGE, "0,1024,0.1"), "set_fps", "get_fps");
@@ -2257,15 +2258,15 @@ RES ResourceFormatLoaderStreamTextureLayered::load(const String &p_path, const S
Ref<StreamTextureLayered> st;
if (p_path.get_extension().to_lower() == "stexarray") {
Ref<StreamTexture2DArray> s;
- s.instance();
+ s.instantiate();
st = s;
} else if (p_path.get_extension().to_lower() == "scube") {
Ref<StreamCubemap> s;
- s.instance();
+ s.instantiate();
st = s;
} else if (p_path.get_extension().to_lower() == "scubearray") {
Ref<StreamCubemapArray> s;
- s.instance();
+ s.instantiate();
st = s;
} else {
if (r_error) {
diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp
index 0d6f3c07f0..4f854ff229 100644
--- a/scene/resources/tile_set.cpp
+++ b/scene/resources/tile_set.cpp
@@ -30,7 +30,10 @@
#include "tile_set.h"
+#include "core/core_string_names.h"
#include "core/math/geometry_2d.h"
+#include "core/templates/local_vector.h"
+
#include "scene/2d/navigation_region_2d.h"
#include "scene/gui/control.h"
#include "scene/resources/convex_polygon_shape_2d.h"
@@ -38,6 +41,25 @@
/////////////////////////////// TileSet //////////////////////////////////////
+const char *TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[] = {
+ "right_side",
+ "right_corner",
+ "bottom_right_side",
+ "bottom_right_corner",
+ "bottom_side",
+ "bottom_corner",
+ "bottom_left_side",
+ "bottom_left_corner",
+ "left_side",
+ "left_corner",
+ "top_left_side",
+ "top_left_corner",
+ "top_side",
+ "top_corner",
+ "top_right_side",
+ "top_right_corner"
+};
+
// --- Plugins ---
Vector<TileSetPlugin *> TileSet::get_tile_set_atlas_plugins() const {
return tile_set_plugins_vector;
@@ -51,6 +73,8 @@ void TileSet::set_tile_shape(TileSet::TileShape p_shape) {
E_source->get()->notify_tile_data_properties_should_change();
}
+ terrain_bits_meshes_dirty = true;
+ tile_meshes_dirty = true;
emit_changed();
}
TileSet::TileShape TileSet::get_tile_shape() const {
@@ -72,6 +96,8 @@ void TileSet::set_tile_offset_axis(TileSet::TileOffsetAxis p_alignment) {
E_source->get()->notify_tile_data_properties_should_change();
}
+ terrain_bits_meshes_dirty = true;
+ tile_meshes_dirty = true;
emit_changed();
}
TileSet::TileOffsetAxis TileSet::get_tile_offset_axis() const {
@@ -81,20 +107,14 @@ TileSet::TileOffsetAxis TileSet::get_tile_offset_axis() const {
void TileSet::set_tile_size(Size2i p_size) {
ERR_FAIL_COND(p_size.x < 1 || p_size.y < 1);
tile_size = p_size;
+ terrain_bits_meshes_dirty = true;
+ tile_meshes_dirty = true;
emit_changed();
}
Size2i TileSet::get_tile_size() const {
return tile_size;
}
-void TileSet::set_tile_skew(Vector2 p_skew) {
- emit_changed();
- tile_skew = p_skew;
-}
-Vector2 TileSet::get_tile_skew() const {
- return tile_skew;
-}
-
int TileSet::get_next_source_id() const {
return next_source_id;
}
@@ -117,7 +137,7 @@ int TileSet::add_source(Ref<TileSetSource> p_tile_set_source, int p_atlas_source
p_tile_set_source->set_tile_set(this);
_compute_next_source_id();
- sources[new_source_id]->connect("changed", callable_mp(this, &TileSet::_source_changed));
+ sources[new_source_id]->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &TileSet::_source_changed));
emit_changed();
@@ -127,7 +147,7 @@ int TileSet::add_source(Ref<TileSetSource> p_tile_set_source, int p_atlas_source
void TileSet::remove_source(int p_source_id) {
ERR_FAIL_COND_MSG(!sources.has(p_source_id), vformat("Cannot remove TileSet atlas source. No tileset atlas source with id %d.", p_source_id));
- sources[p_source_id]->disconnect("changed", callable_mp(this, &TileSet::_source_changed));
+ sources[p_source_id]->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &TileSet::_source_changed));
sources[p_source_id]->set_tile_set(nullptr);
sources.erase(p_source_id);
@@ -240,80 +260,6 @@ bool TileSet::get_occlusion_layer_sdf_collision(int p_layer_index) const {
return occlusion_layers[p_layer_index].sdf_collision;
}
-void TileSet::draw_tile_shape(CanvasItem *p_canvas_item, Rect2 p_region, Color p_color, bool p_filled, Ref<Texture2D> p_texture) {
- // TODO: optimize this with 2D meshes when they work again.
- if (get_tile_shape() == TileSet::TILE_SHAPE_SQUARE) {
- if (p_filled && p_texture.is_valid()) {
- p_canvas_item->draw_texture_rect(p_texture, p_region, false, p_color);
- } else {
- p_canvas_item->draw_rect(p_region, p_color, p_filled);
- }
- } else {
- float overlap = 0.0;
- switch (get_tile_shape()) {
- case TileSet::TILE_SHAPE_ISOMETRIC:
- overlap = 0.5;
- break;
- case TileSet::TILE_SHAPE_HEXAGON:
- overlap = 0.25;
- break;
- case TileSet::TILE_SHAPE_HALF_OFFSET_SQUARE:
- overlap = 0.0;
- break;
- default:
- break;
- }
-
- Vector<Vector2> uvs;
- uvs.append(Vector2(0.5, 0.0));
- uvs.append(Vector2(0.0, overlap));
- uvs.append(Vector2(0.0, 1.0 - overlap));
- uvs.append(Vector2(0.5, 1.0));
- uvs.append(Vector2(1.0, 1.0 - overlap));
- uvs.append(Vector2(1.0, overlap));
- uvs.append(Vector2(0.5, 0.0));
- if (get_tile_offset_axis() == TileSet::TILE_OFFSET_AXIS_VERTICAL) {
- for (int i = 0; i < uvs.size(); i++) {
- uvs.write[i] = Vector2(uvs[i].y, uvs[i].x);
- }
- }
-
- Vector<Vector2> points;
- for (int i = 0; i < uvs.size(); i++) {
- points.append(p_region.position + uvs[i] * p_region.size);
- }
-
- if (p_filled) {
- // This does hurt performances a lot. We should use a mesh if possible instead.
- p_canvas_item->draw_colored_polygon(points, p_color, uvs, p_texture);
-
- // Should improve performances, but does not work as draw_primitive does not work with textures :/ :
- /*for (int i = 0; i < 6; i += 3) {
- Vector<Vector2> quad;
- quad.append(points[i]);
- quad.append(points[(i + 1) % points.size()]);
- quad.append(points[(i + 2) % points.size()]);
- quad.append(points[(i + 3) % points.size()]);
-
- Vector<Vector2> uv_quad;
- uv_quad.append(uvs[i]);
- uv_quad.append(uvs[(i + 1) % uvs.size()]);
- uv_quad.append(uvs[(i + 2) % uvs.size()]);
- uv_quad.append(uvs[(i + 3) % uvs.size()]);
-
- p_control->draw_primitive(quad, Vector<Color>(), uv_quad, p_texture);
- }*/
-
- } else {
- // This does hurt performances a lot. We should use a mesh if possible instead.
- // tile_shape_grid->draw_polyline(points, p_color);
- for (int i = 0; i < points.size() - 1; i++) {
- p_canvas_item->draw_line(points[i], points[i + 1], p_color);
- }
- }
- }
-}
-
// Physics
void TileSet::set_physics_layers_count(int p_physics_layers_count) {
ERR_FAIL_COND(p_physics_layers_count < 0);
@@ -459,14 +405,9 @@ Color TileSet::get_terrain_color(int p_terrain_set, int p_terrain_index) const {
return terrain_sets[p_terrain_set].terrains[p_terrain_index].color;
}
-bool TileSet::is_valid_peering_bit_terrain(int p_terrain_set, TileSet::CellNeighbor p_peering_bit) const {
- if (p_terrain_set < 0 || p_terrain_set >= get_terrain_sets_count()) {
- return false;
- }
-
- TileSet::TerrainMode terrain_mode = get_terrain_set_mode(p_terrain_set);
+bool TileSet::is_valid_peering_bit_for_mode(TileSet::TerrainMode p_terrain_mode, TileSet::CellNeighbor p_peering_bit) const {
if (tile_shape == TileSet::TILE_SHAPE_SQUARE) {
- if (terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS_AND_SIDES || terrain_mode == TileSet::TERRAIN_MODE_MATCH_SIDES) {
+ if (p_terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS_AND_SIDES || p_terrain_mode == TileSet::TERRAIN_MODE_MATCH_SIDES) {
if (p_peering_bit == TileSet::CELL_NEIGHBOR_RIGHT_SIDE ||
p_peering_bit == TileSet::CELL_NEIGHBOR_BOTTOM_SIDE ||
p_peering_bit == TileSet::CELL_NEIGHBOR_LEFT_SIDE ||
@@ -474,7 +415,7 @@ bool TileSet::is_valid_peering_bit_terrain(int p_terrain_set, TileSet::CellNeigh
return true;
}
}
- if (terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS_AND_SIDES || terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS) {
+ if (p_terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS_AND_SIDES || p_terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS) {
if (p_peering_bit == TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_CORNER ||
p_peering_bit == TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_CORNER ||
p_peering_bit == TileSet::CELL_NEIGHBOR_TOP_LEFT_CORNER ||
@@ -483,7 +424,7 @@ bool TileSet::is_valid_peering_bit_terrain(int p_terrain_set, TileSet::CellNeigh
}
}
} else if (tile_shape == TileSet::TILE_SHAPE_ISOMETRIC) {
- if (terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS_AND_SIDES || terrain_mode == TileSet::TERRAIN_MODE_MATCH_SIDES) {
+ if (p_terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS_AND_SIDES || p_terrain_mode == TileSet::TERRAIN_MODE_MATCH_SIDES) {
if (p_peering_bit == TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_SIDE ||
p_peering_bit == TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_SIDE ||
p_peering_bit == TileSet::CELL_NEIGHBOR_TOP_LEFT_SIDE ||
@@ -491,7 +432,7 @@ bool TileSet::is_valid_peering_bit_terrain(int p_terrain_set, TileSet::CellNeigh
return true;
}
}
- if (terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS_AND_SIDES || terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS) {
+ if (p_terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS_AND_SIDES || p_terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS) {
if (p_peering_bit == TileSet::CELL_NEIGHBOR_RIGHT_CORNER ||
p_peering_bit == TileSet::CELL_NEIGHBOR_BOTTOM_CORNER ||
p_peering_bit == TileSet::CELL_NEIGHBOR_LEFT_CORNER ||
@@ -501,7 +442,7 @@ bool TileSet::is_valid_peering_bit_terrain(int p_terrain_set, TileSet::CellNeigh
}
} else {
if (get_tile_offset_axis() == TileSet::TILE_OFFSET_AXIS_HORIZONTAL) {
- if (terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS_AND_SIDES || terrain_mode == TileSet::TERRAIN_MODE_MATCH_SIDES) {
+ if (p_terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS_AND_SIDES || p_terrain_mode == TileSet::TERRAIN_MODE_MATCH_SIDES) {
if (p_peering_bit == TileSet::CELL_NEIGHBOR_RIGHT_SIDE ||
p_peering_bit == TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_SIDE ||
p_peering_bit == TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_SIDE ||
@@ -511,7 +452,7 @@ bool TileSet::is_valid_peering_bit_terrain(int p_terrain_set, TileSet::CellNeigh
return true;
}
}
- if (terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS_AND_SIDES || terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS) {
+ if (p_terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS_AND_SIDES || p_terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS) {
if (p_peering_bit == TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_CORNER ||
p_peering_bit == TileSet::CELL_NEIGHBOR_BOTTOM_CORNER ||
p_peering_bit == TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_CORNER ||
@@ -522,7 +463,7 @@ bool TileSet::is_valid_peering_bit_terrain(int p_terrain_set, TileSet::CellNeigh
}
}
} else {
- if (terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS_AND_SIDES || terrain_mode == TileSet::TERRAIN_MODE_MATCH_SIDES) {
+ if (p_terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS_AND_SIDES || p_terrain_mode == TileSet::TERRAIN_MODE_MATCH_SIDES) {
if (p_peering_bit == TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_SIDE ||
p_peering_bit == TileSet::CELL_NEIGHBOR_BOTTOM_SIDE ||
p_peering_bit == TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_SIDE ||
@@ -532,7 +473,7 @@ bool TileSet::is_valid_peering_bit_terrain(int p_terrain_set, TileSet::CellNeigh
return true;
}
}
- if (terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS_AND_SIDES || terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS) {
+ if (p_terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS_AND_SIDES || p_terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS) {
if (p_peering_bit == TileSet::CELL_NEIGHBOR_RIGHT_CORNER ||
p_peering_bit == TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_CORNER ||
p_peering_bit == TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_CORNER ||
@@ -547,6 +488,15 @@ bool TileSet::is_valid_peering_bit_terrain(int p_terrain_set, TileSet::CellNeigh
return false;
}
+bool TileSet::is_valid_peering_bit_terrain(int p_terrain_set, TileSet::CellNeighbor p_peering_bit) const {
+ if (p_terrain_set < 0 || p_terrain_set >= get_terrain_sets_count()) {
+ return false;
+ }
+
+ TileSet::TerrainMode terrain_mode = get_terrain_set_mode(p_terrain_set);
+ return is_valid_peering_bit_for_mode(terrain_mode, p_peering_bit);
+}
+
// Navigation
void TileSet::set_navigation_layers_count(int p_navigation_layers_count) {
ERR_FAIL_COND(p_navigation_layers_count < 0);
@@ -657,9 +607,926 @@ Variant::Type TileSet::get_custom_data_type(int p_layer_id) const {
return custom_data_layers[p_layer_id].type;
}
+Vector<Vector2> TileSet::get_tile_shape_polygon() {
+ Vector<Vector2> points;
+ if (tile_shape == TileSet::TILE_SHAPE_SQUARE) {
+ points.append(Vector2(0.0, 0.0));
+ points.append(Vector2(1.0, 0.0));
+ points.append(Vector2(1.0, 1.0));
+ points.append(Vector2(0.0, 1.0));
+ } else {
+ float overlap = 0.0;
+ switch (tile_shape) {
+ case TileSet::TILE_SHAPE_ISOMETRIC:
+ overlap = 0.5;
+ break;
+ case TileSet::TILE_SHAPE_HEXAGON:
+ overlap = 0.25;
+ break;
+ case TileSet::TILE_SHAPE_HALF_OFFSET_SQUARE:
+ overlap = 0.0;
+ break;
+ default:
+ break;
+ }
+
+ points.append(Vector2(0.5, 0.0));
+ points.append(Vector2(0.0, overlap));
+ points.append(Vector2(0.0, 1.0 - overlap));
+ points.append(Vector2(0.5, 1.0));
+ points.append(Vector2(1.0, 1.0 - overlap));
+ points.append(Vector2(1.0, overlap));
+ points.append(Vector2(0.5, 0.0));
+ if (get_tile_offset_axis() == TileSet::TILE_OFFSET_AXIS_VERTICAL) {
+ for (int i = 0; i < points.size(); i++) {
+ points.write[i] = Vector2(points[i].y, points[i].x);
+ }
+ }
+ }
+ for (int i = 0; i < points.size(); i++) {
+ points.write[i] = points[i] * tile_size - tile_size / 2;
+ }
+ return points;
+}
+
+void TileSet::draw_tile_shape(CanvasItem *p_canvas_item, Rect2 p_region, Color p_color, bool p_filled, Ref<Texture2D> p_texture) {
+ if (tile_meshes_dirty) {
+ Vector<Vector2> uvs = get_tile_shape_polygon();
+ for (int i = 0; i < uvs.size(); i++) {
+ uvs.write[i] = (uvs[i] + tile_size / 2) / tile_size;
+ }
+
+ Vector<Color> colors;
+ colors.resize(uvs.size());
+ colors.fill(Color(1.0, 1.0, 1.0, 1.0));
+
+ // Filled mesh.
+ tile_filled_mesh->clear_surfaces();
+ Array a;
+ a.resize(Mesh::ARRAY_MAX);
+ a[Mesh::ARRAY_VERTEX] = uvs;
+ a[Mesh::ARRAY_TEX_UV] = uvs;
+ a[Mesh::ARRAY_COLOR] = colors;
+ a[Mesh::ARRAY_INDEX] = Geometry2D::triangulate_polygon(uvs);
+ tile_filled_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, a, Array(), Dictionary(), Mesh::ARRAY_FLAG_USE_2D_VERTICES);
+
+ // Lines mesh.
+ tile_lines_mesh->clear_surfaces();
+ a.clear();
+ a.resize(Mesh::ARRAY_MAX);
+ // Add the first point again when drawing lines.
+ uvs.push_back(uvs[0]);
+ colors.push_back(colors[0]);
+ a[Mesh::ARRAY_VERTEX] = uvs;
+ a[Mesh::ARRAY_COLOR] = colors;
+ tile_lines_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_LINE_STRIP, a, Array(), Dictionary(), Mesh::ARRAY_FLAG_USE_2D_VERTICES);
+
+ tile_meshes_dirty = false;
+ }
+
+ Transform2D xform;
+ xform.scale(p_region.size);
+ xform.set_origin(p_region.get_position());
+ if (p_filled) {
+ p_canvas_item->draw_mesh(tile_filled_mesh, p_texture, xform, p_color);
+ } else {
+ p_canvas_item->draw_mesh(tile_lines_mesh, Ref<Texture2D>(), xform, p_color);
+ }
+}
+
+Vector<Point2> TileSet::get_terrain_bit_polygon(int p_terrain_set, TileSet::CellNeighbor p_bit) {
+ ERR_FAIL_COND_V(p_terrain_set < 0 || p_terrain_set >= get_terrain_sets_count(), Vector<Point2>());
+
+ TileSet::TerrainMode terrain_mode = get_terrain_set_mode(p_terrain_set);
+
+ if (tile_shape == TileSet::TILE_SHAPE_SQUARE) {
+ if (terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS_AND_SIDES) {
+ return _get_square_corner_or_side_terrain_bit_polygon(tile_size, p_bit);
+ } else if (terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS) {
+ return _get_square_corner_terrain_bit_polygon(tile_size, p_bit);
+ } else { // TileData::TERRAIN_MODE_MATCH_SIDES
+ return _get_square_side_terrain_bit_polygon(tile_size, p_bit);
+ }
+ } else if (tile_shape == TileSet::TILE_SHAPE_ISOMETRIC) {
+ if (terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS_AND_SIDES) {
+ return _get_isometric_corner_or_side_terrain_bit_polygon(tile_size, p_bit);
+ } else if (terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS) {
+ return _get_isometric_corner_terrain_bit_polygon(tile_size, p_bit);
+ } else { // TileData::TERRAIN_MODE_MATCH_SIDES
+ return _get_isometric_side_terrain_bit_polygon(tile_size, p_bit);
+ }
+ } else {
+ float overlap = 0.0;
+ switch (tile_shape) {
+ case TileSet::TILE_SHAPE_HEXAGON:
+ overlap = 0.25;
+ break;
+ case TileSet::TILE_SHAPE_HALF_OFFSET_SQUARE:
+ overlap = 0.0;
+ break;
+ default:
+ break;
+ }
+ if (terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS_AND_SIDES) {
+ return _get_half_offset_corner_or_side_terrain_bit_polygon(tile_size, p_bit, overlap, tile_offset_axis);
+ } else if (terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS) {
+ return _get_half_offset_corner_terrain_bit_polygon(tile_size, p_bit, overlap, tile_offset_axis);
+ } else { // TileData::TERRAIN_MODE_MATCH_SIDES
+ return _get_half_offset_side_terrain_bit_polygon(tile_size, p_bit, overlap, tile_offset_axis);
+ }
+ }
+}
+
+#define TERRAIN_ALPHA 0.6
+
+void TileSet::draw_terrains(CanvasItem *p_canvas_item, Transform2D p_transform, const TileData *p_tile_data) {
+ ERR_FAIL_COND(!p_tile_data);
+
+ if (terrain_bits_meshes_dirty) {
+ // Recompute the meshes.
+ terrain_bits_meshes.clear();
+
+ for (int terrain_mode_index = 0; terrain_mode_index < 3; terrain_mode_index++) {
+ TerrainMode terrain_mode = TerrainMode(terrain_mode_index);
+ for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) {
+ CellNeighbor bit = CellNeighbor(i);
+
+ if (is_valid_peering_bit_for_mode(terrain_mode, bit)) {
+ Vector<Vector2> polygon;
+ if (tile_shape == TileSet::TILE_SHAPE_SQUARE) {
+ if (terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS_AND_SIDES) {
+ polygon = _get_square_corner_or_side_terrain_bit_polygon(tile_size, bit);
+ } else if (terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS) {
+ polygon = _get_square_corner_terrain_bit_polygon(tile_size, bit);
+ } else { // TileData::TERRAIN_MODE_MATCH_SIDES
+ polygon = _get_square_side_terrain_bit_polygon(tile_size, bit);
+ }
+ } else if (tile_shape == TileSet::TILE_SHAPE_ISOMETRIC) {
+ if (terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS_AND_SIDES) {
+ polygon = _get_isometric_corner_or_side_terrain_bit_polygon(tile_size, bit);
+ } else if (terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS) {
+ polygon = _get_isometric_corner_terrain_bit_polygon(tile_size, bit);
+ } else { // TileData::TERRAIN_MODE_MATCH_SIDES
+ polygon = _get_isometric_side_terrain_bit_polygon(tile_size, bit);
+ }
+ } else {
+ float overlap = 0.0;
+ switch (tile_shape) {
+ case TileSet::TILE_SHAPE_HEXAGON:
+ overlap = 0.25;
+ break;
+ case TileSet::TILE_SHAPE_HALF_OFFSET_SQUARE:
+ overlap = 0.0;
+ break;
+ default:
+ break;
+ }
+ if (terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS_AND_SIDES) {
+ polygon = _get_half_offset_corner_or_side_terrain_bit_polygon(tile_size, bit, overlap, tile_offset_axis);
+ } else if (terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS) {
+ polygon = _get_half_offset_corner_terrain_bit_polygon(tile_size, bit, overlap, tile_offset_axis);
+ } else { // TileData::TERRAIN_MODE_MATCH_SIDES
+ polygon = _get_half_offset_side_terrain_bit_polygon(tile_size, bit, overlap, tile_offset_axis);
+ }
+ }
+
+ Ref<ArrayMesh> mesh;
+ mesh.instantiate();
+ Vector<Vector2> uvs;
+ uvs.resize(polygon.size());
+ Vector<Color> colors;
+ colors.resize(polygon.size());
+ colors.fill(Color(1.0, 1.0, 1.0, 1.0));
+ Array a;
+ a.resize(Mesh::ARRAY_MAX);
+ a[Mesh::ARRAY_VERTEX] = polygon;
+ a[Mesh::ARRAY_TEX_UV] = uvs;
+ a[Mesh::ARRAY_COLOR] = colors;
+ a[Mesh::ARRAY_INDEX] = Geometry2D::triangulate_polygon(polygon);
+ mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, a, Array(), Dictionary(), Mesh::ARRAY_FLAG_USE_2D_VERTICES);
+ terrain_bits_meshes[terrain_mode][bit] = mesh;
+ }
+ }
+ }
+ terrain_bits_meshes_dirty = false;
+ }
+
+ int terrain_set = p_tile_data->get_terrain_set();
+ if (terrain_set < 0) {
+ return;
+ }
+ TileSet::TerrainMode terrain_mode = get_terrain_set_mode(terrain_set);
+
+ RenderingServer::get_singleton()->canvas_item_add_set_transform(p_canvas_item->get_canvas_item(), p_transform);
+ for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) {
+ CellNeighbor bit = CellNeighbor(i);
+ if (is_valid_peering_bit_terrain(terrain_set, bit)) {
+ int terrain_id = p_tile_data->get_peering_bit_terrain(bit);
+ if (terrain_id >= 0) {
+ Color color = get_terrain_color(terrain_set, terrain_id);
+ color.a = TERRAIN_ALPHA;
+ p_canvas_item->draw_mesh(terrain_bits_meshes[terrain_mode][bit], Ref<Texture2D>(), Transform2D(), color);
+ }
+ }
+ }
+ RenderingServer::get_singleton()->canvas_item_add_set_transform(p_canvas_item->get_canvas_item(), Transform2D());
+}
+
+Vector<Vector<Ref<Texture2D>>> TileSet::generate_terrains_icons(Size2i p_size) {
+ // Counts the number of matching terrain tiles and find the best matching icon.
+ struct Count {
+ int count = 0;
+ float probability = 0.0;
+ Ref<Texture2D> texture;
+ Rect2i region;
+ };
+ Vector<Vector<Ref<Texture2D>>> output;
+ LocalVector<LocalVector<Count>> counts;
+ output.resize(get_terrain_sets_count());
+ counts.resize(get_terrain_sets_count());
+ for (int terrain_set = 0; terrain_set < get_terrain_sets_count(); terrain_set++) {
+ output.write[terrain_set].resize(get_terrains_count(terrain_set));
+ counts[terrain_set].resize(get_terrains_count(terrain_set));
+ }
+
+ for (int source_index = 0; source_index < get_source_count(); source_index++) {
+ int source_id = get_source_id(source_index);
+ Ref<TileSetSource> source = get_source(source_id);
+
+ Ref<TileSetAtlasSource> atlas_source = source;
+ if (atlas_source.is_valid()) {
+ for (int tile_index = 0; tile_index < source->get_tiles_count(); tile_index++) {
+ Vector2i tile_id = source->get_tile_id(tile_index);
+ for (int alternative_index = 0; alternative_index < source->get_alternative_tiles_count(tile_id); alternative_index++) {
+ int alternative_id = source->get_alternative_tile_id(tile_id, alternative_index);
+
+ TileData *tile_data = Object::cast_to<TileData>(atlas_source->get_tile_data(tile_id, alternative_id));
+ int terrain_set = tile_data->get_terrain_set();
+ if (terrain_set >= 0) {
+ ERR_FAIL_INDEX_V(terrain_set, get_terrain_sets_count(), Vector<Vector<Ref<Texture2D>>>());
+
+ LocalVector<int> bit_counts;
+ bit_counts.resize(get_terrains_count(terrain_set));
+ for (int terrain = 0; terrain < get_terrains_count(terrain_set); terrain++) {
+ bit_counts[terrain] = 0;
+ }
+ for (int terrain_bit = 0; terrain_bit < TileSet::CELL_NEIGHBOR_MAX; terrain_bit++) {
+ TileSet::CellNeighbor cell_neighbor = TileSet::CellNeighbor(terrain_bit);
+ if (is_valid_peering_bit_terrain(terrain_set, cell_neighbor)) {
+ int terrain = tile_data->get_peering_bit_terrain(cell_neighbor);
+ if (terrain >= 0) {
+ bit_counts[terrain] += 1;
+ }
+ }
+ }
+
+ for (int terrain = 0; terrain < get_terrains_count(terrain_set); terrain++) {
+ if ((bit_counts[terrain] > counts[terrain_set][terrain].count) || (bit_counts[terrain] == counts[terrain_set][terrain].count && tile_data->get_probability() > counts[terrain_set][terrain].probability)) {
+ counts[terrain_set][terrain].count = bit_counts[terrain];
+ counts[terrain_set][terrain].probability = tile_data->get_probability();
+ counts[terrain_set][terrain].texture = atlas_source->get_texture();
+ counts[terrain_set][terrain].region = atlas_source->get_tile_texture_region(tile_id);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // Generate the icons.
+ for (int terrain_set = 0; terrain_set < get_terrain_sets_count(); terrain_set++) {
+ for (int terrain = 0; terrain < get_terrains_count(terrain_set); terrain++) {
+ Ref<Image> image;
+ image.instantiate();
+ if (counts[terrain_set][terrain].count > 0) {
+ // Get the best tile.
+ Ref<Texture2D> texture = counts[terrain_set][terrain].texture;
+ Rect2 region = counts[terrain_set][terrain].region;
+ image->create(region.size.x, region.size.y, false, Image::FORMAT_RGBA8);
+ image->blit_rect(texture->get_image(), region, Point2());
+ image->resize(p_size.x, p_size.y, Image::INTERPOLATE_NEAREST);
+ } else {
+ image->create(1, 1, false, Image::FORMAT_RGBA8);
+ image->set_pixel(0, 0, get_terrain_color(terrain_set, terrain));
+ }
+ Ref<ImageTexture> icon;
+ icon.instantiate();
+ icon->create_from_image(image);
+ icon->set_size_override(p_size);
+
+ output.write[terrain_set].write[terrain] = icon;
+ }
+ }
+ return output;
+}
+
void TileSet::_source_changed() {
emit_changed();
- notify_property_list_changed();
+}
+
+Vector<Point2> TileSet::_get_square_corner_or_side_terrain_bit_polygon(Vector2i p_size, TileSet::CellNeighbor p_bit) {
+ Rect2 bit_rect;
+ bit_rect.size = Vector2(p_size) / 3;
+ switch (p_bit) {
+ case TileSet::CELL_NEIGHBOR_RIGHT_SIDE:
+ bit_rect.position = Vector2(1, -1);
+ break;
+ case TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_CORNER:
+ bit_rect.position = Vector2(1, 1);
+ break;
+ case TileSet::CELL_NEIGHBOR_BOTTOM_SIDE:
+ bit_rect.position = Vector2(-1, 1);
+ break;
+ case TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_CORNER:
+ bit_rect.position = Vector2(-3, 1);
+ break;
+ case TileSet::CELL_NEIGHBOR_LEFT_SIDE:
+ bit_rect.position = Vector2(-3, -1);
+ break;
+ case TileSet::CELL_NEIGHBOR_TOP_LEFT_CORNER:
+ bit_rect.position = Vector2(-3, -3);
+ break;
+ case TileSet::CELL_NEIGHBOR_TOP_SIDE:
+ bit_rect.position = Vector2(-1, -3);
+ break;
+ case TileSet::CELL_NEIGHBOR_TOP_RIGHT_CORNER:
+ bit_rect.position = Vector2(1, -3);
+ break;
+ default:
+ break;
+ }
+ bit_rect.position *= Vector2(p_size) / 6.0;
+ Vector<Vector2> polygon;
+ polygon.push_back(bit_rect.position);
+ polygon.push_back(Vector2(bit_rect.get_end().x, bit_rect.position.y));
+ polygon.push_back(bit_rect.get_end());
+ polygon.push_back(Vector2(bit_rect.position.x, bit_rect.get_end().y));
+ return polygon;
+}
+
+Vector<Point2> TileSet::_get_square_corner_terrain_bit_polygon(Vector2i p_size, TileSet::CellNeighbor p_bit) {
+ Vector2 unit = Vector2(p_size) / 6.0;
+ Vector<Vector2> polygon;
+ switch (p_bit) {
+ case TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_CORNER:
+ polygon.push_back(Vector2(0, 3) * unit);
+ polygon.push_back(Vector2(3, 3) * unit);
+ polygon.push_back(Vector2(3, 0) * unit);
+ polygon.push_back(Vector2(1, 0) * unit);
+ polygon.push_back(Vector2(1, 1) * unit);
+ polygon.push_back(Vector2(0, 1) * unit);
+ break;
+ case TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_CORNER:
+ polygon.push_back(Vector2(0, 3) * unit);
+ polygon.push_back(Vector2(-3, 3) * unit);
+ polygon.push_back(Vector2(-3, 0) * unit);
+ polygon.push_back(Vector2(-1, 0) * unit);
+ polygon.push_back(Vector2(-1, 1) * unit);
+ polygon.push_back(Vector2(0, 1) * unit);
+ break;
+ case TileSet::CELL_NEIGHBOR_TOP_LEFT_CORNER:
+ polygon.push_back(Vector2(0, -3) * unit);
+ polygon.push_back(Vector2(-3, -3) * unit);
+ polygon.push_back(Vector2(-3, 0) * unit);
+ polygon.push_back(Vector2(-1, 0) * unit);
+ polygon.push_back(Vector2(-1, -1) * unit);
+ polygon.push_back(Vector2(0, -1) * unit);
+ break;
+ case TileSet::CELL_NEIGHBOR_TOP_RIGHT_CORNER:
+ polygon.push_back(Vector2(0, -3) * unit);
+ polygon.push_back(Vector2(3, -3) * unit);
+ polygon.push_back(Vector2(3, 0) * unit);
+ polygon.push_back(Vector2(1, 0) * unit);
+ polygon.push_back(Vector2(1, -1) * unit);
+ polygon.push_back(Vector2(0, -1) * unit);
+ break;
+ default:
+ break;
+ }
+ return polygon;
+}
+
+Vector<Point2> TileSet::_get_square_side_terrain_bit_polygon(Vector2i p_size, TileSet::CellNeighbor p_bit) {
+ Vector2 unit = Vector2(p_size) / 6.0;
+ Vector<Vector2> polygon;
+ switch (p_bit) {
+ case TileSet::CELL_NEIGHBOR_RIGHT_SIDE:
+ polygon.push_back(Vector2(1, -1) * unit);
+ polygon.push_back(Vector2(3, -3) * unit);
+ polygon.push_back(Vector2(3, 3) * unit);
+ polygon.push_back(Vector2(1, 1) * unit);
+ break;
+ case TileSet::CELL_NEIGHBOR_BOTTOM_SIDE:
+ polygon.push_back(Vector2(-1, 1) * unit);
+ polygon.push_back(Vector2(-3, 3) * unit);
+ polygon.push_back(Vector2(3, 3) * unit);
+ polygon.push_back(Vector2(1, 1) * unit);
+ break;
+ case TileSet::CELL_NEIGHBOR_LEFT_SIDE:
+ polygon.push_back(Vector2(-1, -1) * unit);
+ polygon.push_back(Vector2(-3, -3) * unit);
+ polygon.push_back(Vector2(-3, 3) * unit);
+ polygon.push_back(Vector2(-1, 1) * unit);
+ break;
+ case TileSet::CELL_NEIGHBOR_TOP_SIDE:
+ polygon.push_back(Vector2(-1, -1) * unit);
+ polygon.push_back(Vector2(-3, -3) * unit);
+ polygon.push_back(Vector2(3, -3) * unit);
+ polygon.push_back(Vector2(1, -1) * unit);
+ break;
+ default:
+ break;
+ }
+ return polygon;
+}
+
+Vector<Point2> TileSet::_get_isometric_corner_or_side_terrain_bit_polygon(Vector2i p_size, TileSet::CellNeighbor p_bit) {
+ Vector2 unit = Vector2(p_size) / 6.0;
+ Vector<Vector2> polygon;
+ switch (p_bit) {
+ case TileSet::CELL_NEIGHBOR_RIGHT_CORNER:
+ polygon.push_back(Vector2(1, 0) * unit);
+ polygon.push_back(Vector2(2, -1) * unit);
+ polygon.push_back(Vector2(3, 0) * unit);
+ polygon.push_back(Vector2(2, 1) * unit);
+ break;
+ case TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_SIDE:
+ polygon.push_back(Vector2(0, 1) * unit);
+ polygon.push_back(Vector2(1, 2) * unit);
+ polygon.push_back(Vector2(2, 1) * unit);
+ polygon.push_back(Vector2(1, 0) * unit);
+ break;
+ case TileSet::CELL_NEIGHBOR_BOTTOM_CORNER:
+ polygon.push_back(Vector2(0, 1) * unit);
+ polygon.push_back(Vector2(-1, 2) * unit);
+ polygon.push_back(Vector2(0, 3) * unit);
+ polygon.push_back(Vector2(1, 2) * unit);
+ break;
+ case TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_SIDE:
+ polygon.push_back(Vector2(0, 1) * unit);
+ polygon.push_back(Vector2(-1, 2) * unit);
+ polygon.push_back(Vector2(-2, 1) * unit);
+ polygon.push_back(Vector2(-1, 0) * unit);
+ break;
+ case TileSet::CELL_NEIGHBOR_LEFT_CORNER:
+ polygon.push_back(Vector2(-1, 0) * unit);
+ polygon.push_back(Vector2(-2, -1) * unit);
+ polygon.push_back(Vector2(-3, 0) * unit);
+ polygon.push_back(Vector2(-2, 1) * unit);
+ break;
+ case TileSet::CELL_NEIGHBOR_TOP_LEFT_SIDE:
+ polygon.push_back(Vector2(0, -1) * unit);
+ polygon.push_back(Vector2(-1, -2) * unit);
+ polygon.push_back(Vector2(-2, -1) * unit);
+ polygon.push_back(Vector2(-1, 0) * unit);
+ break;
+ case TileSet::CELL_NEIGHBOR_TOP_CORNER:
+ polygon.push_back(Vector2(0, -1) * unit);
+ polygon.push_back(Vector2(-1, -2) * unit);
+ polygon.push_back(Vector2(0, -3) * unit);
+ polygon.push_back(Vector2(1, -2) * unit);
+ break;
+ case TileSet::CELL_NEIGHBOR_TOP_RIGHT_SIDE:
+ polygon.push_back(Vector2(0, -1) * unit);
+ polygon.push_back(Vector2(1, -2) * unit);
+ polygon.push_back(Vector2(2, -1) * unit);
+ polygon.push_back(Vector2(1, 0) * unit);
+ break;
+ default:
+ break;
+ }
+ return polygon;
+}
+
+Vector<Point2> TileSet::_get_isometric_corner_terrain_bit_polygon(Vector2i p_size, TileSet::CellNeighbor p_bit) {
+ Vector2 unit = Vector2(p_size) / 6.0;
+ Vector<Vector2> polygon;
+ switch (p_bit) {
+ case TileSet::CELL_NEIGHBOR_RIGHT_CORNER:
+ polygon.push_back(Vector2(0.5, -0.5) * unit);
+ polygon.push_back(Vector2(1.5, -1.5) * unit);
+ polygon.push_back(Vector2(3, 0) * unit);
+ polygon.push_back(Vector2(1.5, 1.5) * unit);
+ polygon.push_back(Vector2(0.5, 0.5) * unit);
+ polygon.push_back(Vector2(1, 0) * unit);
+ break;
+ case TileSet::CELL_NEIGHBOR_BOTTOM_CORNER:
+ polygon.push_back(Vector2(-0.5, 0.5) * unit);
+ polygon.push_back(Vector2(-1.5, 1.5) * unit);
+ polygon.push_back(Vector2(0, 3) * unit);
+ polygon.push_back(Vector2(1.5, 1.5) * unit);
+ polygon.push_back(Vector2(0.5, 0.5) * unit);
+ polygon.push_back(Vector2(0, 1) * unit);
+ break;
+ case TileSet::CELL_NEIGHBOR_LEFT_CORNER:
+ polygon.push_back(Vector2(-0.5, -0.5) * unit);
+ polygon.push_back(Vector2(-1.5, -1.5) * unit);
+ polygon.push_back(Vector2(-3, 0) * unit);
+ polygon.push_back(Vector2(-1.5, 1.5) * unit);
+ polygon.push_back(Vector2(-0.5, 0.5) * unit);
+ polygon.push_back(Vector2(-1, 0) * unit);
+ break;
+ case TileSet::CELL_NEIGHBOR_TOP_CORNER:
+ polygon.push_back(Vector2(-0.5, -0.5) * unit);
+ polygon.push_back(Vector2(-1.5, -1.5) * unit);
+ polygon.push_back(Vector2(0, -3) * unit);
+ polygon.push_back(Vector2(1.5, -1.5) * unit);
+ polygon.push_back(Vector2(0.5, -0.5) * unit);
+ polygon.push_back(Vector2(0, -1) * unit);
+ break;
+ default:
+ break;
+ }
+ return polygon;
+}
+
+Vector<Point2> TileSet::_get_isometric_side_terrain_bit_polygon(Vector2i p_size, TileSet::CellNeighbor p_bit) {
+ Vector2 unit = Vector2(p_size) / 6.0;
+ Vector<Vector2> polygon;
+ switch (p_bit) {
+ case TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_SIDE:
+ polygon.push_back(Vector2(1, 0) * unit);
+ polygon.push_back(Vector2(3, 0) * unit);
+ polygon.push_back(Vector2(0, 3) * unit);
+ polygon.push_back(Vector2(0, 1) * unit);
+ break;
+ case TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_SIDE:
+ polygon.push_back(Vector2(-1, 0) * unit);
+ polygon.push_back(Vector2(-3, 0) * unit);
+ polygon.push_back(Vector2(0, 3) * unit);
+ polygon.push_back(Vector2(0, 1) * unit);
+ break;
+ case TileSet::CELL_NEIGHBOR_TOP_LEFT_SIDE:
+ polygon.push_back(Vector2(-1, 0) * unit);
+ polygon.push_back(Vector2(-3, 0) * unit);
+ polygon.push_back(Vector2(0, -3) * unit);
+ polygon.push_back(Vector2(0, -1) * unit);
+ break;
+ case TileSet::CELL_NEIGHBOR_TOP_RIGHT_SIDE:
+ polygon.push_back(Vector2(1, 0) * unit);
+ polygon.push_back(Vector2(3, 0) * unit);
+ polygon.push_back(Vector2(0, -3) * unit);
+ polygon.push_back(Vector2(0, -1) * unit);
+ break;
+ default:
+ break;
+ }
+ return polygon;
+}
+
+Vector<Point2> TileSet::_get_half_offset_corner_or_side_terrain_bit_polygon(Vector2i p_size, TileSet::CellNeighbor p_bit, float p_overlap, TileSet::TileOffsetAxis p_offset_axis) {
+ Vector<Vector2> point_list;
+ point_list.push_back(Vector2(3, (3.0 * (1.0 - p_overlap * 2.0)) / 2.0));
+ point_list.push_back(Vector2(3, 3.0 * (1.0 - p_overlap * 2.0)));
+ point_list.push_back(Vector2(2, 3.0 * (1.0 - (p_overlap * 2.0) * 2.0 / 3.0)));
+ point_list.push_back(Vector2(1, 3.0 - p_overlap * 2.0));
+ point_list.push_back(Vector2(0, 3));
+ point_list.push_back(Vector2(-1, 3.0 - p_overlap * 2.0));
+ point_list.push_back(Vector2(-2, 3.0 * (1.0 - (p_overlap * 2.0) * 2.0 / 3.0)));
+ point_list.push_back(Vector2(-3, 3.0 * (1.0 - p_overlap * 2.0)));
+ point_list.push_back(Vector2(-3, (3.0 * (1.0 - p_overlap * 2.0)) / 2.0));
+ point_list.push_back(Vector2(-3, -(3.0 * (1.0 - p_overlap * 2.0)) / 2.0));
+ point_list.push_back(Vector2(-3, -3.0 * (1.0 - p_overlap * 2.0)));
+ point_list.push_back(Vector2(-2, -3.0 * (1.0 - (p_overlap * 2.0) * 2.0 / 3.0)));
+ point_list.push_back(Vector2(-1, -(3.0 - p_overlap * 2.0)));
+ point_list.push_back(Vector2(0, -3));
+ point_list.push_back(Vector2(1, -(3.0 - p_overlap * 2.0)));
+ point_list.push_back(Vector2(2, -3.0 * (1.0 - (p_overlap * 2.0) * 2.0 / 3.0)));
+ point_list.push_back(Vector2(3, -3.0 * (1.0 - p_overlap * 2.0)));
+ point_list.push_back(Vector2(3, -(3.0 * (1.0 - p_overlap * 2.0)) / 2.0));
+
+ Vector2 unit = Vector2(p_size) / 6.0;
+ for (int i = 0; i < point_list.size(); i++) {
+ point_list.write[i] = point_list[i] * unit;
+ }
+
+ Vector<Vector2> polygon;
+ if (p_offset_axis == TileSet::TILE_OFFSET_AXIS_HORIZONTAL) {
+ switch (p_bit) {
+ case TileSet::CELL_NEIGHBOR_RIGHT_SIDE:
+ polygon.push_back(point_list[17]);
+ polygon.push_back(point_list[0]);
+ break;
+ case TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_CORNER:
+ polygon.push_back(point_list[0]);
+ polygon.push_back(point_list[1]);
+ polygon.push_back(point_list[2]);
+ break;
+ case TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_SIDE:
+ polygon.push_back(point_list[2]);
+ polygon.push_back(point_list[3]);
+ break;
+ case TileSet::CELL_NEIGHBOR_BOTTOM_CORNER:
+ polygon.push_back(point_list[3]);
+ polygon.push_back(point_list[4]);
+ polygon.push_back(point_list[5]);
+ break;
+ case TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_SIDE:
+ polygon.push_back(point_list[5]);
+ polygon.push_back(point_list[6]);
+ break;
+ case TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_CORNER:
+ polygon.push_back(point_list[6]);
+ polygon.push_back(point_list[7]);
+ polygon.push_back(point_list[8]);
+ break;
+ case TileSet::CELL_NEIGHBOR_LEFT_SIDE:
+ polygon.push_back(point_list[8]);
+ polygon.push_back(point_list[9]);
+ break;
+ case TileSet::CELL_NEIGHBOR_TOP_LEFT_CORNER:
+ polygon.push_back(point_list[9]);
+ polygon.push_back(point_list[10]);
+ polygon.push_back(point_list[11]);
+ break;
+ case TileSet::CELL_NEIGHBOR_TOP_LEFT_SIDE:
+ polygon.push_back(point_list[11]);
+ polygon.push_back(point_list[12]);
+ break;
+ case TileSet::CELL_NEIGHBOR_TOP_CORNER:
+ polygon.push_back(point_list[12]);
+ polygon.push_back(point_list[13]);
+ polygon.push_back(point_list[14]);
+ break;
+ case TileSet::CELL_NEIGHBOR_TOP_RIGHT_SIDE:
+ polygon.push_back(point_list[14]);
+ polygon.push_back(point_list[15]);
+ break;
+ case TileSet::CELL_NEIGHBOR_TOP_RIGHT_CORNER:
+ polygon.push_back(point_list[15]);
+ polygon.push_back(point_list[16]);
+ polygon.push_back(point_list[17]);
+ break;
+ default:
+ break;
+ }
+ } else {
+ if (p_offset_axis == TileSet::TILE_OFFSET_AXIS_VERTICAL) {
+ for (int i = 0; i < point_list.size(); i++) {
+ point_list.write[i] = Vector2(point_list[i].y, point_list[i].x);
+ }
+ }
+ switch (p_bit) {
+ case TileSet::CELL_NEIGHBOR_RIGHT_CORNER:
+ polygon.push_back(point_list[3]);
+ polygon.push_back(point_list[4]);
+ polygon.push_back(point_list[5]);
+ break;
+ case TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_SIDE:
+ polygon.push_back(point_list[2]);
+ polygon.push_back(point_list[3]);
+ break;
+ case TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_CORNER:
+ polygon.push_back(point_list[0]);
+ polygon.push_back(point_list[1]);
+ polygon.push_back(point_list[2]);
+ break;
+ case TileSet::CELL_NEIGHBOR_BOTTOM_SIDE:
+ polygon.push_back(point_list[17]);
+ polygon.push_back(point_list[0]);
+ break;
+ case TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_CORNER:
+ polygon.push_back(point_list[15]);
+ polygon.push_back(point_list[16]);
+ polygon.push_back(point_list[17]);
+ break;
+ case TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_SIDE:
+ polygon.push_back(point_list[14]);
+ polygon.push_back(point_list[15]);
+ break;
+ case TileSet::CELL_NEIGHBOR_LEFT_CORNER:
+ polygon.push_back(point_list[12]);
+ polygon.push_back(point_list[13]);
+ polygon.push_back(point_list[14]);
+ break;
+ case TileSet::CELL_NEIGHBOR_TOP_LEFT_SIDE:
+ polygon.push_back(point_list[11]);
+ polygon.push_back(point_list[12]);
+ break;
+ case TileSet::CELL_NEIGHBOR_TOP_LEFT_CORNER:
+ polygon.push_back(point_list[9]);
+ polygon.push_back(point_list[10]);
+ polygon.push_back(point_list[11]);
+ break;
+ case TileSet::CELL_NEIGHBOR_TOP_SIDE:
+ polygon.push_back(point_list[8]);
+ polygon.push_back(point_list[9]);
+ break;
+ case TileSet::CELL_NEIGHBOR_TOP_RIGHT_CORNER:
+ polygon.push_back(point_list[6]);
+ polygon.push_back(point_list[7]);
+ polygon.push_back(point_list[8]);
+ break;
+ case TileSet::CELL_NEIGHBOR_TOP_RIGHT_SIDE:
+ polygon.push_back(point_list[5]);
+ polygon.push_back(point_list[6]);
+ break;
+ default:
+ break;
+ }
+ }
+
+ int half_polygon_size = polygon.size();
+ for (int i = 0; i < half_polygon_size; i++) {
+ polygon.push_back(polygon[half_polygon_size - 1 - i] / 3.0);
+ }
+
+ return polygon;
+}
+
+Vector<Point2> TileSet::_get_half_offset_corner_terrain_bit_polygon(Vector2i p_size, TileSet::CellNeighbor p_bit, float p_overlap, TileSet::TileOffsetAxis p_offset_axis) {
+ Vector<Vector2> point_list;
+ point_list.push_back(Vector2(3, 0));
+ point_list.push_back(Vector2(3, 3.0 * (1.0 - p_overlap * 2.0)));
+ point_list.push_back(Vector2(1.5, (3.0 * (1.0 - p_overlap * 2.0) + 3.0) / 2.0));
+ point_list.push_back(Vector2(0, 3));
+ point_list.push_back(Vector2(-1.5, (3.0 * (1.0 - p_overlap * 2.0) + 3.0) / 2.0));
+ point_list.push_back(Vector2(-3, 3.0 * (1.0 - p_overlap * 2.0)));
+ point_list.push_back(Vector2(-3, 0));
+ point_list.push_back(Vector2(-3, -3.0 * (1.0 - p_overlap * 2.0)));
+ point_list.push_back(Vector2(-1.5, -(3.0 * (1.0 - p_overlap * 2.0) + 3.0) / 2.0));
+ point_list.push_back(Vector2(0, -3));
+ point_list.push_back(Vector2(1.5, -(3.0 * (1.0 - p_overlap * 2.0) + 3.0) / 2.0));
+ point_list.push_back(Vector2(3, -3.0 * (1.0 - p_overlap * 2.0)));
+
+ Vector2 unit = Vector2(p_size) / 6.0;
+ for (int i = 0; i < point_list.size(); i++) {
+ point_list.write[i] = point_list[i] * unit;
+ }
+
+ Vector<Vector2> polygon;
+ if (p_offset_axis == TileSet::TILE_OFFSET_AXIS_HORIZONTAL) {
+ switch (p_bit) {
+ case TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_CORNER:
+ polygon.push_back(point_list[0]);
+ polygon.push_back(point_list[1]);
+ polygon.push_back(point_list[2]);
+ break;
+ case TileSet::CELL_NEIGHBOR_BOTTOM_CORNER:
+ polygon.push_back(point_list[2]);
+ polygon.push_back(point_list[3]);
+ polygon.push_back(point_list[4]);
+ break;
+ case TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_CORNER:
+ polygon.push_back(point_list[4]);
+ polygon.push_back(point_list[5]);
+ polygon.push_back(point_list[6]);
+ break;
+ case TileSet::CELL_NEIGHBOR_TOP_LEFT_CORNER:
+ polygon.push_back(point_list[6]);
+ polygon.push_back(point_list[7]);
+ polygon.push_back(point_list[8]);
+ break;
+ case TileSet::CELL_NEIGHBOR_TOP_CORNER:
+ polygon.push_back(point_list[8]);
+ polygon.push_back(point_list[9]);
+ polygon.push_back(point_list[10]);
+ break;
+ case TileSet::CELL_NEIGHBOR_TOP_RIGHT_CORNER:
+ polygon.push_back(point_list[10]);
+ polygon.push_back(point_list[11]);
+ polygon.push_back(point_list[0]);
+ break;
+ default:
+ break;
+ }
+ } else {
+ if (p_offset_axis == TileSet::TILE_OFFSET_AXIS_VERTICAL) {
+ for (int i = 0; i < point_list.size(); i++) {
+ point_list.write[i] = Vector2(point_list[i].y, point_list[i].x);
+ }
+ }
+ switch (p_bit) {
+ case TileSet::CELL_NEIGHBOR_RIGHT_CORNER:
+ polygon.push_back(point_list[2]);
+ polygon.push_back(point_list[3]);
+ polygon.push_back(point_list[4]);
+ break;
+ case TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_CORNER:
+ polygon.push_back(point_list[0]);
+ polygon.push_back(point_list[1]);
+ polygon.push_back(point_list[2]);
+ break;
+ case TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_CORNER:
+ polygon.push_back(point_list[10]);
+ polygon.push_back(point_list[11]);
+ polygon.push_back(point_list[0]);
+ break;
+ case TileSet::CELL_NEIGHBOR_LEFT_CORNER:
+ polygon.push_back(point_list[8]);
+ polygon.push_back(point_list[9]);
+ polygon.push_back(point_list[10]);
+ break;
+ case TileSet::CELL_NEIGHBOR_TOP_LEFT_CORNER:
+ polygon.push_back(point_list[6]);
+ polygon.push_back(point_list[7]);
+ polygon.push_back(point_list[8]);
+ break;
+ case TileSet::CELL_NEIGHBOR_TOP_RIGHT_CORNER:
+ polygon.push_back(point_list[4]);
+ polygon.push_back(point_list[5]);
+ polygon.push_back(point_list[6]);
+ break;
+ default:
+ break;
+ }
+ }
+
+ int half_polygon_size = polygon.size();
+ for (int i = 0; i < half_polygon_size; i++) {
+ polygon.push_back(polygon[half_polygon_size - 1 - i] / 3.0);
+ }
+
+ return polygon;
+}
+
+Vector<Point2> TileSet::_get_half_offset_side_terrain_bit_polygon(Vector2i p_size, TileSet::CellNeighbor p_bit, float p_overlap, TileSet::TileOffsetAxis p_offset_axis) {
+ Vector<Vector2> point_list;
+ point_list.push_back(Vector2(3, 3.0 * (1.0 - p_overlap * 2.0)));
+ point_list.push_back(Vector2(0, 3));
+ point_list.push_back(Vector2(-3, 3.0 * (1.0 - p_overlap * 2.0)));
+ point_list.push_back(Vector2(-3, -3.0 * (1.0 - p_overlap * 2.0)));
+ point_list.push_back(Vector2(0, -3));
+ point_list.push_back(Vector2(3, -3.0 * (1.0 - p_overlap * 2.0)));
+
+ Vector2 unit = Vector2(p_size) / 6.0;
+ for (int i = 0; i < point_list.size(); i++) {
+ point_list.write[i] = point_list[i] * unit;
+ }
+
+ Vector<Vector2> polygon;
+ if (p_offset_axis == TileSet::TILE_OFFSET_AXIS_HORIZONTAL) {
+ switch (p_bit) {
+ case TileSet::CELL_NEIGHBOR_RIGHT_SIDE:
+ polygon.push_back(point_list[5]);
+ polygon.push_back(point_list[0]);
+ break;
+ case TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_SIDE:
+ polygon.push_back(point_list[0]);
+ polygon.push_back(point_list[1]);
+ break;
+ case TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_SIDE:
+ polygon.push_back(point_list[1]);
+ polygon.push_back(point_list[2]);
+ break;
+ case TileSet::CELL_NEIGHBOR_LEFT_SIDE:
+ polygon.push_back(point_list[2]);
+ polygon.push_back(point_list[3]);
+ break;
+ case TileSet::CELL_NEIGHBOR_TOP_LEFT_SIDE:
+ polygon.push_back(point_list[3]);
+ polygon.push_back(point_list[4]);
+ break;
+ case TileSet::CELL_NEIGHBOR_TOP_RIGHT_SIDE:
+ polygon.push_back(point_list[4]);
+ polygon.push_back(point_list[5]);
+ break;
+ default:
+ break;
+ }
+ } else {
+ if (p_offset_axis == TileSet::TILE_OFFSET_AXIS_VERTICAL) {
+ for (int i = 0; i < point_list.size(); i++) {
+ point_list.write[i] = Vector2(point_list[i].y, point_list[i].x);
+ }
+ }
+ switch (p_bit) {
+ case TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_SIDE:
+ polygon.push_back(point_list[0]);
+ polygon.push_back(point_list[1]);
+ break;
+ case TileSet::CELL_NEIGHBOR_BOTTOM_SIDE:
+ polygon.push_back(point_list[5]);
+ polygon.push_back(point_list[0]);
+ break;
+ case TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_SIDE:
+ polygon.push_back(point_list[4]);
+ polygon.push_back(point_list[5]);
+ break;
+ case TileSet::CELL_NEIGHBOR_TOP_LEFT_SIDE:
+ polygon.push_back(point_list[3]);
+ polygon.push_back(point_list[4]);
+ break;
+ case TileSet::CELL_NEIGHBOR_TOP_SIDE:
+ polygon.push_back(point_list[2]);
+ polygon.push_back(point_list[3]);
+ break;
+ case TileSet::CELL_NEIGHBOR_TOP_RIGHT_SIDE:
+ polygon.push_back(point_list[1]);
+ polygon.push_back(point_list[2]);
+ break;
+ default:
+ break;
+ }
+ }
+
+ int half_polygon_size = polygon.size();
+ for (int i = 0; i < half_polygon_size; i++) {
+ polygon.push_back(polygon[half_polygon_size - 1 - i] / 3.0);
+ }
+
+ return polygon;
}
void TileSet::reset_state() {
@@ -747,12 +1614,18 @@ void TileSet::compatibility_conversion() {
for (int k = 0; k < ctd->shapes.size(); k++) {
CompatibilityShapeData csd = ctd->shapes[k];
if (csd.autotile_coords == coords) {
- tile_data->set_collision_shapes_count(0, tile_data->get_collision_shapes_count(0) + 1);
- int index = tile_data->get_collision_shapes_count(0) - 1;
- tile_data->set_collision_shape_one_way(0, index, csd.one_way);
- tile_data->set_collision_shape_one_way_margin(0, index, csd.one_way_margin);
- tile_data->set_collision_shape_shape(0, index, csd.shape);
- // Ignores transform for now.
+ Ref<ConvexPolygonShape2D> convex_shape = csd.shape; // Only ConvexPolygonShape2D are supported, which is the default type used by the 3.x editor
+ if (convex_shape.is_valid()) {
+ Vector<Vector2> polygon = convex_shape->get_points();
+ for (int point_index = 0; point_index < polygon.size(); point_index++) {
+ polygon.write[point_index] = csd.transform.xform(polygon[point_index]);
+ }
+ tile_data->set_collision_polygons_count(0, tile_data->get_collision_polygons_count(0) + 1);
+ int index = tile_data->get_collision_polygons_count(0) - 1;
+ tile_data->set_collision_polygon_one_way(0, index, csd.one_way);
+ tile_data->set_collision_polygon_one_way_margin(0, index, csd.one_way_margin);
+ tile_data->set_collision_polygon_points(0, index, polygon);
+ }
}
}
@@ -801,7 +1674,7 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
#ifndef DISABLE_DEPRECATED
// TODO: THIS IS HOW WE CHECK IF WE HAVE A DEPRECATED RESOURCE
// This should be moved to a dedicated conversion system
- if (components.size() >= 1 && components[0].is_valid_integer()) {
+ if (components.size() >= 1 && components[0].is_valid_int()) {
int id = components[0].to_int();
// Get or create the compatibility object
@@ -966,7 +1839,7 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
#endif // DISABLE_DEPRECATED
// This is now a new property.
- if (components.size() == 2 && components[0].begins_with("occlusion_layer_") && components[0].trim_prefix("occlusion_layer_").is_valid_integer()) {
+ if (components.size() == 2 && components[0].begins_with("occlusion_layer_") && components[0].trim_prefix("occlusion_layer_").is_valid_int()) {
// Occlusion layers.
int index = components[0].trim_prefix("occlusion_layer_").to_int();
ERR_FAIL_COND_V(index < 0, false);
@@ -985,7 +1858,7 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
set_occlusion_layer_sdf_collision(index, p_value);
return true;
}
- } else if (components.size() == 2 && components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_integer()) {
+ } else if (components.size() == 2 && components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_int()) {
// Physics layers.
int index = components[0].trim_prefix("physics_layer_").to_int();
ERR_FAIL_COND_V(index < 0, false);
@@ -1012,7 +1885,7 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
set_physics_layer_physics_material(index, physics_material);
return true;
}
- } else if (components.size() >= 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_integer()) {
+ } else if (components.size() >= 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int()) {
// Terrains.
int terrain_set_index = components[0].trim_prefix("terrain_set_").to_int();
ERR_FAIL_COND_V(terrain_set_index < 0, false);
@@ -1029,7 +1902,7 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
}
set_terrains_count(terrain_set_index, p_value);
return true;
- } else if (components.size() >= 3 && components[1].begins_with("terrain_") && components[1].trim_prefix("terrain_").is_valid_integer()) {
+ } else if (components.size() >= 3 && components[1].begins_with("terrain_") && components[1].trim_prefix("terrain_").is_valid_int()) {
int terrain_index = components[1].trim_prefix("terrain_").to_int();
ERR_FAIL_COND_V(terrain_index < 0, false);
if (components[2] == "name") {
@@ -1054,7 +1927,7 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
return true;
}
}
- } else if (components.size() == 2 && components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_integer()) {
+ } else if (components.size() == 2 && components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_int()) {
// Navigation layers.
int index = components[0].trim_prefix("navigation_layer_").to_int();
ERR_FAIL_COND_V(index < 0, false);
@@ -1066,7 +1939,7 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
set_navigation_layer_layers(index, p_value);
return true;
}
- } else if (components.size() == 2 && components[0].begins_with("custom_data_layer_") && components[0].trim_prefix("custom_data_layer_").is_valid_integer()) {
+ } else if (components.size() == 2 && components[0].begins_with("custom_data_layer_") && components[0].trim_prefix("custom_data_layer_").is_valid_int()) {
// Custom data layers.
int index = components[0].trim_prefix("custom_data_layer_").to_int();
ERR_FAIL_COND_V(index < 0, false);
@@ -1085,7 +1958,7 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
set_custom_data_type(index, Variant::Type(int(p_value)));
return true;
}
- } else if (components.size() == 2 && components[0] == "sources" && components[1].is_valid_integer()) {
+ } else if (components.size() == 2 && components[0] == "sources" && components[1].is_valid_int()) {
// Create source only if it does not exists.
int source_id = components[1].to_int();
@@ -1105,7 +1978,7 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
bool TileSet::_get(const StringName &p_name, Variant &r_ret) const {
Vector<String> components = String(p_name).split("/", true, 2);
- if (components.size() == 2 && components[0].begins_with("occlusion_layer_") && components[0].trim_prefix("occlusion_layer_").is_valid_integer()) {
+ if (components.size() == 2 && components[0].begins_with("occlusion_layer_") && components[0].trim_prefix("occlusion_layer_").is_valid_int()) {
// Occlusion layers.
int index = components[0].trim_prefix("occlusion_layer_").to_int();
if (index < 0 || index >= occlusion_layers.size()) {
@@ -1118,7 +1991,7 @@ bool TileSet::_get(const StringName &p_name, Variant &r_ret) const {
r_ret = get_occlusion_layer_sdf_collision(index);
return true;
}
- } else if (components.size() == 2 && components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_integer()) {
+ } else if (components.size() == 2 && components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_int()) {
// Physics layers.
int index = components[0].trim_prefix("physics_layer_").to_int();
if (index < 0 || index >= physics_layers.size()) {
@@ -1134,7 +2007,7 @@ bool TileSet::_get(const StringName &p_name, Variant &r_ret) const {
r_ret = get_physics_layer_physics_material(index);
return true;
}
- } else if (components.size() >= 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_integer()) {
+ } else if (components.size() >= 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int()) {
// Terrains.
int terrain_set_index = components[0].trim_prefix("terrain_set_").to_int();
if (terrain_set_index < 0 || terrain_set_index >= terrain_sets.size()) {
@@ -1146,7 +2019,7 @@ bool TileSet::_get(const StringName &p_name, Variant &r_ret) const {
} else if (components[1] == "terrains_count") {
r_ret = get_terrains_count(terrain_set_index);
return true;
- } else if (components.size() >= 3 && components[1].begins_with("terrain_") && components[1].trim_prefix("terrain_").is_valid_integer()) {
+ } else if (components.size() >= 3 && components[1].begins_with("terrain_") && components[1].trim_prefix("terrain_").is_valid_int()) {
int terrain_index = components[1].trim_prefix("terrain_").to_int();
if (terrain_index < 0 || terrain_index >= terrain_sets[terrain_set_index].terrains.size()) {
return false;
@@ -1159,7 +2032,7 @@ bool TileSet::_get(const StringName &p_name, Variant &r_ret) const {
return true;
}
}
- } else if (components.size() == 2 && components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_integer()) {
+ } else if (components.size() == 2 && components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_int()) {
// navigation layers.
int index = components[0].trim_prefix("navigation_layer_").to_int();
if (index < 0 || index >= navigation_layers.size()) {
@@ -1169,7 +2042,7 @@ bool TileSet::_get(const StringName &p_name, Variant &r_ret) const {
r_ret = get_navigation_layer_layers(index);
return true;
}
- } else if (components.size() == 2 && components[0].begins_with("custom_data_layer_") && components[0].trim_prefix("custom_data_layer_").is_valid_integer()) {
+ } else if (components.size() == 2 && components[0].begins_with("custom_data_layer_") && components[0].trim_prefix("custom_data_layer_").is_valid_int()) {
// Custom data layers.
int index = components[0].trim_prefix("custom_data_layer_").to_int();
if (index < 0 || index >= custom_data_layers.size()) {
@@ -1182,7 +2055,7 @@ bool TileSet::_get(const StringName &p_name, Variant &r_ret) const {
r_ret = get_custom_data_type(index);
return true;
}
- } else if (components.size() == 2 && components[0] == "sources" && components[1].is_valid_integer()) {
+ } else if (components.size() == 2 && components[0] == "sources" && components[1].is_valid_int()) {
// Atlases data.
int source_id = components[1].to_int();
@@ -1287,14 +2160,11 @@ void TileSet::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_tile_offset_axis"), &TileSet::get_tile_offset_axis);
ClassDB::bind_method(D_METHOD("set_tile_size", "size"), &TileSet::set_tile_size);
ClassDB::bind_method(D_METHOD("get_tile_size"), &TileSet::get_tile_size);
- ClassDB::bind_method(D_METHOD("set_tile_skew", "skew"), &TileSet::set_tile_skew);
- ClassDB::bind_method(D_METHOD("get_tile_skew"), &TileSet::get_tile_skew);
ADD_PROPERTY(PropertyInfo(Variant::INT, "tile_shape", PROPERTY_HINT_ENUM, "Square,Isometric,Half-Offset Square,Hexagon"), "set_tile_shape", "get_tile_shape");
ADD_PROPERTY(PropertyInfo(Variant::INT, "tile_layout", PROPERTY_HINT_ENUM, "Stacked,Stacked Offset,Stairs Right,Stairs Down,Diamond Right,Diamond Down"), "set_tile_layout", "get_tile_layout");
ADD_PROPERTY(PropertyInfo(Variant::INT, "tile_offset_axis", PROPERTY_HINT_ENUM, "Horizontal Offset,Vertical Offset"), "set_tile_offset_axis", "get_tile_offset_axis");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "tile_size"), "set_tile_size", "get_tile_size");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "tile_skew"), "set_tile_skew", "get_tile_skew");
// Rendering.
ClassDB::bind_method(D_METHOD("set_uv_clipping", "uv_clipping"), &TileSet::set_uv_clipping);
@@ -1398,10 +2268,13 @@ void TileSet::_bind_methods() {
}
TileSet::TileSet() {
- // Instanciatie and list all plugins.
+ // Instantiate the tile meshes.
+ tile_lines_mesh.instantiate();
+ tile_filled_mesh.instantiate();
+
+ // Instanciate and list all plugins.
tile_set_plugins_vector.append(memnew(TileSetPluginAtlasRendering));
tile_set_plugins_vector.append(memnew(TileSetPluginAtlasPhysics));
- tile_set_plugins_vector.append(memnew(TileSetPluginAtlasTerrain));
tile_set_plugins_vector.append(memnew(TileSetPluginAtlasNavigation));
tile_set_plugins_vector.append(memnew(TileSetPluginScenesCollections));
}
@@ -1534,7 +2407,7 @@ bool TileSetAtlasSource::_set(const StringName &p_name, const Variant &p_value)
// Compute the vector2i if we have coordinates.
Vector<String> coords_split = components[0].split(":");
Vector2i coords = TileSetSource::INVALID_ATLAS_COORDS;
- if (coords_split.size() == 2 && coords_split[0].is_valid_integer() && coords_split[1].is_valid_integer()) {
+ if (coords_split.size() == 2 && coords_split[0].is_valid_int() && coords_split[1].is_valid_int()) {
coords = Vector2i(coords_split[0].to_int(), coords_split[1].to_int());
}
@@ -1550,7 +2423,7 @@ bool TileSetAtlasSource::_set(const StringName &p_name, const Variant &p_value)
move_tile_in_atlas(coords, coords, p_value);
} else if (components[1] == "next_alternative_id") {
tiles[coords].next_alternative_id = p_value;
- } else if (components[1].is_valid_integer()) {
+ } else if (components[1].is_valid_int()) {
int alternative_id = components[1].to_int();
if (alternative_id != TileSetSource::INVALID_TILE_ALTERNATIVE) {
// Create the alternative if needed ?
@@ -1584,7 +2457,7 @@ bool TileSetAtlasSource::_get(const StringName &p_name, Variant &r_ret) const {
// Properties.
Vector<String> coords_split = components[0].split(":");
- if (coords_split.size() == 2 && coords_split[0].is_valid_integer() && coords_split[1].is_valid_integer()) {
+ if (coords_split.size() == 2 && coords_split[0].is_valid_int() && coords_split[1].is_valid_int()) {
Vector2i coords = Vector2i(coords_split[0].to_int(), coords_split[1].to_int());
if (tiles.has(coords)) {
if (components.size() >= 2) {
@@ -1595,7 +2468,7 @@ bool TileSetAtlasSource::_get(const StringName &p_name, Variant &r_ret) const {
} else if (components[1] == "next_alternative_id") {
r_ret = tiles[coords].next_alternative_id;
return true;
- } else if (components[1].is_valid_integer()) {
+ } else if (components[1].is_valid_int()) {
int alternative_id = components[1].to_int();
if (alternative_id != TileSetSource::INVALID_TILE_ALTERNATIVE && tiles[coords].alternatives.has(alternative_id)) {
if (components.size() >= 3) {
@@ -2160,7 +3033,7 @@ int TileSetScenesCollectionSource::get_next_scene_tile_id() const {
bool TileSetScenesCollectionSource::_set(const StringName &p_name, const Variant &p_value) {
Vector<String> components = String(p_name).split("/", true, 2);
- if (components.size() >= 2 && components[0] == "scenes" && components[1].is_valid_integer()) {
+ if (components.size() >= 2 && components[0] == "scenes" && components[1].is_valid_int()) {
int scene_id = components[1].to_int();
if (components.size() >= 3 && components[2] == "scene") {
if (has_scene_tile_id(scene_id)) {
@@ -2184,7 +3057,7 @@ bool TileSetScenesCollectionSource::_set(const StringName &p_name, const Variant
bool TileSetScenesCollectionSource::_get(const StringName &p_name, Variant &r_ret) const {
Vector<String> components = String(p_name).split("/", true, 2);
- if (components.size() >= 2 && components[0] == "scenes" && components[1].is_valid_integer() && scenes.has(components[1].to_int())) {
+ if (components.size() >= 2 && components[0] == "scenes" && components[1].is_valid_int() && scenes.has(components[1].to_int())) {
if (components.size() >= 3 && components[2] == "scene") {
r_ret = scenes[components[1].to_int()].scene;
return true;
@@ -2237,16 +3110,14 @@ void TileSetScenesCollectionSource::_bind_methods() {
void TileData::set_tile_set(const TileSet *p_tile_set) {
tile_set = p_tile_set;
- if (tile_set) {
- occluders.resize(tile_set->get_occlusion_layers_count());
- physics.resize(tile_set->get_physics_layers_count());
- navigation.resize(tile_set->get_navigation_layers_count());
- custom_data.resize(tile_set->get_custom_data_layers_count());
- }
- notify_property_list_changed();
+ notify_tile_data_properties_should_change();
}
void TileData::notify_tile_data_properties_should_change() {
+ if (!tile_set) {
+ return;
+ }
+
occluders.resize(tile_set->get_occlusion_layers_count());
physics.resize(tile_set->get_physics_layers_count());
for (int bit_index = 0; bit_index < 16; bit_index++) {
@@ -2373,76 +3244,112 @@ Ref<OccluderPolygon2D> TileData::get_occluder(int p_layer_id) const {
}
// Physics
-int TileData::get_collision_shapes_count(int p_layer_id) const {
+int TileData::get_collision_polygons_count(int p_layer_id) const {
ERR_FAIL_INDEX_V(p_layer_id, physics.size(), 0);
- return physics[p_layer_id].shapes.size();
+ return physics[p_layer_id].polygons.size();
}
-void TileData::set_collision_shapes_count(int p_layer_id, int p_shapes_count) {
+void TileData::set_collision_polygons_count(int p_layer_id, int p_polygons_count) {
ERR_FAIL_INDEX(p_layer_id, physics.size());
- ERR_FAIL_COND(p_shapes_count < 0);
- physics.write[p_layer_id].shapes.resize(p_shapes_count);
+ ERR_FAIL_COND(p_polygons_count < 0);
+ physics.write[p_layer_id].polygons.resize(p_polygons_count);
notify_property_list_changed();
emit_signal("changed");
}
-void TileData::add_collision_shape(int p_layer_id) {
+void TileData::add_collision_polygon(int p_layer_id) {
ERR_FAIL_INDEX(p_layer_id, physics.size());
- physics.write[p_layer_id].shapes.push_back(PhysicsLayerTileData::ShapeTileData());
+ physics.write[p_layer_id].polygons.push_back(PhysicsLayerTileData::PolygonShapeTileData());
emit_signal("changed");
}
-void TileData::remove_collision_shape(int p_layer_id, int p_shape_index) {
+void TileData::remove_collision_polygon(int p_layer_id, int p_polygon_index) {
ERR_FAIL_INDEX(p_layer_id, physics.size());
- ERR_FAIL_INDEX(p_shape_index, physics[p_layer_id].shapes.size());
- physics.write[p_layer_id].shapes.remove(p_shape_index);
+ ERR_FAIL_INDEX(p_polygon_index, physics[p_layer_id].polygons.size());
+ physics.write[p_layer_id].polygons.remove(p_polygon_index);
emit_signal("changed");
}
-void TileData::set_collision_shape_shape(int p_layer_id, int p_shape_index, Ref<Shape2D> p_shape) {
+void TileData::set_collision_polygon_points(int p_layer_id, int p_polygon_index, Vector<Vector2> p_polygon) {
ERR_FAIL_INDEX(p_layer_id, physics.size());
- ERR_FAIL_INDEX(p_shape_index, physics[p_layer_id].shapes.size());
- physics.write[p_layer_id].shapes.write[p_shape_index].shape = p_shape;
+ ERR_FAIL_INDEX(p_polygon_index, physics[p_layer_id].polygons.size());
+ ERR_FAIL_COND_MSG(p_polygon.size() != 0 && p_polygon.size() < 3, "Invalid polygon. Needs either 0 or more than 3 points.");
+
+ if (p_polygon.is_empty()) {
+ physics.write[p_layer_id].polygons.write[p_polygon_index].shapes.clear();
+ } else {
+ // Decompose into convex shapes.
+ Vector<Vector<Vector2>> decomp = Geometry2D::decompose_polygon_in_convex(p_polygon);
+ ERR_FAIL_COND_MSG(decomp.is_empty(), "Could not decompose the polygon into convex shapes.");
+
+ physics.write[p_layer_id].polygons.write[p_polygon_index].shapes.resize(decomp.size());
+ for (int i = 0; i < decomp.size(); i++) {
+ Ref<ConvexPolygonShape2D> shape;
+ shape.instantiate();
+ shape->set_points(decomp[i]);
+ physics.write[p_layer_id].polygons.write[p_polygon_index].shapes[i] = shape;
+ }
+ }
+ physics.write[p_layer_id].polygons.write[p_polygon_index].polygon = p_polygon;
emit_signal("changed");
}
-Ref<Shape2D> TileData::get_collision_shape_shape(int p_layer_id, int p_shape_index) const {
- ERR_FAIL_INDEX_V(p_layer_id, physics.size(), Ref<Shape2D>());
- ERR_FAIL_INDEX_V(p_shape_index, physics[p_layer_id].shapes.size(), Ref<Shape2D>());
- return physics[p_layer_id].shapes[p_shape_index].shape;
+Vector<Vector2> TileData::get_collision_polygon_points(int p_layer_id, int p_polygon_index) const {
+ ERR_FAIL_INDEX_V(p_layer_id, physics.size(), Vector<Vector2>());
+ ERR_FAIL_INDEX_V(p_polygon_index, physics[p_layer_id].polygons.size(), Vector<Vector2>());
+ return physics[p_layer_id].polygons[p_polygon_index].polygon;
}
-void TileData::set_collision_shape_one_way(int p_layer_id, int p_shape_index, bool p_one_way) {
+void TileData::set_collision_polygon_one_way(int p_layer_id, int p_polygon_index, bool p_one_way) {
ERR_FAIL_INDEX(p_layer_id, physics.size());
- ERR_FAIL_INDEX(p_shape_index, physics[p_layer_id].shapes.size());
- physics.write[p_layer_id].shapes.write[p_shape_index].one_way = p_one_way;
+ ERR_FAIL_INDEX(p_polygon_index, physics[p_layer_id].polygons.size());
+ physics.write[p_layer_id].polygons.write[p_polygon_index].one_way = p_one_way;
emit_signal("changed");
}
-bool TileData::is_collision_shape_one_way(int p_layer_id, int p_shape_index) const {
+bool TileData::is_collision_polygon_one_way(int p_layer_id, int p_polygon_index) const {
ERR_FAIL_INDEX_V(p_layer_id, physics.size(), false);
- ERR_FAIL_INDEX_V(p_shape_index, physics[p_layer_id].shapes.size(), false);
- return physics[p_layer_id].shapes[p_shape_index].one_way;
+ ERR_FAIL_INDEX_V(p_polygon_index, physics[p_layer_id].polygons.size(), false);
+ return physics[p_layer_id].polygons[p_polygon_index].one_way;
}
-void TileData::set_collision_shape_one_way_margin(int p_layer_id, int p_shape_index, float p_one_way_margin) {
+void TileData::set_collision_polygon_one_way_margin(int p_layer_id, int p_polygon_index, float p_one_way_margin) {
ERR_FAIL_INDEX(p_layer_id, physics.size());
- ERR_FAIL_INDEX(p_shape_index, physics[p_layer_id].shapes.size());
- physics.write[p_layer_id].shapes.write[p_shape_index].one_way_margin = p_one_way_margin;
+ ERR_FAIL_INDEX(p_polygon_index, physics[p_layer_id].polygons.size());
+ physics.write[p_layer_id].polygons.write[p_polygon_index].one_way_margin = p_one_way_margin;
emit_signal("changed");
}
-float TileData::get_collision_shape_one_way_margin(int p_layer_id, int p_shape_index) const {
+float TileData::get_collision_polygon_one_way_margin(int p_layer_id, int p_polygon_index) const {
ERR_FAIL_INDEX_V(p_layer_id, physics.size(), 0.0);
- ERR_FAIL_INDEX_V(p_shape_index, physics[p_layer_id].shapes.size(), 0.0);
- return physics[p_layer_id].shapes[p_shape_index].one_way_margin;
+ ERR_FAIL_INDEX_V(p_polygon_index, physics[p_layer_id].polygons.size(), 0.0);
+ return physics[p_layer_id].polygons[p_polygon_index].one_way_margin;
+}
+
+int TileData::get_collision_polygon_shapes_count(int p_layer_id, int p_polygon_index) const {
+ ERR_FAIL_INDEX_V(p_layer_id, physics.size(), 0);
+ ERR_FAIL_INDEX_V(p_polygon_index, physics[p_layer_id].polygons.size(), 0);
+ return physics[p_layer_id].polygons[p_polygon_index].shapes.size();
+}
+
+Ref<ConvexPolygonShape2D> TileData::get_collision_polygon_shape(int p_layer_id, int p_polygon_index, int shape_index) const {
+ ERR_FAIL_INDEX_V(p_layer_id, physics.size(), 0);
+ ERR_FAIL_INDEX_V(p_polygon_index, physics[p_layer_id].polygons.size(), Ref<ConvexPolygonShape2D>());
+ ERR_FAIL_INDEX_V(shape_index, (int)physics[p_layer_id].polygons[shape_index].shapes.size(), Ref<ConvexPolygonShape2D>());
+ return physics[p_layer_id].polygons[shape_index].shapes[shape_index];
}
// Terrain
void TileData::set_terrain_set(int p_terrain_set) {
ERR_FAIL_COND(p_terrain_set < -1);
+ if (p_terrain_set == terrain_set) {
+ return;
+ }
if (tile_set) {
ERR_FAIL_COND(p_terrain_set >= tile_set->get_terrain_sets_count());
+ for (int i = 0; i < 16; i++) {
+ terrain_peering_bits[i] = -1;
+ }
}
terrain_set = p_terrain_set;
notify_property_list_changed();
@@ -2454,7 +3361,7 @@ int TileData::get_terrain_set() const {
}
void TileData::set_peering_bit_terrain(TileSet::CellNeighbor p_peering_bit, int p_terrain_index) {
- ERR_FAIL_INDEX(p_peering_bit, TileSet::CELL_NEIGHBOR_MAX);
+ ERR_FAIL_COND(terrain_set < 0);
ERR_FAIL_COND(p_terrain_index < -1);
if (tile_set) {
ERR_FAIL_COND(p_terrain_index >= tile_set->get_terrains_count(terrain_set));
@@ -2465,7 +3372,7 @@ void TileData::set_peering_bit_terrain(TileSet::CellNeighbor p_peering_bit, int
}
int TileData::get_peering_bit_terrain(TileSet::CellNeighbor p_peering_bit) const {
- ERR_FAIL_INDEX_V(p_peering_bit, TileSet::CELL_NEIGHBOR_MAX, -1);
+ ERR_FAIL_COND_V(!is_valid_peering_bit_terrain(p_peering_bit), -1);
return terrain_peering_bits[p_peering_bit];
}
@@ -2489,7 +3396,7 @@ Ref<NavigationPolygon> TileData::get_navigation_polygon(int p_layer_id) const {
// Misc
void TileData::set_probability(float p_probability) {
- ERR_FAIL_COND(p_probability <= 0.0);
+ ERR_FAIL_COND(p_probability < 0.0);
probability = p_probability;
emit_signal("changed");
}
@@ -2526,7 +3433,7 @@ Variant TileData::get_custom_data_by_layer_id(int p_layer_id) const {
bool TileData::_set(const StringName &p_name, const Variant &p_value) {
Vector<String> components = String(p_name).split("/", true, 2);
- if (components.size() == 2 && components[0].begins_with("occlusion_layer_") && components[0].trim_prefix("occlusion_layer_").is_valid_integer()) {
+ if (components.size() == 2 && components[0].begins_with("occlusion_layer_") && components[0].trim_prefix("occlusion_layer_").is_valid_int()) {
// Occlusion layers.
int layer_index = components[0].trim_prefix("occlusion_layer_").to_int();
ERR_FAIL_COND_V(layer_index < 0, false);
@@ -2546,11 +3453,11 @@ bool TileData::_set(const StringName &p_name, const Variant &p_value) {
set_occluder(layer_index, polygon);
return true;
}
- } else if (components.size() >= 2 && components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_integer()) {
+ } else if (components.size() >= 2 && components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_int()) {
// Physics layers.
int layer_index = components[0].trim_prefix("physics_layer_").to_int();
ERR_FAIL_COND_V(layer_index < 0, false);
- if (components.size() == 2 && components[1] == "shapes_count") {
+ if (components.size() == 2 && components[1] == "polygons_count") {
if (p_value.get_type() != Variant::INT) {
return false;
}
@@ -2562,13 +3469,13 @@ bool TileData::_set(const StringName &p_name, const Variant &p_value) {
physics.resize(layer_index + 1);
}
}
- set_collision_shapes_count(layer_index, p_value);
+ set_collision_polygons_count(layer_index, p_value);
return true;
- } else if (components.size() == 3 && components[1].begins_with("shape_") && components[1].trim_prefix("shape_").is_valid_integer()) {
- int shape_index = components[1].trim_prefix("shape_").to_int();
- ERR_FAIL_COND_V(shape_index < 0, false);
+ } else if (components.size() == 3 && components[1].begins_with("polygon_") && components[1].trim_prefix("polygon_").is_valid_int()) {
+ int polygon_index = components[1].trim_prefix("polygon_").to_int();
+ ERR_FAIL_COND_V(polygon_index < 0, false);
- if (components[2] == "shape" || components[2] == "one_way" || components[2] == "one_way_margin") {
+ if (components[2] == "points" || components[2] == "one_way" || components[2] == "one_way_margin") {
if (layer_index >= physics.size()) {
if (tile_set) {
return false;
@@ -2577,23 +3484,23 @@ bool TileData::_set(const StringName &p_name, const Variant &p_value) {
}
}
- if (shape_index >= physics[layer_index].shapes.size()) {
- physics.write[layer_index].shapes.resize(shape_index + 1);
+ if (polygon_index >= physics[layer_index].polygons.size()) {
+ physics.write[layer_index].polygons.resize(polygon_index + 1);
}
}
- if (components[2] == "shape") {
- Ref<Shape2D> shape = p_value;
- set_collision_shape_shape(layer_index, shape_index, shape);
+ if (components[2] == "points") {
+ Vector<Vector2> polygon = p_value;
+ set_collision_polygon_points(layer_index, polygon_index, polygon);
return true;
} else if (components[2] == "one_way") {
- set_collision_shape_one_way(layer_index, shape_index, p_value);
+ set_collision_polygon_one_way(layer_index, polygon_index, p_value);
return true;
} else if (components[2] == "one_way_margin") {
- set_collision_shape_one_way_margin(layer_index, shape_index, p_value);
+ set_collision_polygon_one_way_margin(layer_index, polygon_index, p_value);
return true;
}
}
- } else if (components.size() == 2 && components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_integer()) {
+ } else if (components.size() == 2 && components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_int()) {
// Navigation layers.
int layer_index = components[0].trim_prefix("navigation_layer_").to_int();
ERR_FAIL_COND_V(layer_index < 0, false);
@@ -2615,43 +3522,15 @@ bool TileData::_set(const StringName &p_name, const Variant &p_value) {
}
} else if (components.size() == 2 && components[0] == "terrains_peering_bit") {
// Terrains.
- if (components[1] == "right_side") {
- set_peering_bit_terrain(TileSet::CELL_NEIGHBOR_RIGHT_SIDE, p_value);
- } else if (components[1] == "right_corner") {
- set_peering_bit_terrain(TileSet::CELL_NEIGHBOR_RIGHT_CORNER, p_value);
- } else if (components[1] == "bottom_right_side") {
- set_peering_bit_terrain(TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_SIDE, p_value);
- } else if (components[1] == "bottom_right_corner") {
- set_peering_bit_terrain(TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_CORNER, p_value);
- } else if (components[1] == "bottom_side") {
- set_peering_bit_terrain(TileSet::CELL_NEIGHBOR_BOTTOM_SIDE, p_value);
- } else if (components[1] == "bottom_corner") {
- set_peering_bit_terrain(TileSet::CELL_NEIGHBOR_BOTTOM_CORNER, p_value);
- } else if (components[1] == "bottom_left_side") {
- set_peering_bit_terrain(TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_SIDE, p_value);
- } else if (components[1] == "bottom_left_corner") {
- set_peering_bit_terrain(TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_CORNER, p_value);
- } else if (components[1] == "left_side") {
- set_peering_bit_terrain(TileSet::CELL_NEIGHBOR_LEFT_SIDE, p_value);
- } else if (components[1] == "left_corner") {
- set_peering_bit_terrain(TileSet::CELL_NEIGHBOR_LEFT_CORNER, p_value);
- } else if (components[1] == "top_left_side") {
- set_peering_bit_terrain(TileSet::CELL_NEIGHBOR_TOP_LEFT_SIDE, p_value);
- } else if (components[1] == "top_left_corner") {
- set_peering_bit_terrain(TileSet::CELL_NEIGHBOR_TOP_LEFT_CORNER, p_value);
- } else if (components[1] == "top_side") {
- set_peering_bit_terrain(TileSet::CELL_NEIGHBOR_TOP_SIDE, p_value);
- } else if (components[1] == "top_corner") {
- set_peering_bit_terrain(TileSet::CELL_NEIGHBOR_TOP_CORNER, p_value);
- } else if (components[1] == "top_right_side") {
- set_peering_bit_terrain(TileSet::CELL_NEIGHBOR_TOP_RIGHT_SIDE, p_value);
- } else if (components[1] == "top_right_corner") {
- set_peering_bit_terrain(TileSet::CELL_NEIGHBOR_TOP_RIGHT_CORNER, p_value);
- } else {
- return false;
+ for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) {
+ TileSet::CellNeighbor bit = TileSet::CellNeighbor(i);
+ if (components[1] == TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]) {
+ set_peering_bit_terrain(bit, p_value);
+ return true;
+ }
}
- return true;
- } else if (components.size() == 1 && components[0].begins_with("custom_data_") && components[0].trim_prefix("custom_data_").is_valid_integer()) {
+ return false;
+ } else if (components.size() == 1 && components[0].begins_with("custom_data_") && components[0].trim_prefix("custom_data_").is_valid_int()) {
// Custom data layers.
int layer_index = components[0].trim_prefix("custom_data_").to_int();
ERR_FAIL_COND_V(layer_index < 0, false);
@@ -2675,7 +3554,7 @@ bool TileData::_get(const StringName &p_name, Variant &r_ret) const {
Vector<String> components = String(p_name).split("/", true, 2);
if (tile_set) {
- if (components.size() == 2 && components[0].begins_with("occlusion_layer") && components[0].trim_prefix("occlusion_layer_").is_valid_integer()) {
+ if (components.size() == 2 && components[0].begins_with("occlusion_layer") && components[0].trim_prefix("occlusion_layer_").is_valid_int()) {
// Occlusion layers.
int layer_index = components[0].trim_prefix("occlusion_layer_").to_int();
ERR_FAIL_COND_V(layer_index < 0, false);
@@ -2686,72 +3565,43 @@ bool TileData::_get(const StringName &p_name, Variant &r_ret) const {
r_ret = get_occluder(layer_index);
return true;
}
- } else if (components.size() >= 2 && components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_integer()) {
+ } else if (components.size() >= 2 && components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_int()) {
// Physics layers.
int layer_index = components[0].trim_prefix("physics_layer_").to_int();
ERR_FAIL_COND_V(layer_index < 0, false);
if (layer_index >= physics.size()) {
return false;
}
- if (components.size() == 2 && components[1] == "shapes_count") {
- r_ret = get_collision_shapes_count(layer_index);
+ if (components.size() == 2 && components[1] == "polygons_count") {
+ r_ret = get_collision_polygons_count(layer_index);
return true;
- } else if (components.size() == 3 && components[1].begins_with("shape_") && components[1].trim_prefix("shape_").is_valid_integer()) {
- int shape_index = components[1].trim_prefix("shape_").to_int();
- ERR_FAIL_COND_V(shape_index < 0, false);
- if (shape_index >= physics[layer_index].shapes.size()) {
+ } else if (components.size() == 3 && components[1].begins_with("polygon_") && components[1].trim_prefix("polygon_").is_valid_int()) {
+ int polygon_index = components[1].trim_prefix("polygon_").to_int();
+ ERR_FAIL_COND_V(polygon_index < 0, false);
+ if (polygon_index >= physics[layer_index].polygons.size()) {
return false;
}
- if (components[2] == "shape") {
- r_ret = get_collision_shape_shape(layer_index, shape_index);
+ if (components[2] == "points") {
+ r_ret = get_collision_polygon_points(layer_index, polygon_index);
return true;
} else if (components[2] == "one_way") {
- r_ret = is_collision_shape_one_way(layer_index, shape_index);
+ r_ret = is_collision_polygon_one_way(layer_index, polygon_index);
return true;
} else if (components[2] == "one_way_margin") {
- r_ret = get_collision_shape_one_way_margin(layer_index, shape_index);
+ r_ret = get_collision_polygon_one_way_margin(layer_index, polygon_index);
return true;
}
}
} else if (components.size() == 2 && components[0] == "terrains_peering_bit") {
// Terrains.
- if (components[1] == "right_side") {
- r_ret = terrain_peering_bits[TileSet::CELL_NEIGHBOR_RIGHT_SIDE];
- } else if (components[1] == "right_corner") {
- r_ret = terrain_peering_bits[TileSet::CELL_NEIGHBOR_RIGHT_CORNER];
- } else if (components[1] == "bottom_right_side") {
- r_ret = terrain_peering_bits[TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_SIDE];
- } else if (components[1] == "bottom_right_corner") {
- r_ret = terrain_peering_bits[TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_CORNER];
- } else if (components[1] == "bottom_side") {
- r_ret = terrain_peering_bits[TileSet::CELL_NEIGHBOR_BOTTOM_SIDE];
- } else if (components[1] == "bottom_corner") {
- r_ret = terrain_peering_bits[TileSet::CELL_NEIGHBOR_BOTTOM_CORNER];
- } else if (components[1] == "bottom_left_side") {
- r_ret = terrain_peering_bits[TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_SIDE];
- } else if (components[1] == "bottom_left_corner") {
- r_ret = terrain_peering_bits[TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_CORNER];
- } else if (components[1] == "left_side") {
- r_ret = terrain_peering_bits[TileSet::CELL_NEIGHBOR_LEFT_SIDE];
- } else if (components[1] == "left_corner") {
- r_ret = terrain_peering_bits[TileSet::CELL_NEIGHBOR_LEFT_CORNER];
- } else if (components[1] == "top_left_side") {
- r_ret = terrain_peering_bits[TileSet::CELL_NEIGHBOR_TOP_LEFT_SIDE];
- } else if (components[1] == "top_left_corner") {
- r_ret = terrain_peering_bits[TileSet::CELL_NEIGHBOR_TOP_LEFT_CORNER];
- } else if (components[1] == "top_side") {
- r_ret = terrain_peering_bits[TileSet::CELL_NEIGHBOR_TOP_SIDE];
- } else if (components[1] == "top_corner") {
- r_ret = terrain_peering_bits[TileSet::CELL_NEIGHBOR_TOP_CORNER];
- } else if (components[1] == "top_right_side") {
- r_ret = terrain_peering_bits[TileSet::CELL_NEIGHBOR_TOP_RIGHT_SIDE];
- } else if (components[1] == "top_right_corner") {
- r_ret = terrain_peering_bits[TileSet::CELL_NEIGHBOR_TOP_RIGHT_CORNER];
- } else {
- return false;
+ for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) {
+ if (components[1] == TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]) {
+ r_ret = terrain_peering_bits[i];
+ return true;
+ }
}
- return true;
- } else if (components.size() == 2 && components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_integer()) {
+ return false;
+ } else if (components.size() == 2 && components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_int()) {
// Occlusion layers.
int layer_index = components[0].trim_prefix("navigation_layer_").to_int();
ERR_FAIL_COND_V(layer_index < 0, false);
@@ -2762,7 +3612,7 @@ bool TileData::_get(const StringName &p_name, Variant &r_ret) const {
r_ret = get_navigation_polygon(layer_index);
return true;
}
- } else if (components.size() == 1 && components[0].begins_with("custom_data_") && components[0].trim_prefix("custom_data_").is_valid_integer()) {
+ } else if (components.size() == 1 && components[0].begins_with("custom_data_") && components[0].trim_prefix("custom_data_").is_valid_int()) {
// Custom data layers.
int layer_index = components[0].trim_prefix("custom_data_").to_int();
ERR_FAIL_COND_V(layer_index < 0, false);
@@ -2795,26 +3645,26 @@ void TileData::_get_property_list(List<PropertyInfo> *p_list) const {
// Physics layers.
p_list->push_back(PropertyInfo(Variant::NIL, "Physics", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_GROUP));
for (int i = 0; i < physics.size(); i++) {
- p_list->push_back(PropertyInfo(Variant::INT, vformat("physics_layer_%d/shapes_count", i), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR));
+ p_list->push_back(PropertyInfo(Variant::INT, vformat("physics_layer_%d/polygons_count", i), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR));
- for (int j = 0; j < physics[i].shapes.size(); j++) {
- // physics_layer_%d/shapes_count
- property_info = PropertyInfo(Variant::OBJECT, vformat("physics_layer_%d/shape_%d/shape", i, j), PROPERTY_HINT_RESOURCE_TYPE, "Shape2D", PROPERTY_USAGE_DEFAULT);
- if (!physics[i].shapes[j].shape.is_valid()) {
+ for (int j = 0; j < physics[i].polygons.size(); j++) {
+ // physics_layer_%d/points
+ property_info = PropertyInfo(Variant::ARRAY, vformat("physics_layer_%d/polygon_%d/points", i, j), PROPERTY_HINT_ARRAY_TYPE, "Vector2", PROPERTY_USAGE_DEFAULT);
+ if (physics[i].polygons[j].polygon.is_empty()) {
property_info.usage ^= PROPERTY_USAGE_STORAGE;
}
p_list->push_back(property_info);
- // physics_layer_%d/shape_%d/one_way
- property_info = PropertyInfo(Variant::BOOL, vformat("physics_layer_%d/shape_%d/one_way", i, j));
- if (physics[i].shapes[j].one_way == false) {
+ // physics_layer_%d/polygon_%d/one_way
+ property_info = PropertyInfo(Variant::BOOL, vformat("physics_layer_%d/polygon_%d/one_way", i, j));
+ if (physics[i].polygons[j].one_way == false) {
property_info.usage ^= PROPERTY_USAGE_STORAGE;
}
p_list->push_back(property_info);
- // physics_layer_%d/shape_%d/one_way_margin
- property_info = PropertyInfo(Variant::FLOAT, vformat("physics_layer_%d/shape_%d/one_way_margin", i, j));
- if (physics[i].shapes[j].one_way_margin == 1.0) {
+ // physics_layer_%d/polygon_%d/one_way_margin
+ property_info = PropertyInfo(Variant::FLOAT, vformat("physics_layer_%d/polygon_%d/one_way_margin", i, j));
+ if (physics[i].polygons[j].one_way_margin == 1.0) {
property_info.usage ^= PROPERTY_USAGE_STORAGE;
}
p_list->push_back(property_info);
@@ -2824,117 +3674,15 @@ void TileData::_get_property_list(List<PropertyInfo> *p_list) const {
// Terrain data
if (terrain_set >= 0) {
p_list->push_back(PropertyInfo(Variant::NIL, "Terrains", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_GROUP));
- if (is_valid_peering_bit_terrain(TileSet::CELL_NEIGHBOR_RIGHT_SIDE)) {
- property_info = PropertyInfo(Variant::INT, "terrains_peering_bit/right_side");
- if (get_peering_bit_terrain(TileSet::CELL_NEIGHBOR_RIGHT_SIDE) == -1) {
- property_info.usage ^= PROPERTY_USAGE_STORAGE;
- }
- p_list->push_back(property_info);
- }
- if (is_valid_peering_bit_terrain(TileSet::CELL_NEIGHBOR_RIGHT_CORNER)) {
- property_info = PropertyInfo(Variant::INT, "terrains_peering_bit/right_corner");
- if (get_peering_bit_terrain(TileSet::CELL_NEIGHBOR_RIGHT_CORNER) == -1) {
- property_info.usage ^= PROPERTY_USAGE_STORAGE;
- }
- p_list->push_back(property_info);
- }
- if (is_valid_peering_bit_terrain(TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_SIDE)) {
- property_info = PropertyInfo(Variant::INT, "terrains_peering_bit/bottom_right_side");
- if (get_peering_bit_terrain(TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_SIDE) == -1) {
- property_info.usage ^= PROPERTY_USAGE_STORAGE;
- }
- p_list->push_back(property_info);
- }
- if (is_valid_peering_bit_terrain(TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_CORNER)) {
- property_info = PropertyInfo(Variant::INT, "terrains_peering_bit/bottom_right_corner");
- if (get_peering_bit_terrain(TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_CORNER) == -1) {
- property_info.usage ^= PROPERTY_USAGE_STORAGE;
- }
- p_list->push_back(property_info);
- }
- if (is_valid_peering_bit_terrain(TileSet::CELL_NEIGHBOR_BOTTOM_SIDE)) {
- property_info = PropertyInfo(Variant::INT, "terrains_peering_bit/bottom_side");
- if (get_peering_bit_terrain(TileSet::CELL_NEIGHBOR_BOTTOM_SIDE) == -1) {
- property_info.usage ^= PROPERTY_USAGE_STORAGE;
- }
- p_list->push_back(property_info);
- }
- if (is_valid_peering_bit_terrain(TileSet::CELL_NEIGHBOR_BOTTOM_CORNER)) {
- property_info = PropertyInfo(Variant::INT, "terrains_peering_bit/bottom_corner");
- if (get_peering_bit_terrain(TileSet::CELL_NEIGHBOR_BOTTOM_CORNER) == -1) {
- property_info.usage ^= PROPERTY_USAGE_STORAGE;
- }
- p_list->push_back(property_info);
- }
- if (is_valid_peering_bit_terrain(TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_SIDE)) {
- property_info = PropertyInfo(Variant::INT, "terrains_peering_bit/bottom_left_side");
- if (get_peering_bit_terrain(TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_SIDE) == -1) {
- property_info.usage ^= PROPERTY_USAGE_STORAGE;
- }
- p_list->push_back(property_info);
- }
- if (is_valid_peering_bit_terrain(TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_CORNER)) {
- property_info = PropertyInfo(Variant::INT, "terrains_peering_bit/bottom_left_corner");
- if (get_peering_bit_terrain(TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_CORNER) == -1) {
- property_info.usage ^= PROPERTY_USAGE_STORAGE;
- }
- p_list->push_back(property_info);
- }
- if (is_valid_peering_bit_terrain(TileSet::CELL_NEIGHBOR_LEFT_SIDE)) {
- property_info = PropertyInfo(Variant::INT, "terrains_peering_bit/left_side");
- if (get_peering_bit_terrain(TileSet::CELL_NEIGHBOR_LEFT_SIDE) == -1) {
- property_info.usage ^= PROPERTY_USAGE_STORAGE;
- }
- p_list->push_back(property_info);
- }
- if (is_valid_peering_bit_terrain(TileSet::CELL_NEIGHBOR_LEFT_CORNER)) {
- property_info = PropertyInfo(Variant::INT, "terrains_peering_bit/left_corner");
- if (get_peering_bit_terrain(TileSet::CELL_NEIGHBOR_LEFT_CORNER) == -1) {
- property_info.usage ^= PROPERTY_USAGE_STORAGE;
- }
- p_list->push_back(property_info);
- }
- if (is_valid_peering_bit_terrain(TileSet::CELL_NEIGHBOR_TOP_LEFT_SIDE)) {
- property_info = PropertyInfo(Variant::INT, "terrains_peering_bit/top_left_side");
- if (get_peering_bit_terrain(TileSet::CELL_NEIGHBOR_TOP_LEFT_SIDE) == -1) {
- property_info.usage ^= PROPERTY_USAGE_STORAGE;
- }
- p_list->push_back(property_info);
- }
- if (is_valid_peering_bit_terrain(TileSet::CELL_NEIGHBOR_TOP_LEFT_CORNER)) {
- property_info = PropertyInfo(Variant::INT, "terrains_peering_bit/top_left_corner");
- if (get_peering_bit_terrain(TileSet::CELL_NEIGHBOR_TOP_LEFT_CORNER) == -1) {
- property_info.usage ^= PROPERTY_USAGE_STORAGE;
- }
- p_list->push_back(property_info);
- }
- if (is_valid_peering_bit_terrain(TileSet::CELL_NEIGHBOR_TOP_SIDE)) {
- property_info = PropertyInfo(Variant::INT, "terrains_peering_bit/top_side");
- if (get_peering_bit_terrain(TileSet::CELL_NEIGHBOR_TOP_SIDE) == -1) {
- property_info.usage ^= PROPERTY_USAGE_STORAGE;
- }
- p_list->push_back(property_info);
- }
- if (is_valid_peering_bit_terrain(TileSet::CELL_NEIGHBOR_TOP_CORNER)) {
- property_info = PropertyInfo(Variant::INT, "terrains_peering_bit/top_corner");
- if (get_peering_bit_terrain(TileSet::CELL_NEIGHBOR_TOP_CORNER) == -1) {
- property_info.usage ^= PROPERTY_USAGE_STORAGE;
- }
- p_list->push_back(property_info);
- }
- if (is_valid_peering_bit_terrain(TileSet::CELL_NEIGHBOR_TOP_RIGHT_SIDE)) {
- property_info = PropertyInfo(Variant::INT, "terrains_peering_bit/top_right_side");
- if (get_peering_bit_terrain(TileSet::CELL_NEIGHBOR_TOP_RIGHT_SIDE) == -1) {
- property_info.usage ^= PROPERTY_USAGE_STORAGE;
- }
- p_list->push_back(property_info);
- }
- if (is_valid_peering_bit_terrain(TileSet::CELL_NEIGHBOR_TOP_RIGHT_CORNER)) {
- property_info = PropertyInfo(Variant::INT, "terrains_peering_bit/top_right_corner");
- if (get_peering_bit_terrain(TileSet::CELL_NEIGHBOR_TOP_RIGHT_CORNER) == -1) {
- property_info.usage ^= PROPERTY_USAGE_STORAGE;
+ for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) {
+ TileSet::CellNeighbor bit = TileSet::CellNeighbor(i);
+ if (is_valid_peering_bit_terrain(bit)) {
+ property_info = PropertyInfo(Variant::INT, "terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]));
+ if (get_peering_bit_terrain(bit) == -1) {
+ property_info.usage ^= PROPERTY_USAGE_STORAGE;
+ }
+ p_list->push_back(property_info);
}
- p_list->push_back(property_info);
}
}
@@ -2986,16 +3734,16 @@ void TileData::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_occluder", "layer_id"), &TileData::get_occluder);
// Physics.
- ClassDB::bind_method(D_METHOD("get_collision_shapes_count", "layer_id"), &TileData::get_collision_shapes_count);
- ClassDB::bind_method(D_METHOD("set_collision_shapes_count", "layer_id", "shapes_count"), &TileData::set_collision_shapes_count);
- ClassDB::bind_method(D_METHOD("add_collision_shape", "layer_id"), &TileData::add_collision_shape);
- ClassDB::bind_method(D_METHOD("remove_collision_shape", "layer_id", "shape_index"), &TileData::remove_collision_shape);
- ClassDB::bind_method(D_METHOD("set_collision_shape_shape", "layer_id", "shape_index", "shape"), &TileData::set_collision_shape_shape);
- ClassDB::bind_method(D_METHOD("get_collision_shape_shape", "layer_id", "shape_index"), &TileData::get_collision_shape_shape);
- ClassDB::bind_method(D_METHOD("set_collision_shape_one_way", "layer_id", "shape_index", "one_way"), &TileData::set_collision_shape_one_way);
- ClassDB::bind_method(D_METHOD("is_collision_shape_one_way", "layer_id", "shape_index"), &TileData::is_collision_shape_one_way);
- ClassDB::bind_method(D_METHOD("set_collision_shape_one_way_margin", "layer_id", "shape_index", "one_way_margin"), &TileData::set_collision_shape_one_way_margin);
- ClassDB::bind_method(D_METHOD("get_collision_shape_one_way_margin", "layer_id", "shape_index"), &TileData::get_collision_shape_one_way_margin);
+ ClassDB::bind_method(D_METHOD("get_collision_polygons_count", "layer_id"), &TileData::get_collision_polygons_count);
+ ClassDB::bind_method(D_METHOD("set_collision_polygons_count", "layer_id", "polygons_count"), &TileData::set_collision_polygons_count);
+ ClassDB::bind_method(D_METHOD("add_collision_polygon", "layer_id"), &TileData::add_collision_polygon);
+ ClassDB::bind_method(D_METHOD("remove_collision_polygon", "layer_id", "polygon_index"), &TileData::remove_collision_polygon);
+ ClassDB::bind_method(D_METHOD("set_collision_polygon_points", "layer_id", "polygon_index", "polygon"), &TileData::set_collision_polygon_points);
+ ClassDB::bind_method(D_METHOD("get_collision_polygon_points", "layer_id", "polygon_index"), &TileData::get_collision_polygon_points);
+ ClassDB::bind_method(D_METHOD("set_collision_polygon_one_way", "layer_id", "polygon_index", "one_way"), &TileData::set_collision_polygon_one_way);
+ ClassDB::bind_method(D_METHOD("is_collision_polygon_one_way", "layer_id", "polygon_index"), &TileData::is_collision_polygon_one_way);
+ ClassDB::bind_method(D_METHOD("set_collision_polygon_one_way_margin", "layer_id", "polygon_index", "one_way_margin"), &TileData::set_collision_polygon_one_way_margin);
+ ClassDB::bind_method(D_METHOD("get_collision_polygon_one_way_margin", "layer_id", "polygon_index"), &TileData::get_collision_polygon_one_way_margin);
// Terrain
ClassDB::bind_method(D_METHOD("set_terrain_set", "terrain_set"), &TileData::set_terrain_set);
@@ -3034,805 +3782,6 @@ void TileData::_bind_methods() {
ADD_SIGNAL(MethodInfo("changed"));
}
-
-/////////////////////////////// TileSetPluginAtlasTerrain //////////////////////////////////////
-
-// --- PLUGINS ---
-void TileSetPluginAtlasTerrain::_draw_square_corner_or_side_terrain_bit(CanvasItem *p_canvas_item, Color p_color, Vector2i p_size, TileSet::CellNeighbor p_bit) {
- Rect2 bit_rect;
- bit_rect.size = Vector2(p_size) / 3;
- switch (p_bit) {
- case TileSet::CELL_NEIGHBOR_RIGHT_SIDE:
- bit_rect.position = Vector2(1, -1);
- break;
- case TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_CORNER:
- bit_rect.position = Vector2(1, 1);
- break;
- case TileSet::CELL_NEIGHBOR_BOTTOM_SIDE:
- bit_rect.position = Vector2(-1, 1);
- break;
- case TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_CORNER:
- bit_rect.position = Vector2(-3, 1);
- break;
- case TileSet::CELL_NEIGHBOR_LEFT_SIDE:
- bit_rect.position = Vector2(-3, -1);
- break;
- case TileSet::CELL_NEIGHBOR_TOP_LEFT_CORNER:
- bit_rect.position = Vector2(-3, -3);
- break;
- case TileSet::CELL_NEIGHBOR_TOP_SIDE:
- bit_rect.position = Vector2(-1, -3);
- break;
- case TileSet::CELL_NEIGHBOR_TOP_RIGHT_CORNER:
- bit_rect.position = Vector2(1, -3);
- break;
- default:
- break;
- }
- bit_rect.position *= Vector2(p_size) / 6.0;
- p_canvas_item->draw_rect(bit_rect, p_color);
-}
-
-void TileSetPluginAtlasTerrain::_draw_square_corner_terrain_bit(CanvasItem *p_canvas_item, Color p_color, Vector2i p_size, TileSet::CellNeighbor p_bit) {
- PackedColorArray color_array;
- color_array.push_back(p_color);
-
- Vector2 unit = Vector2(p_size) / 6.0;
- PackedVector2Array polygon;
- switch (p_bit) {
- case TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_CORNER:
- polygon.push_back(Vector2(0, 3) * unit);
- polygon.push_back(Vector2(3, 3) * unit);
- polygon.push_back(Vector2(3, 0) * unit);
- polygon.push_back(Vector2(1, 0) * unit);
- polygon.push_back(Vector2(1, 1) * unit);
- polygon.push_back(Vector2(0, 1) * unit);
- break;
- case TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_CORNER:
- polygon.push_back(Vector2(0, 3) * unit);
- polygon.push_back(Vector2(-3, 3) * unit);
- polygon.push_back(Vector2(-3, 0) * unit);
- polygon.push_back(Vector2(-1, 0) * unit);
- polygon.push_back(Vector2(-1, 1) * unit);
- polygon.push_back(Vector2(0, 1) * unit);
- break;
- case TileSet::CELL_NEIGHBOR_TOP_LEFT_CORNER:
- polygon.push_back(Vector2(0, -3) * unit);
- polygon.push_back(Vector2(-3, -3) * unit);
- polygon.push_back(Vector2(-3, 0) * unit);
- polygon.push_back(Vector2(-1, 0) * unit);
- polygon.push_back(Vector2(-1, -1) * unit);
- polygon.push_back(Vector2(0, -1) * unit);
- break;
- case TileSet::CELL_NEIGHBOR_TOP_RIGHT_CORNER:
- polygon.push_back(Vector2(0, -3) * unit);
- polygon.push_back(Vector2(3, -3) * unit);
- polygon.push_back(Vector2(3, 0) * unit);
- polygon.push_back(Vector2(1, 0) * unit);
- polygon.push_back(Vector2(1, -1) * unit);
- polygon.push_back(Vector2(0, -1) * unit);
- break;
- default:
- break;
- }
- if (!polygon.is_empty()) {
- p_canvas_item->draw_polygon(polygon, color_array);
- }
-}
-
-void TileSetPluginAtlasTerrain::_draw_square_side_terrain_bit(CanvasItem *p_canvas_item, Color p_color, Vector2i p_size, TileSet::CellNeighbor p_bit) {
- PackedColorArray color_array;
- color_array.push_back(p_color);
-
- Vector2 unit = Vector2(p_size) / 6.0;
- PackedVector2Array polygon;
- switch (p_bit) {
- case TileSet::CELL_NEIGHBOR_RIGHT_SIDE:
- polygon.push_back(Vector2(1, -1) * unit);
- polygon.push_back(Vector2(3, -3) * unit);
- polygon.push_back(Vector2(3, 3) * unit);
- polygon.push_back(Vector2(1, 1) * unit);
- break;
- case TileSet::CELL_NEIGHBOR_BOTTOM_SIDE:
- polygon.push_back(Vector2(-1, 1) * unit);
- polygon.push_back(Vector2(-3, 3) * unit);
- polygon.push_back(Vector2(3, 3) * unit);
- polygon.push_back(Vector2(1, 1) * unit);
- break;
- case TileSet::CELL_NEIGHBOR_LEFT_SIDE:
- polygon.push_back(Vector2(-1, -1) * unit);
- polygon.push_back(Vector2(-3, -3) * unit);
- polygon.push_back(Vector2(-3, 3) * unit);
- polygon.push_back(Vector2(-1, 1) * unit);
- break;
- case TileSet::CELL_NEIGHBOR_TOP_SIDE:
- polygon.push_back(Vector2(-1, -1) * unit);
- polygon.push_back(Vector2(-3, -3) * unit);
- polygon.push_back(Vector2(3, -3) * unit);
- polygon.push_back(Vector2(1, -1) * unit);
- break;
- default:
- break;
- }
- if (!polygon.is_empty()) {
- p_canvas_item->draw_polygon(polygon, color_array);
- }
-}
-
-void TileSetPluginAtlasTerrain::_draw_isometric_corner_or_side_terrain_bit(CanvasItem *p_canvas_item, Color p_color, Vector2i p_size, TileSet::CellNeighbor p_bit) {
- PackedColorArray color_array;
- color_array.push_back(p_color);
-
- Vector2 unit = Vector2(p_size) / 6.0;
- PackedVector2Array polygon;
- switch (p_bit) {
- case TileSet::CELL_NEIGHBOR_RIGHT_CORNER:
- polygon.push_back(Vector2(1, 0) * unit);
- polygon.push_back(Vector2(2, -1) * unit);
- polygon.push_back(Vector2(3, 0) * unit);
- polygon.push_back(Vector2(2, 1) * unit);
- break;
- case TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_SIDE:
- polygon.push_back(Vector2(0, 1) * unit);
- polygon.push_back(Vector2(1, 2) * unit);
- polygon.push_back(Vector2(2, 1) * unit);
- polygon.push_back(Vector2(1, 0) * unit);
- break;
- case TileSet::CELL_NEIGHBOR_BOTTOM_CORNER:
- polygon.push_back(Vector2(0, 1) * unit);
- polygon.push_back(Vector2(-1, 2) * unit);
- polygon.push_back(Vector2(0, 3) * unit);
- polygon.push_back(Vector2(1, 2) * unit);
- break;
- case TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_SIDE:
- polygon.push_back(Vector2(0, 1) * unit);
- polygon.push_back(Vector2(-1, 2) * unit);
- polygon.push_back(Vector2(-2, 1) * unit);
- polygon.push_back(Vector2(-1, 0) * unit);
- break;
- case TileSet::CELL_NEIGHBOR_LEFT_CORNER:
- polygon.push_back(Vector2(-1, 0) * unit);
- polygon.push_back(Vector2(-2, -1) * unit);
- polygon.push_back(Vector2(-3, 0) * unit);
- polygon.push_back(Vector2(-2, 1) * unit);
- break;
- case TileSet::CELL_NEIGHBOR_TOP_LEFT_SIDE:
- polygon.push_back(Vector2(0, -1) * unit);
- polygon.push_back(Vector2(-1, -2) * unit);
- polygon.push_back(Vector2(-2, -1) * unit);
- polygon.push_back(Vector2(-1, 0) * unit);
- break;
- case TileSet::CELL_NEIGHBOR_TOP_CORNER:
- polygon.push_back(Vector2(0, -1) * unit);
- polygon.push_back(Vector2(-1, -2) * unit);
- polygon.push_back(Vector2(0, -3) * unit);
- polygon.push_back(Vector2(1, -2) * unit);
- break;
- case TileSet::CELL_NEIGHBOR_TOP_RIGHT_SIDE:
- polygon.push_back(Vector2(0, -1) * unit);
- polygon.push_back(Vector2(1, -2) * unit);
- polygon.push_back(Vector2(2, -1) * unit);
- polygon.push_back(Vector2(1, 0) * unit);
- break;
- default:
- break;
- }
- if (!polygon.is_empty()) {
- p_canvas_item->draw_polygon(polygon, color_array);
- }
-}
-
-void TileSetPluginAtlasTerrain::_draw_isometric_corner_terrain_bit(CanvasItem *p_canvas_item, Color p_color, Vector2i p_size, TileSet::CellNeighbor p_bit) {
- PackedColorArray color_array;
- color_array.push_back(p_color);
-
- Vector2 unit = Vector2(p_size) / 6.0;
- PackedVector2Array polygon;
- switch (p_bit) {
- case TileSet::CELL_NEIGHBOR_RIGHT_CORNER:
- polygon.push_back(Vector2(0.5, -0.5) * unit);
- polygon.push_back(Vector2(1.5, -1.5) * unit);
- polygon.push_back(Vector2(3, 0) * unit);
- polygon.push_back(Vector2(1.5, 1.5) * unit);
- polygon.push_back(Vector2(0.5, 0.5) * unit);
- polygon.push_back(Vector2(1, 0) * unit);
- break;
- case TileSet::CELL_NEIGHBOR_BOTTOM_CORNER:
- polygon.push_back(Vector2(-0.5, 0.5) * unit);
- polygon.push_back(Vector2(-1.5, 1.5) * unit);
- polygon.push_back(Vector2(0, 3) * unit);
- polygon.push_back(Vector2(1.5, 1.5) * unit);
- polygon.push_back(Vector2(0.5, 0.5) * unit);
- polygon.push_back(Vector2(0, 1) * unit);
- break;
- case TileSet::CELL_NEIGHBOR_LEFT_CORNER:
- polygon.push_back(Vector2(-0.5, -0.5) * unit);
- polygon.push_back(Vector2(-1.5, -1.5) * unit);
- polygon.push_back(Vector2(-3, 0) * unit);
- polygon.push_back(Vector2(-1.5, 1.5) * unit);
- polygon.push_back(Vector2(-0.5, 0.5) * unit);
- polygon.push_back(Vector2(-1, 0) * unit);
- break;
- case TileSet::CELL_NEIGHBOR_TOP_CORNER:
- polygon.push_back(Vector2(-0.5, -0.5) * unit);
- polygon.push_back(Vector2(-1.5, -1.5) * unit);
- polygon.push_back(Vector2(0, -3) * unit);
- polygon.push_back(Vector2(1.5, -1.5) * unit);
- polygon.push_back(Vector2(0.5, -0.5) * unit);
- polygon.push_back(Vector2(0, -1) * unit);
- break;
- default:
- break;
- }
- if (!polygon.is_empty()) {
- p_canvas_item->draw_polygon(polygon, color_array);
- }
-}
-
-void TileSetPluginAtlasTerrain::_draw_isometric_side_terrain_bit(CanvasItem *p_canvas_item, Color p_color, Vector2i p_size, TileSet::CellNeighbor p_bit) {
- PackedColorArray color_array;
- color_array.push_back(p_color);
-
- Vector2 unit = Vector2(p_size) / 6.0;
- PackedVector2Array polygon;
- switch (p_bit) {
- case TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_SIDE:
- polygon.push_back(Vector2(1, 0) * unit);
- polygon.push_back(Vector2(3, 0) * unit);
- polygon.push_back(Vector2(0, 3) * unit);
- polygon.push_back(Vector2(0, 1) * unit);
- break;
- case TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_SIDE:
- polygon.push_back(Vector2(-1, 0) * unit);
- polygon.push_back(Vector2(-3, 0) * unit);
- polygon.push_back(Vector2(0, 3) * unit);
- polygon.push_back(Vector2(0, 1) * unit);
- break;
- case TileSet::CELL_NEIGHBOR_TOP_LEFT_SIDE:
- polygon.push_back(Vector2(-1, 0) * unit);
- polygon.push_back(Vector2(-3, 0) * unit);
- polygon.push_back(Vector2(0, -3) * unit);
- polygon.push_back(Vector2(0, -1) * unit);
- break;
- case TileSet::CELL_NEIGHBOR_TOP_RIGHT_SIDE:
- polygon.push_back(Vector2(1, 0) * unit);
- polygon.push_back(Vector2(3, 0) * unit);
- polygon.push_back(Vector2(0, -3) * unit);
- polygon.push_back(Vector2(0, -1) * unit);
- break;
- default:
- break;
- }
- if (!polygon.is_empty()) {
- p_canvas_item->draw_polygon(polygon, color_array);
- }
-}
-
-void TileSetPluginAtlasTerrain::_draw_half_offset_corner_or_side_terrain_bit(CanvasItem *p_canvas_item, Color p_color, Vector2i p_size, TileSet::CellNeighbor p_bit, float p_overlap, TileSet::TileOffsetAxis p_offset_axis) {
- PackedColorArray color_array;
- color_array.push_back(p_color);
-
- PackedVector2Array point_list;
- point_list.push_back(Vector2(3, (3.0 * (1.0 - p_overlap * 2.0)) / 2.0));
- point_list.push_back(Vector2(3, 3.0 * (1.0 - p_overlap * 2.0)));
- point_list.push_back(Vector2(2, 3.0 * (1.0 - (p_overlap * 2.0) * 2.0 / 3.0)));
- point_list.push_back(Vector2(1, 3.0 - p_overlap * 2.0));
- point_list.push_back(Vector2(0, 3));
- point_list.push_back(Vector2(-1, 3.0 - p_overlap * 2.0));
- point_list.push_back(Vector2(-2, 3.0 * (1.0 - (p_overlap * 2.0) * 2.0 / 3.0)));
- point_list.push_back(Vector2(-3, 3.0 * (1.0 - p_overlap * 2.0)));
- point_list.push_back(Vector2(-3, (3.0 * (1.0 - p_overlap * 2.0)) / 2.0));
- point_list.push_back(Vector2(-3, -(3.0 * (1.0 - p_overlap * 2.0)) / 2.0));
- point_list.push_back(Vector2(-3, -3.0 * (1.0 - p_overlap * 2.0)));
- point_list.push_back(Vector2(-2, -3.0 * (1.0 - (p_overlap * 2.0) * 2.0 / 3.0)));
- point_list.push_back(Vector2(-1, -(3.0 - p_overlap * 2.0)));
- point_list.push_back(Vector2(0, -3));
- point_list.push_back(Vector2(1, -(3.0 - p_overlap * 2.0)));
- point_list.push_back(Vector2(2, -3.0 * (1.0 - (p_overlap * 2.0) * 2.0 / 3.0)));
- point_list.push_back(Vector2(3, -3.0 * (1.0 - p_overlap * 2.0)));
- point_list.push_back(Vector2(3, -(3.0 * (1.0 - p_overlap * 2.0)) / 2.0));
-
- Vector2 unit = Vector2(p_size) / 6.0;
- for (int i = 0; i < point_list.size(); i++) {
- point_list.write[i] = point_list[i] * unit;
- }
-
- PackedVector2Array polygon;
- if (p_offset_axis == TileSet::TILE_OFFSET_AXIS_HORIZONTAL) {
- switch (p_bit) {
- case TileSet::CELL_NEIGHBOR_RIGHT_SIDE:
- polygon.push_back(point_list[17]);
- polygon.push_back(point_list[0]);
- break;
- case TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_CORNER:
- polygon.push_back(point_list[0]);
- polygon.push_back(point_list[1]);
- polygon.push_back(point_list[2]);
- break;
- case TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_SIDE:
- polygon.push_back(point_list[2]);
- polygon.push_back(point_list[3]);
- break;
- case TileSet::CELL_NEIGHBOR_BOTTOM_CORNER:
- polygon.push_back(point_list[3]);
- polygon.push_back(point_list[4]);
- polygon.push_back(point_list[5]);
- break;
- case TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_SIDE:
- polygon.push_back(point_list[5]);
- polygon.push_back(point_list[6]);
- break;
- case TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_CORNER:
- polygon.push_back(point_list[6]);
- polygon.push_back(point_list[7]);
- polygon.push_back(point_list[8]);
- break;
- case TileSet::CELL_NEIGHBOR_LEFT_SIDE:
- polygon.push_back(point_list[8]);
- polygon.push_back(point_list[9]);
- break;
- case TileSet::CELL_NEIGHBOR_TOP_LEFT_CORNER:
- polygon.push_back(point_list[9]);
- polygon.push_back(point_list[10]);
- polygon.push_back(point_list[11]);
- break;
- case TileSet::CELL_NEIGHBOR_TOP_LEFT_SIDE:
- polygon.push_back(point_list[11]);
- polygon.push_back(point_list[12]);
- break;
- case TileSet::CELL_NEIGHBOR_TOP_CORNER:
- polygon.push_back(point_list[12]);
- polygon.push_back(point_list[13]);
- polygon.push_back(point_list[14]);
- break;
- case TileSet::CELL_NEIGHBOR_TOP_RIGHT_SIDE:
- polygon.push_back(point_list[14]);
- polygon.push_back(point_list[15]);
- break;
- case TileSet::CELL_NEIGHBOR_TOP_RIGHT_CORNER:
- polygon.push_back(point_list[15]);
- polygon.push_back(point_list[16]);
- polygon.push_back(point_list[17]);
- break;
- default:
- break;
- }
- } else {
- if (p_offset_axis == TileSet::TILE_OFFSET_AXIS_VERTICAL) {
- for (int i = 0; i < point_list.size(); i++) {
- point_list.write[i] = Vector2(point_list[i].y, point_list[i].x);
- }
- }
- switch (p_bit) {
- case TileSet::CELL_NEIGHBOR_RIGHT_CORNER:
- polygon.push_back(point_list[3]);
- polygon.push_back(point_list[4]);
- polygon.push_back(point_list[5]);
- break;
- case TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_SIDE:
- polygon.push_back(point_list[2]);
- polygon.push_back(point_list[3]);
- break;
- case TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_CORNER:
- polygon.push_back(point_list[0]);
- polygon.push_back(point_list[1]);
- polygon.push_back(point_list[2]);
- break;
- case TileSet::CELL_NEIGHBOR_BOTTOM_SIDE:
- polygon.push_back(point_list[17]);
- polygon.push_back(point_list[0]);
- break;
- case TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_CORNER:
- polygon.push_back(point_list[15]);
- polygon.push_back(point_list[16]);
- polygon.push_back(point_list[17]);
- break;
- case TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_SIDE:
- polygon.push_back(point_list[14]);
- polygon.push_back(point_list[15]);
- break;
- case TileSet::CELL_NEIGHBOR_LEFT_CORNER:
- polygon.push_back(point_list[12]);
- polygon.push_back(point_list[13]);
- polygon.push_back(point_list[14]);
- break;
- case TileSet::CELL_NEIGHBOR_TOP_LEFT_SIDE:
- polygon.push_back(point_list[11]);
- polygon.push_back(point_list[12]);
- break;
- case TileSet::CELL_NEIGHBOR_TOP_LEFT_CORNER:
- polygon.push_back(point_list[9]);
- polygon.push_back(point_list[10]);
- polygon.push_back(point_list[11]);
- break;
- case TileSet::CELL_NEIGHBOR_TOP_SIDE:
- polygon.push_back(point_list[8]);
- polygon.push_back(point_list[9]);
- break;
- case TileSet::CELL_NEIGHBOR_TOP_RIGHT_CORNER:
- polygon.push_back(point_list[6]);
- polygon.push_back(point_list[7]);
- polygon.push_back(point_list[8]);
- break;
- case TileSet::CELL_NEIGHBOR_TOP_RIGHT_SIDE:
- polygon.push_back(point_list[5]);
- polygon.push_back(point_list[6]);
- break;
- default:
- break;
- }
- }
-
- int half_polygon_size = polygon.size();
- for (int i = 0; i < half_polygon_size; i++) {
- polygon.push_back(polygon[half_polygon_size - 1 - i] / 3.0);
- }
-
- if (!polygon.is_empty()) {
- p_canvas_item->draw_polygon(polygon, color_array);
- }
-}
-
-void TileSetPluginAtlasTerrain::_draw_half_offset_corner_terrain_bit(CanvasItem *p_canvas_item, Color p_color, Vector2i p_size, TileSet::CellNeighbor p_bit, float p_overlap, TileSet::TileOffsetAxis p_offset_axis) {
- PackedColorArray color_array;
- color_array.push_back(p_color);
-
- PackedVector2Array point_list;
- point_list.push_back(Vector2(3, 0));
- point_list.push_back(Vector2(3, 3.0 * (1.0 - p_overlap * 2.0)));
- point_list.push_back(Vector2(1.5, (3.0 * (1.0 - p_overlap * 2.0) + 3.0) / 2.0));
- point_list.push_back(Vector2(0, 3));
- point_list.push_back(Vector2(-1.5, (3.0 * (1.0 - p_overlap * 2.0) + 3.0) / 2.0));
- point_list.push_back(Vector2(-3, 3.0 * (1.0 - p_overlap * 2.0)));
- point_list.push_back(Vector2(-3, 0));
- point_list.push_back(Vector2(-3, -3.0 * (1.0 - p_overlap * 2.0)));
- point_list.push_back(Vector2(-1.5, -(3.0 * (1.0 - p_overlap * 2.0) + 3.0) / 2.0));
- point_list.push_back(Vector2(0, -3));
- point_list.push_back(Vector2(1.5, -(3.0 * (1.0 - p_overlap * 2.0) + 3.0) / 2.0));
- point_list.push_back(Vector2(3, -3.0 * (1.0 - p_overlap * 2.0)));
-
- Vector2 unit = Vector2(p_size) / 6.0;
- for (int i = 0; i < point_list.size(); i++) {
- point_list.write[i] = point_list[i] * unit;
- }
-
- PackedVector2Array polygon;
- if (p_offset_axis == TileSet::TILE_OFFSET_AXIS_HORIZONTAL) {
- switch (p_bit) {
- case TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_CORNER:
- polygon.push_back(point_list[0]);
- polygon.push_back(point_list[1]);
- polygon.push_back(point_list[2]);
- break;
- case TileSet::CELL_NEIGHBOR_BOTTOM_CORNER:
- polygon.push_back(point_list[2]);
- polygon.push_back(point_list[3]);
- polygon.push_back(point_list[4]);
- break;
- case TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_CORNER:
- polygon.push_back(point_list[4]);
- polygon.push_back(point_list[5]);
- polygon.push_back(point_list[6]);
- break;
- case TileSet::CELL_NEIGHBOR_TOP_LEFT_CORNER:
- polygon.push_back(point_list[6]);
- polygon.push_back(point_list[7]);
- polygon.push_back(point_list[8]);
- break;
- case TileSet::CELL_NEIGHBOR_TOP_CORNER:
- polygon.push_back(point_list[8]);
- polygon.push_back(point_list[9]);
- polygon.push_back(point_list[10]);
- break;
- case TileSet::CELL_NEIGHBOR_TOP_RIGHT_CORNER:
- polygon.push_back(point_list[10]);
- polygon.push_back(point_list[11]);
- polygon.push_back(point_list[0]);
- break;
- default:
- break;
- }
- } else {
- if (p_offset_axis == TileSet::TILE_OFFSET_AXIS_VERTICAL) {
- for (int i = 0; i < point_list.size(); i++) {
- point_list.write[i] = Vector2(point_list[i].y, point_list[i].x);
- }
- }
- switch (p_bit) {
- case TileSet::CELL_NEIGHBOR_RIGHT_CORNER:
- polygon.push_back(point_list[2]);
- polygon.push_back(point_list[3]);
- polygon.push_back(point_list[4]);
- break;
- case TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_CORNER:
- polygon.push_back(point_list[0]);
- polygon.push_back(point_list[1]);
- polygon.push_back(point_list[2]);
- break;
- case TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_CORNER:
- polygon.push_back(point_list[10]);
- polygon.push_back(point_list[11]);
- polygon.push_back(point_list[0]);
- break;
- case TileSet::CELL_NEIGHBOR_LEFT_CORNER:
- polygon.push_back(point_list[8]);
- polygon.push_back(point_list[9]);
- polygon.push_back(point_list[10]);
- break;
- case TileSet::CELL_NEIGHBOR_TOP_LEFT_CORNER:
- polygon.push_back(point_list[6]);
- polygon.push_back(point_list[7]);
- polygon.push_back(point_list[8]);
- break;
- case TileSet::CELL_NEIGHBOR_TOP_RIGHT_CORNER:
- polygon.push_back(point_list[4]);
- polygon.push_back(point_list[5]);
- polygon.push_back(point_list[6]);
- break;
- default:
- break;
- }
- }
-
- int half_polygon_size = polygon.size();
- for (int i = 0; i < half_polygon_size; i++) {
- polygon.push_back(polygon[half_polygon_size - 1 - i] / 3.0);
- }
-
- if (!polygon.is_empty()) {
- p_canvas_item->draw_polygon(polygon, color_array);
- }
-}
-
-void TileSetPluginAtlasTerrain::_draw_half_offset_side_terrain_bit(CanvasItem *p_canvas_item, Color p_color, Vector2i p_size, TileSet::CellNeighbor p_bit, float p_overlap, TileSet::TileOffsetAxis p_offset_axis) {
- PackedColorArray color_array;
- color_array.push_back(p_color);
-
- PackedVector2Array point_list;
- point_list.push_back(Vector2(3, 3.0 * (1.0 - p_overlap * 2.0)));
- point_list.push_back(Vector2(0, 3));
- point_list.push_back(Vector2(-3, 3.0 * (1.0 - p_overlap * 2.0)));
- point_list.push_back(Vector2(-3, -3.0 * (1.0 - p_overlap * 2.0)));
- point_list.push_back(Vector2(0, -3));
- point_list.push_back(Vector2(3, -3.0 * (1.0 - p_overlap * 2.0)));
-
- Vector2 unit = Vector2(p_size) / 6.0;
- for (int i = 0; i < point_list.size(); i++) {
- point_list.write[i] = point_list[i] * unit;
- }
-
- PackedVector2Array polygon;
- if (p_offset_axis == TileSet::TILE_OFFSET_AXIS_HORIZONTAL) {
- switch (p_bit) {
- case TileSet::CELL_NEIGHBOR_RIGHT_SIDE:
- polygon.push_back(point_list[5]);
- polygon.push_back(point_list[0]);
- break;
- case TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_SIDE:
- polygon.push_back(point_list[0]);
- polygon.push_back(point_list[1]);
- break;
- case TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_SIDE:
- polygon.push_back(point_list[1]);
- polygon.push_back(point_list[2]);
- break;
- case TileSet::CELL_NEIGHBOR_LEFT_SIDE:
- polygon.push_back(point_list[2]);
- polygon.push_back(point_list[3]);
- break;
- case TileSet::CELL_NEIGHBOR_TOP_LEFT_SIDE:
- polygon.push_back(point_list[3]);
- polygon.push_back(point_list[4]);
- break;
- case TileSet::CELL_NEIGHBOR_TOP_RIGHT_SIDE:
- polygon.push_back(point_list[4]);
- polygon.push_back(point_list[5]);
- break;
- default:
- break;
- }
- } else {
- if (p_offset_axis == TileSet::TILE_OFFSET_AXIS_VERTICAL) {
- for (int i = 0; i < point_list.size(); i++) {
- point_list.write[i] = Vector2(point_list[i].y, point_list[i].x);
- }
- }
- switch (p_bit) {
- case TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_SIDE:
- polygon.push_back(point_list[0]);
- polygon.push_back(point_list[1]);
- break;
- case TileSet::CELL_NEIGHBOR_BOTTOM_SIDE:
- polygon.push_back(point_list[5]);
- polygon.push_back(point_list[0]);
- break;
- case TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_SIDE:
- polygon.push_back(point_list[4]);
- polygon.push_back(point_list[5]);
- break;
- case TileSet::CELL_NEIGHBOR_TOP_LEFT_SIDE:
- polygon.push_back(point_list[3]);
- polygon.push_back(point_list[4]);
- break;
- case TileSet::CELL_NEIGHBOR_TOP_SIDE:
- polygon.push_back(point_list[2]);
- polygon.push_back(point_list[3]);
- break;
- case TileSet::CELL_NEIGHBOR_TOP_RIGHT_SIDE:
- polygon.push_back(point_list[1]);
- polygon.push_back(point_list[2]);
- break;
- default:
- break;
- }
- }
-
- int half_polygon_size = polygon.size();
- for (int i = 0; i < half_polygon_size; i++) {
- polygon.push_back(polygon[half_polygon_size - 1 - i] / 3.0);
- }
-
- if (!polygon.is_empty()) {
- p_canvas_item->draw_polygon(polygon, color_array);
- }
-}
-
-#define TERRAIN_ALPHA 0.8
-
-#define DRAW_TERRAIN_BIT(f, bit) \
- { \
- int terrain_id = p_tile_data->get_peering_bit_terrain((bit)); \
- if (terrain_id >= 0) { \
- Color color = p_tile_set->get_terrain_color(terrain_set, terrain_id); \
- color.a = TERRAIN_ALPHA; \
- f(p_canvas_item, color, size, (bit)); \
- } \
- }
-
-#define DRAW_HALF_OFFSET_TERRAIN_BIT(f, bit, overlap, half_offset_axis) \
- { \
- int terrain_id = p_tile_data->get_peering_bit_terrain((bit)); \
- if (terrain_id >= 0) { \
- Color color = p_tile_set->get_terrain_color(terrain_set, terrain_id); \
- color.a = TERRAIN_ALPHA; \
- f(p_canvas_item, color, size, (bit), overlap, half_offset_axis); \
- } \
- }
-
-void TileSetPluginAtlasTerrain::draw_terrains(CanvasItem *p_canvas_item, Transform2D p_transform, TileSet *p_tile_set, const TileData *p_tile_data) {
- ERR_FAIL_COND(!p_tile_set);
- ERR_FAIL_COND(!p_tile_data);
-
- int terrain_set = p_tile_data->get_terrain_set();
- if (terrain_set < 0) {
- return;
- }
- TileSet::TerrainMode terrain_mode = p_tile_set->get_terrain_set_mode(terrain_set);
-
- TileSet::TileShape shape = p_tile_set->get_tile_shape();
- Vector2i size = p_tile_set->get_tile_size();
-
- RenderingServer::get_singleton()->canvas_item_add_set_transform(p_canvas_item->get_canvas_item(), p_transform);
- if (shape == TileSet::TILE_SHAPE_SQUARE) {
- if (terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS_AND_SIDES) {
- DRAW_TERRAIN_BIT(_draw_square_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_RIGHT_SIDE);
- DRAW_TERRAIN_BIT(_draw_square_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_CORNER);
- DRAW_TERRAIN_BIT(_draw_square_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_BOTTOM_SIDE);
- DRAW_TERRAIN_BIT(_draw_square_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_CORNER);
- DRAW_TERRAIN_BIT(_draw_square_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_LEFT_SIDE);
- DRAW_TERRAIN_BIT(_draw_square_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_TOP_LEFT_CORNER);
- DRAW_TERRAIN_BIT(_draw_square_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_TOP_SIDE);
- DRAW_TERRAIN_BIT(_draw_square_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_TOP_RIGHT_CORNER);
- } else if (terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS) {
- DRAW_TERRAIN_BIT(_draw_square_corner_terrain_bit, TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_CORNER);
- DRAW_TERRAIN_BIT(_draw_square_corner_terrain_bit, TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_CORNER);
- DRAW_TERRAIN_BIT(_draw_square_corner_terrain_bit, TileSet::CELL_NEIGHBOR_TOP_LEFT_CORNER);
- DRAW_TERRAIN_BIT(_draw_square_corner_terrain_bit, TileSet::CELL_NEIGHBOR_TOP_RIGHT_CORNER);
- } else { // TileData::TERRAIN_MODE_MATCH_SIDES
- DRAW_TERRAIN_BIT(_draw_square_side_terrain_bit, TileSet::CELL_NEIGHBOR_RIGHT_SIDE);
- DRAW_TERRAIN_BIT(_draw_square_side_terrain_bit, TileSet::CELL_NEIGHBOR_BOTTOM_SIDE);
- DRAW_TERRAIN_BIT(_draw_square_side_terrain_bit, TileSet::CELL_NEIGHBOR_LEFT_SIDE);
- DRAW_TERRAIN_BIT(_draw_square_side_terrain_bit, TileSet::CELL_NEIGHBOR_TOP_SIDE);
- }
- } else if (shape == TileSet::TILE_SHAPE_ISOMETRIC) {
- if (terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS_AND_SIDES) {
- DRAW_TERRAIN_BIT(_draw_isometric_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_RIGHT_CORNER);
- DRAW_TERRAIN_BIT(_draw_isometric_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_SIDE);
- DRAW_TERRAIN_BIT(_draw_isometric_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_BOTTOM_CORNER);
- DRAW_TERRAIN_BIT(_draw_isometric_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_SIDE);
- DRAW_TERRAIN_BIT(_draw_isometric_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_LEFT_CORNER);
- DRAW_TERRAIN_BIT(_draw_isometric_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_TOP_LEFT_SIDE);
- DRAW_TERRAIN_BIT(_draw_isometric_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_TOP_CORNER);
- DRAW_TERRAIN_BIT(_draw_isometric_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_TOP_RIGHT_SIDE);
- } else if (terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS) {
- DRAW_TERRAIN_BIT(_draw_isometric_corner_terrain_bit, TileSet::CELL_NEIGHBOR_RIGHT_CORNER);
- DRAW_TERRAIN_BIT(_draw_isometric_corner_terrain_bit, TileSet::CELL_NEIGHBOR_BOTTOM_CORNER);
- DRAW_TERRAIN_BIT(_draw_isometric_corner_terrain_bit, TileSet::CELL_NEIGHBOR_LEFT_CORNER);
- DRAW_TERRAIN_BIT(_draw_isometric_corner_terrain_bit, TileSet::CELL_NEIGHBOR_TOP_CORNER);
- } else { // TileData::TERRAIN_MODE_MATCH_SIDES
- DRAW_TERRAIN_BIT(_draw_isometric_side_terrain_bit, TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_SIDE);
- DRAW_TERRAIN_BIT(_draw_isometric_side_terrain_bit, TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_SIDE);
- DRAW_TERRAIN_BIT(_draw_isometric_side_terrain_bit, TileSet::CELL_NEIGHBOR_TOP_LEFT_SIDE);
- DRAW_TERRAIN_BIT(_draw_isometric_side_terrain_bit, TileSet::CELL_NEIGHBOR_TOP_RIGHT_SIDE);
- }
- } else {
- TileSet::TileOffsetAxis offset_axis = p_tile_set->get_tile_offset_axis();
- float overlap = 0.0;
- switch (p_tile_set->get_tile_shape()) {
- case TileSet::TILE_SHAPE_HEXAGON:
- overlap = 0.25;
- break;
- case TileSet::TILE_SHAPE_HALF_OFFSET_SQUARE:
- overlap = 0.0;
- break;
- default:
- break;
- }
- if (terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS_AND_SIDES) {
- if (offset_axis == TileSet::TILE_OFFSET_AXIS_HORIZONTAL) {
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_RIGHT_SIDE, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_CORNER, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_SIDE, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_BOTTOM_CORNER, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_SIDE, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_CORNER, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_LEFT_SIDE, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_TOP_LEFT_CORNER, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_TOP_LEFT_SIDE, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_TOP_CORNER, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_TOP_RIGHT_SIDE, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_TOP_RIGHT_CORNER, overlap, offset_axis);
- } else {
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_RIGHT_CORNER, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_SIDE, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_CORNER, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_BOTTOM_SIDE, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_CORNER, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_SIDE, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_LEFT_CORNER, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_TOP_LEFT_SIDE, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_TOP_LEFT_CORNER, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_TOP_SIDE, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_TOP_RIGHT_CORNER, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_or_side_terrain_bit, TileSet::CELL_NEIGHBOR_TOP_RIGHT_SIDE, overlap, offset_axis);
- }
- } else if (terrain_mode == TileSet::TERRAIN_MODE_MATCH_CORNERS) {
- if (offset_axis == TileSet::TILE_OFFSET_AXIS_HORIZONTAL) {
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_terrain_bit, TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_CORNER, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_terrain_bit, TileSet::CELL_NEIGHBOR_BOTTOM_CORNER, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_terrain_bit, TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_CORNER, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_terrain_bit, TileSet::CELL_NEIGHBOR_TOP_LEFT_CORNER, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_terrain_bit, TileSet::CELL_NEIGHBOR_TOP_CORNER, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_terrain_bit, TileSet::CELL_NEIGHBOR_TOP_RIGHT_CORNER, overlap, offset_axis);
- } else {
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_terrain_bit, TileSet::CELL_NEIGHBOR_RIGHT_CORNER, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_terrain_bit, TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_CORNER, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_terrain_bit, TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_CORNER, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_terrain_bit, TileSet::CELL_NEIGHBOR_LEFT_CORNER, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_terrain_bit, TileSet::CELL_NEIGHBOR_TOP_LEFT_CORNER, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_corner_terrain_bit, TileSet::CELL_NEIGHBOR_TOP_RIGHT_CORNER, overlap, offset_axis);
- }
- } else { // TileData::TERRAIN_MODE_MATCH_SIDES
- if (offset_axis == TileSet::TILE_OFFSET_AXIS_HORIZONTAL) {
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_side_terrain_bit, TileSet::CELL_NEIGHBOR_RIGHT_SIDE, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_side_terrain_bit, TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_SIDE, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_side_terrain_bit, TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_SIDE, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_side_terrain_bit, TileSet::CELL_NEIGHBOR_LEFT_SIDE, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_side_terrain_bit, TileSet::CELL_NEIGHBOR_TOP_LEFT_SIDE, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_side_terrain_bit, TileSet::CELL_NEIGHBOR_TOP_RIGHT_SIDE, overlap, offset_axis);
- } else {
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_side_terrain_bit, TileSet::CELL_NEIGHBOR_BOTTOM_RIGHT_SIDE, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_side_terrain_bit, TileSet::CELL_NEIGHBOR_BOTTOM_SIDE, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_side_terrain_bit, TileSet::CELL_NEIGHBOR_BOTTOM_LEFT_SIDE, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_side_terrain_bit, TileSet::CELL_NEIGHBOR_TOP_LEFT_SIDE, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_side_terrain_bit, TileSet::CELL_NEIGHBOR_TOP_SIDE, overlap, offset_axis);
- DRAW_HALF_OFFSET_TERRAIN_BIT(_draw_half_offset_side_terrain_bit, TileSet::CELL_NEIGHBOR_TOP_RIGHT_SIDE, overlap, offset_axis);
- }
- }
- }
- RenderingServer::get_singleton()->canvas_item_add_set_transform(p_canvas_item->get_canvas_item(), Transform2D());
-}
-
/////////////////////////////// TileSetPluginAtlasRendering //////////////////////////////////////
void TileSetPluginAtlasRendering::tilemap_notification(TileMap *p_tile_map, int p_what) {
@@ -4218,15 +4167,17 @@ void TileSetPluginAtlasPhysics::update_dirty_quadrants(TileMap *p_tile_map, Self
for (int body_index = 0; body_index < q.bodies.size(); body_index++) {
// Add the shapes again.
- for (int shape_index = 0; shape_index < tile_data->get_collision_shapes_count(body_index); shape_index++) {
- bool one_way_collision = tile_data->is_collision_shape_one_way(body_index, shape_index);
- float one_way_collision_margin = tile_data->get_collision_shape_one_way_margin(body_index, shape_index);
- Ref<Shape2D> shape = tile_data->get_collision_shape_shape(body_index, shape_index);
- if (shape.is_valid()) {
+ for (int polygon_index = 0; polygon_index < tile_data->get_collision_polygons_count(body_index); polygon_index++) {
+ bool one_way_collision = tile_data->is_collision_polygon_one_way(body_index, polygon_index);
+ float one_way_collision_margin = tile_data->get_collision_polygon_one_way_margin(body_index, polygon_index);
+
+ int shapes_count = tile_data->get_collision_polygon_shapes_count(body_index, polygon_index);
+ for (int shape_index = 0; shape_index < shapes_count; shape_index++) {
Transform2D xform = Transform2D();
xform.set_origin(p_tile_map->map_to_world(E_cell->get()) - quadrant_pos);
// Add decomposed convex shapes.
+ Ref<ConvexPolygonShape2D> shape = tile_data->get_collision_polygon_shape(body_index, polygon_index, shape_index);
ps->body_add_shape(q.bodies[body_index], shape->get_rid(), xform);
ps->body_set_shape_metadata(q.bodies[body_index], shape_index, E_cell->get());
ps->body_set_shape_as_one_way_collision(q.bodies[body_index], shape_index, one_way_collision, one_way_collision_margin);
@@ -4343,11 +4294,13 @@ void TileSetPluginAtlasPhysics::draw_quadrant_debug(TileMap *p_tile_map, TileMap
TileData *tile_data = Object::cast_to<TileData>(atlas_source->get_tile_data(c.get_atlas_coords(), c.alternative_tile));
for (int body_index = 0; body_index < p_quadrant->bodies.size(); body_index++) {
- for (int shape_index = 0; shape_index < tile_data->get_collision_shapes_count(body_index); shape_index++) {
- // Draw the debug shape.
- Ref<Shape2D> shape = tile_data->get_collision_shape_shape(body_index, shape_index);
- if (shape.is_valid()) {
- shape->draw(p_quadrant->debug_canvas_item, debug_collision_color);
+ for (int polygon_index = 0; polygon_index < tile_data->get_collision_polygons_count(body_index); polygon_index++) {
+ // Draw the debug polygon.
+ Vector<Vector2> polygon = tile_data->get_collision_polygon_points(body_index, polygon_index);
+ if (polygon.size() >= 3) {
+ Vector<Color> color;
+ color.push_back(debug_collision_color);
+ rs->canvas_item_add_polygon(p_quadrant->debug_canvas_item, polygon, color);
}
}
}
@@ -4587,7 +4540,7 @@ void TileSetPluginScenesCollections::update_dirty_quadrants(TileMap *p_tile_map,
if (scenes_collection_source) {
Ref<PackedScene> packed_scene = scenes_collection_source->get_scene_tile_scene(c.alternative_tile);
if (packed_scene.is_valid()) {
- Node *scene = packed_scene->instance();
+ Node *scene = packed_scene->instantiate();
p_tile_map->add_child(scene);
Control *scene_as_control = Object::cast_to<Control>(scene);
Node2D *scene_as_node2d = Object::cast_to<Node2D>(scene);
diff --git a/scene/resources/tile_set.h b/scene/resources/tile_set.h
index 6cf4198f30..dbf6dbabe6 100644
--- a/scene/resources/tile_set.h
+++ b/scene/resources/tile_set.h
@@ -33,19 +33,18 @@
#include "core/io/resource.h"
#include "core/object/object.h"
+#include "core/templates/local_vector.h"
#include "scene/2d/light_occluder_2d.h"
#include "scene/2d/navigation_region_2d.h"
#include "scene/main/canvas_item.h"
+#include "scene/resources/concave_polygon_shape_2d.h"
#include "scene/resources/convex_polygon_shape_2d.h"
#include "scene/resources/packed_scene.h"
#include "scene/resources/physics_material.h"
#include "scene/resources/shape_2d.h"
#ifndef DISABLE_DEPRECATED
-#include "scene/2d/light_occluder_2d.h"
-#include "scene/2d/navigation_region_2d.h"
#include "scene/resources/shader.h"
-#include "scene/resources/shape_2d.h"
#include "scene/resources/texture.h"
#endif
@@ -60,7 +59,6 @@ class TileSetPlugin;
class TileSetPluginAtlasRendering;
class TileSetPluginAtlasPhysics;
class TileSetPluginAtlasNavigation;
-class TileSetPluginAtlasTerrain;
class TileSet : public Resource {
GDCLASS(TileSet, Resource);
@@ -138,6 +136,8 @@ public:
CELL_NEIGHBOR_MAX,
};
+ static const char *CELL_NEIGHBOR_ENUM_TO_TEXT[];
+
enum TerrainMode {
TERRAIN_MODE_MATCH_CORNERS_AND_SIDES = 0,
TERRAIN_MODE_MATCH_CORNERS,
@@ -194,6 +194,10 @@ private:
};
Vector<OcclusionLayer> occlusion_layers;
+ Ref<ArrayMesh> tile_lines_mesh;
+ Ref<ArrayMesh> tile_filled_mesh;
+ bool tile_meshes_dirty = true;
+
// Physics
struct PhysicsLayer {
uint32_t collision_layer = 1;
@@ -213,6 +217,9 @@ private:
};
Vector<TerrainSet> terrain_sets;
+ Map<TerrainMode, Map<CellNeighbor, Ref<ArrayMesh>>> terrain_bits_meshes;
+ bool terrain_bits_meshes_dirty = true;
+
// Navigation
struct Navigationlayer {
uint32_t layers = 1;
@@ -239,6 +246,19 @@ private:
void _compute_next_source_id();
void _source_changed();
+ // Helpers
+ Vector<Point2> _get_square_corner_or_side_terrain_bit_polygon(Vector2i p_size, TileSet::CellNeighbor p_bit);
+ Vector<Point2> _get_square_corner_terrain_bit_polygon(Vector2i p_size, TileSet::CellNeighbor p_bit);
+ Vector<Point2> _get_square_side_terrain_bit_polygon(Vector2i p_size, TileSet::CellNeighbor p_bit);
+
+ Vector<Point2> _get_isometric_corner_or_side_terrain_bit_polygon(Vector2i p_size, TileSet::CellNeighbor p_bit);
+ Vector<Point2> _get_isometric_corner_terrain_bit_polygon(Vector2i p_size, TileSet::CellNeighbor p_bit);
+ Vector<Point2> _get_isometric_side_terrain_bit_polygon(Vector2i p_size, TileSet::CellNeighbor p_bit);
+
+ Vector<Point2> _get_half_offset_corner_or_side_terrain_bit_polygon(Vector2i p_size, TileSet::CellNeighbor p_bit, float p_overlap, TileSet::TileOffsetAxis p_offset_axis);
+ Vector<Point2> _get_half_offset_corner_terrain_bit_polygon(Vector2i p_size, TileSet::CellNeighbor p_bit, float p_overlap, TileSet::TileOffsetAxis p_offset_axis);
+ Vector<Point2> _get_half_offset_side_terrain_bit_polygon(Vector2i p_size, TileSet::CellNeighbor p_bit, float p_overlap, TileSet::TileOffsetAxis p_offset_axis);
+
protected:
static void _bind_methods();
@@ -257,8 +277,6 @@ public:
TileOffsetAxis get_tile_offset_axis() const;
void set_tile_size(Size2i p_size);
Size2i get_tile_size() const;
- void set_tile_skew(Vector2 p_skew);
- Vector2 get_tile_skew() const;
// -- Sources management --
int get_next_source_id() const;
@@ -305,6 +323,7 @@ public:
String get_terrain_name(int p_terrain_set, int p_terrain_index) const;
void set_terrain_color(int p_terrain_set, int p_terrain_index, Color p_color);
Color get_terrain_color(int p_terrain_set, int p_terrain_index) const;
+ bool is_valid_peering_bit_for_mode(TileSet::TerrainMode p_terrain_mode, TileSet::CellNeighbor p_peering_bit) const;
bool is_valid_peering_bit_terrain(int p_terrain_set, TileSet::CellNeighbor p_peering_bit) const;
// Navigation
@@ -323,8 +342,14 @@ public:
Variant::Type get_custom_data_type(int p_layer_id) const;
// Helpers
+ Vector<Vector2> get_tile_shape_polygon();
void draw_tile_shape(CanvasItem *p_canvas_item, Rect2 p_region, Color p_color, bool p_filled = false, Ref<Texture2D> p_texture = Ref<Texture2D>());
+ Vector<Point2> get_terrain_bit_polygon(int p_terrain_set, TileSet::CellNeighbor p_bit);
+ void draw_terrains(CanvasItem *p_canvas_item, Transform2D p_transform, const TileData *p_tile_data);
+ Vector<Vector<Ref<Texture2D>>> generate_terrains_icons(Size2i p_size);
+
+ // Resource management
virtual void reset_state() override;
TileSet();
@@ -509,13 +534,14 @@ private:
// Physics
struct PhysicsLayerTileData {
- struct ShapeTileData {
- Ref<Shape2D> shape = Ref<Shape2D>();
+ struct PolygonShapeTileData {
+ LocalVector<Vector2> polygon;
+ LocalVector<Ref<ConvexPolygonShape2D>> shapes;
bool one_way = false;
float one_way_margin = 1.0;
};
- Vector<ShapeTileData> shapes;
+ Vector<PolygonShapeTileData> polygons;
};
Vector<PhysicsLayerTileData> physics;
// TODO add support for areas.
@@ -570,16 +596,18 @@ public:
Ref<OccluderPolygon2D> get_occluder(int p_layer_id) const;
// Physics
- int get_collision_shapes_count(int p_layer_id) const;
- void set_collision_shapes_count(int p_layer_id, int p_shapes_count);
- void add_collision_shape(int p_layer_id);
- void remove_collision_shape(int p_layer_id, int p_shape_index);
- void set_collision_shape_shape(int p_layer_id, int p_shape_index, Ref<Shape2D> p_shape);
- Ref<Shape2D> get_collision_shape_shape(int p_layer_id, int p_shape_index) const;
- void set_collision_shape_one_way(int p_layer_id, int p_shape_index, bool p_one_way);
- bool is_collision_shape_one_way(int p_layer_id, int p_shape_index) const;
- void set_collision_shape_one_way_margin(int p_layer_id, int p_shape_index, float p_one_way_margin);
- float get_collision_shape_one_way_margin(int p_layer_id, int p_shape_index) const;
+ int get_collision_polygons_count(int p_layer_id) const;
+ void set_collision_polygons_count(int p_layer_id, int p_shapes_count);
+ void add_collision_polygon(int p_layer_id);
+ void remove_collision_polygon(int p_layer_id, int p_polygon_index);
+ void set_collision_polygon_points(int p_layer_id, int p_polygon_index, Vector<Vector2> p_polygon);
+ Vector<Vector2> get_collision_polygon_points(int p_layer_id, int p_polygon_index) const;
+ void set_collision_polygon_one_way(int p_layer_id, int p_polygon_index, bool p_one_way);
+ bool is_collision_polygon_one_way(int p_layer_id, int p_polygon_index) const;
+ void set_collision_polygon_one_way_margin(int p_layer_id, int p_polygon_index, float p_one_way_margin);
+ float get_collision_polygon_one_way_margin(int p_layer_id, int p_polygon_index) const;
+ int get_collision_polygon_shapes_count(int p_layer_id, int p_polygon_index) const;
+ Ref<ConvexPolygonShape2D> get_collision_polygon_shape(int p_layer_id, int p_polygon_index, int shape_index) const;
// Terrain
void set_terrain_set(int p_terrain_id);
@@ -637,26 +665,6 @@ public:
static void draw_tile(RID p_canvas_item, Vector2i p_position, const Ref<TileSet> p_tile_set, int p_atlas_source_id, Vector2i p_atlas_coords, int p_alternative_tile, Color p_modulation = Color(1.0, 1.0, 1.0, 1.0));
};
-class TileSetPluginAtlasTerrain : public TileSetPlugin {
- GDCLASS(TileSetPluginAtlasTerrain, TileSetPlugin);
-
-private:
- static void _draw_square_corner_or_side_terrain_bit(CanvasItem *p_canvas_item, Color p_color, Vector2i p_size, TileSet::CellNeighbor p_bit);
- static void _draw_square_corner_terrain_bit(CanvasItem *p_canvas_item, Color p_color, Vector2i p_size, TileSet::CellNeighbor p_bit);
- static void _draw_square_side_terrain_bit(CanvasItem *p_canvas_item, Color p_color, Vector2i p_size, TileSet::CellNeighbor p_bit);
-
- static void _draw_isometric_corner_or_side_terrain_bit(CanvasItem *p_canvas_item, Color p_color, Vector2i p_size, TileSet::CellNeighbor p_bit);
- static void _draw_isometric_corner_terrain_bit(CanvasItem *p_canvas_item, Color p_color, Vector2i p_size, TileSet::CellNeighbor p_bit);
- static void _draw_isometric_side_terrain_bit(CanvasItem *p_canvas_item, Color p_color, Vector2i p_size, TileSet::CellNeighbor p_bit);
-
- static void _draw_half_offset_corner_or_side_terrain_bit(CanvasItem *p_canvas_item, Color p_color, Vector2i p_size, TileSet::CellNeighbor p_bit, float p_overlap, TileSet::TileOffsetAxis p_offset_axis);
- static void _draw_half_offset_corner_terrain_bit(CanvasItem *p_canvas_item, Color p_color, Vector2i p_size, TileSet::CellNeighbor p_bit, float p_overlap, TileSet::TileOffsetAxis p_offset_axis);
- static void _draw_half_offset_side_terrain_bit(CanvasItem *p_canvas_item, Color p_color, Vector2i p_size, TileSet::CellNeighbor p_bit, float p_overlap, TileSet::TileOffsetAxis p_offset_axis);
-
-public:
- static void draw_terrains(CanvasItem *p_canvas_item, Transform2D p_transform, TileSet *p_tile_set, const TileData *p_tile_data);
-};
-
class TileSetPluginAtlasPhysics : public TileSetPlugin {
GDCLASS(TileSetPluginAtlasPhysics, TileSetPlugin);
diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp
index 5759948fe6..54bc7382db 100644
--- a/scene/resources/visual_shader.cpp
+++ b/scene/resources/visual_shader.cpp
@@ -617,7 +617,7 @@ void VisualShader::replace_node(Type p_type, int p_id, const StringName &p_new_c
if (g->nodes[p_id].node->get_class_name() == p_new_class) {
return;
}
- VisualShaderNode *vsn = Object::cast_to<VisualShaderNode>(ClassDB::instance(p_new_class));
+ VisualShaderNode *vsn = Object::cast_to<VisualShaderNode>(ClassDB::instantiate(p_new_class));
vsn->connect("changed", callable_mp(this, &VisualShader::_queue_update));
g->nodes[p_id].node = Ref<VisualShaderNode>(vsn);
@@ -2020,13 +2020,13 @@ VisualShader::VisualShader() {
for (int i = 0; i < TYPE_MAX; i++) {
if (i > (int)TYPE_LIGHT && i < (int)TYPE_SKY) {
Ref<VisualShaderNodeParticleOutput> output;
- output.instance();
+ output.instantiate();
output->shader_type = Type(i);
output->shader_mode = shader_mode;
graph[i].nodes[NODE_ID_OUTPUT].node = output;
} else {
Ref<VisualShaderNodeOutput> output;
- output.instance();
+ output.instantiate();
output->shader_type = Type(i);
output->shader_mode = shader_mode;
graph[i].nodes[NODE_ID_OUTPUT].node = output;
@@ -2533,6 +2533,14 @@ Vector<StringName> VisualShaderNodeInput::get_editable_properties() const {
return props;
}
+void VisualShaderNodeInput::set_shader_type(VisualShader::Type p_shader_type) {
+ shader_type = p_shader_type;
+}
+
+void VisualShaderNodeInput::set_shader_mode(Shader::Mode p_shader_mode) {
+ shader_mode = p_shader_mode;
+}
+
void VisualShaderNodeInput::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_input_name", "name"), &VisualShaderNodeInput::set_input_name);
ClassDB::bind_method(D_METHOD("get_input_name"), &VisualShaderNodeInput::get_input_name);
diff --git a/scene/resources/visual_shader.h b/scene/resources/visual_shader.h
index 53b165fe0f..454012b7ed 100644
--- a/scene/resources/visual_shader.h
+++ b/scene/resources/visual_shader.h
@@ -350,6 +350,10 @@ class VisualShaderNodeInput : public VisualShaderNode {
String input_name = "[None]";
+public:
+ void set_shader_type(VisualShader::Type p_shader_type);
+ void set_shader_mode(Shader::Mode p_shader_mode);
+
protected:
static void _bind_methods();
void _validate_property(PropertyInfo &property) const override;
diff --git a/scene/resources/world_2d.cpp b/scene/resources/world_2d.cpp
index 8af4deda83..eceb42ee14 100644
--- a/scene/resources/world_2d.cpp
+++ b/scene/resources/world_2d.cpp
@@ -57,10 +57,10 @@ void World2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_direct_space_state"), &World2D::get_direct_space_state);
- ADD_PROPERTY(PropertyInfo(Variant::RID, "canvas", PROPERTY_HINT_NONE, "", 0), "", "get_canvas");
- ADD_PROPERTY(PropertyInfo(Variant::RID, "space", PROPERTY_HINT_NONE, "", 0), "", "get_space");
- ADD_PROPERTY(PropertyInfo(Variant::RID, "navigation_map", PROPERTY_HINT_NONE, "", 0), "", "get_navigation_map");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "direct_space_state", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsDirectSpaceState2D", 0), "", "get_direct_space_state");
+ ADD_PROPERTY(PropertyInfo(Variant::RID, "canvas", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_canvas");
+ ADD_PROPERTY(PropertyInfo(Variant::RID, "space", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_space");
+ ADD_PROPERTY(PropertyInfo(Variant::RID, "navigation_map", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_navigation_map");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "direct_space_state", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsDirectSpaceState2D", PROPERTY_USAGE_NONE), "", "get_direct_space_state");
}
PhysicsDirectSpaceState2D *World2D::get_direct_space_state() {
diff --git a/scene/resources/world_3d.cpp b/scene/resources/world_3d.cpp
index 8d9b1fd6ec..42047f104f 100644
--- a/scene/resources/world_3d.cpp
+++ b/scene/resources/world_3d.cpp
@@ -130,10 +130,10 @@ void World3D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "environment", PROPERTY_HINT_RESOURCE_TYPE, "Environment"), "set_environment", "get_environment");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "fallback_environment", PROPERTY_HINT_RESOURCE_TYPE, "Environment"), "set_fallback_environment", "get_fallback_environment");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "camera_effects", PROPERTY_HINT_RESOURCE_TYPE, "CameraEffects"), "set_camera_effects", "get_camera_effects");
- ADD_PROPERTY(PropertyInfo(Variant::RID, "space", PROPERTY_HINT_NONE, "", 0), "", "get_space");
- ADD_PROPERTY(PropertyInfo(Variant::RID, "navigation_map", PROPERTY_HINT_NONE, "", 0), "", "get_navigation_map");
- ADD_PROPERTY(PropertyInfo(Variant::RID, "scenario", PROPERTY_HINT_NONE, "", 0), "", "get_scenario");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "direct_space_state", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsDirectSpaceState3D", 0), "", "get_direct_space_state");
+ ADD_PROPERTY(PropertyInfo(Variant::RID, "space", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_space");
+ ADD_PROPERTY(PropertyInfo(Variant::RID, "navigation_map", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_navigation_map");
+ ADD_PROPERTY(PropertyInfo(Variant::RID, "scenario", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_scenario");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "direct_space_state", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsDirectSpaceState3D", PROPERTY_USAGE_NONE), "", "get_direct_space_state");
}
World3D::World3D() {
diff --git a/scene/scene_string_names.cpp b/scene/scene_string_names.cpp
index 8acab79c9e..2e0af89c1a 100644
--- a/scene/scene_string_names.cpp
+++ b/scene/scene_string_names.cpp
@@ -103,7 +103,6 @@ SceneStringNames::SceneStringNames() {
_update_scroll = StaticCString::create("_update_scroll");
_update_xform = StaticCString::create("_update_xform");
- _clips_input = StaticCString::create("_clips_input");
_structured_text_parser = StaticCString::create("_structured_text_parser");
_proxgroup_add = StaticCString::create("_proxgroup_add");
diff --git a/scene/scene_string_names.h b/scene/scene_string_names.h
index 0c528a45f7..01865b0d2f 100644
--- a/scene/scene_string_names.h
+++ b/scene/scene_string_names.h
@@ -129,7 +129,6 @@ public:
StringName _update_scroll;
StringName _update_xform;
- StringName _clips_input;
StringName _structured_text_parser;
StringName _proxgroup_add;
diff --git a/servers/audio/audio_effect.h b/servers/audio/audio_effect.h
index 5d14f03199..bea7292b8e 100644
--- a/servers/audio/audio_effect.h
+++ b/servers/audio/audio_effect.h
@@ -46,7 +46,7 @@ class AudioEffect : public Resource {
GDCLASS(AudioEffect, Resource);
public:
- virtual Ref<AudioEffectInstance> instance() = 0;
+ virtual Ref<AudioEffectInstance> instantiate() = 0;
AudioEffect();
};
diff --git a/servers/audio/audio_stream.cpp b/servers/audio/audio_stream.cpp
index ae07f999ed..aec6932326 100644
--- a/servers/audio/audio_stream.cpp
+++ b/servers/audio/audio_stream.cpp
@@ -100,7 +100,7 @@ void AudioStream::_bind_methods() {
Ref<AudioStreamPlayback> AudioStreamMicrophone::instance_playback() {
Ref<AudioStreamPlaybackMicrophone> playback;
- playback.instance();
+ playback.instantiate();
playbacks.insert(playback.ptr());
@@ -256,7 +256,7 @@ float AudioStreamRandomPitch::get_random_pitch() const {
Ref<AudioStreamPlayback> AudioStreamRandomPitch::instance_playback() {
Ref<AudioStreamPlaybackRandomPitch> playback;
- playback.instance();
+ playback.instantiate();
if (audio_stream.is_valid()) {
playback->playback = audio_stream->instance_playback();
}
diff --git a/servers/audio/effects/audio_effect_amplify.cpp b/servers/audio/effects/audio_effect_amplify.cpp
index c5c1174670..79788d334b 100644
--- a/servers/audio/effects/audio_effect_amplify.cpp
+++ b/servers/audio/effects/audio_effect_amplify.cpp
@@ -44,9 +44,9 @@ void AudioEffectAmplifyInstance::process(const AudioFrame *p_src_frames, AudioFr
mix_volume_db = volume_db;
}
-Ref<AudioEffectInstance> AudioEffectAmplify::instance() {
+Ref<AudioEffectInstance> AudioEffectAmplify::instantiate() {
Ref<AudioEffectAmplifyInstance> ins;
- ins.instance();
+ ins.instantiate();
ins->base = Ref<AudioEffectAmplify>(this);
ins->mix_volume_db = volume_db;
return ins;
diff --git a/servers/audio/effects/audio_effect_amplify.h b/servers/audio/effects/audio_effect_amplify.h
index 2ece57854c..9d3facc230 100644
--- a/servers/audio/effects/audio_effect_amplify.h
+++ b/servers/audio/effects/audio_effect_amplify.h
@@ -56,7 +56,7 @@ protected:
static void _bind_methods();
public:
- Ref<AudioEffectInstance> instance() override;
+ Ref<AudioEffectInstance> instantiate() override;
void set_volume_db(float p_volume);
float get_volume_db() const;
diff --git a/servers/audio/effects/audio_effect_capture.cpp b/servers/audio/effects/audio_effect_capture.cpp
index 78837c7531..065065042e 100644
--- a/servers/audio/effects/audio_effect_capture.cpp
+++ b/servers/audio/effects/audio_effect_capture.cpp
@@ -73,7 +73,7 @@ void AudioEffectCapture::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "buffer_length", PROPERTY_HINT_RANGE, "0.01,10,0.01"), "set_buffer_length", "get_buffer_length");
}
-Ref<AudioEffectInstance> AudioEffectCapture::instance() {
+Ref<AudioEffectInstance> AudioEffectCapture::instantiate() {
if (!buffer_initialized) {
float target_buffer_size = AudioServer::get_singleton()->get_mix_rate() * buffer_length_seconds;
ERR_FAIL_COND_V(target_buffer_size <= 0 || target_buffer_size >= (1 << 27), Ref<AudioEffectInstance>());
@@ -84,7 +84,7 @@ Ref<AudioEffectInstance> AudioEffectCapture::instance() {
clear_buffer();
Ref<AudioEffectCaptureInstance> ins;
- ins.instance();
+ ins.instantiate();
ins->base = Ref<AudioEffectCapture>(this);
return ins;
diff --git a/servers/audio/effects/audio_effect_capture.h b/servers/audio/effects/audio_effect_capture.h
index 82686d5b4c..7f50fc4965 100644
--- a/servers/audio/effects/audio_effect_capture.h
+++ b/servers/audio/effects/audio_effect_capture.h
@@ -64,7 +64,7 @@ protected:
static void _bind_methods();
public:
- virtual Ref<AudioEffectInstance> instance() override;
+ virtual Ref<AudioEffectInstance> instantiate() override;
void set_buffer_length(float p_buffer_length_seconds);
float get_buffer_length();
diff --git a/servers/audio/effects/audio_effect_chorus.cpp b/servers/audio/effects/audio_effect_chorus.cpp
index eb2268aa2e..54cd5ed0bf 100644
--- a/servers/audio/effects/audio_effect_chorus.cpp
+++ b/servers/audio/effects/audio_effect_chorus.cpp
@@ -141,9 +141,9 @@ void AudioEffectChorusInstance::_process_chunk(const AudioFrame *p_src_frames, A
buffer_pos += p_frame_count;
}
-Ref<AudioEffectInstance> AudioEffectChorus::instance() {
+Ref<AudioEffectInstance> AudioEffectChorus::instantiate() {
Ref<AudioEffectChorusInstance> ins;
- ins.instance();
+ ins.instantiate();
ins->base = Ref<AudioEffectChorus>(this);
for (int i = 0; i < 4; i++) {
ins->filter_h[i] = AudioFrame(0, 0);
diff --git a/servers/audio/effects/audio_effect_chorus.h b/servers/audio/effects/audio_effect_chorus.h
index f5b023734a..f81bebb0ae 100644
--- a/servers/audio/effects/audio_effect_chorus.h
+++ b/servers/audio/effects/audio_effect_chorus.h
@@ -128,7 +128,7 @@ public:
void set_dry(float amount);
float get_dry() const;
- Ref<AudioEffectInstance> instance() override;
+ Ref<AudioEffectInstance> instantiate() override;
AudioEffectChorus();
};
diff --git a/servers/audio/effects/audio_effect_compressor.cpp b/servers/audio/effects/audio_effect_compressor.cpp
index bb4a90f3d6..cfa2ae6f79 100644
--- a/servers/audio/effects/audio_effect_compressor.cpp
+++ b/servers/audio/effects/audio_effect_compressor.cpp
@@ -112,9 +112,9 @@ void AudioEffectCompressorInstance::process(const AudioFrame *p_src_frames, Audi
}
}
-Ref<AudioEffectInstance> AudioEffectCompressor::instance() {
+Ref<AudioEffectInstance> AudioEffectCompressor::instantiate() {
Ref<AudioEffectCompressorInstance> ins;
- ins.instance();
+ ins.instantiate();
ins->base = Ref<AudioEffectCompressor>(this);
ins->rundb = 0;
ins->runratio = 0;
diff --git a/servers/audio/effects/audio_effect_compressor.h b/servers/audio/effects/audio_effect_compressor.h
index 33c60680fc..dae4618a64 100644
--- a/servers/audio/effects/audio_effect_compressor.h
+++ b/servers/audio/effects/audio_effect_compressor.h
@@ -65,7 +65,7 @@ protected:
static void _bind_methods();
public:
- Ref<AudioEffectInstance> instance() override;
+ Ref<AudioEffectInstance> instantiate() override;
void set_threshold(float p_threshold);
float get_threshold() const;
diff --git a/servers/audio/effects/audio_effect_delay.cpp b/servers/audio/effects/audio_effect_delay.cpp
index ba50eeb0a3..07475e1ed4 100644
--- a/servers/audio/effects/audio_effect_delay.cpp
+++ b/servers/audio/effects/audio_effect_delay.cpp
@@ -111,9 +111,9 @@ void AudioEffectDelayInstance::_process_chunk(const AudioFrame *p_src_frames, Au
}
}
-Ref<AudioEffectInstance> AudioEffectDelay::instance() {
+Ref<AudioEffectInstance> AudioEffectDelay::instantiate() {
Ref<AudioEffectDelayInstance> ins;
- ins.instance();
+ ins.instantiate();
ins->base = Ref<AudioEffectDelay>(this);
float ring_buffer_max_size = MAX_DELAY_MS + 100; //add 100ms of extra room, just in case
diff --git a/servers/audio/effects/audio_effect_delay.h b/servers/audio/effects/audio_effect_delay.h
index ff267d5023..50a2233e5f 100644
--- a/servers/audio/effects/audio_effect_delay.h
+++ b/servers/audio/effects/audio_effect_delay.h
@@ -126,7 +126,7 @@ public:
void set_feedback_lowpass(float p_lowpass);
float get_feedback_lowpass() const;
- Ref<AudioEffectInstance> instance() override;
+ Ref<AudioEffectInstance> instantiate() override;
AudioEffectDelay();
};
diff --git a/servers/audio/effects/audio_effect_distortion.cpp b/servers/audio/effects/audio_effect_distortion.cpp
index 5c076ca3fe..188b7a3301 100644
--- a/servers/audio/effects/audio_effect_distortion.cpp
+++ b/servers/audio/effects/audio_effect_distortion.cpp
@@ -93,9 +93,9 @@ void AudioEffectDistortionInstance::process(const AudioFrame *p_src_frames, Audi
}
}
-Ref<AudioEffectInstance> AudioEffectDistortion::instance() {
+Ref<AudioEffectInstance> AudioEffectDistortion::instantiate() {
Ref<AudioEffectDistortionInstance> ins;
- ins.instance();
+ ins.instantiate();
ins->base = Ref<AudioEffectDistortion>(this);
ins->h[0] = 0;
ins->h[1] = 0;
diff --git a/servers/audio/effects/audio_effect_distortion.h b/servers/audio/effects/audio_effect_distortion.h
index 9da800b79f..3a762f8cf6 100644
--- a/servers/audio/effects/audio_effect_distortion.h
+++ b/servers/audio/effects/audio_effect_distortion.h
@@ -68,7 +68,7 @@ protected:
static void _bind_methods();
public:
- Ref<AudioEffectInstance> instance() override;
+ Ref<AudioEffectInstance> instantiate() override;
void set_mode(Mode p_mode);
Mode get_mode() const;
diff --git a/servers/audio/effects/audio_effect_eq.cpp b/servers/audio/effects/audio_effect_eq.cpp
index 01ac605bd7..e87944b74b 100644
--- a/servers/audio/effects/audio_effect_eq.cpp
+++ b/servers/audio/effects/audio_effect_eq.cpp
@@ -59,9 +59,9 @@ void AudioEffectEQInstance::process(const AudioFrame *p_src_frames, AudioFrame *
}
}
-Ref<AudioEffectInstance> AudioEffectEQ::instance() {
+Ref<AudioEffectInstance> AudioEffectEQ::instantiate() {
Ref<AudioEffectEQInstance> ins;
- ins.instance();
+ ins.instantiate();
ins->base = Ref<AudioEffectEQ>(this);
ins->gains.resize(eq.get_band_count());
for (int i = 0; i < 2; i++) {
diff --git a/servers/audio/effects/audio_effect_eq.h b/servers/audio/effects/audio_effect_eq.h
index 38c63a7d4f..b99727d7c0 100644
--- a/servers/audio/effects/audio_effect_eq.h
+++ b/servers/audio/effects/audio_effect_eq.h
@@ -66,7 +66,7 @@ protected:
static void _bind_methods();
public:
- Ref<AudioEffectInstance> instance() override;
+ Ref<AudioEffectInstance> instantiate() override;
void set_band_gain_db(int p_band, float p_volume);
float get_band_gain_db(int p_band) const;
int get_band_count() const;
diff --git a/servers/audio/effects/audio_effect_filter.cpp b/servers/audio/effects/audio_effect_filter.cpp
index c2d6074825..1db8b1f1b5 100644
--- a/servers/audio/effects/audio_effect_filter.cpp
+++ b/servers/audio/effects/audio_effect_filter.cpp
@@ -100,9 +100,9 @@ AudioEffectFilterInstance::AudioEffectFilterInstance() {
}
}
-Ref<AudioEffectInstance> AudioEffectFilter::instance() {
+Ref<AudioEffectInstance> AudioEffectFilter::instantiate() {
Ref<AudioEffectFilterInstance> ins;
- ins.instance();
+ ins.instantiate();
ins->base = Ref<AudioEffectFilter>(this);
return ins;
diff --git a/servers/audio/effects/audio_effect_filter.h b/servers/audio/effects/audio_effect_filter.h
index 9a48ccf70b..9aab97da29 100644
--- a/servers/audio/effects/audio_effect_filter.h
+++ b/servers/audio/effects/audio_effect_filter.h
@@ -88,7 +88,7 @@ public:
void set_db(FilterDB p_db);
FilterDB get_db() const;
- Ref<AudioEffectInstance> instance() override;
+ Ref<AudioEffectInstance> instantiate() override;
AudioEffectFilter(AudioFilterSW::Mode p_mode = AudioFilterSW::LOWPASS);
};
diff --git a/servers/audio/effects/audio_effect_limiter.cpp b/servers/audio/effects/audio_effect_limiter.cpp
index 1a4b01d947..280411641b 100644
--- a/servers/audio/effects/audio_effect_limiter.cpp
+++ b/servers/audio/effects/audio_effect_limiter.cpp
@@ -67,9 +67,9 @@ void AudioEffectLimiterInstance::process(const AudioFrame *p_src_frames, AudioFr
}
}
-Ref<AudioEffectInstance> AudioEffectLimiter::instance() {
+Ref<AudioEffectInstance> AudioEffectLimiter::instantiate() {
Ref<AudioEffectLimiterInstance> ins;
- ins.instance();
+ ins.instantiate();
ins->base = Ref<AudioEffectLimiter>(this);
return ins;
diff --git a/servers/audio/effects/audio_effect_limiter.h b/servers/audio/effects/audio_effect_limiter.h
index 8f3092c0e2..d5def670a4 100644
--- a/servers/audio/effects/audio_effect_limiter.h
+++ b/servers/audio/effects/audio_effect_limiter.h
@@ -71,7 +71,7 @@ public:
void set_soft_clip_ratio(float p_soft_clip);
float get_soft_clip_ratio() const;
- Ref<AudioEffectInstance> instance() override;
+ Ref<AudioEffectInstance> instantiate() override;
void set_volume_db(float p_volume);
float get_volume_db() const;
diff --git a/servers/audio/effects/audio_effect_panner.cpp b/servers/audio/effects/audio_effect_panner.cpp
index 238e979e13..e2062609b9 100644
--- a/servers/audio/effects/audio_effect_panner.cpp
+++ b/servers/audio/effects/audio_effect_panner.cpp
@@ -40,9 +40,9 @@ void AudioEffectPannerInstance::process(const AudioFrame *p_src_frames, AudioFra
}
}
-Ref<AudioEffectInstance> AudioEffectPanner::instance() {
+Ref<AudioEffectInstance> AudioEffectPanner::instantiate() {
Ref<AudioEffectPannerInstance> ins;
- ins.instance();
+ ins.instantiate();
ins->base = Ref<AudioEffectPanner>(this);
return ins;
}
diff --git a/servers/audio/effects/audio_effect_panner.h b/servers/audio/effects/audio_effect_panner.h
index 0938824c64..d75bcaeb95 100644
--- a/servers/audio/effects/audio_effect_panner.h
+++ b/servers/audio/effects/audio_effect_panner.h
@@ -54,7 +54,7 @@ protected:
static void _bind_methods();
public:
- Ref<AudioEffectInstance> instance() override;
+ Ref<AudioEffectInstance> instantiate() override;
void set_pan(float p_cpanume);
float get_pan() const;
diff --git a/servers/audio/effects/audio_effect_phaser.cpp b/servers/audio/effects/audio_effect_phaser.cpp
index 9b70f03a19..c76692eed7 100644
--- a/servers/audio/effects/audio_effect_phaser.cpp
+++ b/servers/audio/effects/audio_effect_phaser.cpp
@@ -78,9 +78,9 @@ void AudioEffectPhaserInstance::process(const AudioFrame *p_src_frames, AudioFra
}
}
-Ref<AudioEffectInstance> AudioEffectPhaser::instance() {
+Ref<AudioEffectInstance> AudioEffectPhaser::instantiate() {
Ref<AudioEffectPhaserInstance> ins;
- ins.instance();
+ ins.instantiate();
ins->base = Ref<AudioEffectPhaser>(this);
ins->phase = 0;
ins->h = AudioFrame(0, 0);
diff --git a/servers/audio/effects/audio_effect_phaser.h b/servers/audio/effects/audio_effect_phaser.h
index 563927c678..2a0ed64805 100644
--- a/servers/audio/effects/audio_effect_phaser.h
+++ b/servers/audio/effects/audio_effect_phaser.h
@@ -83,7 +83,7 @@ protected:
static void _bind_methods();
public:
- Ref<AudioEffectInstance> instance() override;
+ Ref<AudioEffectInstance> instantiate() override;
void set_range_min_hz(float p_hz);
float get_range_min_hz() const;
diff --git a/servers/audio/effects/audio_effect_pitch_shift.cpp b/servers/audio/effects/audio_effect_pitch_shift.cpp
index 7b0151b9c1..bfbaeee3f3 100644
--- a/servers/audio/effects/audio_effect_pitch_shift.cpp
+++ b/servers/audio/effects/audio_effect_pitch_shift.cpp
@@ -298,9 +298,9 @@ void AudioEffectPitchShiftInstance::process(const AudioFrame *p_src_frames, Audi
shift_r.PitchShift(base->pitch_scale, p_frame_count, fft_size, base->oversampling, sample_rate, in_r, out_r, 2);
}
-Ref<AudioEffectInstance> AudioEffectPitchShift::instance() {
+Ref<AudioEffectInstance> AudioEffectPitchShift::instantiate() {
Ref<AudioEffectPitchShiftInstance> ins;
- ins.instance();
+ ins.instantiate();
ins->base = Ref<AudioEffectPitchShift>(this);
static const int fft_sizes[FFT_SIZE_MAX] = { 256, 512, 1024, 2048, 4096 };
ins->fft_size = fft_sizes[fft_size];
diff --git a/servers/audio/effects/audio_effect_pitch_shift.h b/servers/audio/effects/audio_effect_pitch_shift.h
index 669943fa43..3ed096cd94 100644
--- a/servers/audio/effects/audio_effect_pitch_shift.h
+++ b/servers/audio/effects/audio_effect_pitch_shift.h
@@ -109,7 +109,7 @@ protected:
static void _bind_methods();
public:
- Ref<AudioEffectInstance> instance() override;
+ Ref<AudioEffectInstance> instantiate() override;
void set_pitch_scale(float p_pitch_scale);
float get_pitch_scale() const;
diff --git a/servers/audio/effects/audio_effect_record.cpp b/servers/audio/effects/audio_effect_record.cpp
index 2015ede81f..f71679d30f 100644
--- a/servers/audio/effects/audio_effect_record.cpp
+++ b/servers/audio/effects/audio_effect_record.cpp
@@ -134,9 +134,9 @@ AudioEffectRecordInstance::~AudioEffectRecordInstance() {
finish();
}
-Ref<AudioEffectInstance> AudioEffectRecord::instance() {
+Ref<AudioEffectInstance> AudioEffectRecord::instantiate() {
Ref<AudioEffectRecordInstance> ins;
- ins.instance();
+ ins.instantiate();
ins->base = Ref<AudioEffectRecord>(this);
ins->is_recording = false;
@@ -269,7 +269,7 @@ Ref<AudioStreamSample> AudioEffectRecord::get_recording() const {
}
Ref<AudioStreamSample> sample;
- sample.instance();
+ sample.instantiate();
sample->set_data(dst_data);
sample->set_format(dst_format);
sample->set_mix_rate(AudioServer::get_singleton()->get_mix_rate());
diff --git a/servers/audio/effects/audio_effect_record.h b/servers/audio/effects/audio_effect_record.h
index 8f56e227e0..1a89821f80 100644
--- a/servers/audio/effects/audio_effect_record.h
+++ b/servers/audio/effects/audio_effect_record.h
@@ -96,7 +96,7 @@ protected:
static void debug(uint64_t time_diff, int p_frame_count);
public:
- Ref<AudioEffectInstance> instance() override;
+ Ref<AudioEffectInstance> instantiate() override;
void set_recording_active(bool p_record);
bool is_recording_active() const;
void set_format(AudioStreamSample::Format p_format);
diff --git a/servers/audio/effects/audio_effect_reverb.cpp b/servers/audio/effects/audio_effect_reverb.cpp
index b8d812680e..819f906773 100644
--- a/servers/audio/effects/audio_effect_reverb.cpp
+++ b/servers/audio/effects/audio_effect_reverb.cpp
@@ -79,9 +79,9 @@ AudioEffectReverbInstance::AudioEffectReverbInstance() {
reverb[1].set_extra_spread_base(0.000521); //for stereo effect
}
-Ref<AudioEffectInstance> AudioEffectReverb::instance() {
+Ref<AudioEffectInstance> AudioEffectReverb::instantiate() {
Ref<AudioEffectReverbInstance> ins;
- ins.instance();
+ ins.instantiate();
ins->base = Ref<AudioEffectReverb>(this);
return ins;
}
diff --git a/servers/audio/effects/audio_effect_reverb.h b/servers/audio/effects/audio_effect_reverb.h
index 141ba48e29..d01d1120bd 100644
--- a/servers/audio/effects/audio_effect_reverb.h
+++ b/servers/audio/effects/audio_effect_reverb.h
@@ -89,7 +89,7 @@ public:
float get_wet() const;
float get_hpf() const;
- Ref<AudioEffectInstance> instance() override;
+ Ref<AudioEffectInstance> instantiate() override;
void set_volume_db(float p_volume);
float get_volume_db() const;
diff --git a/servers/audio/effects/audio_effect_spectrum_analyzer.cpp b/servers/audio/effects/audio_effect_spectrum_analyzer.cpp
index 44b7f64d52..6f9e7ac67d 100644
--- a/servers/audio/effects/audio_effect_spectrum_analyzer.cpp
+++ b/servers/audio/effects/audio_effect_spectrum_analyzer.cpp
@@ -207,9 +207,9 @@ Vector2 AudioEffectSpectrumAnalyzerInstance::get_magnitude_for_frequency_range(f
}
}
-Ref<AudioEffectInstance> AudioEffectSpectrumAnalyzer::instance() {
+Ref<AudioEffectInstance> AudioEffectSpectrumAnalyzer::instantiate() {
Ref<AudioEffectSpectrumAnalyzerInstance> ins;
- ins.instance();
+ ins.instantiate();
ins->base = Ref<AudioEffectSpectrumAnalyzer>(this);
static const int fft_sizes[FFT_SIZE_MAX] = { 256, 512, 1024, 2048, 4096 };
ins->fft_size = fft_sizes[fft_size];
diff --git a/servers/audio/effects/audio_effect_spectrum_analyzer.h b/servers/audio/effects/audio_effect_spectrum_analyzer.h
index fc275446f0..3c5ae4a5e8 100644
--- a/servers/audio/effects/audio_effect_spectrum_analyzer.h
+++ b/servers/audio/effects/audio_effect_spectrum_analyzer.h
@@ -90,7 +90,7 @@ protected:
static void _bind_methods();
public:
- Ref<AudioEffectInstance> instance() override;
+ Ref<AudioEffectInstance> instantiate() override;
void set_buffer_length(float p_seconds);
float get_buffer_length() const;
void set_tap_back_pos(float p_seconds);
diff --git a/servers/audio/effects/audio_effect_stereo_enhance.cpp b/servers/audio/effects/audio_effect_stereo_enhance.cpp
index dfdf154aa4..3a016b06b8 100644
--- a/servers/audio/effects/audio_effect_stereo_enhance.cpp
+++ b/servers/audio/effects/audio_effect_stereo_enhance.cpp
@@ -74,9 +74,9 @@ AudioEffectStereoEnhanceInstance::~AudioEffectStereoEnhanceInstance() {
memdelete_arr(delay_ringbuff);
}
-Ref<AudioEffectInstance> AudioEffectStereoEnhance::instance() {
+Ref<AudioEffectInstance> AudioEffectStereoEnhance::instantiate() {
Ref<AudioEffectStereoEnhanceInstance> ins;
- ins.instance();
+ ins.instantiate();
ins->base = Ref<AudioEffectStereoEnhance>(this);
diff --git a/servers/audio/effects/audio_effect_stereo_enhance.h b/servers/audio/effects/audio_effect_stereo_enhance.h
index f99256470b..e0f9d79a94 100644
--- a/servers/audio/effects/audio_effect_stereo_enhance.h
+++ b/servers/audio/effects/audio_effect_stereo_enhance.h
@@ -68,7 +68,7 @@ protected:
static void _bind_methods();
public:
- Ref<AudioEffectInstance> instance() override;
+ Ref<AudioEffectInstance> instantiate() override;
void set_pan_pullout(float p_amount);
float get_pan_pullout() const;
diff --git a/servers/audio/effects/audio_stream_generator.cpp b/servers/audio/effects/audio_stream_generator.cpp
index d1a05ccf2a..bced2997ce 100644
--- a/servers/audio/effects/audio_stream_generator.cpp
+++ b/servers/audio/effects/audio_stream_generator.cpp
@@ -48,7 +48,7 @@ float AudioStreamGenerator::get_buffer_length() const {
Ref<AudioStreamPlayback> AudioStreamGenerator::instance_playback() {
Ref<AudioStreamGeneratorPlayback> playback;
- playback.instance();
+ playback.instantiate();
playback->generator = this;
int target_buffer_size = mix_rate * buffer_len;
playback->buffer.resize(nearest_shift(target_buffer_size));
diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp
index acfdfa783a..667087d1ec 100644
--- a/servers/audio_server.cpp
+++ b/servers/audio_server.cpp
@@ -794,7 +794,7 @@ void AudioServer::_update_bus_effects(int p_bus) {
for (int i = 0; i < buses[p_bus]->channels.size(); i++) {
buses.write[p_bus]->channels.write[i].effect_instances.resize(buses[p_bus]->effects.size());
for (int j = 0; j < buses[p_bus]->effects.size(); j++) {
- Ref<AudioEffectInstance> fx = buses.write[p_bus]->effects.write[j].effect->instance();
+ Ref<AudioEffectInstance> fx = buses.write[p_bus]->effects.write[j].effect->instantiate();
if (Object::cast_to<AudioEffectCompressorInstance>(*fx)) {
Object::cast_to<AudioEffectCompressorInstance>(*fx)->set_current_channel(i);
}
@@ -813,7 +813,7 @@ void AudioServer::add_bus_effect(int p_bus, const Ref<AudioEffect> &p_effect, in
Bus::Effect fx;
fx.effect = p_effect;
- //fx.instance=p_effect->instance();
+ //fx.instance=p_effect->instantiate();
fx.enabled = true;
#ifdef DEBUG_ENABLED
fx.prof_time = 0;
@@ -1188,7 +1188,7 @@ void AudioServer::set_bus_layout(const Ref<AudioBusLayout> &p_bus_layout) {
Ref<AudioBusLayout> AudioServer::generate_bus_layout() const {
Ref<AudioBusLayout> state;
- state.instance();
+ state.instantiate();
state->buses.resize(buses.size());
diff --git a/servers/display_server.cpp b/servers/display_server.cpp
index ded4b849ef..d746117884 100644
--- a/servers/display_server.cpp
+++ b/servers/display_server.cpp
@@ -148,8 +148,8 @@ Point2i DisplayServer::mouse_get_position() const {
ERR_FAIL_V_MSG(Point2i(), "Mouse is not supported by this display server.");
}
-int DisplayServer::mouse_get_button_state() const {
- ERR_FAIL_V_MSG(0, "Mouse is not supported by this display server.");
+MouseButton DisplayServer::mouse_get_button_state() const {
+ ERR_FAIL_V_MSG(MOUSE_BUTTON_NONE, "Mouse is not supported by this display server.");
}
void DisplayServer::clipboard_set(const String &p_text) {
diff --git a/servers/display_server.h b/servers/display_server.h
index b8201f6fd5..7dab7b7481 100644
--- a/servers/display_server.h
+++ b/servers/display_server.h
@@ -152,7 +152,7 @@ public:
virtual void mouse_warp_to_position(const Point2i &p_to);
virtual Point2i mouse_get_position() const;
virtual Point2i mouse_get_absolute_position() const;
- virtual int mouse_get_button_state() const;
+ virtual MouseButton mouse_get_button_state() const;
virtual void clipboard_set(const String &p_text);
virtual String clipboard_get() const;
diff --git a/servers/register_server_types.cpp b/servers/register_server_types.cpp
index deb230c4fb..59c7dcc7d2 100644
--- a/servers/register_server_types.cpp
+++ b/servers/register_server_types.cpp
@@ -55,6 +55,7 @@
#include "audio_server.h"
#include "camera/camera_feed.h"
#include "camera_server.h"
+#include "core/extension/native_extension_manager.h"
#include "display_server.h"
#include "navigation_server_2d.h"
#include "navigation_server_3d.h"
@@ -194,6 +195,7 @@ void register_server_types() {
ClassDB::register_class<RDTextureFormat>();
ClassDB::register_class<RDTextureView>();
ClassDB::register_class<RDAttachmentFormat>();
+ ClassDB::register_class<RDFramebufferPass>();
ClassDB::register_class<RDSamplerState>();
ClassDB::register_class<RDVertexAttribute>();
ClassDB::register_class<RDUniform>();
@@ -232,22 +234,26 @@ void register_server_types() {
PhysicsServer3DManager::register_server("GodotPhysics3D", &_createGodotPhysics3DCallback);
PhysicsServer3DManager::set_default_server("GodotPhysics3D");
+
+ NativeExtensionManager::get_singleton()->initialize_extensions(NativeExtension::INITIALIZATION_LEVEL_SERVERS);
}
void unregister_server_types() {
+ NativeExtensionManager::get_singleton()->deinitialize_extensions(NativeExtension::INITIALIZATION_LEVEL_SERVERS);
+
memdelete(shader_types);
TextServer::finish_hex_code_box_fonts();
}
void register_server_singletons() {
- Engine::get_singleton()->add_singleton(Engine::Singleton("DisplayServer", DisplayServer::get_singleton()));
- Engine::get_singleton()->add_singleton(Engine::Singleton("RenderingServer", RenderingServer::get_singleton()));
- Engine::get_singleton()->add_singleton(Engine::Singleton("AudioServer", AudioServer::get_singleton()));
- Engine::get_singleton()->add_singleton(Engine::Singleton("PhysicsServer2D", PhysicsServer2D::get_singleton()));
- Engine::get_singleton()->add_singleton(Engine::Singleton("PhysicsServer3D", PhysicsServer3D::get_singleton()));
- Engine::get_singleton()->add_singleton(Engine::Singleton("NavigationServer2D", NavigationServer2D::get_singleton_mut()));
- Engine::get_singleton()->add_singleton(Engine::Singleton("NavigationServer3D", NavigationServer3D::get_singleton_mut()));
- Engine::get_singleton()->add_singleton(Engine::Singleton("TextServerManager", TextServerManager::get_singleton()));
- Engine::get_singleton()->add_singleton(Engine::Singleton("XRServer", XRServer::get_singleton()));
- Engine::get_singleton()->add_singleton(Engine::Singleton("CameraServer", CameraServer::get_singleton()));
+ Engine::get_singleton()->add_singleton(Engine::Singleton("DisplayServer", DisplayServer::get_singleton(), "DisplayServer"));
+ Engine::get_singleton()->add_singleton(Engine::Singleton("RenderingServer", RenderingServer::get_singleton(), "RenderingServer"));
+ Engine::get_singleton()->add_singleton(Engine::Singleton("AudioServer", AudioServer::get_singleton(), "AudioServer"));
+ Engine::get_singleton()->add_singleton(Engine::Singleton("PhysicsServer2D", PhysicsServer2D::get_singleton(), "PhysicsServer2D"));
+ Engine::get_singleton()->add_singleton(Engine::Singleton("PhysicsServer3D", PhysicsServer3D::get_singleton(), "PhysicsServer3D"));
+ Engine::get_singleton()->add_singleton(Engine::Singleton("NavigationServer2D", NavigationServer2D::get_singleton_mut(), "NavigationServer2D"));
+ Engine::get_singleton()->add_singleton(Engine::Singleton("NavigationServer3D", NavigationServer3D::get_singleton_mut(), "NavigationServer3D"));
+ Engine::get_singleton()->add_singleton(Engine::Singleton("TextServerManager", TextServerManager::get_singleton(), "TextServerManager"));
+ Engine::get_singleton()->add_singleton(Engine::Singleton("XRServer", XRServer::get_singleton(), "XRServer"));
+ Engine::get_singleton()->add_singleton(Engine::Singleton("CameraServer", CameraServer::get_singleton(), "CameraServer"));
}
diff --git a/servers/rendering/renderer_rd/effects_rd.cpp b/servers/rendering/renderer_rd/effects_rd.cpp
index 4fd5520e56..4290e0d574 100644
--- a/servers/rendering/renderer_rd/effects_rd.cpp
+++ b/servers/rendering/renderer_rd/effects_rd.cpp
@@ -37,21 +37,6 @@
#include "servers/rendering/renderer_rd/renderer_compositor_rd.h"
#include "thirdparty/misc/cubemap_coeffs.h"
-static _FORCE_INLINE_ void store_transform_3x3(const Basis &p_basis, float *p_array) {
- p_array[0] = p_basis.elements[0][0];
- p_array[1] = p_basis.elements[1][0];
- p_array[2] = p_basis.elements[2][0];
- p_array[3] = 0;
- p_array[4] = p_basis.elements[0][1];
- p_array[5] = p_basis.elements[1][1];
- p_array[6] = p_basis.elements[2][1];
- p_array[7] = 0;
- p_array[8] = p_basis.elements[0][2];
- p_array[9] = p_basis.elements[1][2];
- p_array[10] = p_basis.elements[2][2];
- p_array[11] = 0;
-}
-
static _FORCE_INLINE_ void store_camera(const CameraMatrix &p_mtx, float *p_array) {
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
@@ -1371,45 +1356,6 @@ void EffectsRD::cubemap_filter(RID p_source_cubemap, Vector<RID> p_dest_cubemap,
RD::get_singleton()->compute_list_end();
}
-void EffectsRD::render_sky(RD::DrawListID p_list, float p_time, RID p_fb, RID p_samplers, RID p_fog, PipelineCacheRD *p_pipeline, RID p_uniform_set, RID p_texture_set, uint32_t p_view_count, const CameraMatrix *p_projections, const Basis &p_orientation, float p_multiplier, const Vector3 &p_position) {
- SkyPushConstant sky_push_constant;
-
- memset(&sky_push_constant, 0, sizeof(SkyPushConstant));
-
- for (uint32_t v = 0; v < p_view_count; v++) {
- // We only need key components of our projection matrix
- sky_push_constant.projections[v][0] = p_projections[v].matrix[2][0];
- sky_push_constant.projections[v][1] = p_projections[v].matrix[0][0];
- sky_push_constant.projections[v][2] = p_projections[v].matrix[2][1];
- sky_push_constant.projections[v][3] = p_projections[v].matrix[1][1];
- }
- sky_push_constant.position[0] = p_position.x;
- sky_push_constant.position[1] = p_position.y;
- sky_push_constant.position[2] = p_position.z;
- sky_push_constant.multiplier = p_multiplier;
- sky_push_constant.time = p_time;
- store_transform_3x3(p_orientation, sky_push_constant.orientation);
-
- RenderingDevice::FramebufferFormatID fb_format = RD::get_singleton()->framebuffer_get_format(p_fb);
-
- RD::DrawListID draw_list = p_list;
-
- RD::get_singleton()->draw_list_bind_render_pipeline(draw_list, p_pipeline->get_render_pipeline(RD::INVALID_ID, fb_format));
-
- RD::get_singleton()->draw_list_bind_uniform_set(draw_list, p_samplers, 0);
- if (p_uniform_set.is_valid()) { //material may not have uniform set
- RD::get_singleton()->draw_list_bind_uniform_set(draw_list, p_uniform_set, 1);
- }
- RD::get_singleton()->draw_list_bind_uniform_set(draw_list, p_texture_set, 2);
- RD::get_singleton()->draw_list_bind_uniform_set(draw_list, p_fog, 3);
-
- RD::get_singleton()->draw_list_bind_index_array(draw_list, index_array);
-
- RD::get_singleton()->draw_list_set_push_constant(draw_list, &sky_push_constant, sizeof(SkyPushConstant));
-
- RD::get_singleton()->draw_list_draw(draw_list, true);
-}
-
void EffectsRD::resolve_gi(RID p_source_depth, RID p_source_normal_roughness, RID p_source_voxel_gi, RID p_dest_depth, RID p_dest_normal_roughness, RID p_dest_voxel_gi, Vector2i p_screen_size, int p_samples, uint32_t p_barrier) {
ResolvePushConstant push_constant;
push_constant.screen_size[0] = p_screen_size.x;
diff --git a/servers/rendering/renderer_rd/effects_rd.h b/servers/rendering/renderer_rd/effects_rd.h
index 8b31ffbbd0..b4ddd400a8 100644
--- a/servers/rendering/renderer_rd/effects_rd.h
+++ b/servers/rendering/renderer_rd/effects_rd.h
@@ -456,15 +456,6 @@ class EffectsRD {
} filter;
- struct SkyPushConstant {
- float orientation[12]; // 48 - 48
- float projections[RendererSceneRender::MAX_RENDER_VIEWS][4]; // 2 x 16 - 64, if we ever need more then 3 we should consider adding this to a set.
- float position[3]; // 12 - 92
- float multiplier; // 4 - 96
- float time; // 4 - 100
- float pad[3]; // 12 - 112
- };
-
enum SpecularMergeMode {
SPECULAR_MERGE_ADD,
SPECULAR_MERGE_SSR,
@@ -749,7 +740,6 @@ public:
void roughness_limit(RID p_source_normal, RID p_roughness, const Size2i &p_size, float p_curve);
void cubemap_downsample(RID p_source_cubemap, RID p_dest_cubemap, const Size2i &p_size);
void cubemap_filter(RID p_source_cubemap, Vector<RID> p_dest_cubemap, bool p_use_array);
- void render_sky(RD::DrawListID p_list, float p_time, RID p_fb, RID p_samplers, RID p_fog, PipelineCacheRD *p_pipeline, RID p_uniform_set, RID p_texture_set, uint32_t p_view_count, const CameraMatrix *p_projections, const Basis &p_orientation, float p_multiplier, const Vector3 &p_position);
void screen_space_reflection(RID p_diffuse, RID p_normal_roughness, RS::EnvironmentSSRRoughnessQuality p_roughness_quality, RID p_blur_radius, RID p_blur_radius2, RID p_metallic, const Color &p_metallic_mask, RID p_depth, RID p_scale_depth, RID p_scale_normal, RID p_output, RID p_output_blur, const Size2i &p_screen_size, int p_max_steps, float p_fade_in, float p_fade_out, float p_tolerance, const CameraMatrix &p_camera);
void merge_specular(RID p_dest_framebuffer, RID p_specular, RID p_base, RID p_reflection);
diff --git a/servers/rendering/renderer_rd/pipeline_cache_rd.cpp b/servers/rendering/renderer_rd/pipeline_cache_rd.cpp
index b2b919c40e..22888ddbe5 100644
--- a/servers/rendering/renderer_rd/pipeline_cache_rd.cpp
+++ b/servers/rendering/renderer_rd/pipeline_cache_rd.cpp
@@ -31,20 +31,21 @@
#include "pipeline_cache_rd.h"
#include "core/os/memory.h"
-RID PipelineCacheRD::_generate_version(RD::VertexFormatID p_vertex_format_id, RD::FramebufferFormatID p_framebuffer_format_id, bool p_wireframe) {
+RID PipelineCacheRD::_generate_version(RD::VertexFormatID p_vertex_format_id, RD::FramebufferFormatID p_framebuffer_format_id, bool p_wireframe, uint32_t p_render_pass) {
RD::PipelineMultisampleState multisample_state_version = multisample_state;
- multisample_state_version.sample_count = RD::get_singleton()->framebuffer_format_get_texture_samples(p_framebuffer_format_id);
+ multisample_state_version.sample_count = RD::get_singleton()->framebuffer_format_get_texture_samples(p_framebuffer_format_id, p_render_pass);
RD::PipelineRasterizationState raster_state_version = rasterization_state;
raster_state_version.wireframe = p_wireframe;
- RID pipeline = RD::get_singleton()->render_pipeline_create(shader, p_framebuffer_format_id, p_vertex_format_id, render_primitive, raster_state_version, multisample_state_version, depth_stencil_state, blend_state, dynamic_state_flags);
+ RID pipeline = RD::get_singleton()->render_pipeline_create(shader, p_framebuffer_format_id, p_vertex_format_id, render_primitive, raster_state_version, multisample_state_version, depth_stencil_state, blend_state, dynamic_state_flags, p_render_pass);
ERR_FAIL_COND_V(pipeline.is_null(), RID());
versions = (Version *)memrealloc(versions, sizeof(Version) * (version_count + 1));
versions[version_count].framebuffer_id = p_framebuffer_format_id;
versions[version_count].vertex_id = p_vertex_format_id;
versions[version_count].wireframe = p_wireframe;
versions[version_count].pipeline = pipeline;
+ versions[version_count].render_pass = p_render_pass;
version_count++;
return pipeline;
}
diff --git a/servers/rendering/renderer_rd/pipeline_cache_rd.h b/servers/rendering/renderer_rd/pipeline_cache_rd.h
index b1c8f21ecc..387a8a038f 100644
--- a/servers/rendering/renderer_rd/pipeline_cache_rd.h
+++ b/servers/rendering/renderer_rd/pipeline_cache_rd.h
@@ -50,6 +50,7 @@ class PipelineCacheRD {
struct Version {
RD::VertexFormatID vertex_id;
RD::FramebufferFormatID framebuffer_id;
+ uint32_t render_pass;
bool wireframe;
RID pipeline;
};
@@ -57,7 +58,7 @@ class PipelineCacheRD {
Version *versions;
uint32_t version_count;
- RID _generate_version(RD::VertexFormatID p_vertex_format_id, RD::FramebufferFormatID p_framebuffer_format_id, bool p_wireframe);
+ RID _generate_version(RD::VertexFormatID p_vertex_format_id, RD::FramebufferFormatID p_framebuffer_format_id, bool p_wireframe, uint32_t p_render_pass);
void _clear();
@@ -65,7 +66,7 @@ public:
void setup(RID p_shader, RD::RenderPrimitive p_primitive, const RD::PipelineRasterizationState &p_rasterization_state, RD::PipelineMultisampleState p_multisample, const RD::PipelineDepthStencilState &p_depth_stencil_state, const RD::PipelineColorBlendState &p_blend_state, int p_dynamic_state_flags = 0);
void update_shader(RID p_shader);
- _FORCE_INLINE_ RID get_render_pipeline(RD::VertexFormatID p_vertex_format_id, RD::FramebufferFormatID p_framebuffer_format_id, bool p_wireframe = false) {
+ _FORCE_INLINE_ RID get_render_pipeline(RD::VertexFormatID p_vertex_format_id, RD::FramebufferFormatID p_framebuffer_format_id, bool p_wireframe = false, uint32_t p_render_pass = 0) {
#ifdef DEBUG_ENABLED
ERR_FAIL_COND_V_MSG(shader.is_null(), RID(),
"Attempted to use an unused shader variant (shader is null),");
@@ -74,13 +75,13 @@ public:
spin_lock.lock();
RID result;
for (uint32_t i = 0; i < version_count; i++) {
- if (versions[i].vertex_id == p_vertex_format_id && versions[i].framebuffer_id == p_framebuffer_format_id && versions[i].wireframe == p_wireframe) {
+ if (versions[i].vertex_id == p_vertex_format_id && versions[i].framebuffer_id == p_framebuffer_format_id && versions[i].wireframe == p_wireframe && versions[i].render_pass == p_render_pass) {
result = versions[i].pipeline;
spin_lock.unlock();
return result;
}
}
- result = _generate_version(p_vertex_format_id, p_framebuffer_format_id, p_wireframe);
+ result = _generate_version(p_vertex_format_id, p_framebuffer_format_id, p_wireframe, p_render_pass);
spin_lock.unlock();
return result;
}
diff --git a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp
index fe6d3be82e..026969c09f 100644
--- a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp
@@ -408,6 +408,7 @@ void RendererCanvasRenderRD::_render_item(RD::DrawListID p_draw_list, RID p_rend
PushConstant push_constant;
Transform2D base_transform = p_canvas_transform_inverse * p_item->final_transform;
+ Transform2D draw_transform;
_update_transform_2d_to_mat2x3(base_transform, push_constant.world);
Color base_color = p_item->final_modulate;
@@ -731,7 +732,7 @@ void RendererCanvasRenderRD::_render_item(RD::DrawListID p_draw_list, RID p_rend
mesh_instance = m->mesh_instance;
texture = m->texture;
modulate = m->modulate;
- _update_transform_2d_to_mat2x3(base_transform * m->transform, push_constant.world);
+ _update_transform_2d_to_mat2x3(base_transform * draw_transform * m->transform, push_constant.world);
} else if (c->type == Item::Command::TYPE_MULTIMESH) {
const Item::CommandMultiMesh *mm = static_cast<const Item::CommandMultiMesh *>(c);
RID multimesh = mm->multimesh;
@@ -864,10 +865,10 @@ void RendererCanvasRenderRD::_render_item(RD::DrawListID p_draw_list, RID p_rend
for (int j = 0; j < 6; j++) {
push_constant.world[j] = world_backup[j];
}
-
} break;
case Item::Command::TYPE_TRANSFORM: {
const Item::CommandTransform *transform = static_cast<const Item::CommandTransform *>(c);
+ draw_transform = transform->xform;
_update_transform_2d_to_mat2x3(base_transform * transform->xform, push_constant.world);
} break;
diff --git a/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp
index 43a4058ab6..be1642998c 100644
--- a/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp
@@ -1862,7 +1862,7 @@ void RendererSceneGIRD::SDFGI::render_region(RID p_render_buffers, int p_region,
#if 0
Vector<uint8_t> data = RD::get_singleton()->texture_get_data(cascades[cascade].sdf, 0);
Ref<Image> img;
- img.instance();
+ img.instantiate();
for (uint32_t i = 0; i < cascade_size; i++) {
Vector<uint8_t> subarr = data.subarray(128 * 128 * i, 128 * 128 * (i + 1) - 1);
img->create(cascade_size, cascade_size, false, Image::FORMAT_L8, subarr);
@@ -1875,7 +1875,7 @@ void RendererSceneGIRD::SDFGI::render_region(RID p_render_buffers, int p_region,
#if 0
Vector<uint8_t> data = RD::get_singleton()->texture_get_data(render_albedo, 0);
Ref<Image> img;
- img.instance();
+ img.instantiate();
for (uint32_t i = 0; i < cascade_size; i++) {
Vector<uint8_t> subarr = data.subarray(128 * 128 * i * 2, 128 * 128 * (i + 1) * 2 - 1);
img->createcascade_size, cascade_size, false, Image::FORMAT_RGB565, subarr);
diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp
index be98fb42c0..089651cbfb 100644
--- a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp
@@ -486,7 +486,7 @@ Ref<Image> RendererSceneRenderRD::environment_bake_panorama(RID p_env, bool p_ba
color.b *= env->bg_energy;
Ref<Image> ret;
- ret.instance();
+ ret.instantiate();
ret->create(p_size.width, p_size.height, false, Image::FORMAT_RGBAF);
for (int i = 0; i < p_size.width; i++) {
for (int j = 0; j < p_size.height; j++) {
@@ -4174,7 +4174,7 @@ TypedArray<Image> RendererSceneRenderRD::bake_render_uv2(RID p_base, const Vecto
{
PackedByteArray data = RD::get_singleton()->texture_get_data(albedo_alpha_tex, 0);
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create(p_image_size.width, p_image_size.height, false, Image::FORMAT_RGBA8, data);
RD::get_singleton()->free(albedo_alpha_tex);
ret.push_back(img);
@@ -4183,7 +4183,7 @@ TypedArray<Image> RendererSceneRenderRD::bake_render_uv2(RID p_base, const Vecto
{
PackedByteArray data = RD::get_singleton()->texture_get_data(normal_tex, 0);
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create(p_image_size.width, p_image_size.height, false, Image::FORMAT_RGBA8, data);
RD::get_singleton()->free(normal_tex);
ret.push_back(img);
@@ -4192,7 +4192,7 @@ TypedArray<Image> RendererSceneRenderRD::bake_render_uv2(RID p_base, const Vecto
{
PackedByteArray data = RD::get_singleton()->texture_get_data(orm_tex, 0);
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create(p_image_size.width, p_image_size.height, false, Image::FORMAT_RGBA8, data);
RD::get_singleton()->free(orm_tex);
ret.push_back(img);
@@ -4201,7 +4201,7 @@ TypedArray<Image> RendererSceneRenderRD::bake_render_uv2(RID p_base, const Vecto
{
PackedByteArray data = RD::get_singleton()->texture_get_data(emission_tex, 0);
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create(p_image_size.width, p_image_size.height, false, Image::FORMAT_RGBAH, data);
RD::get_singleton()->free(emission_tex);
ret.push_back(img);
diff --git a/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp
index 1aa01dd16e..956609b77e 100644
--- a/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp
@@ -323,6 +323,63 @@ RendererSceneSkyRD::SkyMaterialData::~SkyMaterialData() {
}
////////////////////////////////////////////////////////////////////////////////
+// Render sky
+
+static _FORCE_INLINE_ void store_transform_3x3(const Basis &p_basis, float *p_array) {
+ p_array[0] = p_basis.elements[0][0];
+ p_array[1] = p_basis.elements[1][0];
+ p_array[2] = p_basis.elements[2][0];
+ p_array[3] = 0;
+ p_array[4] = p_basis.elements[0][1];
+ p_array[5] = p_basis.elements[1][1];
+ p_array[6] = p_basis.elements[2][1];
+ p_array[7] = 0;
+ p_array[8] = p_basis.elements[0][2];
+ p_array[9] = p_basis.elements[1][2];
+ p_array[10] = p_basis.elements[2][2];
+ p_array[11] = 0;
+}
+
+void RendererSceneSkyRD::_render_sky(RD::DrawListID p_list, float p_time, RID p_fb, PipelineCacheRD *p_pipeline, RID p_uniform_set, RID p_texture_set, uint32_t p_view_count, const CameraMatrix *p_projections, const Basis &p_orientation, float p_multiplier, const Vector3 &p_position) {
+ SkyPushConstant sky_push_constant;
+
+ memset(&sky_push_constant, 0, sizeof(SkyPushConstant));
+
+ for (uint32_t v = 0; v < p_view_count; v++) {
+ // We only need key components of our projection matrix
+ sky_push_constant.projections[v][0] = p_projections[v].matrix[2][0];
+ sky_push_constant.projections[v][1] = p_projections[v].matrix[0][0];
+ sky_push_constant.projections[v][2] = p_projections[v].matrix[2][1];
+ sky_push_constant.projections[v][3] = p_projections[v].matrix[1][1];
+ }
+ sky_push_constant.position[0] = p_position.x;
+ sky_push_constant.position[1] = p_position.y;
+ sky_push_constant.position[2] = p_position.z;
+ sky_push_constant.multiplier = p_multiplier;
+ sky_push_constant.time = p_time;
+ store_transform_3x3(p_orientation, sky_push_constant.orientation);
+
+ RenderingDevice::FramebufferFormatID fb_format = RD::get_singleton()->framebuffer_get_format(p_fb);
+
+ RD::DrawListID draw_list = p_list;
+
+ RD::get_singleton()->draw_list_bind_render_pipeline(draw_list, p_pipeline->get_render_pipeline(RD::INVALID_ID, fb_format));
+
+ RD::get_singleton()->draw_list_bind_uniform_set(draw_list, sky_scene_state.uniform_set, 0);
+ if (p_uniform_set.is_valid()) { //material may not have uniform set
+ RD::get_singleton()->draw_list_bind_uniform_set(draw_list, p_uniform_set, 1);
+ }
+ RD::get_singleton()->draw_list_bind_uniform_set(draw_list, p_texture_set, 2);
+ RD::get_singleton()->draw_list_bind_uniform_set(draw_list, sky_scene_state.fog_uniform_set, 3);
+
+ RD::get_singleton()->draw_list_bind_index_array(draw_list, index_array);
+
+ RD::get_singleton()->draw_list_set_push_constant(draw_list, &sky_push_constant, sizeof(SkyPushConstant));
+
+ RD::get_singleton()->draw_list_draw(draw_list, true);
+}
+
+////////////////////////////////////////////////////////////////////////////////
// ReflectionData
void RendererSceneSkyRD::ReflectionData::clear_reflection_data() {
@@ -628,7 +685,7 @@ Ref<Image> RendererSceneSkyRD::Sky::bake_panorama(RendererStorageRD *p_storage,
RD::get_singleton()->free(rad_tex);
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create(p_size.width, p_size.height, false, Image::FORMAT_RGBAF, data);
for (int i = 0; i < p_size.width; i++) {
for (int j = 0; j < p_size.height; j++) {
@@ -892,6 +949,41 @@ void RendererSceneSkyRD::init(RendererStorageRD *p_storage) {
sky_scene_state.fog_only_texture_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, sky_shader.default_shader_rd, SKY_SET_TEXTURES);
}
+
+ { //create index array for copy shaders
+ Vector<uint8_t> pv;
+ pv.resize(6 * 4);
+ {
+ uint8_t *w = pv.ptrw();
+ int *p32 = (int *)w;
+ p32[0] = 0;
+ p32[1] = 1;
+ p32[2] = 2;
+ p32[3] = 0;
+ p32[4] = 2;
+ p32[5] = 3;
+ }
+ index_buffer = RD::get_singleton()->index_buffer_create(6, RenderingDevice::INDEX_BUFFER_FORMAT_UINT32, pv);
+ index_array = RD::get_singleton()->index_array_create(index_buffer, 0, 6);
+ }
+}
+
+RendererSceneSkyRD::~RendererSceneSkyRD() {
+ // TODO cleanup anything created in init...
+
+ if (RD::get_singleton()->uniform_set_is_valid(sky_scene_state.uniform_set)) {
+ RD::get_singleton()->free(sky_scene_state.uniform_set);
+ }
+
+ if (RD::get_singleton()->uniform_set_is_valid(sky_scene_state.default_fog_uniform_set)) {
+ RD::get_singleton()->free(sky_scene_state.default_fog_uniform_set);
+ }
+
+ if (RD::get_singleton()->uniform_set_is_valid(sky_scene_state.fog_only_texture_uniform_set)) {
+ RD::get_singleton()->free(sky_scene_state.fog_only_texture_uniform_set);
+ }
+
+ RD::get_singleton()->free(index_buffer); //array gets freed as dependency
}
void RendererSceneSkyRD::setup(RendererSceneEnvironmentRD *p_env, RID p_render_buffers, const CameraMatrix &p_projection, const Transform3D &p_transform, const Size2i p_screen_size, RendererSceneRenderRD *p_scene_render) {
@@ -1156,7 +1248,7 @@ void RendererSceneSkyRD::update(RendererSceneEnvironmentRD *p_env, const CameraM
RID texture_uniform_set = sky->get_textures(storage, SKY_TEXTURE_SET_CUBEMAP_QUARTER_RES, sky_shader.default_shader_rd);
cubemap_draw_list = RD::get_singleton()->draw_list_begin(sky->reflection.layers[0].mipmaps[2].framebuffers[i], RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_DISCARD);
- storage->get_effects()->render_sky(cubemap_draw_list, p_time, sky->reflection.layers[0].mipmaps[2].framebuffers[i], sky_scene_state.uniform_set, sky_scene_state.fog_uniform_set, pipeline, material->uniform_set, texture_uniform_set, 1, &cm, local_view.basis, multiplier, p_transform.origin);
+ _render_sky(cubemap_draw_list, p_time, sky->reflection.layers[0].mipmaps[2].framebuffers[i], pipeline, material->uniform_set, texture_uniform_set, 1, &cm, local_view.basis, multiplier, p_transform.origin);
RD::get_singleton()->draw_list_end();
}
}
@@ -1174,7 +1266,7 @@ void RendererSceneSkyRD::update(RendererSceneEnvironmentRD *p_env, const CameraM
RID texture_uniform_set = sky->get_textures(storage, SKY_TEXTURE_SET_CUBEMAP_HALF_RES, sky_shader.default_shader_rd);
cubemap_draw_list = RD::get_singleton()->draw_list_begin(sky->reflection.layers[0].mipmaps[1].framebuffers[i], RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_DISCARD);
- storage->get_effects()->render_sky(cubemap_draw_list, p_time, sky->reflection.layers[0].mipmaps[1].framebuffers[i], sky_scene_state.uniform_set, sky_scene_state.fog_uniform_set, pipeline, material->uniform_set, texture_uniform_set, 1, &cm, local_view.basis, multiplier, p_transform.origin);
+ _render_sky(cubemap_draw_list, p_time, sky->reflection.layers[0].mipmaps[1].framebuffers[i], pipeline, material->uniform_set, texture_uniform_set, 1, &cm, local_view.basis, multiplier, p_transform.origin);
RD::get_singleton()->draw_list_end();
}
}
@@ -1188,7 +1280,7 @@ void RendererSceneSkyRD::update(RendererSceneEnvironmentRD *p_env, const CameraM
RID texture_uniform_set = sky->get_textures(storage, SKY_TEXTURE_SET_CUBEMAP, sky_shader.default_shader_rd);
cubemap_draw_list = RD::get_singleton()->draw_list_begin(sky->reflection.layers[0].mipmaps[0].framebuffers[i], RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_DISCARD);
- storage->get_effects()->render_sky(cubemap_draw_list, p_time, sky->reflection.layers[0].mipmaps[0].framebuffers[i], sky_scene_state.uniform_set, sky_scene_state.fog_uniform_set, pipeline, material->uniform_set, texture_uniform_set, 1, &cm, local_view.basis, multiplier, p_transform.origin);
+ _render_sky(cubemap_draw_list, p_time, sky->reflection.layers[0].mipmaps[0].framebuffers[i], pipeline, material->uniform_set, texture_uniform_set, 1, &cm, local_view.basis, multiplier, p_transform.origin);
RD::get_singleton()->draw_list_end();
}
@@ -1305,7 +1397,7 @@ void RendererSceneSkyRD::draw(RendererSceneEnvironmentRD *p_env, bool p_can_cont
clear_colors.push_back(Color(0.0, 0.0, 0.0));
RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(sky->quarter_res_framebuffer, RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_DISCARD, clear_colors);
- storage->get_effects()->render_sky(draw_list, p_time, sky->quarter_res_framebuffer, sky_scene_state.uniform_set, sky_scene_state.fog_uniform_set, pipeline, material->uniform_set, texture_uniform_set, view_count, projections, sky_transform, multiplier, p_transform.origin);
+ _render_sky(draw_list, p_time, sky->quarter_res_framebuffer, pipeline, material->uniform_set, texture_uniform_set, view_count, projections, sky_transform, multiplier, p_transform.origin);
RD::get_singleton()->draw_list_end();
}
@@ -1318,7 +1410,7 @@ void RendererSceneSkyRD::draw(RendererSceneEnvironmentRD *p_env, bool p_can_cont
clear_colors.push_back(Color(0.0, 0.0, 0.0));
RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(sky->half_res_framebuffer, RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_DISCARD, clear_colors);
- storage->get_effects()->render_sky(draw_list, p_time, sky->half_res_framebuffer, sky_scene_state.uniform_set, sky_scene_state.fog_uniform_set, pipeline, material->uniform_set, texture_uniform_set, view_count, projections, sky_transform, multiplier, p_transform.origin);
+ _render_sky(draw_list, p_time, sky->half_res_framebuffer, pipeline, material->uniform_set, texture_uniform_set, view_count, projections, sky_transform, multiplier, p_transform.origin);
RD::get_singleton()->draw_list_end();
}
@@ -1332,7 +1424,7 @@ void RendererSceneSkyRD::draw(RendererSceneEnvironmentRD *p_env, bool p_can_cont
}
RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(p_fb, RD::INITIAL_ACTION_CONTINUE, p_can_continue_color ? RD::FINAL_ACTION_CONTINUE : RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_CONTINUE, p_can_continue_depth ? RD::FINAL_ACTION_CONTINUE : RD::FINAL_ACTION_READ);
- storage->get_effects()->render_sky(draw_list, p_time, p_fb, sky_scene_state.uniform_set, sky_scene_state.fog_uniform_set, pipeline, material->uniform_set, texture_uniform_set, view_count, projections, sky_transform, multiplier, p_transform.origin);
+ _render_sky(draw_list, p_time, p_fb, pipeline, material->uniform_set, texture_uniform_set, view_count, projections, sky_transform, multiplier, p_transform.origin);
RD::get_singleton()->draw_list_end();
}
diff --git a/servers/rendering/renderer_rd/renderer_scene_sky_rd.h b/servers/rendering/renderer_rd/renderer_scene_sky_rd.h
index 200902bff2..1292622fca 100644
--- a/servers/rendering/renderer_rd/renderer_scene_sky_rd.h
+++ b/servers/rendering/renderer_rd/renderer_scene_sky_rd.h
@@ -43,9 +43,6 @@
class RendererSceneRenderRD;
class RendererSceneSkyRD {
-private:
- RendererStorageRD *storage;
-
public:
enum SkySet {
SKY_SET_UNIFORMS,
@@ -55,6 +52,22 @@ public:
SKY_SET_MAX
};
+ // Skys need less info from Directional Lights than the normal shaders
+ struct SkyDirectionalLightData {
+ float direction[3];
+ float energy;
+ float color[3];
+ float size;
+ uint32_t enabled;
+ uint32_t pad[3];
+ };
+
+private:
+ RendererStorageRD *storage;
+
+ RID index_buffer;
+ RID index_array;
+
enum SkyTextureSetVersion {
SKY_TEXTURE_SET_BACKGROUND,
SKY_TEXTURE_SET_HALF_RES,
@@ -80,16 +93,53 @@ public:
SKY_VERSION_MAX
};
- // Skys need less info from Directional Lights than the normal shaders
- struct SkyDirectionalLightData {
- float direction[3];
- float energy;
- float color[3];
- float size;
- uint32_t enabled;
- uint32_t pad[3];
+ struct SkyPushConstant {
+ float orientation[12]; // 48 - 48
+ float projections[RendererSceneRender::MAX_RENDER_VIEWS][4]; // 2 x 16 - 80
+ float position[3]; // 12 - 92
+ float multiplier; // 4 - 96
+ float time; // 4 - 100
+ float pad[3]; // 12 - 112 // Using pad to align on 16 bytes
+ // 128 is the max size of a push constant. We can replace "pad" but we can't add any more.
+ };
+
+ struct SkyShaderData : public RendererStorageRD::ShaderData {
+ bool valid;
+ RID version;
+
+ PipelineCacheRD pipelines[SKY_VERSION_MAX];
+ Map<StringName, ShaderLanguage::ShaderNode::Uniform> uniforms;
+ Vector<ShaderCompilerRD::GeneratedCode::Texture> texture_uniforms;
+
+ Vector<uint32_t> ubo_offsets;
+ uint32_t ubo_size;
+
+ String path;
+ String code;
+ Map<StringName, RID> default_texture_params;
+
+ bool uses_time;
+ bool uses_position;
+ bool uses_half_res;
+ bool uses_quarter_res;
+ bool uses_light;
+
+ virtual void set_code(const String &p_Code);
+ virtual void set_default_texture_param(const StringName &p_name, RID p_texture);
+ virtual void get_param_list(List<PropertyInfo> *p_param_list) const;
+ virtual void get_instance_param_list(List<RendererStorage::InstanceShaderParam> *p_param_list) const;
+ virtual bool is_param_texture(const StringName &p_param) const;
+ virtual bool is_animated() const;
+ virtual bool casts_shadows() const;
+ virtual Variant get_default_parameter(const StringName &p_parameter) const;
+ virtual RS::ShaderNativeSourceCode get_native_source_code() const;
+ SkyShaderData();
+ virtual ~SkyShaderData();
};
+ void _render_sky(RD::DrawListID p_list, float p_time, RID p_fb, PipelineCacheRD *p_pipeline, RID p_uniform_set, RID p_texture_set, uint32_t p_view_count, const CameraMatrix *p_projections, const Basis &p_orientation, float p_multiplier, const Vector3 &p_position);
+
+public:
struct SkySceneState {
struct UBO {
uint32_t volumetric_fog_enabled;
@@ -160,40 +210,6 @@ public:
void update_reflection_mipmaps(RendererStorageRD *p_storage, int p_start, int p_end);
};
- struct SkyShaderData : public RendererStorageRD::ShaderData {
- bool valid;
- RID version;
-
- PipelineCacheRD pipelines[SKY_VERSION_MAX];
- Map<StringName, ShaderLanguage::ShaderNode::Uniform> uniforms;
- Vector<ShaderCompilerRD::GeneratedCode::Texture> texture_uniforms;
-
- Vector<uint32_t> ubo_offsets;
- uint32_t ubo_size;
-
- String path;
- String code;
- Map<StringName, RID> default_texture_params;
-
- bool uses_time;
- bool uses_position;
- bool uses_half_res;
- bool uses_quarter_res;
- bool uses_light;
-
- virtual void set_code(const String &p_Code);
- virtual void set_default_texture_param(const StringName &p_name, RID p_texture);
- virtual void get_param_list(List<PropertyInfo> *p_param_list) const;
- virtual void get_instance_param_list(List<RendererStorage::InstanceShaderParam> *p_param_list) const;
- virtual bool is_param_texture(const StringName &p_param) const;
- virtual bool is_animated() const;
- virtual bool casts_shadows() const;
- virtual Variant get_default_parameter(const StringName &p_parameter) const;
- virtual RS::ShaderNativeSourceCode get_native_source_code() const;
- SkyShaderData();
- virtual ~SkyShaderData();
- };
-
/* Sky shader */
struct SkyShader {
@@ -270,8 +286,8 @@ public:
static RendererStorageRD::MaterialData *_create_sky_material_funcs(RendererStorageRD::ShaderData *p_shader);
RendererSceneSkyRD();
-
void init(RendererStorageRD *p_storage);
+ ~RendererSceneSkyRD();
void setup(RendererSceneEnvironmentRD *p_env, RID p_render_buffers, const CameraMatrix &p_projection, const Transform3D &p_transform, const Size2i p_screen_size, RendererSceneRenderRD *p_scene_render);
void update(RendererSceneEnvironmentRD *p_env, const CameraMatrix &p_projection, const Transform3D &p_transform, double p_time);
diff --git a/servers/rendering/renderer_rd/renderer_storage_rd.cpp b/servers/rendering/renderer_rd/renderer_storage_rd.cpp
index 246b5f0e4c..b95647b8b7 100644
--- a/servers/rendering/renderer_rd/renderer_storage_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_storage_rd.cpp
@@ -972,7 +972,7 @@ void RendererStorageRD::texture_2d_placeholder_initialize(RID p_texture) {
//this could be better optimized to reuse an existing image , done this way
//for now to get it working
Ref<Image> image;
- image.instance();
+ image.instantiate();
image->create(4, 4, false, Image::FORMAT_RGBA8);
for (int i = 0; i < 4; i++) {
@@ -988,7 +988,7 @@ void RendererStorageRD::texture_2d_layered_placeholder_initialize(RID p_texture,
//this could be better optimized to reuse an existing image , done this way
//for now to get it working
Ref<Image> image;
- image.instance();
+ image.instantiate();
image->create(4, 4, false, Image::FORMAT_RGBA8);
for (int i = 0; i < 4; i++) {
@@ -1014,7 +1014,7 @@ void RendererStorageRD::texture_3d_placeholder_initialize(RID p_texture) {
//this could be better optimized to reuse an existing image , done this way
//for now to get it working
Ref<Image> image;
- image.instance();
+ image.instantiate();
image->create(4, 4, false, Image::FORMAT_RGBA8);
for (int i = 0; i < 4; i++) {
@@ -1044,7 +1044,7 @@ Ref<Image> RendererStorageRD::texture_2d_get(RID p_texture) const {
Vector<uint8_t> data = RD::get_singleton()->texture_get_data(tex->rd_texture, 0);
ERR_FAIL_COND_V(data.size() == 0, Ref<Image>());
Ref<Image> image;
- image.instance();
+ image.instantiate();
image->create(tex->width, tex->height, tex->mipmaps > 1, tex->validated_format, data);
ERR_FAIL_COND_V(image->is_empty(), Ref<Image>());
if (tex->format != tex->validated_format) {
@@ -1067,7 +1067,7 @@ Ref<Image> RendererStorageRD::texture_2d_layer_get(RID p_texture, int p_layer) c
Vector<uint8_t> data = RD::get_singleton()->texture_get_data(tex->rd_texture, p_layer);
ERR_FAIL_COND_V(data.size() == 0, Ref<Image>());
Ref<Image> image;
- image.instance();
+ image.instantiate();
image->create(tex->width, tex->height, tex->mipmaps > 1, tex->validated_format, data);
ERR_FAIL_COND_V(image->is_empty(), Ref<Image>());
if (tex->format != tex->validated_format) {
@@ -1095,7 +1095,7 @@ Vector<Ref<Image>> RendererStorageRD::texture_3d_get(RID p_texture) const {
Vector<uint8_t> sub_region = all_data.subarray(bs.offset, bs.offset + bs.buffer_size - 1);
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create(bs.size.width, bs.size.height, false, tex->validated_format, sub_region);
ERR_FAIL_COND_V(img->is_empty(), Vector<Ref<Image>>());
if (tex->format != tex->validated_format) {
diff --git a/servers/rendering/renderer_rd/shaders/canvas.glsl b/servers/rendering/renderer_rd/shaders/canvas.glsl
index 2186bd174b..a443bcdcb8 100644
--- a/servers/rendering/renderer_rd/shaders/canvas.glsl
+++ b/servers/rendering/renderer_rd/shaders/canvas.glsl
@@ -65,7 +65,7 @@ void main() {
#elif defined(USE_ATTRIBUTES)
vec2 vertex = vertex_attrib;
- vec4 color = color_attrib;
+ vec4 color = color_attrib * draw_data.modulation;
vec2 uv = uv_attrib;
uvec4 bones = bone_attrib;
diff --git a/servers/rendering/renderer_scene_cull.cpp b/servers/rendering/renderer_scene_cull.cpp
index 60c7dbf3b7..e0d0ce76be 100644
--- a/servers/rendering/renderer_scene_cull.cpp
+++ b/servers/rendering/renderer_scene_cull.cpp
@@ -2578,10 +2578,10 @@ void RendererSceneCull::_scene_cull(CullData &cull_data, InstanceCullResult &cul
#define HIDDEN_BY_VISIBILITY_CHECKS (visibility_flags == InstanceData::FLAG_VISIBILITY_DEPENDENCY_HIDDEN_CLOSE_RANGE || visibility_flags == InstanceData::FLAG_VISIBILITY_DEPENDENCY_HIDDEN)
#define LAYER_CHECK (cull_data.visible_layers & idata.layer_mask)
#define IN_FRUSTUM(f) (cull_data.scenario->instance_aabbs[i].in_frustum(f))
-#define VIS_RANGE_CHECK ((idata.visibility_index == -1) || _visibility_range_check(cull_data.scenario->instance_visibility[idata.visibility_index], cull_data.cam_transform.origin, cull_data.visibility_cull_data->viewport_mask) == 0)
+#define VIS_RANGE_CHECK ((idata.visibility_index == -1) || _visibility_range_check(cull_data.scenario->instance_visibility[idata.visibility_index], cull_data.cam_transform.origin, cull_data.visibility_viewport_mask) == 0)
#define VIS_PARENT_CHECK ((idata.parent_array_index == -1) || ((cull_data.scenario->instance_data[idata.parent_array_index].flags & InstanceData::FLAG_VISIBILITY_DEPENDENCY_NEEDS_CHECK) == InstanceData::FLAG_VISIBILITY_DEPENDENCY_HIDDEN_CLOSE_RANGE))
#define VIS_CHECK (visibility_check < 0 ? (visibility_check = (visibility_flags != InstanceData::FLAG_VISIBILITY_DEPENDENCY_NEEDS_CHECK || (VIS_RANGE_CHECK && VIS_PARENT_CHECK))) : visibility_check)
-#define OCCLUSION_CULLED (cull_data.occlusion_buffer != nullptr && cull_data.scenario->instance_data[i].flags & InstanceData::FLAG_IGNORE_OCCLUSION_CULLING && cull_data.occlusion_buffer->is_occluded(cull_data.scenario->instance_aabbs[i].bounds, cull_data.cam_transform.origin, inv_cam_transform, *cull_data.camera_matrix, z_near))
+#define OCCLUSION_CULLED (cull_data.occlusion_buffer != nullptr && (cull_data.scenario->instance_data[i].flags & InstanceData::FLAG_IGNORE_OCCLUSION_CULLING) == 0 && cull_data.occlusion_buffer->is_occluded(cull_data.scenario->instance_aabbs[i].bounds, cull_data.cam_transform.origin, inv_cam_transform, *cull_data.camera_matrix, z_near))
if (!HIDDEN_BY_VISIBILITY_CHECKS) {
if (LAYER_CHECK && IN_FRUSTUM(cull_data.cull->frustum) && VIS_CHECK && !OCCLUSION_CULLED) {
@@ -2808,12 +2808,12 @@ void RendererSceneCull::_render_scene(const RendererSceneRender::CameraData *p_c
RENDER_TIMESTAMP("Visibility Dependencies");
- VisibilityCullData visibility_cull_data;
if (scenario->instance_visibility.get_bin_count() > 0) {
if (!scenario->viewport_visibility_masks.has(p_viewport)) {
scenario_add_viewport_visibility_mask(scenario->self, p_viewport);
}
+ VisibilityCullData visibility_cull_data;
visibility_cull_data.scenario = scenario;
visibility_cull_data.viewport_mask = scenario->viewport_visibility_masks[p_viewport];
visibility_cull_data.camera_position = p_camera_data->main_transform.origin;
@@ -2924,6 +2924,7 @@ void RendererSceneCull::_render_scene(const RendererSceneRender::CameraData *p_c
cull_data.render_reflection_probe = render_reflection_probe;
cull_data.occlusion_buffer = RendererSceneOcclusionCull::get_singleton()->buffer_get_ptr(p_viewport);
cull_data.camera_matrix = &p_camera_data->main_projection;
+ cull_data.visibility_viewport_mask = scenario->viewport_visibility_masks.has(p_viewport) ? scenario->viewport_visibility_masks[p_viewport] : 0;
//#define DEBUG_CULL_TIME
#ifdef DEBUG_CULL_TIME
uint64_t time_from = OS::get_singleton()->get_ticks_usec();
diff --git a/servers/rendering/renderer_scene_cull.h b/servers/rendering/renderer_scene_cull.h
index d9466d8b04..652d322731 100644
--- a/servers/rendering/renderer_scene_cull.h
+++ b/servers/rendering/renderer_scene_cull.h
@@ -1016,7 +1016,7 @@ public:
Instance *render_reflection_probe;
const RendererSceneOcclusionCull::HZBuffer *occlusion_buffer;
const CameraMatrix *camera_matrix;
- const VisibilityCullData *visibility_cull_data;
+ uint64_t visibility_viewport_mask;
};
void _scene_cull_threaded(uint32_t p_thread, CullData *cull_data);
diff --git a/servers/rendering/renderer_scene_occlusion_cull.cpp b/servers/rendering/renderer_scene_occlusion_cull.cpp
index c491ccbe7a..54795f32a7 100644
--- a/servers/rendering/renderer_scene_occlusion_cull.cpp
+++ b/servers/rendering/renderer_scene_occlusion_cull.cpp
@@ -172,7 +172,7 @@ RID RendererSceneOcclusionCull::HZBuffer::get_debug_texture() {
}
if (debug_image.is_null()) {
- debug_image.instance();
+ debug_image.instantiate();
}
unsigned char *ptrw = debug_data.ptrw();
diff --git a/servers/rendering/renderer_scene_render.cpp b/servers/rendering/renderer_scene_render.cpp
index 3aa97f4084..3a230ac89d 100644
--- a/servers/rendering/renderer_scene_render.cpp
+++ b/servers/rendering/renderer_scene_render.cpp
@@ -175,7 +175,7 @@ void RendererSceneRender::CameraData::set_multiview_camera(uint32_t p_view_count
/////////////////////////////////////////////////////////////////////////////
// 3. Copy our view data
for (uint32_t v = 0; v < view_count; v++) {
- view_offset[v] = p_transforms[v] * main_transform_inv;
- view_projection[v] = p_projections[v] * CameraMatrix(view_offset[v]);
+ view_offset[v] = main_transform_inv * p_transforms[v];
+ view_projection[v] = p_projections[v] * CameraMatrix(view_offset[v].inverse());
}
}
diff --git a/servers/rendering/rendering_device.cpp b/servers/rendering/rendering_device.cpp
index 056cec4c1f..c52d97a3de 100644
--- a/servers/rendering/rendering_device.cpp
+++ b/servers/rendering/rendering_device.cpp
@@ -98,7 +98,7 @@ RID RenderingDevice::_texture_create_shared_from_slice(const Ref<RDTextureView>
return texture_create_shared_from_slice(p_view->base, p_with_texture, p_layer, p_mipmap, p_slice_type);
}
-RenderingDevice::FramebufferFormatID RenderingDevice::_framebuffer_format_create(const TypedArray<RDAttachmentFormat> &p_attachments) {
+RenderingDevice::FramebufferFormatID RenderingDevice::_framebuffer_format_create(const TypedArray<RDAttachmentFormat> &p_attachments, uint32_t p_view_count) {
Vector<AttachmentFormat> attachments;
attachments.resize(p_attachments.size());
@@ -107,12 +107,43 @@ RenderingDevice::FramebufferFormatID RenderingDevice::_framebuffer_format_create
ERR_FAIL_COND_V(af.is_null(), INVALID_FORMAT_ID);
attachments.write[i] = af->base;
}
- return framebuffer_format_create(attachments);
+ return framebuffer_format_create(attachments, p_view_count);
}
-RID RenderingDevice::_framebuffer_create(const Array &p_textures, FramebufferFormatID p_format_check) {
+RenderingDevice::FramebufferFormatID RenderingDevice::_framebuffer_format_create_multipass(const TypedArray<RDAttachmentFormat> &p_attachments, const TypedArray<RDFramebufferPass> &p_passes, uint32_t p_view_count) {
+ Vector<AttachmentFormat> attachments;
+ attachments.resize(p_attachments.size());
+
+ for (int i = 0; i < p_attachments.size(); i++) {
+ Ref<RDAttachmentFormat> af = p_attachments[i];
+ ERR_FAIL_COND_V(af.is_null(), INVALID_FORMAT_ID);
+ attachments.write[i] = af->base;
+ }
+
+ Vector<FramebufferPass> passes;
+ for (int i = 0; i < p_passes.size(); i++) {
+ Ref<RDFramebufferPass> pass = p_passes[i];
+ ERR_CONTINUE(pass.is_null());
+ passes.push_back(pass->base);
+ }
+
+ return framebuffer_format_create_multipass(attachments, passes, p_view_count);
+}
+
+RID RenderingDevice::_framebuffer_create(const TypedArray<RID> &p_textures, FramebufferFormatID p_format_check, uint32_t p_view_count) {
Vector<RID> textures = Variant(p_textures);
- return framebuffer_create(textures, p_format_check);
+ return framebuffer_create(textures, p_format_check, p_view_count);
+}
+
+RID RenderingDevice::_framebuffer_create_multipass(const TypedArray<RID> &p_textures, const TypedArray<RDFramebufferPass> &p_passes, FramebufferFormatID p_format_check, uint32_t p_view_count) {
+ Vector<RID> textures = Variant(p_textures);
+ Vector<FramebufferPass> passes;
+ for (int i = 0; i < p_passes.size(); i++) {
+ Ref<RDFramebufferPass> pass = p_passes[i];
+ ERR_CONTINUE(pass.is_null());
+ passes.push_back(pass->base);
+ }
+ return framebuffer_create_multipass(textures, passes, p_format_check, p_view_count);
}
RID RenderingDevice::_sampler_create(const Ref<RDSamplerState> &p_state) {
@@ -143,7 +174,7 @@ Ref<RDShaderBytecode> RenderingDevice::_shader_compile_from_source(const Ref<RDS
ERR_FAIL_COND_V(p_source.is_null(), Ref<RDShaderBytecode>());
Ref<RDShaderBytecode> bytecode;
- bytecode.instance();
+ bytecode.instantiate();
for (int i = 0; i < RD::SHADER_STAGE_MAX; i++) {
String error;
@@ -190,7 +221,7 @@ Error RenderingDevice::_buffer_update(RID p_buffer, uint32_t p_offset, uint32_t
return buffer_update(p_buffer, p_offset, p_size, p_data.ptr(), p_post_barrier);
}
-RID RenderingDevice::_render_pipeline_create(RID p_shader, FramebufferFormatID p_framebuffer_format, VertexFormatID p_vertex_format, RenderPrimitive p_render_primitive, const Ref<RDPipelineRasterizationState> &p_rasterization_state, const Ref<RDPipelineMultisampleState> &p_multisample_state, const Ref<RDPipelineDepthStencilState> &p_depth_stencil_state, const Ref<RDPipelineColorBlendState> &p_blend_state, int p_dynamic_state_flags) {
+RID RenderingDevice::_render_pipeline_create(RID p_shader, FramebufferFormatID p_framebuffer_format, VertexFormatID p_vertex_format, RenderPrimitive p_render_primitive, const Ref<RDPipelineRasterizationState> &p_rasterization_state, const Ref<RDPipelineMultisampleState> &p_multisample_state, const Ref<RDPipelineDepthStencilState> &p_depth_stencil_state, const Ref<RDPipelineColorBlendState> &p_blend_state, int p_dynamic_state_flags, uint32_t p_for_render_pass) {
PipelineRasterizationState rasterization_state;
if (p_rasterization_state.is_valid()) {
rasterization_state = p_rasterization_state->base;
@@ -221,7 +252,7 @@ RID RenderingDevice::_render_pipeline_create(RID p_shader, FramebufferFormatID p
}
}
- return render_pipeline_create(p_shader, p_framebuffer_format, p_vertex_format, p_render_primitive, rasterization_state, multisample_state, depth_stencil_state, color_blend_state, p_dynamic_state_flags);
+ return render_pipeline_create(p_shader, p_framebuffer_format, p_vertex_format, p_render_primitive, rasterization_state, multisample_state, depth_stencil_state, color_blend_state, p_dynamic_state_flags, p_for_render_pass);
}
Vector<int64_t> RenderingDevice::_draw_list_begin_split(RID p_framebuffer, uint32_t p_splits, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, const Vector<Color> &p_clear_color_values, float p_clear_depth, uint32_t p_clear_stencil, const Rect2 &p_region, const TypedArray<RID> &p_storage_textures) {
@@ -242,6 +273,22 @@ Vector<int64_t> RenderingDevice::_draw_list_begin_split(RID p_framebuffer, uint3
return split_ids;
}
+Vector<int64_t> RenderingDevice::_draw_list_switch_to_next_pass_split(uint32_t p_splits) {
+ Vector<DrawListID> splits;
+ splits.resize(p_splits);
+
+ Error err = draw_list_switch_to_next_pass_split(p_splits, splits.ptrw());
+ ERR_FAIL_COND_V(err != OK, Vector<int64_t>());
+
+ Vector<int64_t> split_ids;
+ split_ids.resize(splits.size());
+ for (int i = 0; i < splits.size(); i++) {
+ split_ids.write[i] = splits[i];
+ }
+
+ return split_ids;
+}
+
void RenderingDevice::_draw_list_set_push_constant(DrawListID p_list, const Vector<uint8_t> &p_data, uint32_t p_data_size) {
ERR_FAIL_COND((uint32_t)p_data.size() > p_data_size);
draw_list_set_push_constant(p_list, p_data.ptr(), p_data_size);
@@ -269,10 +316,12 @@ void RenderingDevice::_bind_methods() {
ClassDB::bind_method(D_METHOD("texture_clear", "texture", "color", "base_mipmap", "mipmap_count", "base_layer", "layer_count", "post_barrier"), &RenderingDevice::texture_clear, DEFVAL(BARRIER_MASK_ALL));
ClassDB::bind_method(D_METHOD("texture_resolve_multisample", "from_texture", "to_texture", "post_barrier"), &RenderingDevice::texture_resolve_multisample, DEFVAL(BARRIER_MASK_ALL));
- ClassDB::bind_method(D_METHOD("framebuffer_format_create", "attachments"), &RenderingDevice::_framebuffer_format_create);
+ ClassDB::bind_method(D_METHOD("framebuffer_format_create", "attachments", "view_count"), &RenderingDevice::_framebuffer_format_create, DEFVAL(1));
+ ClassDB::bind_method(D_METHOD("framebuffer_format_create_multipass", "attachments", "passes", "view_count"), &RenderingDevice::_framebuffer_format_create_multipass, DEFVAL(1));
ClassDB::bind_method(D_METHOD("framebuffer_format_create_empty", "samples"), &RenderingDevice::framebuffer_format_create_empty, DEFVAL(TEXTURE_SAMPLES_1));
- ClassDB::bind_method(D_METHOD("framebuffer_format_get_texture_samples", "format"), &RenderingDevice::framebuffer_format_get_texture_samples);
- ClassDB::bind_method(D_METHOD("framebuffer_create", "textures", "validate_with_format"), &RenderingDevice::_framebuffer_create, DEFVAL(INVALID_FORMAT_ID));
+ ClassDB::bind_method(D_METHOD("framebuffer_format_get_texture_samples", "format", "render_pass"), &RenderingDevice::framebuffer_format_get_texture_samples, DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("framebuffer_create", "textures", "validate_with_format", "view_count"), &RenderingDevice::_framebuffer_create, DEFVAL(INVALID_FORMAT_ID), DEFVAL(1));
+ ClassDB::bind_method(D_METHOD("framebuffer_create_multipass", "textures", "passes", "validate_with_format", "view_count"), &RenderingDevice::_framebuffer_create_multipass, DEFVAL(INVALID_FORMAT_ID), DEFVAL(1));
ClassDB::bind_method(D_METHOD("framebuffer_create_empty", "size", "samples", "validate_with_format"), &RenderingDevice::framebuffer_create_empty, DEFVAL(TEXTURE_SAMPLES_1), DEFVAL(INVALID_FORMAT_ID));
ClassDB::bind_method(D_METHOD("framebuffer_get_format", "framebuffer"), &RenderingDevice::framebuffer_get_format);
@@ -299,7 +348,7 @@ void RenderingDevice::_bind_methods() {
ClassDB::bind_method(D_METHOD("buffer_clear", "buffer", "offset", "size_bytes", "post_barrier"), &RenderingDevice::buffer_clear, DEFVAL(BARRIER_MASK_ALL));
ClassDB::bind_method(D_METHOD("buffer_get_data", "buffer"), &RenderingDevice::buffer_get_data);
- ClassDB::bind_method(D_METHOD("render_pipeline_create", "shader", "framebuffer_format", "vertex_format", "primitive", "rasterization_state", "multisample_state", "stencil_state", "color_blend_state", "dynamic_state_flags"), &RenderingDevice::_render_pipeline_create, DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("render_pipeline_create", "shader", "framebuffer_format", "vertex_format", "primitive", "rasterization_state", "multisample_state", "stencil_state", "color_blend_state", "dynamic_state_flags", "for_render_pass"), &RenderingDevice::_render_pipeline_create, DEFVAL(0), DEFVAL(0));
ClassDB::bind_method(D_METHOD("render_pipeline_is_valid", "render_pipeline"), &RenderingDevice::render_pipeline_is_valid);
ClassDB::bind_method(D_METHOD("compute_pipeline_create", "shader"), &RenderingDevice::compute_pipeline_create);
@@ -325,6 +374,9 @@ void RenderingDevice::_bind_methods() {
ClassDB::bind_method(D_METHOD("draw_list_enable_scissor", "draw_list", "rect"), &RenderingDevice::draw_list_enable_scissor, DEFVAL(Rect2i()));
ClassDB::bind_method(D_METHOD("draw_list_disable_scissor", "draw_list"), &RenderingDevice::draw_list_disable_scissor);
+ ClassDB::bind_method(D_METHOD("draw_list_switch_to_next_pass"), &RenderingDevice::draw_list_switch_to_next_pass);
+ ClassDB::bind_method(D_METHOD("draw_list_switch_to_next_pass_split", "splits"), &RenderingDevice::_draw_list_switch_to_next_pass_split);
+
ClassDB::bind_method(D_METHOD("draw_list_end", "post_barrier"), &RenderingDevice::draw_list_end, DEFVAL(BARRIER_MASK_ALL));
ClassDB::bind_method(D_METHOD("compute_list_begin", "allow_draw_overlap"), &RenderingDevice::compute_list_begin, DEFVAL(false));
diff --git a/servers/rendering/rendering_device.h b/servers/rendering/rendering_device.h
index c13dc01dd7..be7e127491 100644
--- a/servers/rendering/rendering_device.h
+++ b/servers/rendering/rendering_device.h
@@ -47,6 +47,7 @@ class RDPipelineRasterizationState;
class RDPipelineMultisampleState;
class RDPipelineDepthStencilState;
class RDPipelineColorBlendState;
+class RDFramebufferPass;
class RenderingDevice : public Object {
GDCLASS(RenderingDevice, Object)
@@ -517,10 +518,23 @@ public:
// This ID is warranted to be unique for the same formats, does not need to be freed
virtual FramebufferFormatID framebuffer_format_create(const Vector<AttachmentFormat> &p_format, uint32_t p_view_count = 1) = 0;
+ struct FramebufferPass {
+ enum {
+ ATTACHMENT_UNUSED = -1
+ };
+ Vector<int32_t> color_attachments;
+ Vector<int32_t> input_attachments;
+ Vector<int32_t> resolve_attachments;
+ Vector<int32_t> preserve_attachments;
+ int32_t depth_attachment = ATTACHMENT_UNUSED;
+ };
+
+ virtual FramebufferFormatID framebuffer_format_create_multipass(const Vector<AttachmentFormat> &p_attachments, Vector<FramebufferPass> &p_passes, uint32_t p_view_count = 1) = 0;
virtual FramebufferFormatID framebuffer_format_create_empty(TextureSamples p_samples = TEXTURE_SAMPLES_1) = 0;
- virtual TextureSamples framebuffer_format_get_texture_samples(FramebufferFormatID p_format) = 0;
+ virtual TextureSamples framebuffer_format_get_texture_samples(FramebufferFormatID p_format, uint32_t p_pass = 0) = 0;
virtual RID framebuffer_create(const Vector<RID> &p_texture_attachments, FramebufferFormatID p_format_check = INVALID_ID, uint32_t p_view_count = 1) = 0;
+ virtual RID framebuffer_create_multipass(const Vector<RID> &p_texture_attachments, Vector<FramebufferPass> &p_passes, FramebufferFormatID p_format_check = INVALID_ID, uint32_t p_view_count = 1) = 0;
virtual RID framebuffer_create_empty(const Size2i &p_size, TextureSamples p_samples = TEXTURE_SAMPLES_1, FramebufferFormatID p_format_check = INVALID_ID) = 0;
virtual FramebufferFormatID framebuffer_get_format(RID p_framebuffer) = 0;
@@ -962,7 +976,7 @@ public:
};
virtual bool render_pipeline_is_valid(RID p_pipeline) = 0;
- virtual RID render_pipeline_create(RID p_shader, FramebufferFormatID p_framebuffer_format, VertexFormatID p_vertex_format, RenderPrimitive p_render_primitive, const PipelineRasterizationState &p_rasterization_state, const PipelineMultisampleState &p_multisample_state, const PipelineDepthStencilState &p_depth_stencil_state, const PipelineColorBlendState &p_blend_state, int p_dynamic_state_flags = 0) = 0;
+ virtual RID render_pipeline_create(RID p_shader, FramebufferFormatID p_framebuffer_format, VertexFormatID p_vertex_format, RenderPrimitive p_render_primitive, const PipelineRasterizationState &p_rasterization_state, const PipelineMultisampleState &p_multisample_state, const PipelineDepthStencilState &p_depth_stencil_state, const PipelineColorBlendState &p_blend_state, int p_dynamic_state_flags = 0, uint32_t p_for_render_pass = 0) = 0;
/**************************/
/**** COMPUTE PIPELINE ****/
@@ -1018,6 +1032,9 @@ public:
virtual void draw_list_enable_scissor(DrawListID p_list, const Rect2 &p_rect) = 0;
virtual void draw_list_disable_scissor(DrawListID p_list) = 0;
+ virtual DrawListID draw_list_switch_to_next_pass() = 0;
+ virtual Error draw_list_switch_to_next_pass_split(uint32_t p_splits, DrawListID *r_split_ids) = 0;
+
virtual void draw_list_end(uint32_t p_post_barrier = BARRIER_MASK_ALL) = 0;
/***********************/
@@ -1134,8 +1151,10 @@ protected:
RID _texture_create_shared(const Ref<RDTextureView> &p_view, RID p_with_texture);
RID _texture_create_shared_from_slice(const Ref<RDTextureView> &p_view, RID p_with_texture, uint32_t p_layer, uint32_t p_mipmap, TextureSliceType p_slice_type = TEXTURE_SLICE_2D);
- FramebufferFormatID _framebuffer_format_create(const TypedArray<RDAttachmentFormat> &p_attachments);
- RID _framebuffer_create(const Array &p_textures, FramebufferFormatID p_format_check = INVALID_ID);
+ FramebufferFormatID _framebuffer_format_create(const TypedArray<RDAttachmentFormat> &p_attachments, uint32_t p_view_count);
+ FramebufferFormatID _framebuffer_format_create_multipass(const TypedArray<RDAttachmentFormat> &p_attachments, const TypedArray<RDFramebufferPass> &p_passes, uint32_t p_view_count);
+ RID _framebuffer_create(const TypedArray<RID> &p_textures, FramebufferFormatID p_format_check = INVALID_ID, uint32_t p_view_count = 1);
+ RID _framebuffer_create_multipass(const TypedArray<RID> &p_textures, const TypedArray<RDFramebufferPass> &p_passes, FramebufferFormatID p_format_check = INVALID_ID, uint32_t p_view_count = 1);
RID _sampler_create(const Ref<RDSamplerState> &p_state);
VertexFormatID _vertex_format_create(const TypedArray<RDVertexAttribute> &p_vertex_formats);
RID _vertex_array_create(uint32_t p_vertex_count, VertexFormatID p_vertex_format, const TypedArray<RID> &p_src_buffers);
@@ -1146,11 +1165,12 @@ protected:
Error _buffer_update(RID p_buffer, uint32_t p_offset, uint32_t p_size, const Vector<uint8_t> &p_data, uint32_t p_post_barrier = BARRIER_MASK_ALL);
- RID _render_pipeline_create(RID p_shader, FramebufferFormatID p_framebuffer_format, VertexFormatID p_vertex_format, RenderPrimitive p_render_primitive, const Ref<RDPipelineRasterizationState> &p_rasterization_state, const Ref<RDPipelineMultisampleState> &p_multisample_state, const Ref<RDPipelineDepthStencilState> &p_depth_stencil_state, const Ref<RDPipelineColorBlendState> &p_blend_state, int p_dynamic_state_flags = 0);
+ RID _render_pipeline_create(RID p_shader, FramebufferFormatID p_framebuffer_format, VertexFormatID p_vertex_format, RenderPrimitive p_render_primitive, const Ref<RDPipelineRasterizationState> &p_rasterization_state, const Ref<RDPipelineMultisampleState> &p_multisample_state, const Ref<RDPipelineDepthStencilState> &p_depth_stencil_state, const Ref<RDPipelineColorBlendState> &p_blend_state, int p_dynamic_state_flags = 0, uint32_t p_for_render_pass = 0);
Vector<int64_t> _draw_list_begin_split(RID p_framebuffer, uint32_t p_splits, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, const Vector<Color> &p_clear_color_values = Vector<Color>(), float p_clear_depth = 1.0, uint32_t p_clear_stencil = 0, const Rect2 &p_region = Rect2(), const TypedArray<RID> &p_storage_textures = TypedArray<RID>());
void _draw_list_set_push_constant(DrawListID p_list, const Vector<uint8_t> &p_data, uint32_t p_data_size);
void _compute_list_set_push_constant(ComputeListID p_list, const Vector<uint8_t> &p_data, uint32_t p_data_size);
+ Vector<int64_t> _draw_list_switch_to_next_pass_split(uint32_t p_splits);
};
VARIANT_ENUM_CAST(RenderingDevice::ShaderStage)
diff --git a/servers/rendering/rendering_device_binds.cpp b/servers/rendering/rendering_device_binds.cpp
index 2f11360364..2652edb1bc 100644
--- a/servers/rendering/rendering_device_binds.cpp
+++ b/servers/rendering/rendering_device_binds.cpp
@@ -156,7 +156,7 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String
}
Ref<RDShaderFile> shader_file;
- shader_file.instance();
+ shader_file.instantiate();
if (base_error == "") {
if (stage_found[RD::SHADER_STAGE_COMPUTE] && stages_found > 1) {
@@ -173,7 +173,7 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String
for (Map<StringName, String>::Element *E = version_texts.front(); E; E = E->next()) {
Ref<RDShaderBytecode> bytecode;
- bytecode.instance();
+ bytecode.instantiate();
for (int i = 0; i < RD::SHADER_STAGE_MAX; i++) {
String code = stage_code[i];
diff --git a/servers/rendering/rendering_device_binds.h b/servers/rendering/rendering_device_binds.h
index 912674e309..dc59568ce9 100644
--- a/servers/rendering/rendering_device_binds.h
+++ b/servers/rendering/rendering_device_binds.h
@@ -128,6 +128,34 @@ protected:
}
};
+class RDFramebufferPass : public RefCounted {
+ GDCLASS(RDFramebufferPass, RefCounted)
+ friend class RenderingDevice;
+
+ RD::FramebufferPass base;
+
+public:
+ RD_SETGET(PackedInt32Array, color_attachments)
+ RD_SETGET(PackedInt32Array, input_attachments)
+ RD_SETGET(PackedInt32Array, resolve_attachments)
+ RD_SETGET(PackedInt32Array, preserve_attachments)
+ RD_SETGET(int32_t, depth_attachment)
+protected:
+ enum {
+ ATTACHMENT_UNUSED = -1
+ };
+
+ static void _bind_methods() {
+ RD_BIND(Variant::PACKED_INT32_ARRAY, RDFramebufferPass, color_attachments);
+ RD_BIND(Variant::PACKED_INT32_ARRAY, RDFramebufferPass, input_attachments);
+ RD_BIND(Variant::PACKED_INT32_ARRAY, RDFramebufferPass, resolve_attachments);
+ RD_BIND(Variant::PACKED_INT32_ARRAY, RDFramebufferPass, preserve_attachments);
+ RD_BIND(Variant::INT, RDFramebufferPass, depth_attachment);
+
+ BIND_CONSTANT(ATTACHMENT_UNUSED);
+ }
+};
+
class RDSamplerState : public RefCounted {
GDCLASS(RDSamplerState, RefCounted)
friend class RenderingDevice;
diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp
index 8ed774f8e7..9b2ba36358 100644
--- a/servers/rendering/shader_language.cpp
+++ b/servers/rendering/shader_language.cpp
@@ -631,7 +631,7 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
if (!_is_number(last_char)) {
return _make_token(TK_ERROR, "Invalid (integer) numeric constant");
}
- if (!str.is_valid_integer()) {
+ if (!str.is_valid_int()) {
return _make_token(TK_ERROR, "Invalid numeric constant");
}
}
diff --git a/servers/text_server.cpp b/servers/text_server.cpp
index daed612b02..6f48148cab 100644
--- a/servers/text_server.cpp
+++ b/servers/text_server.cpp
@@ -466,16 +466,16 @@ void TextServer::initialize_hex_code_box_fonts() {
Vector<uint8_t> hex_box_data;
Ref<Image> image;
- image.instance();
+ image.instantiate();
Ref<ImageTexture> hex_code_image_tex[2];
hex_box_data.resize(tamsyn5x9_png_len);
memcpy(hex_box_data.ptrw(), tamsyn5x9_png, tamsyn5x9_png_len);
image->load_png_from_buffer(hex_box_data);
- hex_code_image_tex[0].instance();
+ hex_code_image_tex[0].instantiate();
hex_code_image_tex[0]->create_from_image(image);
- hex_code_box_font_tex[0].instance();
+ hex_code_box_font_tex[0].instantiate();
hex_code_box_font_tex[0]->set_diffuse_texture(hex_code_image_tex[0]);
hex_code_box_font_tex[0]->set_texture_filter(CanvasItem::TEXTURE_FILTER_NEAREST);
hex_box_data.clear();
@@ -483,9 +483,9 @@ void TextServer::initialize_hex_code_box_fonts() {
hex_box_data.resize(tamsyn10x20_png_len);
memcpy(hex_box_data.ptrw(), tamsyn10x20_png, tamsyn10x20_png_len);
image->load_png_from_buffer(hex_box_data);
- hex_code_image_tex[1].instance();
+ hex_code_image_tex[1].instantiate();
hex_code_image_tex[1]->create_from_image(image);
- hex_code_box_font_tex[1].instance();
+ hex_code_box_font_tex[1].instantiate();
hex_code_box_font_tex[1]->set_diffuse_texture(hex_code_image_tex[1]);
hex_code_box_font_tex[1]->set_texture_filter(CanvasItem::TEXTURE_FILTER_NEAREST);
hex_box_data.clear();
diff --git a/tests/test_aabb.h b/tests/test_aabb.h
index 39e3c6e45b..c4daa56e5a 100644
--- a/tests/test_aabb.h
+++ b/tests/test_aabb.h
@@ -278,24 +278,24 @@ TEST_CASE("[AABB] Get endpoints") {
TEST_CASE("[AABB] Get longest/shortest axis") {
const AABB aabb = AABB(Vector3(-1.5, 2, -2.5), Vector3(4, 5, 6));
CHECK_MESSAGE(
- aabb.get_longest_axis().is_equal_approx(Vector3(0, 0, 1)),
+ aabb.get_longest_axis() == Vector3(0, 0, 1),
"get_longest_axis() should return the expected value.");
CHECK_MESSAGE(
aabb.get_longest_axis_index() == Vector3::AXIS_Z,
- "get_longest_axis() should return the expected value.");
+ "get_longest_axis_index() should return the expected value.");
CHECK_MESSAGE(
- Math::is_equal_approx(aabb.get_longest_axis_size(), 6),
- "get_longest_axis() should return the expected value.");
+ aabb.get_longest_axis_size() == 6,
+ "get_longest_axis_size() should return the expected value.");
CHECK_MESSAGE(
- aabb.get_shortest_axis().is_equal_approx(Vector3(1, 0, 0)),
+ aabb.get_shortest_axis() == Vector3(1, 0, 0),
"get_shortest_axis() should return the expected value.");
CHECK_MESSAGE(
aabb.get_shortest_axis_index() == Vector3::AXIS_X,
- "get_shortest_axis() should return the expected value.");
+ "get_shortest_axis_index() should return the expected value.");
CHECK_MESSAGE(
- Math::is_equal_approx(aabb.get_shortest_axis_size(), 4),
- "get_shortest_axis() should return the expected value.");
+ aabb.get_shortest_axis_size() == 4,
+ "get_shortest_axis_size() should return the expected value.");
}
#ifndef _MSC_VER
diff --git a/tests/test_config_file.h b/tests/test_config_file.h
index 958341018b..33fd30ffa1 100644
--- a/tests/test_config_file.h
+++ b/tests/test_config_file.h
@@ -138,8 +138,8 @@ name="Unnamed Player"
tagline="Waiting
for
Godot"
-color=Color( 0, 0.5, 1, 1 )
-position=Vector2( 3, 4 )
+color=Color(0, 0.5, 1, 1)
+position=Vector2(3, 4)
[graphics]
diff --git a/tests/test_curve.h b/tests/test_curve.h
index 3055cfd97b..7eeee86f32 100644
--- a/tests/test_curve.h
+++ b/tests/test_curve.h
@@ -80,7 +80,7 @@ TEST_CASE("[Curve] Custom curve with free tangents") {
"Custom free curve should contain the expected number of points.");
CHECK_MESSAGE(
- Math::is_equal_approx(curve->interpolate(-0.1), 0),
+ Math::is_zero_approx(curve->interpolate(-0.1)),
"Custom free curve should return the expected value at offset 0.1.");
CHECK_MESSAGE(
Math::is_equal_approx(curve->interpolate(0.1), (real_t)0.352),
@@ -99,7 +99,7 @@ TEST_CASE("[Curve] Custom curve with free tangents") {
"Custom free curve should return the expected value at offset 0.1.");
CHECK_MESSAGE(
- Math::is_equal_approx(curve->interpolate_baked(-0.1), 0),
+ Math::is_zero_approx(curve->interpolate_baked(-0.1)),
"Custom free curve should return the expected baked value at offset 0.1.");
CHECK_MESSAGE(
Math::is_equal_approx(curve->interpolate_baked(0.1), (real_t)0.352),
@@ -169,7 +169,7 @@ TEST_CASE("[Curve] Custom curve with linear tangents") {
"Custom linear curve should contain the expected number of points.");
CHECK_MESSAGE(
- Math::is_equal_approx(curve->interpolate(-0.1), 0),
+ Math::is_zero_approx(curve->interpolate(-0.1)),
"Custom linear curve should return the expected value at offset -0.1.");
CHECK_MESSAGE(
Math::is_equal_approx(curve->interpolate(0.1), (real_t)0.4),
@@ -188,7 +188,7 @@ TEST_CASE("[Curve] Custom curve with linear tangents") {
"Custom linear curve should return the expected value at offset 2.0.");
CHECK_MESSAGE(
- Math::is_equal_approx(curve->interpolate_baked(-0.1), 0),
+ Math::is_zero_approx(curve->interpolate_baked(-0.1)),
"Custom linear curve should return the expected baked value at offset -0.1.");
CHECK_MESSAGE(
Math::is_equal_approx(curve->interpolate_baked(0.1), (real_t)0.4),
diff --git a/tests/test_json.h b/tests/test_json.h
index f1cb4799dc..3af58dfa1c 100644
--- a/tests/test_json.h
+++ b/tests/test_json.h
@@ -45,75 +45,65 @@ TEST_CASE("[JSON] Parsing single data types") {
// Parsing a single data type as JSON is valid per the JSON specification.
JSON json;
- Variant result;
- String err_str;
- int err_line;
- json.parse("null", result, err_str, err_line);
+ json.parse("null");
CHECK_MESSAGE(
- err_line == 0,
+ json.get_error_line() == 0,
"Parsing `null` as JSON should parse successfully.");
CHECK_MESSAGE(
- result == Variant(),
+ json.get_data() == Variant(),
"Parsing a double quoted string as JSON should return the expected value.");
- json.parse("true", result, err_str, err_line);
+ json.parse("true");
CHECK_MESSAGE(
- err_line == 0,
+ json.get_error_line() == 0,
"Parsing boolean `true` as JSON should parse successfully.");
CHECK_MESSAGE(
- result,
+ json.get_data(),
"Parsing boolean `true` as JSON should return the expected value.");
- json.parse("false", result, err_str, err_line);
+ json.parse("false");
CHECK_MESSAGE(
- err_line == 0,
+ json.get_error_line() == 0,
"Parsing boolean `false` as JSON should parse successfully.");
CHECK_MESSAGE(
- !result,
+ !json.get_data(),
"Parsing boolean `false` as JSON should return the expected value.");
- // JSON only has a floating-point number type, no integer type.
- // This is why we use `is_equal_approx()` for the comparison.
- json.parse("123456", result, err_str, err_line);
+ json.parse("123456");
CHECK_MESSAGE(
- err_line == 0,
+ json.get_error_line() == 0,
"Parsing an integer number as JSON should parse successfully.");
CHECK_MESSAGE(
- (int)result == 123'456,
+ (int)(json.get_data()) == 123456,
"Parsing an integer number as JSON should return the expected value.");
- json.parse("0.123456", result, err_str, err_line);
+ json.parse("0.123456");
CHECK_MESSAGE(
- err_line == 0,
+ json.get_error_line() == 0,
"Parsing a floating-point number as JSON should parse successfully.");
CHECK_MESSAGE(
- Math::is_equal_approx(result, 0.123456),
+ Math::is_equal_approx(double(json.get_data()), 0.123456),
"Parsing a floating-point number as JSON should return the expected value.");
- json.parse("\"hello\"", result, err_str, err_line);
+ json.parse("\"hello\"");
CHECK_MESSAGE(
- err_line == 0,
+ json.get_error_line() == 0,
"Parsing a double quoted string as JSON should parse successfully.");
CHECK_MESSAGE(
- result == "hello",
+ json.get_data() == "hello",
"Parsing a double quoted string as JSON should return the expected value.");
}
TEST_CASE("[JSON] Parsing arrays") {
JSON json;
- Variant result;
- String err_str;
- int err_line;
// JSON parsing fails if it's split over several lines (even if leading indentation is removed).
- json.parse(
- R"(["Hello", "world.", "This is",["a","json","array.",[]], "Empty arrays ahoy:", [[["Gotcha!"]]]])",
- result, err_str, err_line);
+ json.parse(R"(["Hello", "world.", "This is",["a","json","array.",[]], "Empty arrays ahoy:", [[["Gotcha!"]]]])");
- const Array array = result;
+ const Array array = json.get_data();
CHECK_MESSAGE(
- err_line == 0,
+ json.get_error_line() == 0,
"Parsing a JSON array should parse successfully.");
CHECK_MESSAGE(
array[0] == "Hello",
@@ -136,15 +126,10 @@ TEST_CASE("[JSON] Parsing arrays") {
TEST_CASE("[JSON] Parsing objects (dictionaries)") {
JSON json;
- Variant result;
- String err_str;
- int err_line;
- json.parse(
- R"({"name": "Godot Engine", "is_free": true, "bugs": null, "apples": {"red": 500, "green": 0, "blue": -20}, "empty_object": {}})",
- result, err_str, err_line);
+ json.parse(R"({"name": "Godot Engine", "is_free": true, "bugs": null, "apples": {"red": 500, "green": 0, "blue": -20}, "empty_object": {}})");
- const Dictionary dictionary = result;
+ const Dictionary dictionary = json.get_data();
CHECK_MESSAGE(
dictionary["name"] == "Godot Engine",
"The parsed JSON should contain the expected values.");
diff --git a/tests/test_string.h b/tests/test_string.h
index 7f404a34e8..1982d8de60 100644
--- a/tests/test_string.h
+++ b/tests/test_string.h
@@ -1317,7 +1317,7 @@ TEST_CASE("[String] Is_*") {
for (int i = 0; i < 12; i++) {
String s = String(data[i]);
CHECK(s.is_numeric() == isnum[i]);
- CHECK(s.is_valid_integer() == isint[i]);
+ CHECK(s.is_valid_int() == isint[i]);
CHECK(s.is_valid_hex_number(false) == ishex[i]);
CHECK(s.is_valid_hex_number(true) == ishex_p[i]);
CHECK(s.is_valid_float() == isflt[i]);
diff --git a/thirdparty/enet/godot.cpp b/thirdparty/enet/godot.cpp
index fd7968204b..f6a56f1f5d 100644
--- a/thirdparty/enet/godot.cpp
+++ b/thirdparty/enet/godot.cpp
@@ -164,7 +164,7 @@ public:
verify = p_verify;
for_hostname = p_for_hostname;
cert = p_cert;
- udp.instance();
+ udp.instantiate();
dtls = Ref<PacketPeerDTLS>(PacketPeerDTLS::create());
if (p_base->bound) {
uint16_t port;
@@ -254,7 +254,7 @@ class ENetDTLSServer : public ENetGodotSocket {
public:
ENetDTLSServer(ENetUDP *p_base, Ref<CryptoKey> p_key, Ref<X509Certificate> p_cert) {
- udp_server.instance();
+ udp_server.instantiate();
if (p_base->bound) {
uint16_t port;
p_base->get_socket_address(&local_address, &port);
diff --git a/thirdparty/misc/easing_equations.cpp b/thirdparty/misc/easing_equations.cpp
index af48aaf079..ce32c1a362 100644
--- a/thirdparty/misc/easing_equations.cpp
+++ b/thirdparty/misc/easing_equations.cpp
@@ -297,7 +297,7 @@ static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
}
}; // namespace back
-Tween::interpolater Tween::interpolaters[Tween::TRANS_COUNT][Tween::EASE_COUNT] = {
+Tween::interpolater Tween::interpolaters[Tween::TRANS_MAX][Tween::EASE_MAX] = {
{ &linear::in, &linear::out, &linear::in_out, &linear::out_in },
{ &sine::in, &sine::out, &sine::in_out, &sine::out_in },
{ &quint::in, &quint::out, &quint::in_out, &quint::out_in },
@@ -311,7 +311,7 @@ Tween::interpolater Tween::interpolaters[Tween::TRANS_COUNT][Tween::EASE_COUNT]
{ &back::in, &back::out, &back::in_out, &back::out_in },
};
-real_t Tween::_run_equation(TransitionType p_trans_type, EaseType p_ease_type, real_t t, real_t b, real_t c, real_t d) {
+real_t Tween::run_equation(TransitionType p_trans_type, EaseType p_ease_type, real_t t, real_t b, real_t c, real_t d) {
interpolater cb = interpolaters[p_trans_type][p_ease_type];
ERR_FAIL_COND_V(cb == NULL, b);