summaryrefslogtreecommitdiffstats
path: root/servers/physics_server_3d.h
Commit message (Collapse)AuthorAgeFilesLines
* Add a new HashSet templatereduz2022-05-201-5/+5
| | | | | * Intended to replace RBSet in most cases. * Optimized for iteration speed
* Add motion parameter to toggle whether recovery is reported as a collisionRicardo Buring2022-05-181-0/+4
| | | | This makes the intent explicit in each use case.
* Replace most uses of Map by HashMapreduz2022-05-161-5/+5
| | | | | | | | | | | | * 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!
* Remove `RES` and `REF` typedefs in favor of spelled out `Ref<>`Hugo Locurcio2022-05-031-3/+3
| | | | | | These typedefs don't save much typing compared to the full `Ref<Resource>` and `Ref<RefCounted>`, yet they sometimes introduce confusion among new contributors.
* Create GDExtension clases for PhysicsServer3Dreduz2022-03-151-7/+18
| | | | | | | * Allows creating a GDExtension based 3D Physics Server (for Bullet, PhysX, etc. support) * Some changes on native struct binding for PhysicsServer This allows a 3D Physics server created entirely from GDExtension. Once it works, the idea is to port the 2D one to it.
* Update copyright statements to 2022Rémi Verschelde2022-01-031-2/+2
| | | | Happy new year to the wonderful Godot community!
* Improve RigidDynamicBody force and torque APIPouleyKetchoupp2021-12-101-14/+29
| | | | | | | | | | | | | 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.
* Add physics solver settings to project settingsPouleyKetchoupp2021-12-071-2/+0
| | | | | | | | | | | | Helps with discovery and setup of physics solver settings, in a specific project settings section for both 2D and 3D. Other changes for cleanup: -Removed unused space parameters in 3D SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS -Added custom solver bias for Shape3D (same as Shape2D) -Improved documentation for solver settings
* Merge pull request #55602 from nekomatata/improve-rigidbody-contactsRémi Verschelde2021-12-061-3/+3
|\
| * Update space parameters in 2D and 3DPouleyKetchoupp2021-12-031-3/+3
| | | | | | | | | | | | | | | | | | | | | | 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
* | Don't return reference on copy assignment operatorsRémi Verschelde2021-11-301-2/+1
|/ | | | | | | | | | | | | We prefer to prevent using chained assignment (`T a = b = c = T();`) as this can lead to confusing code and subtle bugs. According to https://en.wikipedia.org/wiki/Assignment_operator_(C%2B%2B), C++ allows any arbitrary return type, so this is standard compliant. This could be re-assessed if/when we have an actual need for a behavior more akin to that of the C++ STL, for now this PR simply changes a handful of cases which were inconsistent with the rest of the codebase (`void` return type was already the most common case prior to this commit).
* Merge pull request #54810 from nekomatata/area-separate-override-modesCamille Mohr-Daurat2021-11-111-3/+3
|\ | | | | Separate space override modes for gravity/damping in Area
| * Separate space override modes for gravity/damping in AreaPouleyKetchoupp2021-11-091-3/+3
| | | | | | | | Also make inspector clearer for gravity point properties.
* | Add raycast options to hit when starting inside / hit back facesPouleyKetchoupp2021-11-101-0/+9
|/ | | | | Makes the results consistent for all shape types with options to set the desired behavior.
* Merge pull request #54134 from nekomatata/body-center-of-mass-localCamille Mohr-Daurat2021-11-081-0/+1
|\ | | | | Expose local center of mass in physics servers
| * Expose local center of mass in physics serversPouleyKetchoupp2021-11-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Use parameter classes instead of arguments for all physics queriesPouleyKetchoupp2021-11-041-56/+147
|/ | | | | | | | 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.
* Use `Callable` in Area monitor callbackrafallus2021-11-011-2/+2
|
* Improved RigidDynamicBody linear/angular damping overridePouleyKetchoupp2021-10-251-0/+8
| | | | | | | | | 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).
* Rename Godot Physics classes from *SW to Godot*PouleyKetchoupp2021-10-181-3/+3
| | | | | Also moved MT physics server wrappers to the main servers folder, since they don't have to be implementation specific.
* Fix physics glitch with TileMap moving platformsPouleyKetchoupp2021-10-041-0/+4
| | | | | | | | | 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.
* Script interface improvements for test body motionPouleyKetchoupp2021-10-041-16/+54
| | | | | | | | | -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)
* Remove scene code in physics serversPouleyKetchoupp2021-10-011-1/+1
| | | | Replaced Mesh with mesh RID in Godot Physics 3D and Bullet.
* Remove shape metadata from 2D physics serverPouleyKetchoupp2021-09-301-1/+0
| | | | | | 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.
* Merge pull request #52754 from nekomatata/dynamic-body-modesCamille Mohr-Daurat2021-09-281-1/+1
|\ | | | | Clarify RigidDynamicBody modes
| * Clarify RigidDynamicBody modesPouleyKetchoupp2021-09-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | 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.
* | Improved logic for CharacterBody collision recovery depthPouleyKetchoupp2021-09-271-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Port 2D improvement to move and slide 3Dfabriceci2021-09-221-24/+41
|/ | | | Co-authored-by: Camille Mohr-Daurat <pouleyketchoup@gmail.com>
* Rename WorldMarginShape to WorldBoundaryShapePouleyKetchoupp2021-09-141-2/+2
|
* Proper support for custom mass properties in 2D/3D physics bodiesPouleyKetchoupp2021-09-061-2/+6
| | | | | | | | | | | | 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
* Merge pull request #52271 from nekomatata/query-layer-default-maskCamille Mohr-Daurat2021-09-061-13/+11
|\ | | | | Harmonize default value for collision mask in ray/shape queries
| * Harmonize default value for collision mask in ray/shape queriesPouleyKetchoupp2021-08-301-13/+11
| | | | | | | | | | | | | | | | 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.
* | Merge pull request #49471 from nekomatata/body-state-sync-callbackJuan Linietsky2021-08-311-0/+4
|\ \ | |/ |/| Clean physics direct body state usage in 2D and 3D physics
| * Clean physics direct body state usage in 2D and 3D physicsPouleyKetchoupp2021-08-251-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Rename RayShape to SeparationRayShapePouleyKetchoupp2021-08-241-2/+2
| | | | | | | | | | Makes it clearer that it's used for special cases when picking a collision shape.
* | Fix CharacterBody motion with RayShapePouleyKetchoupp2021-08-241-2/+2
| | | | | | | | | | | | | | | | | | | | 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).
* | Restore RayShape as a regular shape typePouleyKetchoupp2021-08-241-0/+2
|/ | | | | Partial revert from previously removing ray shapes completely, added back as a shape type but without the specific character controller code.
* Enabled area-specific wind forcesJeffrey Cochran2021-08-231-1/+5
|
* API improvement on physics, mainly CharacterBodyfabriceci2021-08-151-3/+7
| | | | | | | | | | | | 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.
* Remove infinite inertia and ray shapes from CharacterBodyPouleyKetchoupp2021-08-101-18/+2
| | | | | | | | | | | 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.
* Fix 3D moving platform logicPouleyKetchoupp2021-08-091-2/+2
| | | | | | | | | | | | | 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>
* Fix applied rotation from moving platforms in move_and_slidePouleyKetchoupp2021-08-091-0/+2
| | | | | | | | | 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.
* Add a method to set the number of physics solver iterations in 3DHugo Locurcio2021-07-101-0/+2
| | | | | This is only for GodotPhysics, and adds a 3D counterpart to the 2D method that was recently added.
* Remove unused PhysicsShapeQueryResult3D & PhysicsShapeQueryResult2DPouleyKetchoupp2021-07-051-22/+0
|
* Expose body_test_motion in 3D physics serverPouleyKetchoupp2021-07-021-0/+31
| | | | | | | Results are exposed through PhysicsTestMotionResult3D, the same way it's done for 2D. Also cleaned a few things in the 2D version.
* Fix move_and_collide causing sliding on slopesPouleyKetchoupp2021-06-281-0/+3
| | | | | | | | | | | 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>
* Rename Reference to RefCountedPedro J. Estébanez2021-06-111-4/+4
|
* Fix uninitialized members in physics query resultsPouleyKetchoupp2021-06-071-5/+5
|
* Safe margin cleanupPouleyKetchoupp2021-06-041-4/+1
| | | | | | | | Safe margin property on CharacterBody only, used as argument in move_and_collide. Removed kinematic_safe_margin in 3D physics server, not really useful and now harmonized with 2D.
* More explanatory names for RigidBody modesPouleyKetchoupp2021-06-041-2/+2
| | | | | | | | | 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).