Commit graph

1381 commits

Author SHA1 Message Date
Juan Linietsky
7946066577
Merge pull request #49471 from nekomatata/body-state-sync-callback
Clean physics direct body state usage in 2D and 3D physics
2021-08-31 14:30:17 -03:00
Camille Mohr-Daurat
0ee1179c1c
Merge pull request #52279 from fabriceci/delta-double
Change delta type to double in Physics_body_2/3D
2021-08-31 08:25:36 -07:00
fabriceci
f9d548627d delta time as double 2021-08-31 14:32:56 +02:00
fabriceci
1a481c8191 Change platform detection by allowing select layers by type (wall or floor) 2021-08-31 09:59:04 +02:00
Juan Linietsky
07707a3627
Revert "Display a matrix for Node2D and don't display a duplicate origin" 2021-08-29 17:01:07 -03:00
Aaron Franke
ee7bb9bbb9
Display a matrix for Node2D and don't display a duplicate origin 2021-08-29 10:34:50 -05:00
Juan Linietsky
54caaa21ce
Merge pull request #51296 from ellenhp/mix_in_audio_server
Move mixing out of the AudioStreamPlayback* nodes
2021-08-27 15:38:20 -03:00
Camille Mohr-Daurat
87f575efdd
Merge pull request #52135 from fabriceci/fix-transmission-velocity-on-wall-4
Remove velocity transmission on_wall when collider is CharacterBody.
2021-08-27 10:56:42 -07:00
Ellen Poe
3598d300cb Do all audio mixing in the AudioServer 2021-08-27 10:41:57 -07:00
fabriceci
4da0cfe459 Remove velocity transmission on_wall when collider is CharacterBody. 2021-08-26 23:02:30 +02:00
PouleyKetchoupp
6a9ed72185 Clean physics direct body state usage in 2D and 3D physics
Use a C++ callback instead of Callable for synchronizing physics nodes' state with physics servers.

Remove usage of PhysicsDirectBodyState in physics nodes when not
necessary.

Store PhysicsDirectBodyState for bodies individually instead of a
singleton to avoid issues when accessing direct body state for multiple
bodies.

PhysicsDirectBodyState is initialized only when needed, so it doesn't
have to be created when using the physics server directly.

Move PhysicsDirectBodyState2D and PhysicsDirectBodyState3D to separate
cpp files.
2021-08-25 08:57:42 -07:00
PouleyKetchoupp
d9720d4395 Fix CharacterBody motion with RayShape
Make separation ray shapes work properly in move_and_slide, wihtout the
specific code in CharacterBody like before.

Now most of the logic is handled inside the physics server. The only
thing that's needed is to use ray shapes only for recovery and ignore
them when performing the motion itself (unless we're snapping or slips
on slope is on).
2021-08-24 17:34:55 -07:00
reduz
44d62a9f4b Implement NativeExtension pointer arguments
* Allows calling into native extensions directly with a pointer
* Makes it easier to implement some APIs more efficiently
* Appears with a "*" in the documentation for the argument.
* Implementing the pointer handling is entirely up to the implementation, although the extension API provides some hint.
* AudioStream has been implemented as an example, allowing to create NativeExtension based AudioStreams.
2021-08-23 19:58:40 -03:00
Hugo Locurcio
0af213a4e0
Merge pull request #51259 from nekomatata/fix-tilemap-one-way-collision
Fix one-way collision in Tilemap
2021-08-23 18:54:01 +02: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
QbieShay
d6672096fc moved particle parameters to minmax and split scale axis
This commit adds quite a chunk of modifications to particles
- particle (value + randomness) now use min and max instead
- passing a curveXYZtexture is now possible and will scale particles per-axis
- CPUParticle3D have an optional parameter to split the scale curve per-axis
2021-08-22 18:42:17 +02: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
fabriceci
68f0cf97bc add motion mode to handle TPS 2021-08-20 17:32:33 +02:00
Rémi Verschelde
4f640762f7
Merge pull request #51881 from KoBeWi/zz__iinnddeexx
Fix z_index applied twice for TileMap layers
2021-08-19 21:30:10 +02:00
ThreeRhinosInAnElephantCostume
78e2d35a7e fixed camera2d's "current" property getting reset when switching scenes 2021-08-19 15:19:19 +02:00
kobewi
a7ace9fec1 Fix z_index applied twice for TileMap layers 2021-08-19 12:40:09 +02:00
fabriceci
0cfb7de052 Correct jitter and clean code 2021-08-16 17:17:24 +02:00
fabriceci
d776b6c154 API improvement on physics, mainly CharacterBody
Changes:

- Rename few methods/property and group them in the editor when it's possible
- Make MotionResult API consistency with KinematicCollision
- Return a boolean in move_and_slide if there was a collision
- New methods:
  - get_floor_angle on CharacterBody to get the floor angle.
  - get_angle on KinematicCollision to get the collision angle.
  - get_last_slide_collision to quickly get the latest collision of move_and_slide.
