Velocities synchronization fix in btDeformableMultiBodyConstraintSolver::writeToSolverBody #4667
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The synchronization of velocities into the solver body was not working as it should have. Consider the following scene: there is a rigid static obstacle (let's say a box) at x coordinate 0. There is a rigid dynamic box not far from the obstacle in positive x axis direction. To this rigid dynamic box is connected another box, which is a deformable soft body. They are connected by, say, 5 deformable anchors to the nodes of the soft body. The soft body is sufficiently rigid, which also helps to amplify the problem described. Now, when the rigid dynamic box is pushed in the negative x direction into the obstacle (for example by a gravity force), then as soon as it hits the obstacle, the soft body explodes. The problem is that in
btDeformableMultiBodyConstraintSolver::solveDeformableGroupIterations
, the resulting velocity always ends up with negative x component, which makes the body go though the obstacle. The proper result should be a slightly positive x velocity, because the obstacle is blocking that direction. The reason for this is wrong synchro of solver body velocities, which this PR fixes.Sorry for the unrelated formatting changes. Probably caused by clang-format.