GameDevTecnico / cubos

A still very barebones game engine focused on voxels and data-oriented programming
https://cubosengine.org
MIT License
83 stars 36 forks source link

Transition to TGS Soft impulse solver #1273

Closed fallenatlas closed 3 months ago

fallenatlas commented 3 months ago

Description

Oh boy...

Transition from XPBD solver to TGS solver.

Much of the solver for the penetration constraints was changed, we now make corrections based on impulses, based mainly on the equations for conservation of momentum with some bias proportional to the penetration which will work to separate the particles.

Collisions also work as soft constraints now, the values might need some tweaking in the future but they seem ok for now.

The integration also had to be changed and is now under the solver, because it just makes more sense.

The new loop is as follows:

Currently the impulses are enough only to separate the particles, this means that some collisions may not look as expected because everything is perfectly inelastic. Elastic and inelastic collisions will come with restitution which should be the next PR.

Also of note that stacks of more than 2 particles aren't very good yet, so the complex physics sample won't look the best.

Checklist

github-actions[bot] commented 3 months ago

PR Preview Action v1.4.7 :---: :rocket: Deployed preview to https://GameDevTecnico.github.io/cubos/docs-preview/pr-1273/ on branch gh-pages at 2024-06-30 13:49 UTC

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 0% with 145 lines in your changes missing coverage. Please review.

Project coverage is 40.54%. Comparing base (8627172) to head (2bf3064).

Files Patch % Lines
...c/physics/solver/penetration_constraint/plugin.cpp 0.00% 66 Missing :warning:
engine/src/physics/solver/integration/plugin.cpp 0.00% 54 Missing :warning:
engine/src/physics/solver/plugin.cpp 0.00% 16 Missing :warning:
...src/physics/constraints/penetration_constraint.cpp 0.00% 4 Missing :warning:
engine/src/physics/plugin.cpp 0.00% 3 Missing :warning:
engine/src/defaults/plugin.cpp 0.00% 1 Missing :warning:
engine/src/physics/fixed_substep/plugin.cpp 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1273 +/- ## ========================================== - Coverage 40.58% 40.54% -0.04% ========================================== Files 359 359 Lines 26354 26379 +25 ========================================== Hits 10695 10695 - Misses 15659 15684 +25 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.