summaryrefslogtreecommitdiff
path: root/servers/physics_server_2d.cpp
AgeCommit message (Collapse)Author
2022-02-14Validate PhysicsDirectSpaceState{2,3}D::_intersect_point inputHaoyu Qiu
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-12-03Update space parameters in 2D and 3DPouleyKetchoupp
Clarified space parameters for contacts and added missing ones. List of changes: -Add contact bias to space parameters -Add solver iterations to space parameters, instead of a specific physics server function -Renamed BODY_MAX_ALLOWED_PENETRATION to CONTACT_MAX_ALLOWED_PENETRATION to make it consistent with other contact parameters
2021-11-11Merge pull request #54810 from nekomatata/area-separate-override-modesCamille Mohr-Daurat
Separate space override modes for gravity/damping in Area
2021-11-10Add raycast options to hit when starting inside / hit back facesPouleyKetchoupp
Makes the results consistent for all shape types with options to set the desired behavior.
2021-11-09Separate space override modes for gravity/damping in AreaPouleyKetchoupp
Also make inspector clearer for gravity point properties.
2021-11-08Merge pull request #54134 from nekomatata/body-center-of-mass-localCamille Mohr-Daurat
Expose local center of mass in physics servers
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-11-04Use parameter classes instead of arguments for all physics queriesPouleyKetchoupp
Same as what is already done for shape queries, applied to point and ray queries. Easier to document and more flexible to add more parameters. Also expose intersect_point method to script in 3D. Remove intersect_point_on_canvas in 2D, replaced with a parameter.
2021-11-01Use `Callable` in Area monitor callbackrafallus
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-09Fix missing argument names in bindingsRémi Verschelde
While at it, tweak some boolean setters to use `p_enabled` for the bool. Also renames `draw_minimap()` to `set_draw_minimap()`.
2021-10-04Fix physics glitch with TileMap moving platformsPouleyKetchoupp
Added a parameter in test_body_motion to exclude attached objects from collision, used to avoid collision with all TileMap tiles with moving platform motion instead of just the one tile the character touches. Same changes made in 3D for consistency, and handling potential similar cases.
2021-10-04Script interface improvements for test body motionPouleyKetchoupp
-Physics servers test body motion use a class to hold parameters instead of multiple arguments to make it more readable and flexible since there are many options -Improved documentation for test body motion and kinematic collision -Removed read-only properties for body motion results (not handled in scripts, so they should be get_ methods only instead)
2021-10-03Merge pull request #42364 from madmiraal/fix-39887Rémi Verschelde
2021-09-30Remove shape metadata from 2D physics serverPouleyKetchoupp
Shape metadata was only used to get tile information when colliding with tilemaps. It's not needed anymore since there's an API in tilemap using body ids instead.
2021-09-28Merge pull request #52754 from nekomatata/dynamic-body-modesCamille Mohr-Daurat
Clarify RigidDynamicBody modes
2021-09-27Improved logic for CharacterBody collision recovery depthPouleyKetchoupp
Allows 2D character controller to work without applying gravity when touching the ground (also more safely in 3D), and collision detection is more flexible with different safe margin values. Character body motion changes in 2D and 3D: -Recovery only for depth > min contact depth to help with collision detection consistency (rest info could be lost if recovery was too much) -Adaptive min contact depth (based on margin) instead of space parameter Extra CharacterBody changes: -2D: apply changes made in 3D for stop on slope and floor snap that help fixing some jittering cases -3D: fix minor inconsistencies in stop on slope and floor snap logic
2021-09-16Clarify RigidDynamicBody modesPouleyKetchoupp
RigidDynamicBody modes are replaced with several properties to make their usage clearer: -lock_rotation: disable body's rotation (instead of MODE_LOCKED) -freeze: no gravity or forces (instead of MODE_STATIC and MODE_KINEMATIC) -freeze_mode: Static (can be only teleported) or Kinematic (can be animated) Also renamed MODE_DYNAMIC_LOCKED to MODE_DYNAMIC_LINEAR in the physics servers.
2021-09-14Rename WorldMarginShape to WorldBoundaryShapePouleyKetchoupp
2021-09-06Proper support for custom mass properties in 2D/3D physics bodiesPouleyKetchoupp
Changes: -Added support for custom inertia and center of mass in 3D -Added support for custom center of mass in 2D -Calculated center of mass from shapes in 2D (same as in 3D) -Fixed mass properties calculation with disabled shapes in 2D/3D -Removed first_integration which is not used in 2D and doesn't seem to make a lot of sense (prevents omit_force_integration to work during the first frame) -Support for custom inertia on different axes for RigidBody3D
2021-08-30Harmonize default value for collision mask in ray/shape queriesPouleyKetchoupp
The default mask for queries was 0, 0x7FFFFFFF or 0xFFFFFFFF depending on the cases. Now always using 0xFFFFFFFF (in the form of UINT32_MAX to make it clear) in order to use all layers by default.
2021-08-24Rename RayShape to SeparationRayShapePouleyKetchoupp
Makes it clearer that it's used for special cases when picking a collision shape.
2021-08-24Fix CharacterBody motion with RayShapePouleyKetchoupp
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-24Restore RayShape as a regular shape typePouleyKetchoupp
Partial revert from previously removing ray shapes completely, added back as a shape type but without the specific character controller code.
2021-08-15API improvement on physics, mainly CharacterBodyfabriceci
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-14Rename LineShape2D to WorldMarginShape2DHugo Locurcio
The new name makes it more obvious that it acts as an infinite plane, and is consistent with its 3D counterpart (WorldMarginShape3D).
2021-08-12Uniformize layer names, script methods and documentationPouleyKetchoupp
- 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-10Remove infinite inertia and ray shapes from CharacterBodyPouleyKetchoupp
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-09Fix applied rotation from moving platforms in move_and_slidePouleyKetchoupp
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-07-15Fixing 2D moving platform logicfabriceci
Fixing by applying the movement in two steps, first the platform movement, and then the body movement. Plus, add the platform movement when we are on_wall.
2021-07-05Remove unused PhysicsShapeQueryResult3D & PhysicsShapeQueryResult2DPouleyKetchoupp
2021-06-28Fix move_and_collide causing sliding on slopesPouleyKetchoupp
Make sure the direction of the motion is preserved, unless the depth is higher than the margin, which means the body needs depenetration in any direction. Also changed move_and_slide to avoid sliding on the first motion, in order to avoid issues with unstable position on ground when jumping. Co-authored-by: fabriceci <fabricecipolla@gmail.com>
2021-06-04More explanatory names for RigidBody modesPouleyKetchoupp
MODE_DYNAMIC instead of MODE_RIGID MODE_DYNAMIC_LOCKED instead of MODE_CHARACTER No more special case for sleeping behavior for MODE_DYNAMIC_LOCKED (MODE_CHARACTER was forcing the body not to sleep, which is redundant with can_sleep and wasn't done in Bullet).
2021-06-04KinematicBody split between new CharacterBody and PhysicsBodyPouleyKetchoupp
PhysicsBody now has methods move_and_collide/test_move and needed properties for these methods: safe margin, locked axes (3D only). Moved collision_exceptions from StaticBody to PhysicsBody for 3D (same as 2D, and conforms to documentation). RigidBody doesn't have test_motion method anymore, it's now redundant with PhysicsBody.test_move.
2021-05-19Enable setting of collision iterations in PhysicsServer2DRhathe
This allows fine-tuning of collision iterations for more accurate collision physics with a performance cost.
2021-04-30Prevent setting too big or too small Collision Mask and LayerRafał Mikrut
2021-04-22Unexpose _direct_state_changed in PhysicsBodyrafallus
Removed _direct_state_changed bindings Affects 2D and 3D nodes Callbacks now use Callable Tests were changed accordingly
2021-02-10Make Servers truly Thread Safereduz
-Rendering server now uses a split RID allocate/initialize internally, this allows generating RIDs immediately but initialization to happen later on the proper thread (as rendering APIs generally requiere to call on the right thread). -RenderingServerWrapMT is no more, multithreading is done in RenderingServerDefault. -Some functions like texture or mesh creation, when renderer supports it, can register and return immediately (so no waiting for server API to flush, and saving staging and command buffer memory). -3D physics server changed to be made multithread friendly. -Added PhysicsServer3DWrapMT to use 3D physics server from multiple threads. -Disablet Bullet (too much effort to make multithread friendly, this needs to be fixed eventually).
2021-01-28Use real_t in physics codeAaron Franke
2021-01-01Update copyright statements to 2021Rémi Verschelde
Happy new year to the wonderful Godot community! 2020 has been a tough year for most of us personally, but a good year for Godot development nonetheless with a huge amount of work done towards Godot 4.0 and great improvements backported to the long-lived 3.2 branch. We've had close to 400 contributors to engine code this year, authoring near 7,000 commit! (And that's only for the `master` branch and for the engine code, there's a lot more when counting docs, demos and other first-party repos.) Here's to a great year 2021 for all Godot users 🎆
2020-11-09Variant: Rename Type::_RID to Type::RIDRémi Verschelde
The underscore prefix was used to avoid the conflict between the `RID` class name and the matching enum value in `Variant::Type`. This can be fixed differently by prefixing uses of the `RID` class in `Variant` with the scope resolution operator, as done already for `AABB`.
2020-11-07Reorganized core/ directory, it was too fatty alreadyreduz
-Removed FuncRef, since Callable makes it obsolete -Removed int_types.h as its obsolete in c++11+ -Changed color names code
2020-10-18Refactor MethodBind to use variadic templatesreduz
Removed make_binders and the old style generated binders.
2020-09-27Increment index when populating PhysicsShapeQueryParameters exclude array.Marcel Admiraal
2020-07-02Merge pull request #37350 from aaronfranke/force-impulseRémi Verschelde
Refactor physics force and impulse code to use (force, position) order
2020-06-26Expose shape property for shape query parameters classesAndrii Doroshenko (Xrayez)
Co-authored-by: PouleyKetchoupp <pouleyketchoup@gmail.com>
2020-06-04Correct misspellings of damped spring.Marcel Admiraal
2020-06-02Refactor physics force and impulse codeAaron Franke