2021-08-15 12:53:29 +02:00
Anilforextra
c390f0515d Use get_global_* functions instead of using transforms. 2021-08-14 14:01:57 +05:45
Aaron Franke
eb4902a455
Fix some unnecessary includes 2021-08-13 00:27:38 -05:00
Aaron Franke
03e2544d50
Use real_t and double where appropriate in Particles 2021-08-12 11:35:31 -05:00
Rémi Verschelde
c89ad92c96
Merge pull request #51532 from nekomatata/layer-mask-accessors
Uniformize layer names, script methods and documentation
2021-08-12 17:55:11 +02:00
PouleyKetchoupp
989acbbe81 Uniformize layer names, script methods and documentation
- Back to 1-based layer names to make it clearer in editor UI
- Layer bit accessors are renamed to layer value and 1-based too
- Uniform errors and documentation in render and physics
- Fix a few remaining collision_layer used in place of collision_mask
2021-08-12 08:06:42 -07:00
Rémi Verschelde
78c8b7ffec
Merge pull request #51568 from AnilBK/remove-swap
Remove unused swap template.
2021-08-12 15:52:05 +02:00
Rémi Verschelde
f54c5707b5
Merge pull request #50363 from JestemStefan/node2D_zero_scale_det_error
Limit scale of `Node2D` to EPSILON (0.00001) to prevent `det==0` error
2021-08-12 15:40:11 +02:00
Anilforextra
e3872a244d Remove unused swap template. 2021-08-12 16:58:03 +05:45
PouleyKetchoupp
4da3a87f7d Remove infinite inertia and ray shapes from CharacterBody
Infinite inertia:
Not needed anymore, since it's now possible to set one-directional
collision layers in order for characters to ignore rigid bodies, while
rigid bodies still collide with characters.

Ray shapes:
They were introduced as a work around to allow constant speed on slopes,
which is now possible with the new property in CharacterBody instead.
2021-08-10 12:10:26 -07:00
fabriceci
c6666cc051 Add properties to CharacterBody for more move_and_slide options 2021-08-10 15:57:33 +02:00
Rémi Verschelde
50d5569ad4
Merge pull request #51457 from nekomatata/moving-platforms-3d
Fix 3D moving platform logic
2021-08-10 14:12:01 +02:00
PouleyKetchoupp
ec9fed69f4 Fix 3D moving platform logic
Same thing that was already done in 2D, applies moving platform motion
by using a call to move_and_collide that excludes the platform itself,
instead of making it part of the body motion.

Helps with handling walls and slopes correctly when the character walks
on the moving platform.

Also made some minor adjustments to the 2D version and documentation.

Co-authored-by: fabriceci <fabricecipolla@gmail.com>
2021-08-09 20:21:04 -07:00
Aaron Franke
430ad75963
Some work on double support 2021-08-09 17:43:48 -05:00
Rémi Verschelde
2de5d2361a
Merge pull request #51446 from nekomatata/fix-moving-platform-rotation
Fix applied rotation from moving platforms in move_and_slide
2021-08-09 23:20:44 +02:00
PouleyKetchoupp
5650c83e4b Fix applied rotation from moving platforms in move_and_slide
When synchronizing CharacterBody motion with moving the platform using
direct body state, only the linear velocity was taken into account.

This change exposes velocity at local point in direct body state and
uses it in move_and_slide to get the proper velocity that includes
rotations.
2021-08-09 12:30:17 -07:00
Aaron Franke
84f720966c
Use doubles for time in many other places 2021-08-09 14:05:42 -05:00
PouleyKetchoupp
b9e68c8155 Fix one-way collision in Tilemap
In a given quadrant there can be one or more bodies used, and the
process iterated over cells to add the shapes, so the shape index
doesn't necessarily correspond to the polygon shape index.

Instead body shape indices need to be tracked separately.
2021-08-05 12:10:35 -07:00
kobewi
665dc7805b Fix get_used_rect() calculation 2021-08-05 20:40:21 +02:00
PouleyKetchoupp
7d0a28f875 Fix inverted condition in CharacterBody2D/3D set_max_slides 2021-08-03 19:24:46 -07:00
Gilles Roudière
ad8b5cd5a4 Implements TileMap layers and move TileSetPlugins's functions to the TileMap node instead 2021-08-02 13:54:39 +02:00
Rémi Verschelde
63be3c1f00
Merge pull request #50935 from Vitika9/50807 2021-07-30 23:37:07 +02:00
Rémi Verschelde
78f0d2d1d6
Merge pull request #50905 from fabriceci/fix-multiple-direction-collision
Allow multiple collision direction at the same time
2021-07-27 19:10:47 +02:00
vitika9
22eaec6895 Fixed Camera2D's reset_smoothing() does not work as described 2021-07-27 16:29:30 +05:30
Haoyu Qiu
448295cd51 Add check to internal methods to prevent crash 2021-07-27 12:26:13 +08:00
fabriceci
f45af43784 Allow to have multiple collision direction at the same time 2021-07-26 19:14:41 +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