Commit graph

453 commits

Author SHA1 Message Date
bruvzg
0103af1ddd
Fix MSVC warnings, rename shadowed variables, fix uninitialized values, change warnings=all to use /W4. 2022-10-07 11:32:33 +03:00
Rémi Verschelde
f501e4f665 Unix: Remove now unnecessary I/O defines, cleanup
- `LIBC_FILEIO_ENABLED` wasn't defined anywhere, even in _other platforms_.
- `NO_NETWORK` is also never defined. It probably isn't enough anyway to
  disable network APIs in the current codebase.
- `UNIX_SOCKET_UNAVAILABLE` is never defined in this code but used by some
  other platforms, clarify that.
- `NO_STATVFS` can be removed as Android supports it since API level 19,
  which is our current min SDK level. It's also only used for
  `DirAccessUnix::get_space_left()` which is anyway overridden by
  `DirAccessJAndroid::get_space_left()` so it shouldn't make a difference.
  * Fixed documentation for `DirAccess.get_space_left()`.
- `NO_FCNTL` is likely also a remnant of early Android days, in current NDK
  r23 it seems to be available. Also cleaned up unused `fcntl.h` includes.
- `NO_ALLOCA` is never defined, and we use alloca in many places now.
2022-10-03 12:33:41 +02:00
Marc Gilleron
aed3822a93 Change return type of get_configuration_warnings to PackedStringArray 2022-09-19 16:43:15 +01:00
Rémi Verschelde
8899f1eec2
Merge pull request #65595 from KoBeWi/minus_children
Allow negative indices in `move_child()`
2022-09-10 09:59:15 +02:00
kobewi
31e62ca827 Allow negative indices in move_child() 2022-09-10 03:54:04 +02:00
VolTer
e19f7b2407 Remove Remove and Skip 2022-09-09 23:44:31 +02:00
Rémi Verschelde
7936b3cc4c Merge pull request #60108 from KoBeWi/arise_to_top
Rename raise() to move_to_front()
2022-09-08 09:23:31 +02:00
Micky
f577bae76f Rename legible_unique_name param to force_readable_name
With the introduction of Scene Unique Nodes, `is_unique_in_owner`, "Unique Name in Scene" and other descriptions related to the feature, the second parameter of add_child() and add_simbling() could be misunderstood to be related, at first glance.
2022-09-07 11:58:30 +02:00
kobewi
b218727599 Rename raise() to move_to_front() 2022-09-06 22:13:06 +02:00
Rémi Verschelde
0bf3f79157
Merge pull request #63902 from dalexeev/string-cases 2022-08-30 14:06:28 +02:00
Rémi Verschelde
889c522a19
Merge pull request #64410 from MewPurPur/rename-notification-instanced 2022-08-30 12:01:58 +02:00
Danil Alexeev
d4555ef5fb
Add String.to_{camel,pascal,snake}_case methods 2022-08-30 12:36:24 +03:00
Rémi Verschelde
d93d646723
Merge pull request #64570 from KoBeWi/node🧳ing
Unify node casing adjustment
2022-08-26 09:49:58 +02:00
kobewi
1abdffe7a0 Replace Array return types with TypedArray 2 2022-08-23 23:21:32 +02:00
kobewi
fdab23163f Unify node casing adjustment 2022-08-18 14:08:40 +02:00
Tomasz Chabora
2bdd7e9ea0 Add methods for node reparenting 2022-08-16 19:44:41 +02:00
VolTer
2599710793 Rename NOTIFICATION_INSTANCED to NOTIFICATION_SCENE_INSTANTIATED 2022-08-16 12:41:10 +02:00
Nathan Franke
c3c5985189
move rpc and rpc_id implementations back to header
StackOverflow on why this is needed: https://stackoverflow.com/questions/495021/why-can-templates-only-be-implemented-in-the-header-file
Minor mistake in commit ca7d572908
2022-08-02 18:35:29 -05: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
Fabio Alessandrelli
ca7d572908 [Net] Modularize multiplayer, expose MultiplayerAPI to extensions.
- RPC configurations are now dictionaries.
- Script.get_rpc_methods renamed to Script.get_rpc_config.
- Node.rpc[_id] and Callable.rpc now return an Error.
- Refactor MultiplayerAPI to allow extension.
- New MultiplayerAPI.rpc method with Array argument (for scripts).
- Move the default MultiplayerAPI implementation to a module.
2022-07-26 09:31:12 +02:00
Hugo Locurcio
462432f89f
Add an underscore to internal group names as per engine policy
This also adds `SNAME()` macros where relevant to improve performance.
2022-07-01 20:16:25 +02:00
Rémi Verschelde
11f5d2141a
Merge pull request #61577 from YuriSizov/core-fix-events-for-moved-nodes 2022-06-27 12:02:19 +02:00
reduz
d69e3791bf Fix editor-only visibility for lights
* Update visibility again for editor-only lights if owner changes.

