Suggestions about collision response. #812
Replies: 1 comment 10 replies
-
Thank you for the in-depth suggestions. Again, I haven't really spent enough time reading up on or implementing character movers that I can speak to the validity of your suggestions, nor the parallels you draw to Jolt's You'll find the implementation in this branch. It performs ever so slightly worse in the test scene provided in #529, but frankly it's close enough that it's hard to tell if it's just different rather than worse. When ripping out It does fix the performance regression (#626) introduced by the current contact depth threshold, since there's no longer any need for I am however not seeing a huge difference in its ability to detect walls (#758), although there might be some improvement. I'm assuming this is what you're referring to when you say "having to move towards a wall to get the information about it". This phenomenon is present in Godot Physics as well to some degree, but is (from what I understand) supposed to be alleviated (in a somewhat odd way) by leaving the depenetration ever so slightly short. I am also seeing a new discrepancy when comparing with Godot Physics, which is that the number of slide iterations actually go down from 2 to 1 when pushing up against a wall. I'll need to look into where that comes from to see whether it's a good or bad thing.
I'm not sure what you mean by sweep test in this context. There is no traditional sweep test in Godot, nor in Godot Jolt. Any shape-casting is done using a binary search, by stretching the shape by the cast distance along its support vector a number of times until you've found a spot where you didn't collide and a spot where you did collide, which are the "safe" and "unsafe" fractions. This binary search is (unfortunately) more or less required by any physics implementation in Godot due to needing to output these two fractions. The only part of |
Beta Was this translation helpful? Give feedback.
-
Hi!
Regarding problematic collisions, there are, in my eyes, two clearly identified issues:
This points us toward another issue: Ghost collisions. More often than not, we can collide with the same plane two times in a row even if it should not be possible.
Move and slide it's is own thing, so i will focus on the Godot jolt side of things.
The minimum depth threshold has for sure showed useful to alleviate issues, but has introduced the problem of missing collisions.
What i propose is another way of contact validation for
_body_motion_collide
. Instead of discarding contacts based on their depth, we can get rid of multiple issues by discarding contacts that matches the following rules:If the collision normal is parallel (regardless of the orientation) to the motion vector we know its not a valid contact plane, as you could continue the motion parallel to the plane infinitely without ever stopping. This would cause the body to not get stuck because a collision parallel to the movement and reduce the number of times the same plane can be processed two times in move and slide, triggering the stop_all_motion behaviour.
If the collision plane points towards the motion vector it is not a valid plane, as you can not be stopped by something that is on your back while moving forward. This should allow the body to be released from the wall in the case you overlap slightly, because at the moment there is a velocity pointing outside the wall the wall would stop taking participation on the collision response.
Still with this changes move and slide needs improvements in which i'm trying to work on with mi limited resources, but they should improve the situation while making sure we don't discard any valid collision.
I was going to propose this changes earlier but i wanted to be sure. All the research i did fight this type of problems in this two ways. We can see something very similar here in the excellent Jolt CharacterVirtual:
https://github.com/jrouwe/JoltPhysics/blob/master/Jolt/Physics/Character/CharacterVirtual.cpp#L675-L681
https://github.com/jrouwe/JoltPhysics/blob/master/Jolt/Physics/Character/CharacterVirtual.cpp#L754-L771
https://github.com/jrouwe/JoltPhysics/blob/master/Jolt/Physics/Character/CharacterVirtual.cpp#L177
&& inResult.mPenetrationAxis.Dot(mDisplacement) > 0.0f) // Ignore penetrations that we're moving away from
This would have the side effect of having to move towards a wall to get the information about it. But that is because move and slide mixes the collisions to which it should react with the collisions used to gather information about the environment, but that should be improved by it's own.
PseudoCode:
PS: I seen that is a recurring pattern using the sweep test to collect information about static collisions in Godot, so may i ask, is there a specific method other than _body_motion_collide to gather collision data? Because it is not possible to satisfy the necessities of a movement check and a collision gathering check with the same rules, and may be one of the issues forcing this constant balancing between correct sliding and correct data gathering.
Beta Was this translation helpful? Give feedback.
All reactions