Commit graph

140 commits

Author SHA1 Message Date
Hugo Locurcio 66f7c48e39
Implement adjusting the maximum number of physics steps per rendered frame
When using high physics FPS (which is a requirement to minimize input
lag and improve precision in simulation racing games), a higher value
prevents the game from slowing down at low rendering FPS.

This can be done via an Engine property for run-time changes,
or a project setting for initial changes.
2022-10-09 23:00:09 +02:00
Hugo Locurcio 1c6c72caf1
Rename Engine.target_fps and associated project setting to max_fps
This makes the setting easier to find, as research has found there are
numerous use cases to limiting FPS. This also improves documentation
related to the Engine property and project setting.

The project setting also works in projects exported in release mode,
so its location in the `debug/` section was misleading.
2022-10-03 23:54:36 +02:00
Rémi Verschelde d598fff7c2 Merge pull request #66803 from akien-mga/core-remove-NO_THREADS
Remove `NO_THREADS` fallback code, Godot 4 requires thread support
2022-10-03 14:51:02 +02:00
Rémi Verschelde 04a28763c0
Merge pull request #65751 from Faless/os/4.x_expose_read_from_stdin 2022-10-03 14:08:00 +02:00
Rémi Verschelde 54418ea659 Remove NO_THREADS fallback code, Godot 4 requires thread support
This also removes `OS::can_use_threads` from the public API since it's always
true.
2022-10-03 11:23:26 +02:00
Mansur Isaev 623e23c625 Add method bind for Geometry2D.decompose_polygon_in_convex 2022-09-21 09:40:03 +04:00
Rémi Verschelde ec60c4ee9e Merge pull request #65271 from KoBeWi/FirAccess🌲
Replace File/Directory with FileAccess/DirAccess
2022-09-19 15:33:24 +02:00
Marc Gilleron 700bb066e0 Use Vector2i when returning atlas size in Geometry2D::make_atlas 2022-09-19 11:37:02 +01:00
kobewi 9f2dc68279 Replace File/Directory with FileAccess/DirAccess 2022-09-19 11:03:31 +02:00
MJacred ac9786c525 Add get_distribution_name() and get_version() to OS
supports: LinuxBSD, Windows, macOS, iOS, Android, UWP