Fixes #26399, supersedes #52327
2022-06-23 08:19:18 +02:00
Rémi Verschelde
3e6de687b8 Node: Rename child_exited_tree to child_exiting_tree
The name was confusing as this signal is emitted around the same time as
`tree_exiting` and `NOTIFICATION_EXIT_TREE`, i.e. while the child node is
still in tree.

Fixes #59210.
2022-06-20 11:55:19 +02:00
Yuri Sizov
8e5ad7be46 Mark node groups as dirty for every children if parent is moved 2022-05-31 21:28:04 +03:00
reduz
45af29da80 Add a new HashSet template
* Intended to replace RBSet in most cases.
* Optimized for iteration speed
2022-05-20 22:40:38 +02:00
BimDav
3e96abce07 fix a bug in get_node_and_resource 2022-05-16 19:40:59 +02: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
kobewi
1dc7bcc83c Cleanup metadata usage 2022-05-06 00:27:10 +02: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
Fabio Alessandrelli
aee2240d5f [Net] Allow branch-specific MultiplayerAPIs.
Removes custom_multiplayer from Node.
MultiplayerAPI overrides are now set at SceneTree level, and apply to
whole branches.
Impact on performance when using only the default multiplayer or
overriding it is minimal, the use of branches can likely be further
optimized by caching nodes and relevant MultiplayerAPI IDs.
2022-04-26 17:22:54 +02:00
Rémi Verschelde
9c2ea7e296 Node: Re-add find_node as find_child, improve docs
The new name contrasts it better with `find_parent`, and makes it clear
that it only matches child/descendant nodes.

Also rename `find_nodes` to `find_children` accordingly.
2022-04-25 15:21:22 +02:00
reduz
8580f377a3 Implement Scene Unique Nodes
Implements https://github.com/godotengine/godot-proposals/issues/4096

* Nodes can be marked unique to the scene in the editor (or via code).
* Unique nodes can be accessed via the **%** prefix at any point in the path. From that point in the path (depending on whether the scene of the path is), the unique node will be fetched.
* Implementation is very optimal, as these nodes are cached.
2022-04-25 12:19:17 +02:00
bruvzg
d1207a0504
[Input] Add extra shortcut_input input processing step to process Unicode character input with Alt / Ctrl modifiers, after processing of shortcuts. 2022-04-05 13:46:45 +03:00
Rémi Verschelde
8e5d927af5
Merge pull request #59590 from Calinou/rename-print-stray-nodes 2022-03-31 22:21:51 +02:00
Hugo Locurcio
a29f2bfe54
Rename Node.print_stray_nodes() to Node.print_orphan_nodes()
The "orphan" terminology is already used elsewhere.
2022-03-31 18:33:02 +02:00
Pierre-Thomas Meisels
63f7f44ccb Make vararg method bind no return and return
Type emit_signal exposed method return type

set UndoRedo add_do_method and add_undo_method exposed return void

Set TreeItem::_call_recursive_bind returns void

Set _rpc_bind and _rpc_id_bind returns void in Node

Set _call_group and _call_group_flags method returns void in SceneTree

