summaryrefslogtreecommitdiff
path: root/servers/physics_3d
AgeCommit message (Collapse)Author
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.
2021-03-02Merge pull request #46581 from Riteo/fix-capsule-shapeRémi Verschelde
Change CapsuleShape3D's collision detection axis to vertical
2021-03-02Change CapsuleShape3D's collision detection axis to verticalRiteo Siuga
This fixes an issue where its collision detection would actually work as if it had the old default orientation.
2021-02-27Move removal of the constraints from bodies to Joint3DSW destructorEryk Dwornicki
Joint3DSW instances are also destroyed without explicitly calling free() for example when changing constrainted bodies at runtime using set_node method.
2021-02-24Merge pull request #45863 from nekomatata/physics-queries-disabled-shapesRémi Verschelde
Fix physics queries not filtering out disabled collision shapes
2021-02-17Fix test_body_motion recoveryPouleyKetchoupp
This change makes test_body_motion more reliable when the kinematic body recovers from being stuck. - When recovery occurs, the rest information is generated, in order to make sure collision results from test_move, move_and_collide and move_and_slide are consistent and return a collision in case of overlap. - The new calculation for recovery vector makes sure the recovery is never more than the overlap depth between shapes. This can help with cases where the kinematic body overlaps with several shapes. Recovery is made iteratively, without forcing a full overlap at each step. This helps with getting proper rest information when recovery occurs. - One Way Collision: When attempting motion, contact direction is checked against motion before skipping in order to solve cases where kinematic bodies can sink into one-way collision shapes. Rest info now sets max contact depth in order to properly handle one-way collision. - Low speed motion is now handled in the rest info, by never setting min_allowed_depth lower than motion length. Separation is always applied with full margin, otherwise contact is lost when low speed motion occurs right after higher speed motion. - Similar changes are applied to 3D in order to make 2D and 3D consistent.
2021-02-12Revised cylinder contact point generationPouleyKetchoupp
Cylinder contact points generation is adjusted to make it more stable when standing on triangle meshes. Point-Circle: Switched to simpler plane projection as it's done for Point-Face contact points. It solves some cases where discrepancies between the two points caused the cylinder to jump. Edge-Circle: Same as before, the case for edge has just been moved from Face-Circle to a specific method. Face-Circle: The previous method was clipping edges against the circle, and then tried to add contact points when there wasn't enough support and failed in some cases. Now using a different algorithm which adds proper contact points around the circle more consistently. First, by clipping edges against circle segments using Face-Face algorithm. Second, by clipping edges against the circle plane.
2021-02-10Cylinder support in Godot Physics 3DPouleyKetchoupp
Cylinder collision detection uses a mix of SAT and GJKEPA. GJKEPA is used to find the best separation axis in cases where finding it analytically is too complex. Changes in SAT solver: Added support for generating separation axes for cylinder shape. Added support for generating contact points with circle feature. Changes in GJKEPA solver: Updated from latest Bullet version which includes EPA fixes in some scenarios. Setting a lower EPA_ACCURACY to fix accuracy problems with cylinder vs. cylinder in some cases.
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-02-09Fix physics queries not filtering out disabled collision shapesPouleyKetchoupp
This change allows collide_shape, intersect_shape, cast_motion and rest_info in both 2D and 3D to ignore disabled shapes and make them consistent with the physics simulation. In some other cases, _cull_aabb_for_body is used and filters shapes out internally, but whenever a physics query uses the broadphase directly without calling _cull_aabb_for_body, disabled shapes can be returned and need to be filtered out.
2021-02-01Merge pull request #37547 from aaronfranke/tauRémi Verschelde
Use Math_TAU and deg2rad/etc in more places and optimize code
2021-01-28Use real_t in physics codeAaron Franke
2021-01-14Merge pull request #43923 from madmiraal/fix-43588Rémi Verschelde
Fix cast_motion sometimes failing
2021-01-12CI: Update to clang-format 11 and apply ternary operator changesRémi Verschelde
2021-01-09Use Math_TAU and deg2rad/rad2deg in more places and optimize codeAaron Franke
2021-01-07Fix multiple issues with one-way collisionsMarcel Admiraal
For RigidBodies, uses the collision normal determined by relative motion to determine whether or not a one-way collision has occurred. For KinematicBodies, performs additional checks to ensure a one-way collision has occurred, and averages the recovery step over all collision shapes. Co-authored-by: Sergej Gureev <sergej.gureev@relex.fi>