summaryrefslogtreecommitdiff
path: root/servers/physics_2d/godot_body_2d.cpp
AgeCommit message (Collapse)Author
2023-01-05One Copyright Update to rule them allRémi Verschelde
As many open source projects have started doing it, we're removing the current year from the copyright notice, so that we don't need to bump it every year. It seems like only the first year of publication is technically relevant for copyright notices, and even that seems to be something that many companies stopped listing altogether (in a version controlled codebase, the commits are a much better source of date of publication than a hardcoded copyright statement). We also now list Godot Engine contributors first as we're collectively the current maintainers of the project, and we clarify that the "exclusive" copyright of the co-founders covers the timespan before opensourcing (their further contributions are included as part of Godot Engine contributors). Also fixed "cf." Frenchism - it's meant as "refer to / see".
2022-10-07Fix MSVC warnings, rename shadowed variables, fix uninitialized values, ↵bruvzg
change warnings=all to use /W4.
2022-09-15PhysicsServer2D and PhysicsServer3D: make body_set_state_sync_callback take ↵Ricardo Buring
a Callable Prefer Callable to a C-style callback. This is helpful for GDExtension.
2022-08-26Restore RigidBody2/3D, SoftBody names in physicsfabriceci
2022-07-29Remove Signal connect bindsJuan Linietsky
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-01-03Update copyright statements to 2022Rémi Verschelde
Happy new year to the wonderful Godot community!
2021-12-10Improve RigidDynamicBody force and torque APIPouleyKetchoupp
Makes the API for forces and impulses more flexible, easier to understand and harmonized between 2D and 3D. Rigid bodies now have 3 sets of methods for forces and impulses: -apply_impulse() for impulses (one-shot and time independent) -apply_force() for forces (time dependent) applied for the current step -add_constant_force() for forces that keeps being applied each step Also updated the documentation to clarify the different methods and parameters in rigid body nodes, body direct state and physics servers.
2021-11-25Fix RigidDynamicBody gaining momentum with bouncePouleyKetchoupp
Bounce calculation now uses the previous frame's velocity, so it's consistent with the actual motion of the bodies involved and not the yet-to-be-applied forces. When bounce is 1, using the current velocity was causing the new forces (including gravity) to be taken into account, which lead to the bounce velocity to be higher than the falling velocity at the moment of impact, adding more and more energy over time.
2021-11-22Add wakeup() conditional if previous gravity was 0Brennen Green
2021-11-09Separate space override modes for gravity/damping in AreaPouleyKetchoupp
Also make inspector clearer for gravity point properties.
2021-11-08Expose local center of mass in physics serversPouleyKetchoupp
Center of mass in body's local space is more useful than the transformed one in some cases, like drawing its position for debug. It's especially useful to get the generated local center of mass when in auto mode (by default). Physics Server BODY_PARAM_CENTER_OF_MASS: Now always returns the local center of mass, instead of setting a local center of mass and getting a transformed one. This causes compatibility breaking, but it makes more sense for the parameter to be consistent between getter and setter. Direct Body State: There are now two properties, because both of them can be useful in different situations. center_of_mass: relative position in global coordinates (same as before) center_of_mass_local: position in local coordinates
2021-10-25Improved RigidDynamicBody linear/angular damping overridePouleyKetchoupp
Damping values are now non-negative. Add new properties linear_damp_mode and angular_damp_mode to set the way RigidDynamicBody and PhysicalBone (2D & 3D) use damping values. It can now be Combine (default) to add to the default/areas, or Replace to override the value completely (current behavior).
2021-10-22Merge pull request #54124 from Uxeron/CenterOfMassRotationFixCamille Mohr-Daurat
Fix physics body rotating incorrectly around it's center of mass
2021-10-22Fix physics body rotating incorrectly around it's center of massUxeron
2021-10-22Fix RigidDynamicBody2D auto center of mass calculationPouleyKetchoupp
Should be changing the local center of mass, which is then transformed into `center_of_mass`. It was causing the center of mass to be always in (0,0) by default with multiple shapes.
2021-10-21Fix RigidDynamicBody collision update after changing collision layer/maskPouleyKetchoupp
Changing the collision layer of a sleeping body was not triggering area updates correctly. Bodies need to be active for collision to be checked against already overlapping bodies and areas. Neighbors need to be activated too in order to handle the case where a static body is modified (it can't be activated directly but paired bodies need to check their collision again). In 3D, moved the call to wakeup() from the physics server to GodotBody3D::_shapes_changed to make it consistent with 2D and also handle the case where shapes are modified (_shapes_changed is called in both this case and collision layer changes).
2021-10-19Fix 2D center of mass not updated from transformPouleyKetchoupp
Same logic as what was done in 3D, applied to 2D center of mass. Also did some minor cleanup in 3D and fixed center of mass transform during the first frame after teleporting a dynamic body.
2021-10-18Rename Godot Physics classes from *SW to Godot*PouleyKetchoupp
Also moved MT physics server wrappers to the main servers folder, since they don't have to be implementation specific.