Set godot-cpp-test CI flag to false
2022-03-30 11:43:12 +02:00
reduz
21637dfc25 Remove VARIANT_ARG* macros
* Very old macros from the time Godot was created.
* Limited arguments to 5 (then later changed to 8) in many places.
* They were replaced by C++11 Variadic Templates.
* Renamed methods that take argument pointers to have a "p" suffix. This was used in some places and not in others, so made it standard.
* Also added a dereference check for Variant*. Helped catch a couple of bugs.
2022-03-09 18:39:13 +01:00
Rémi Verschelde
417698c202
Merge pull request #58042 from Sauermann/fix-viewport-border-notifications
Fix Viewport mouse enter+exit notifications
2022-02-19 09:07:07 +01:00
diddykonga
78dc608aa8 Change 'find_node' to 'find_nodes' and Add 'type' parameter
Changed 'find_node' to 'find_nodes' which now returns an 'TypedArray<Node>', as well as Added a 'type' parameter to match against specific node types, which supports inheritance.
2022-02-17 01:44:13 -06:00
Markus Sauermann
415042ac89 Connect notifications from Container to Viewport
mouse enter+exit
2022-02-15 22:41:30 +01:00
Rémi Verschelde
0f5455230c
Use switch consistently in _notification (scene folder) 2022-02-15 18:44:55 +01:00
Hendrik Brucker
b396fd4eef Improve compilation speed (forward declarations/includes cleanup) 2022-02-12 02:46:22 +01:00
Fabio Alessandrelli
a18ba63417 [Net] Allow to use strings as method name in RPC.
Node::rpc and Node::rpc_id will now also accepts Strings instead of only
accepting StringNames.
2022-02-09 14:27:16 +01:00
Fabio Alessandrelli
d219547c96 [Net] New replication interface, spawner and synchronizer nodes.
Initial implementation of the MultiplayerReplicationInterface and its
default implementation (SceneReplicationInterface).

New MultiplayerSpawner node helps dealing with instantiation of scenes
on remote peers (e.g. clients).
It supports both custom spawns via a `_spawn_custom` virtual function,
and optional auto-spawn of known scenes via a TypedArray<PackedScenes>
property.

