summaryrefslogtreecommitdiff
path: root/servers/physics_3d/space_3d_sw.cpp
AgeCommit message (Collapse)Author
2021-08-24Rename RayShape to SeparationRayShapePouleyKetchoupp
Makes it clearer that it's used for special cases when picking a collision shape.
2021-08-24Rename slips_on_slope to slide_on_slopePouleyKetchoupp
Also added some precision to the documentation.
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-16Merge pull request #51645 from fabriceci/improve-physics-apiRémi Verschelde
API improvement on the physics (CharacterBody and related classes)
2021-08-15Enabled softbody-area collision (intersection) and enabled area-specific ↵Jeffrey Cochran
gravity for soft bodies.
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-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 3D moving platform logicPouleyKetchoupp
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>
2021-07-19One-directional collision layer check for rigid bodies and soft bodiesPouleyKetchoupp
Check for each body individually if it collides with the other one or ignores it. When a body is being ignored, the other body's mass is considered infinite when applying impulses to avoid extra overlapping.
2021-07-19Ensure KinematicBodies only interact with other Bodies with matching mask.Marcel Admiraal
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-03Rename Transform to Transform3D in coreAaron Franke
2021-03-20Merge pull request #47130 from e344fde6bf/fix-angular-velocity-calculationRémi Verschelde
Fix kinematic angular velocity calculations
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-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-06Apply infinite inertia checks to Godot physics 3DMarcel Admiraal
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-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-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>
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-27Fix cast_motion sometimes failingMarcel Admiraal
- Fixes Godot physics failing when the cast Shape is inside of, or already colliding with another Shape. - Fixes Bullet physics failing when there is no motion. - Ensures Godot and Bullet physics behave the same. - Updates the documentation to exclude the caveats for the failures and differences.
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-07-27Revert "Allow Area2D and 3D mouse events without a collision layer"Rémi Verschelde
This reverts commit 7eebb06b5571437828d8c5099558c303c72cd1f4.
2020-07-10Allow Area2D and 3D mouse events without a collision layerTomasz Chabora
Co-authored-by: madmiraal <madmiraal@users.noreply.github.com>
2020-06-08Test collision mask before creating constraint pair in Godot physics ↵Marcel Admiraal
broadphase 2D and 3D.
2020-05-14Style: Enforce braces around if blocks and loopsRémi Verschelde
Using clang-tidy's `readability-braces-around-statements`. https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
2020-05-14Style: Enforce separation line between function definitionsRémi Verschelde
I couldn't find a tool that enforces it, so I went the manual route: ``` find -name "thirdparty" -prune \ -o -name "*.cpp" -o -name "*.h" -o -name "*.m" -o -name "*.mm" \ -o -name "*.glsl" > files perl -0777 -pi -e 's/\n}\n([^#])/\n}\n\n\1/g' $(cat files) misc/scripts/fix_style.sh -c ``` This adds a newline after all `}` on the first column, unless they are followed by `#` (typically `#endif`). This leads to having lots of places with two lines between function/class definitions, but clang-format then fixes it as we enforce max one line of separation. This doesn't fix potential occurrences of function definitions which are indented (e.g. for a helper class defined in a .cpp), but it's better than nothing. Also can't be made to run easily on CI/hooks so we'll have to be careful with new code. Part of #33027.
2020-05-14Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocksRémi Verschelde
Which means that reduz' beloved style which we all became used to will now be changed automatically to remove the first empty line. This makes us lean closer to 1TBS (the one true brace style) instead of hybridating it with some Allman-inspired spacing. There's still the case of braces around single-statement blocks that needs to be addressed (but clang-format can't help with that, but clang-tidy may if we agree about it). Part of #33027.
2020-05-14Enforce use of bool literals instead of integersRémi Verschelde
Using clang-tidy's `modernize-use-bool-literals`. https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-bool-literals.html
2020-05-10Style: clang-format: Disable AllowShortCaseLabelsOnASingleLineRémi Verschelde
Part of #33027.
2020-04-02Replace NULL with nullptrlupoDharkael
2020-03-28More server renames for consistency after #37361Rémi Verschelde
2020-03-27Renaming of servers for coherency.Juan Linietsky
VisualServer -> RenderingServer PhysicsServer -> PhysicsServer3D Physics2DServer -> PhysicsServer2D NavigationServer -> NavigationServer3D Navigation2DServer -> NavigationServer2D Also renamed corresponding files.