Open Paavs-Git opened 4 years ago
I confirm this bug is also hitting with CSG objects when collision on (probably generating convex/cave meshes at the back). The behavior is even worst between softbodies and convex/cave shapes. @Paavs-Git have you tried to increase (or even decrease) the physics fps (default 60) ?
I see some algos over there to "recover from penetration" which makes me think this issue is not that new: https://github.com/godotengine/godot/blob/9fc4f17281a25a74a916c29dd629c7aca5498aab/modules/bullet/space_bullet.cpp#L1219 https://github.com/godotengine/godot/blob/9fc4f17281a25a74a916c29dd629c7aca5498aab/modules/bullet/space_bullet.cpp#L934
@Paavs-Git have you tried to increase (or even decrease) the physics fps (default 60) ?
Yes, lower pfps makes it easier for collision to penetrate and go through and higher pfps makes it harder. In the demo you can also see it bounces hard on the seam of the 'floor' but that's another issue.
@AndreaCatania are the "recover" algos in space_bullet.h/cpp the ones trying to avoid that bug or is it unrelated ?
@Calinou could you please tag that one for 3.2 ?
@WilliamTambellini We generally add a 4.0
milestone to important issues, but milestones are purely indicative in Godot development. (The fix can still be cherry-picked to the 3.2
branch if one is made.)
@AndreaCatania are the "recover" algos in space_bullet.h/cpp the ones trying to avoid that bug or is it unrelated ?
Nup, CCD should prevent it from going through.
This is an expected behaviour in any physics engine. To improve it you can:
Tks @AndreaCatania
Kind
did nt know CCD was broken : is there any github ticket about that ?
Consider that concave shapes are made of thin triangles. Is hard to get good contacts out of those, also they are generally complex to solve. Decompose the CSG using convex shapes is much better under many aspects.
On current master
, CCD seems to fix this with convex polygon shapes, but collision with concave polygon shapes in Bullet seems to just be completely broken. The box just falls right through.
EDIT: Turns out this is compiler-dependent, or something. Only happens if you build with LLVM. No idea why it was broken on my machine, but it's fixed now. Looks like CCD fixes this with concave shapes, too.
I've come across a similar issue in my project: the box doesn't go through the convex floor, but it jitters just like in OP's post.
Increasing the physics FPS and changing the collision shape of the floor to a box shape both fix the issue, but I cannot reasonably implement these fixes in my project.
From what I've seen in the comments thus far, CCD should fix this issue - I've made a test project for both 3.2.4-rc4
and the latest master
version, and while the issue persists for the 3.2.4-rc4
version even with CCD enabled, it no longer exists in the master
version (even without CCD!).
3.2.4-rc4 video: https://user-images.githubusercontent.com/13645454/111029925-5881e280-83f7-11eb-91a0-d52f4527d5bc.mp4
master video: https://user-images.githubusercontent.com/13645454/111029926-5c156980-83f7-11eb-9fb5-b77e62460cfa.mp4
Projects:
v3.2.4-rc4
: CollisionTestProject.zip
master
: CollisionTestProject4.zip
So from what I understand, the necessary fix is already in the master
branch - is it feasible for the fix to be cherry-picked to the 3.2
branch at all?
Hi @drwhut Interesting. Increasing the physic fps or switching to a plain box coll shape is indeed not a solution. Have you tried the original bug repro project https://github.com/godotengine/godot/files/5104508/Coll.bug.zip with master ?
Yeah, the red box just bounces around on the floor - it doesn't go through it at all.
Hi Camille @pouleyKetchoupp, We have been suffering from that bug for some (actually all) of our games. I see that you are adding regression tests for physics in the godot demo repo. Do you know if there is already any regtest there checking for such a bug (whatever the physic engine) ? Kind
@skaiware There's no CCD test (yet) in the physics test projects, but anybody's very welcome to add it.
@pouleyKetchoupp we would be ready to help if you can drive me the way it is expected to be done to avoid multiple PR retouches as we dont have much free time. I suppose it would be a new test scene over there : https://github.com/godotengine/godot-demo-projects/tree/master/3d/physics_tests/tests/functional ?
@skaiware That would be amazing! Yes it would be a new scene in that folder.
You can check the recent PR that a contributor made to add two more tests: https://github.com/godotengine/godot-demo-projects/pull/619
I imagine the CCD test to be a bit similar to the RigidBody impact test from that PR, probably with impulses like the minimal project from the current issue does.
Important things to avoid iterations when adding tests are:
Other than that, as long as the test is useful and functional I'll be happy to approve it, even if it's not covering everything that's needed. Improvements can be added later.
ok tks @pouleyKetchoupp, I ve forked and cloned the demo repo. That bug still hits 3.3.2. In which branch would you like me to add that new test case ?
Just tested and still an issue with v3.3.3.stable.official.b973f997f I m wondering if fixing that one would need first to fix https://github.com/godotengine/godot/issues/9071 @pouleyKetchoupp would you be able to summarize what would be needed to be changed in the 3.4 branch in order to fix that bug ?
I m wondering if fixing that one would need first to fix
9071
@WilliamTambellini Yeah I think improving CCD might help for this issue.
You're very welcome to give it a try! There are two possible directions depending what your goal is:
Bullet is the default physics engine for Godot 3.3 and the upcoming 3.4, although it will become a separate add-on in Godot 4. So if you're targeting 3.4 in particular you probably want to fix Bullet's CCD.
You can start by checking this detailed post from @e344fde6bf and the links: https://github.com/godotengine/godot/issues/9071#issuecomment-812956331 I can't help much more because I don't know much about CCD in Bullet, but it seems one of the issues is it might not support concave shapes the way it's configured at the moment.
You can also have a look into the Godot Physics implementation, which is probably easier to understand and modify.
Godot Physics is optional in Godot 3.3/3.4 and has specific issues, but you can test if it generally works for your use case. It's probably more useful to fix CCD there for long term, as it will become the default physics engine for 3D in Godot 4.0, and a fix in CCD could be easily backported to 3.x as long as it doesn't break compatibility.
CCD for two rigid bodies is done here: https://github.com/godotengine/godot/blob/c39d31899a9e35fb1166834c68b566978ef5066d/servers/physics_3d/body_pair_3d_sw.cpp#L250-L262
It's very basic (raycast only), and seems strange that it still returns false (which means no collision) whatever the result from CCD, so there's a lot of room for improvements.
Also, in this PR's MRP when Godot Physics is enabled the rigid body doesn't move at all, so it's another thing worth investigating (in the same class, methods pre_solve
and solve
).
Whether you choose to fix Bullet or Godot Physics, I would be happy to help figuring things out once you start investigating what happens exactly on a specific case.
Godot version: 3.2.2-stable_win64; 3.2.3-beta1_win64; 3.2.3-rc3_win64;
OS/device including version: Windows 10, 64bit
Issue description: When applying a moderate to strong impulse to a RigidBody (BoxShape), the body will very often go through both ConvexPolygonShape and ConcavePolygonShape (created with Trimesh Collision Sibling and Single Convex Collision Sibling). This has been tested only on Bullet, for some reason impulse isn't being applied on GodotPhysics. 'continuous_cd' and 'can_sleep' have seemingly no effect, the issue happens regardless these being ticked or not.
To be clear, this issue doesn't happen if the collision shape it collides against is a BoxShape, even on very high impulse forces.
Steps to reproduce: Press right a couple times in the attached project. You can press left and right, it will quickly go through the floor with visible jitter.
Minimal reproduction project: Coll bug.zip
There are a few other issues with physics and collision but I couldn't find something describing this specifically, hopefully it's not a duplicate.