Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cylinder support in Godot Physics 3D #45854

Merged
merged 1 commit into from
Feb 10, 2021

Conversation

pouleyKetchoupp
Copy link
Contributor

@pouleyKetchoupp pouleyKetchoupp commented Feb 9, 2021

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.

It's mostly functional but will still require fixing specific cases and it can benefit from further optimization.

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 (https://code.google.com/archive/p/bullet/issues/606)
Setting a lower EPA_ACCURACY to fix accuracy problems with cylinder vs. cylinder in some cases.

Known issues:
-Cylinder is not stable when resting on its disk on a dense triangle mesh. Some extra contact points are probably needed to help support in face-circle cases, more investigation is needed.
-Cylinder vs. convex polyhedron could probably be solved analytically for better performance.
-Some cases might benefit from specific optimization, especially when it comes to using GJKEPA with no margin.

Project used for tests on 4.0:
cylinder-tests-4.0.zip

It would be interesting to backport cylinder support to 3.2 once it's considered stable enough since it doesn't affect other areas of the physics server. I'll make a separate PR later.

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.
@pouleyKetchoupp
Copy link
Contributor Author

Updated COPYRIGHT.txt and rebased after #45852.

@akien-mga akien-mga merged commit 3c39aa8 into godotengine:master Feb 10, 2021
@akien-mga
Copy link
Member

Thanks!

r_amount = 1;
r_type = FEATURE_POINT;
r_supports[0] = get_support(p_normal);
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why here is return?
It should be described why is here or just removed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I forgot to clean the code after doing some tests. The return and code below should be removed, but I don't know if it's worth a specific PR.

@elvisish
Copy link

elvisish commented Jan 24, 2022

A lot of the issues seen in my example come from using a cylinder collider with godot physics, getting stuck doesn't happen with bullet or seem to with godot physics and a capsule collider: #57048

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants