-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
[3.x] Fix multiple issues with test_body_motion() and test_body_ray_separaton(). #37498
Conversation
afea44e
to
f8a255e
Compare
Hi, travisryte shared his compiled version and I've been testing it with my project. With no code changes to my character controller, the bumps which happen when crossing from one collider to another on the floor are gone. However, the body occasionally gets stuck if I'm touching both the floor and the wall at the same time. is_on_floor() becomes unstable then. |
IIRC is_on_floor being unstable when you touch two things is a different preexisting problem? |
Here's a video of what I mean. I'm simply doing this in my code:
|
No, it's new with this fix. |
@MBZSoftProds, please share your project; so I can investigate. |
Here you go. Hope this works. It's rather large. Edit: |
Can confirm that this is a 3.2 regression. In my game, the golf ball constantly bounces if placed on tile seams. In 3.2, if the ball comes to rest on a seam, it resolves the collision slightly into the air. Then the ball is no longer colliding with anything, and drops back down to the ground. It usually spends 2 frames in the air, before returning to the ground. I just tested in 3.1 and sure enough, this bug is not there. Here's hoping that this gets merged and that the code in general gets cleaned up. It's pretty complicated, and critical code. I'm pretty sure that there are a whole host of problems with test_body_motion. There is another bug I've noticed with Using a BoxShape for the ground causes move_and_collide to produce unpredictable and inexact normals around seams. Even on top of the middle of the BoxShape, you get normals like this: (-0.000001, 1, -0.000002) from move_and_collide. Using ConvexPolygonShape also has the issue. Using ConcavePolygonShape produces precise normals using move_and_collide. I wrote about it in this issue: I will test this as soon as I can and report if the seam depenetration issue I'm seeing is resolved. I imagine it will be. I will also report if the imprecise normal issue is resolved or not. Thank you so much @madmiraal |
f8a255e
to
f0718b6
Compare
Added a fix for the sticking identified by @MBZSoftProds. Note: There is still some stickiness, and some |
Would be really nice to have this merged for the upcoming release, let me know if there is anything I can do to help with that |
Hi @madmiraal, great fix so far. I've noticed some issues with regards to KinematicBody sticking in this branch. Here are some of my observations: Using the stock Below is a gif of the player (using a BoxShape, but still reproducible with a CapsuleShape in my experience) attempting to slide across a continuous wall (not made of GridMap tiles or multiple meshes) but getting stuck along the way. When you remove the floor check however, you can see that the character gets stuck in it intermittently: In my experience, setting the CollisionShape margin within reasonable bounds (0.04 to 0.2) did not have an effect. Anything beyond those margin values seemed to either worsen it or have no effect at all. Here is a minimal reproduction project. This was created with the fix-34596-3.2 branch, compiled with Mono. Apologies if this is an inconvenience, as my project is being written in C#. To test just the walls, insert
at the beginning of |
Tried the fix-34596-3.2 branch too. It works much better than before. It fixes the floor issues still and wall sticking is almost gone. It only happens rarely and to a much lesser extent than before. However, multiple moving KinematicBody entities, i.e. AI controlled entities, together with the player introduces regular slow downs and stutter for around a second ... |
Tested this in my golf game. When the golf ball is on the ground and gravity is present, move_and_collide will no longer apply horizontal forces. Seems like the gravity causes the golf ball to instantly collide and instantly stop, the perpendicular velocity vector is not applied to the transform at all. Is this intended behaviour? |
@DenisBelmondo This is the residual stickiness (and floor instability) I'm referring to. As @jknightdoeswork pointed out, and beautifully illustrated by @Zylann here, this appears to be due to the effective rounding of box shapes created by the collision margin and the non-perpendicular collision normals returned when colliding with the edge of a This non-perpendicular normal will push the In short, this is a separate, pre-existing issue, and addressing it is not part of this PR. |
@MBZSoftProds I think the stuttering you're seeing may be related to #37118. |
@jknightdoeswork I'm confused by what you're asking. If you're referring to the sliding seen in #18433, this was a bug, which has been resolved with this PR. |
When a sphere is on a box, calling I'm not certain whether this new behavior is "more correct" than before the patch, since it makes sense that In my golf game, I am integrating forces myself and using move_and_collide in order to move the ball. I do this so I can have very custom control over bounces and friction, and so I can fully predict the path of the ball before shooting. Before the patch, when the ball was on the ground, it would behave much differently. I can make a reproduction project if needed. |
@DenisBelmondo You can try to get exact normals by using Concave shape for your walls/ground. You can do this by creating a cube mesh, then clicking Mesh -> Create Trimesh Static Body (above the viewport), and then using that collision shape. |
I am working on an identical project as @jknightdoeswork -- a minigolf game where I use move_and_collide to handle bouncing and movement, with collisions happening between a sphere and Trimesh Static Bodies. I can try to provide a stripped down project if it would be useful for comparison, but I haven't tried this patch yet with that project. @jknightdoeswork We should get in touch and share our experiences :b |
@asheraryam Definetly should. I'm 00jknight in the godot discord. @madmiraal This code block causes the patch to behave similarly to before the patch:
Note that this is moving the object along the remaining velocity vector. You could theoretically move it using move_and_collide again in a loop, until the velocity vector has been consumed. Again, I'm not sure if this is better or worse than before the patch. At first glance, it seems like a regression, but upon reflection you can see that the patch is now causing move_and_collide to behave more like how it claims to behave in it's documentation ie: instantly stopping on a collision. Note that this branch resolves the "seam bouncing" issue that I was previously seeing. So great job on that! |
Great commit, can it be included in stable? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great commit, very important changes that need to be included in Godot as soon as possible.
…on(). The test_body_motion() and test_body_ray_separation() functions perform an initial recovery step to attempt to move the body to a safe place before testing whether the body can safely move. Currently this is done in four partial steps, and during each step the detected penetrations are reversed by summing them together. This patch changes this approach to a single step and uses the maximum penetration instead of the sum. The same approach is applied to Godot Physics 2D, 3D and Bullet Physics, and to both CollisionShapes and RayShapes. Also, fixes Bullet physics not detecting collisions and relying on the recovery step. Furthermore, ensures that Bullet physics only moves a safe amount by using a binary search as done in Godot physics.
8385c83
to
7e0b110
Compare
Rebased following merge of #42575. |
Is there any chance of this being merged soon? |
To be honest, even though I like the PR, I doubt it. On the other hand a lot of the physics issues seem to be getting fixed for 4.0 thanks to @pouleyKetchoupp |
It being fixed in 4.0 is great and all, but that is irrelevant for people
that expect to be using 3.2 long term.
…On Sat, Feb 27, 2021 at 7:38 AM Vesk ***@***.***> wrote:
Is there any chance of this being merged soon?
To be honest, even though I like the PR, I doubt it. On the other hand a
lot of the physics issues seem to be getting fixed for 4.0 thanks to
@pouleyKetchoupp <https://github.com/pouleyKetchoupp>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#37498 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABBEIS4VFMO3UUUVOSLKW43TBDYVXANCNFSM4LZBYY7A>
.
|
I highly doubt it. If you look at the 4.0 version of this PR you'll see how this set of changed isn't planned to be merged, but instead is kept open just to be able to salvage whatever is considered good by @pouleyKetchoupp. In any case though, you can just merge this PR in your own fork and call it a day. |
And again, what about all the other people who'll be still using 3.2? Do you really expect thousands of developers to support a custom fork of 3.2 just for fixes like these when they could have just been merged instead of going "It's fixed in 4.0, fuck em"? The whole "if you don't like it make your own fork" attitude is unnecessarily hostile towards users and gamedevs. |
Oh sorry, I thought you really needed it right now for a project of yours. I liked this PR a lot too but apparently the methods behind it may lead to a few different issues down the line. There has been a pretty extensive discussion about it in #35945. Also, AFAIK it is planned to fix them properly in this version too, but this simply isn't the right solution. |
@Two-Tone sorry for the double-post, but it seems also that @pouleyKetchoupp has actually ported at least some of the fixes he's made to 3.2. #46149 is an example of this. |
I mean at the end of the day at some point any team just has to push future updates to a new version of their product. They can't support older versions forever. To be honest I'm glad that they hired @pouleyKetchoupp and these physics issues are getting fixed at all in 4.0 as I wasn't sure that would be happening any time soon. Yeah maybe they should just merge this PR as a kind of quick fix before 4.0 comes out. But I don't really see much of a problem as I just compiled it myself and have been using it while waiting for 4.0. Also I don't know really know why you might want to use 3.2 instead of 4.0 unless it's hard to transition a project (which it hopefully shouldn't be), although I do respect that there might be some reasons to do so, but then again you could just compile this yourself and from my experience it works perfectly well. |
@madmiraal Having read this and the related PRs very throughly, I know that this PR will not be merged. But is it still possible that per the discussion in #35945 that your technique could still be put to the test in the tests? So that we might understand if the Unique but still possible cases that this solution will not work, to see if they actually exist? Or have you concluded that the "U" "anisotropy limitation" scenario mentioned by Reduz would indeed not be solvable in a single iteration? Thank you for your time and for fueling fixes faster than they other wise would have landed. Also so that core contributors don't see that statement as being rude. Please know that I am aware we are all human, we can only do so much so fast, especially if we are to do it well. So that is why many hands make the load lighter. |
@FeralBytes, the 'U' scenario presented in #35945, is a red herring. As presented previously, 'in reality, things either fit or not but not "just fit" (I mean whathever you collide to has to actually reach this scenario from a previous one where it's not colliding, which is likely impossible) so in these cases, users just realize this and shrink the kinematic body a tiny bit to solve the problem. Just think about it, you will realize it's not a realistic use case.' The 'U' scenario presented is not a realistic use case. No approach and no finite number of iterations will resolve this situation. Furthermore, the solution: jumping to a collision-free zone somewhere outside of the enclosed space is not a desirable outcome either; so I don't think it's a scenario worth discussing. What can cause a problem is how Godot physics tries to avoid the possibility of unwanted collisions being detected when moving perpendicular to a surface due to floating point numerical impression. Godot physics moves the Note: This is not a problem in the Bullet physics solution, because, instead of moving the |
Closing as the |
This is a the 3.2 branch version of PR #35945.
I've created this because #34098, #34436, #34596, #35713 and #35780 are regression issues from 3.1 and since master has changed so much, #35945 is no longer cherry-pickable.
Update:
Now includes additional fixes added to #35945 for #17893, #18433, #26550, #28717 and #32182.