New MultiplayerSynchornizer helps synchronizing states between the local
and remote peers, supports both sync and spawn properties and is
configured via a `SceneReplicationConfig` resource.
It can also sync via path (i.e. without being spawned by a
MultiplayerSpawner if both peers has it in tree, but will not send the
spawn state in that case, only the sync one.
2022-02-04 14:56:30 +01:00
bruvzg
244db37508
Cleanup and move char functions to the char_utils.h header. 2022-02-04 11:35:01 +02:00
reduz
fbd9599b04 Add a signal to notify when children nodes enter or exit tree
-Allows more fine grained notifications (hence better performance) than using the global scene tree signals (node added and removed).
-Required for #55950
2022-02-02 11:28:11 +01:00
Rémi Verschelde
d681d99e12
Merge pull request #52134 from RandomShaper/fix_naming 2022-01-20 22:01:37 +01:00
Pedro J. Estébanez
7b0ed2aa5e Rename Variant::is_ref() to is_ref_counted() 2022-01-20 18:46:25 +01:00
Bartłomiej T. Listwon
e2792cc71c Rework Node::get_node to omit is_absolute() check in best case scenario 2022-01-19 21:38:18 +01:00
Haoyu Qiu
6aecf91e4f Replicate load-as-placeholder state on node duplication 2022-01-16 15:08:03 +08:00
Pedro J. Estébanez
2db9397fb9 Clear only owners that are no longer in the same tree 2022-01-05 14:00:49 +01:00
Rémi Verschelde
91b5c358fc
Merge pull request #55512 from RandomShaper/better_node_delete 2022-01-05 10:25:13 +01:00
Rémi Verschelde
23342ac23c
Merge pull request #54987 from KoBeWi/@@Node2D@@69@@420@@@ 2022-01-04 10:08:32 +01:00
Rémi Verschelde
fe52458154
Update copyright statements to 2022
Happy new year to the wonderful Godot community!
2022-01-03 21:27:34 +01:00
Nathan Franke
49403cbfa0
Replace String comparisons with "", String() to is_empty()
Also:
- Adds two stress tests to test_string.h
- Changes to .empty() on std::strings
2021-12-09 04:48:38 -06:00
Pedro J. Estébanez
0a0381dd0a Rationalize Node removals and deletions
- Regarding preservation of owner, `free()` and `remove_child()` now behave the same: owner is kept during `tree_exiting` signal and `null` during `tree_exited`.
- `tree_exited` is emitted in the same order as `tree_exiting`.
- Superfluous code to handle cancelation of ownership is removed.
2021-12-01 14:28:59 +01:00
Max Hilbrunner
a6a2e0feb9
Merge pull request #52387 from Calinou/node-rename-path-changed-notification
Rename Node's `NOTIFICATION_PATH_CHANGED` to `NOTIFICATION_PATH_RENAMED`
2021-11-25 17:47:44 +01:00
Lightning_A
e078f970db Rename remove() to remove_at() when removing by index 2021-11-23 18:58:57 -07:00
kobewi
58146a74f7 Fix nodes being renamed into garbage upon conflict 2021-11-15 02:05:44 +01:00
megalobyte
e3def40160 Update editor description property flag 2021-11-10 13:44:54 -05:00
Rémi Verschelde
665fa3d839
Merge pull request #52943 from RandomShaper/property_pin_control_natural 2021-11-08 18:53:08 +01:00
Pedro J. Estébanez
8d6f80d367 Add property value pinning 2021-11-08 17:42:30 +01:00
kobewi
313ef412f5 Fix preview sun and environment names 2021-11-07 00:40:15 +01:00
Hugo Locurcio
c012fbc8b2
Rename PROPERTY_USAGE_NOEDITOR to PROPERTY_USAGE_NO_EDITOR
This is consistent with other constants that include `NO`,
such as `PROPERTY_HINT_COLOR_NO_ALPHA`.
2021-11-03 23:06:17 +01:00
kobewi
de4f29f458 Remove node_hrcr hack 2021-10-28 01:43:34 +02:00
Fabio Alessandrelli
7c93931751 [Net] Add call_local argument to Node.rpc_config. 2021-10-08 12:49:20 +02:00
Rémi Verschelde
b85dfd990e
GDScript completion: Handle quote style ad-hoc to remove editor dependency
`core` and `scene` shouldn't depend on `editor`, so they can't query this style
setting in `get_argument_options`. But we can handle it after the fact in
GDScript's completion code.

Also cleans up a couple extra unused invalid includes in `core`.
2021-10-04 16:16:05 +02:00
Lightning_A
c63b18507d Use range iterators for Map 2021-09-30 15:09:12 -06:00
Hugo Locurcio
570cdc128f
Rename Node's filename property to scene_file_path for clarity 2021-09-30 16:50:25 +02:00
Rémi Verschelde
583eaa9869
Merge pull request #49819 from nekomatata/fix-process-mode-inherit 2021-09-17 19:16:19 +02:00
Max Hilbrunner
5b25457794 Multiplayer networking renames/simplification
Removes _networking_ prefix from some methods and members, now that multiplayer has been largely moved out of Node and SceneTree and is seperated into its own set of classes.
2021-09-08 12:05:54 +02:00
Max Hilbrunner
acc776f7b6
Merge pull request #52442 from Faless/mp/4.x_rpc_manager
[Net] Move multiplayer classes to own subfolder. Split RPC from MultiplayerAPI.
2021-09-07 18:44:39 +02:00
Fabio Alessandrelli
bf9aae09ba [Net] Move multiplayer to core subdir, split RPCManager.
Move multiplayer classes to "core/multiplayer" subdir.

Move the RPCConfig and enums (TransferMode, RPCMode) to a separate
file (multiplayer.h), and bind them to the global namespace.

Move the RPC handling code to its own class (RPCManager).

Renames "get_rpc_sender_id" to "get_remote_sender_id".
2021-09-07 11:14:30 +02:00
PouleyKetchoupp
226d6337e5 Fix process mode update when mode owner is set to Inherit
Prevent the root node to be set to PROCESS_MODE_INHERIT, since it causes
undefined behavior.

Fix a case where the process owner node is wrongly set to the direct
parent instead of the proper node.

Add errors for all unhandled cases.
2021-09-06 17:14:12 -07:00
Hennadii Chernyshchyk
2b78353e79
Remove extra get_script_instance check
Otherwise, `_ready()` will not be called on classes
that define this function and doesn't have a script attached.
2021-09-04 12:14:54 +03:00
Hugo Locurcio
879c37d658
Rename Node's NOTIFICATION_PATH_CHANGED to NOTIFICATION_PATH_RENAMED
The new name is less misleading, as the notification is only emitted
when the node name (or one of its parents' names) is changed.
2021-09-04 00:15:15 +02:00
Fabio Alessandrelli
64b9f30b92 [Net] Rename RPC "puppet" to "auth" (authority). Drop "master".
This commit completely removes the RPC_MODE_MASTER ("master" keyword),
and renames the RPC_MODE_PUPPET to RPC_MODE_AUTHORITY ("auth" keyword).

This commit also renames the "Node.[get|set]_network_master" methods to
"Node.[get|set]_network_authority".

This commit also renames the RPC_MODE_REMOTE constant to RPC_MODE_ANY.

RPC_MODE_MASTER in Godot 3.x meant that a given RPC would be callable by
any puppet peer on the master, while RPC_MODE_PUPPET meant that it would
be callable by the master on any puppet.

Beside proving to be very confusing to the user (referring to where it
could be called instead of who can call it) the RPC_MODE_MASTER is quite
useless. It is almost the same as RPC_MODE_REMOTE (anyone can call) with
the exception that the network master cannot. While this could be useful
to check in some case, in such a function you would anyway need to check
in code who is the caller via get_rpc_sender_id(), so adding the check
there for those rare cases does not warrants a dedicated mode.
2021-08-30 00:54:38 +02:00
kobewi
a913ae8d56 Add support for internal nodes 2021-08-28 02:07:23 +02:00
Camille Mohr-Daurat
adafc509f3
Merge pull request #52132 from nekomatata/fix-physics-process-delta
Fix delta passed in _physics_process
2021-08-26 11:27:38 -07:00
PouleyKetchoupp
cbce1550ff Fix delta passed in _physics_process
Regression due to typo in recent GDVIRTUAL_CALL change.
2021-08-26 10:49:12 -07:00
Haoyu Qiu
eba7265a1c Fix misspelled "overriden"
In recent GDVIRTUAL PR and SkeletonModification3DJiggle doc.
2021-08-26 01:44:01 +08:00
Juan Linietsky
6609ce1944
Merge pull request #52000 from lyuma/set_editable_instance
Make Node editable_instance methods available to GDScript
2021-08-24 08:31:34 -03:00
Lyuma
7eb6ae2798 Make Node editable_instance methods available to GDScript 2021-08-23 21:45:18 -07:00
reduz
5cecdfa8af Entirely removes BIND_VMETHOD in favor of GDVIRTUAL
* `_gui_input`, `_input`, `_unhandled_input` and `_unhandled_key_input` are now regular C++ virutal functions.
* Everything else converted to GDVIRTUAL
* BIND_VMETHOD is gone, always use the new syntax from now on.

Creating `_gui_input` method and using the binder to register events will no longer work, simply override the virtual function now.
2021-08-23 08:10:13 -03:00
reduz
3682978aee Replace BIND_VMETHOD by new GDVIRTUAL syntax
* New syntax is type safe.
* New syntax allows for type safe virtuals in native extensions.
* New syntax permits extremely fast calling.

Note: Everything was replaced where possible except for `_gui_input` `_input` and `_unhandled_input`.
These will require API rework on a separate PR as they work different than the rest of the functions.

Added a new method flag METHOD_FLAG_OBJECT_CORE, used internally. Allows to not dump the core virtuals like `_notification` to the json API, since each language will implement those as it is best fits.
2021-08-22 08:23:58 -03:00
Juan Linietsky
1990721d1b
Revert "Add Node processing and physics processing cumulative (as opposed to delta) time" 2021-08-22 08:21:34 -03:00
Mohammad Khashashneh
0c027ef0f1 Add Node processing and physics processing cumulative (as opposed to delta) time. 2021-08-17 21:34:50 +03:00
Rémi Verschelde
81512a3732
Style: Cleanup code using text_editor/completion/use_single_quotes 2021-08-13 21:27:57 +02:00
Aaron Franke
84f720966c
Use doubles for time in many other places 2021-08-09 14:05:42 -05:00
Fabio Alessandrelli
9fcf3b5a9c [Net] Basic extensible MultiplayerAPI spawn/despawn.
`PackedScene`s can be configured to be spawnable via a new
`MultiplayerAPI.spawnable_config` method.
They can be configured either to be spawned automatically when coming
from the server or to always require verification.
Another method, `MultiplayerAPI.send_spawn` lets you request a spawn on
the remote peers.
When a peer receive a spawn request:
- If it comes from the server and the scene is configured as
  `SPAWN_MODE_SERVER`:
  - Spawn the scene (instantiate it, add it to tree).
  - Emit signal `network_spawn`.
- Else:
  - Emit signal `network_spawn_request`.

In a similar way, `despawn`s are handled automatically in
`SPAWN_MODE_SERVER`.

In `SPAWN_MODE_SERVER`, when a new client connects it will also receive,
from the server all the spawned (and not yet despawned) instances.
2021-08-09 16:34:40 +02:00
Rémi Verschelde
ac3322b0af
Use const references where possible for List range iterators 2021-07-25 12:22:25 +02:00
Aaron Franke
4e6efd1b07
Use C++ iterators for Lists in many situations 2021-07-23 17:38:28 -04:00
reduz
6631f66c2a Optimize StringName usage
* Added a new macro SNAME() that constructs and caches a local stringname.
* Subsequent usages use the cached version.
* Since these use a global static variable, a second refcounter of static usages need to be kept for cleanup time.
* Replaced all theme usages by this new macro.
* Replace all signal emission usages by this new macro.
* Replace all call_deferred usages by this new macro.

This is part of ongoing work to optimize GUI and the editor.
2021-07-18 21:20:02 -03:00
Rémi Verschelde
f79e79d479
Merge pull request #38819 from EricEzaM/improve-to_string-for-nodes
Added Node name to print() of all Nodes by making to_string() in Object virtual, so it can be overriden in C++.
2021-07-15 15:11:21 +02:00
Eric M
3ca25ffe8a Added Node name to print() when printing Nodes. 2021-07-15 21:48:58 +10:00
Fabio Alessandrelli
88d68346ee [Net] Rename NetworkedMultiplayerPeer to MultiplayerPeer. 2021-07-12 16:36:34 +02:00
Hugo Locurcio
730ffcf65d
Format node configuration warnings as a bullet point list
This makes multiple warnings easier to distinguish from each other.
2021-07-06 19:36:40 +02:00
Rémi Verschelde
915344fe76
Merge pull request #49834 from nekomatata/physics-disable-modes
Add support for controlling physics nodes' behavior when disabled
2021-06-30 20:36:36 +02:00
PouleyKetchoupp
5cbdc7a0ac Add support for controlling physics nodes' behavior when disabled
New property disable_mode to set different behaviors:
Remove: remove from physics simulation
MakeStatic: change body mode to static (doesn't affect area and soft body)
KeepActive: do nothing

Extra change:
Handle disable/enable node state with specific notifications, in order
to differentiate global pause from disabled nodes.
2021-06-30 09:20:44 -07:00