Co-authored-by: bruvzg
2022-09-16 11:17:36 +02:00
Fabio Alessandrelli 8b5bb7eeea [OS] Expose get_stdin_string to Scripting.
Exposed as read_string_from_stdin so it's clear it's not retrieving a
property.
The method is kept with the block parameter, but a note is added to the
docs specifying that is not implemented on any platform (should we just
remove it?).
2022-09-13 18:37:11 +02:00
Rémi Verschelde eb56d1d1eb Drop obsolete resource usage debug methods from OS class
These methods exist since the dawn of (open source) Godot and have hardly
been updated over time, so they barely work and I'm fairly sure nobody is
using them. (See #46505 for details.)

While some of the functionality they aimed to provide might be useful for
optimization work and introspection, this should likely be redesigned from
scratch with a cleaner and more modern interface (e.g. exposed via the
Performance singleton, or ResourceLoader, and a better API overall).
2022-08-29 12:57:37 +02:00
Rémi Verschelde ce78d280b3
Merge pull request #58530 from Calinou/os-remove-dump-memory-to-file
Remove unimplemented `OS.dump_memory_to_file()` method
2022-08-25 20:55:30 +02:00
kobewi 1abdffe7a0 Replace Array return types with TypedArray 2 2022-08-23 23:21:32 +02:00
kobewi 8be27dc59e Replace Array return types with TypedArray 2022-08-22 22:42:36 +02:00
Hugo Locurcio 465c423abb
Remove unimplemented OS.dump_memory_to_file() method
This method never did anything in Godot since 3.0, since its code
was commented out. The last time the method had an implementation
was in Godot 2.1.x.
2022-08-18 18:51:25 +02:00
Hugo Locurcio 27a072c884
Print expected os.arch tuple for current platform in GDExtension error
This also adds `Engine.get_architecture_name()` to get the name of the
CPU architecture the Godot binary was built for.
2022-08-08 19:30:34 +02:00
Hakim 500766329f Bring back Geometry2D.segment_intersects_circle 2022-08-03 17:05:21 +02:00
Hugo Locurcio 1b713175b2
Expose the "restart on exit" OS functionality
This can be used to restart a project with specific command line arguments
applied. This can work in tandem with `OS.get_cmdline_args()` to restart
with the same command line arguments as used to originally run the project.

Example use cases:

- Restart to apply an user setting change that requires a restart to work.
- Restart with a Godot command line argument to change the video driver,
  audio driver, etc.
2022-08-01 14:06:13 +02:00
Rémi Verschelde 44f1e540f6
Merge pull request #63733 from akien-mga/file-get_as_text-skip-CR
File: Re-add support to skip CR (`\r`) in `File::get_as_text`
2022-08-01 07:54:20 +02:00
Juan Linietsky 0dd65378e7 Add support for command-line user arguments.
Implements the standard Unix double dash (--) commandline argument:
* Arguments after a double dash (--) are ignored by Godot and stored for the user.
* User can access them via `OS.get_cmdline_user_args()`

Example:

`godot.exe scene_to_run.tscn --fullscreen -- --start-level 2`
2022-08-01 00:56:59 +02:00
Rémi Verschelde 1418f97c70 File: Re-add support to skip CR (\r) in File::get_as_text
This was removed in #63481, and we confirmed that it's better like this,
but we add back the possibility to strip CR as an option, to optionally
restore the previous behavior.

For performance this is done directly in `String::parse_utf8`.

Also fixes Android `FileAccess::get_line()` as this one _should_ strip CR.

Supersedes #63717.
2022-08-01 00:40:35 +02:00
Robin Arys 1cfe3c3f8b Expose load_threaded_request's cachemode to GDScript 2022-07-31 14:04:11 +02:00
kobewi c3606cb5f3 Swap arguments of ResourceSaver.save() 2022-07-29 19:53:09 +02:00
Juan Linietsky d4433ae6d3 Remove Signal connect binds
Remove the optional argument p_binds from `Object::connect` since it was deprecated by Callable.bind().
Changed all uses of it to Callable.bind()
2022-07-29 16:26:13 +02:00
Hugo Locurcio aaeb60eafc
Add a Movie Quit On Finish property to AnimationPlayer
This quits the project when an animation is done playing in the
given AnimationPlayer, but only in Movie Maker mode.
When this happens, a message is printed with the absolute path of the
AnimationPlayer node that caused the engine to quit.

This can be used to create videos that stop at a specified time
without having to write any script.

A report is now also printed to the console when the video is done
recording (as long as the engine was exited properly).
This report is unfortunately not always visible in the editor's
Output panel, as it's printed too late.

A method was also added to get the path to the output file from the
scripting API.
2022-07-27 18:50:28 +02:00
Rémi Verschelde cc5135959b
Merge pull request #62973 from bruvzg/sysfont_support 2022-07-27 13:38:30 +02:00
Fredia Huya-Kouadio 9679c67904 Address remaining scoped storage regressions
- Accelerate common path used to check the storage scope for a given path
- Update the logic for the `get_as_text()` method - previous logic loads the content of a text file one byte at a time
2022-07-26 07:44:08 -07:00
bruvzg 36ef8f29dc
Implement support for loading system fonts on Linux, macOS / iOS and Windows. 2022-07-26 08:38:05 +03:00
reduz 5ac42cf576 Implement a BitField hint
Allows to specify the binder that an enum must be treated as a bitfield.
2022-07-05 22:13:37 +02:00
kobewi 7d5c943202 Handle custom Callables in Thread.start() 2022-07-01 13:11:31 +02:00
leogeier 359f7fc51f Exposes methods for adding and removing ResourceFormatLoaders and -Savers in the ClassDB 2022-06-29 21:38:20 +02:00
kobewi a6f0aba43d Remove userdata from Thread.start() 2022-06-23 12:50:28 +02:00
bruvzg 860e24683f
Make enum/constant binds 64-bit. 2022-06-17 16:36:26 +03:00
reduz 746dddc067 Replace most uses of Map by HashMap
* Map is unnecessary and inefficient in almost every case.
* Replaced by the new HashMap.
* Renamed Map to RBMap and Set to RBSet for cases that still make sense
  (order matters) but use is discouraged.

There were very few cases where replacing by HashMap was undesired because
keeping the key order was intended.
I tried to keep those (as RBMap) as much as possible, but might have missed
some. Review appreciated!
2022-05-16 10:37:48 +02:00
mdavisprog f3c1232c59 Add OS::is_process_running function.
Adds the is_process_running function to the native OS class and exposes it to script.

This is implemented on Windows and Unix platforms. A stub is provided for other platforms that do not support this function.

Documentation is updated to reflect new API function.
2022-05-03 17:27:17 -07:00
Hugo Locurcio 180e5d3028
Remove RES and REF typedefs in favor of spelled out Ref<>
These typedefs don't save much typing compared to the full `Ref<Resource>`
and `Ref<RefCounted>`, yet they sometimes introduce confusion among
new contributors.
2022-05-03 01:43:50 +02:00
kobewi b80e52f048 Expose move_to_trash() 2022-04-27 01:02:11 +02:00
nova++ 1a3cb23955 Fix "File must be opened" error with File.open() 2022-04-13 08:51:07 -04:00
bruvzg 4bf99f4af2 Narrow FileAccess scope to prevent deadlocks. 2022-04-12 10:54:39 +03:00
bruvzg 9381acb6a4
Make FileAccess and DirAccess classes reference counted. 2022-04-11 13:28:51 +03:00
Rémi Verschelde abbb0dc082
Merge pull request #59548 from akien-mga/obj-remove-unused-categories 2022-03-28 14:17:24 +02:00
reduz 360dea5348 Add GDExtension support to Script
* Ability to create script languages from GDExtension
* Some additions to gdnative_extension.h to make this happen
* Moved the GDExtension binder to core

This now allows creating scripting languages from GDExtension, with the same ease as if it was a module. It replaces the old PluginScript from Godot 3.x.
Warning: GodotCPP will need to be updated to support this (it may be a bit of work as ScriptInstance needs to be created over there again).
2022-03-27 16:13:00 +02:00
Rémi Verschelde 5371009d8e Object: Remove unused category boilerplate
We might want to re-add something like this if/when we find a good use case
for it and do the effort to categorize all objects in the API properly.

Until then, it's better to remove that boilerplate since it's not needed.

Closes #18711.
2022-03-26 15:46:01 +01:00
reduz 2f651277da Add static method support to ClassDB
* Based on the work done for Variant in the past.
* Added `ClassDB::bind_static_method`
* Cleaned up ClassDB::bind_method to use variadic templates.

This adds support for having static methods in Object derived classes.
Note that this does not make it work yet in GDScript or Mono and, while it works for GDExtension, GodotCPP needs to be updated.
2022-03-22 16:27:34 +01:00
Rémi Verschelde 768f9422bc Convert uses of DirAccess * to DirAccessRef to prevent memleaks
`DirAccess *` needs to be deleted manually, and this is often forgotten
especially when doing early returns with `ERR_FAIL_COND`.
`DirAccessRef` is deleted automatically when it goes out of scope.

Co-authored-by: bruvzg <7645683+bruvzg@users.noreply.github.com>
2022-03-11 09:13:11 +01:00
Rémi Verschelde 6c3170e875
Merge pull request #57930 from piiertho/bugfix/add-none-flag-to-resource-saver 2022-03-07 12:05:35 +01:00
Pierre-Thomas Meisels f9d4f08090 Fix ResourceSaver::save method exposition flag parameter
enh: Add FLAG_NONE to SaverFlags in ResourceSaver to fix api inconsistency
fix: flags parameter of ResourceSaver::save is now uint32_t to allow flag composition in scripts
2022-03-07 10:39:51 +01:00
Rémi Verschelde b8b4580448
Style: Cleanup single-line blocks, semicolons, dead code
Remove currently unused implementation of TextureBasisU, could be re-added
later on if needed and ported.
2022-02-16 14:06:29 +01:00
Hugo Locurcio ee7cd9a3a1
Add an OS.get_processor_name() method
This method can be used to get the CPU model name.
It can be used in conjunction with
`RenderingServer.get_video_adapter_name()` and
`RenderingServer.get_video_adapter_vendor()` for annotating benchmarks
and automatic graphics quality configuration.
2022-02-15 20:55:53 +01:00