summaryrefslogtreecommitdiff
path: root/servers/physics_3d
AgeCommit message (Collapse)Author
2021-07-25Fix various typos with codespellluz paz
Found via `codespell -q 3 -S ./thirdparty,*.po,./DONORS.md -L ackward,ang,ans,ba,beng,cas,childs,childrens,dof,doubleclick,fave,findn,hist,inout,leapyear,lod,nd,numer,ois,ony,paket,seeked,sinc,switchs,te,uint`
2021-07-21Merge pull request #50686 from Calinou/use-standard-inf-nan-constantsRémi Verschelde
Use the standard C `INFINITY` and `NAN` constants directly
2021-07-21Use the standard C `INFINITY` and `NAN` constants directlyHugo Locurcio
The `Math_INF` and `Math_NAN` defines were just aliases for those constants, so we might as well use them directly. Some portions of the code were already using `INFINITY` directly.
2021-07-21Use is_equal_approx in more placesAaron Franke
2021-07-19Ensure KinematicBodies only interact with other Bodies with matching mask.Marcel Admiraal
2021-07-14Merge pull request #50255 from Calinou/physicsserver3d-add-set-iterationsRémi Verschelde
Add a method to set the number of physics solver iterations in 3D
2021-07-13Merge pull request #50063 from nekomatata/more-accurate-move-and-slideRémi Verschelde
Make move_and_slide collision detection more accurate
2021-07-10Add a method to set the number of physics solver iterations in 3DHugo Locurcio
This is only for GodotPhysics, and adds a 3D counterpart to the 2D method that was recently added.
2021-07-06Fix concave collision with backface collision disabledPouleyKetchoupp
Disabled backface collision is only applied on face separation axes, because applying it also on edges and vertices was causing some contacts to be wrongly disabled and contact points to be off.
2021-07-01Make move_and_slide collision detection more accuratePouleyKetchoupp
More accurate unsafe motion calculation * Safe and unsafe motion are calculated by dichotomy with a limited number of steps. It's good for performance, but on long motions that either collide near the beginning or near the end, the result can be very imprecise. * Now a factor 0.25 or 0.75 is used to converge faster when this case happens, which allows longer motions to get more accurate collision detection. * Makes snap collision more precise, and helps with cases where diagonal collision on the border of a platform can lead to the character being stuck. Additional improvements to move_and_slide: * Handle slide canceling in move_and_collide with 0 velocity instead of not applying it. * Better handling of snap with custom logic to cancel sliding. * Remove small jittering when using stop on slope, by canceling the motion completely when the resulting motion is less than margin instead of always projecting to the up direction (in both body motion and snap). Co-authored-by: fabriceci <fabricecipolla@gmail.com>
2021-06-30Merge pull request #49844 from nekomatata/physics-disabled-shapesRémi Verschelde
Fix and clean disabled shapes handling in godot physics servers
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-22Fix and clean disabled shapes handling in godot physics serversPouleyKetchoupp
In 3D, disabled shapes are now not added to the broadphase anymore. Since they are removed right away when disabled, no need to check for disabled shapes for any query that comes from the broadphase. Also Fixes raycast queries returning disabled shapes. In 2D, disabled shapes where already not added to the broadphase. Remove the same unnecessary checks as in 3D. Overall harmonized API for disabled shapes in the physics servers and removed duplicate method.
2021-06-11Merge pull request #42636 from madmiraal/fix-infinite-inertiaRémi Verschelde
2021-06-09Refactor CommandQueueMTreduz
* RingBuffer had no reason to be in this context * A single buffer is used that can grow as much as the game needs. This should make thread loading entirely reliable.
2021-06-07Style: Cleanup uses of double spaces between wordsRémi Verschelde
Or after punctuation. Tried to leave third-party stuff alone, unless it has been heavily modified for Godot.
2021-06-05Merge pull request #45364 from madmiraal/rename-quatRémi Verschelde
Rename Quat to Quaternion
2021-06-04Safe margin cleanupPouleyKetchoupp
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.
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-04Rename Quat to QuaternionMarcel Admiraal
2021-06-03Rename files and the exposed name for Transform3DAaron Franke
2021-06-03Rename Transform to Transform3D in coreAaron Franke
2021-05-29Avoid division by zero when calculating inertias for bodies with colliders ↵Arkadiusz Marcin Kołek
without areas.
2021-05-22Replace QuickHull with Bullet's convex hull computer.Morris Tabor
The code is based on the current version of thirdparty/vhacd and modified to use Godot's types and code style. Additional changes: - extended PagedAllocator to allow leaked objects - applied patch from https://github.com/bulletphysics/bullet3/pull/3037
2021-05-20Fix typos with codespellRémi Verschelde
Using codespell 2.0.0. Method: ``` $ cat > ../godot-word-whitelist.txt << EOF ang curvelinear dof doubleclick fave findn GIRD leapyear lod merchantibility nd numer ois ony que seeked synching te uint unselect webp EOF $ codespell -w -q 3 -I ../godot-word-whitelist.txt --skip="./thirdparty,*.po" $ git diff // undo unwanted changes ```
2021-05-10Dynamic BVH broadphase in 2D & 3D Godot PhysicsPouleyKetchoupp
Port lawnjelly's dynamic BVH implementation from 3.x to be used in both 2D and 3D broadphases. Removed alternative broadphase implementations which are not meant to be used anymore since they are much slower. Includes changes in Rect2, Vector2, Vector3 that help with the template implementation of the dynamic BVH by uniformizing the interface between 2D and 3D math. Co-authored-by: lawnjelly <lawnjelly@gmail.com>
2021-04-26Godot Physics collisions and solver processed on threadsPouleyKetchoupp
Use ThreadWorkPool to process physics step tasks in multiple threads. Collisions are all processed in parallel and solving impulses is processed in parallel for rigid body islands. Additional changes: - Proper islands for soft bodies linked to active bodies - All moving areas are on separate islands (can be parallelized) - Fix inconsistencies with body islands (Kinematic bodies could link bodies together or not depending on the processing order) - Completely prevent static bodies to be active (it could cause islands to be wrongly created and cause dangerous multi-threading operations as well as inconsistencies in created islands) - Apply impulses only on dynamic bodies to avoid unsafe multi-threaded operations (static bodies can be on multiple islands) - Removed inverted iterations when populating body islands, it's now faster in regular order (maybe after fixing inconsistencies)
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-04-20Merge pull request #47347 from nekomatata/heightmap-supportRémi Verschelde
Heightmap collision shape support in Godot Physics
2021-04-15Fix errors related to joints setup with two non-dynamic bodiesPouleyKetchoupp
2021-04-14Merge pull request #47846 from nekomatata/solver-optimizationRémi Verschelde
Godot Physics solver optimization
2021-04-12Godot Physics solver optimizationPouleyKetchoupp
Several optimizations in the way solver islands are processed in both 2D and 3D physics: - Use LocalVector instead of linked list to avoid cache misses (with persistent storage based on worst case scenario) - Remove pairs when setup fails (no valid contact) to avoid unnecessary solving of non-colliding rigid bodies just to return immediately
2021-04-12Fix SoftBody contact impulses applied on rigid bodiesPouleyKetchoupp
Parameters were inverted in `apply_impulse` and `apply_bias_impulse` due to a modification on master.
2021-04-06Ensure ConvexPolygonShape3D support count variable is initialisedMarcel Admiraal
2021-04-05Style: Apply clang-tidy's `readability-braces-around-statements`Rémi Verschelde
2021-04-05Style: Apply clang-tidy's `modernize-use-nullptr`Rémi Verschelde
2021-03-26Merge pull request #44695 from madmiraal/fix-44632Rémi Verschelde
Remove all elements from monitored_bodies and monitored_areas when processed
2021-03-25Heightmap collision shape support in Godot PhysicsPouleyKetchoupp
2021-03-22[Godot Physics]: Correct typo in moment of inertia calculations.Josh Jones
The moment of inertia calculation for BoxShape is: ``` Vector3( (p_mass / 3.0) * (ly * ly + lz * lz), (p_mass / 3.0) * (lx * lx + lz * lz), (p_mass / 3.0) * (lx * lx + ly * ly)); ``` where the final line includes both the x and y extents. However, for CapsuleShape3D, CylinderShape3D, ConvexPolygonShape3D, ConcavePolygonShape3D, and HeightMapShape3D, the final line read `(p_mass / 3.0) * (extents.y * extents.y + extents.y * extents.y)`. I believe this is a mistake, considering the comment in each case mentions using an AABB approximation, which should follow the same approach as BoxShape. This change corrects the final line to include both the x and y components of the shape's extent.
2021-03-20Merge pull request #46917 from nekomatata/solver-kinematic-bug-fixRémi Verschelde
Fix GodotPhysics solver with kinematic body set to report contacts
2021-03-20Merge pull request #47130 from e344fde6bf/fix-angular-velocity-calculationRémi Verschelde
Fix kinematic angular velocity calculations
2021-03-20Merge pull request #46937 from nekomatata/soft-body-supportRémi Verschelde
SoftBody support in GodotPhysics 3D
2021-03-20Fix some angular velocity calculationse344fde6bf
The angular velocity estimate for kinematic bodies was calculated incorrectly. Also, fixes its use in some kinematic/rigid collision calculations. This fixes #47029.
2021-03-18Disable backface collision with ConcavePolygonShape by defaultPouleyKetchoupp
Helps a lot with soft bodies and generally useful to avoid shapes to go through the ground in certain cases. Added an option in ConcavePolygonShape to re-enable backface collision on specific bodies if needed.
2021-03-18SoftBody support in GodotPhysics 3DPouleyKetchoupp
- Fixed SoftBody surface update with new rendering system - Added GodotPhysics implementation for SoftBody - Added support to get SoftBody rid to interact with the physics server - Added support to get SoftBody bounds from the physics server - Removed support for unused get_vertex_position and get_point_offset from the physics server - Removed SoftBody properties that are unused in both Bullet and GodotPhysics (angular and volume stiffness, pose matching) - Added RenderingServerHandler interface to PhysicsServer3D so the physics servers don't need to reference the class from SoftBody node directly
2021-03-17Merge pull request #47067 from nekomatata/cylinder-fix-marginsRémi Verschelde
Fix Cylinder shape collision with margins when using GJK-EPA
2021-03-16Fix capsule-cylinder collision in godot physicsPouleyKetchoupp
Test specific axes before falling back to GJK-EPA algorithm to get more accurate separation axes for common cases, the same way it's done for cylinder-cylinder collision.
2021-03-16Fix Cylinder shape collision with margins when using GJK-EPAPouleyKetchoupp
In the case of falling back to GJK-EPA algorithm to generate cylinder contact points, margins were never taken into account. This fixes the depenetration phase for kinematic bodies and allows consistent floor detection for cylinder shapes.
2021-03-11Fix GodotPhysics solver with kinematic body set to report contactsPouleyKetchoupp
In 3D, collision is disabled between kinematic/static bodies when contacts are generated only to report them. In 2D, this case was already fixed but the code is cleaned to make it easier to follow.
2021-03-08Fixes division by zero when 3d body does not have valid shapeKyle
Fixes #46738 by setting the default inertia to a valid value when there are no valid shapes for a 3d body. Changed the comment style for the update_inertias method as well.