InteractiveComputerGraphics / PositionBasedDynamics

PositionBasedDynamics is a library for the physically-based simulation of rigid bodies, deformable solids and fluids.
MIT License
1.9k stars 358 forks source link

PositionBasedFluids::solveDensityConstraint uses mass in correction #81

Closed AtheMathmo closed 4 years ago

AtheMathmo commented 4 years ago

Hi!

I think I have spotted a bug: https://github.com/InteractiveComputerGraphics/PositionBasedDynamics/blob/86483ffac0fc30fbdd57196ee4893157e6d72893/PositionBasedDynamics/PositionBasedFluids.cpp#L119

The density solver uses the mass to scale the kernel gradient in the correction. I do not think that this mass term should be present. E.g. Section 5.10 in your notes or Eqn (12) in Position Based Fluids.

janbender commented 4 years ago

In our implementation we use the correct SPH formulation. However, Macklin used a simplified formulation in his paper and in our course notes where he assumed that all particles have an equal mass. One example where this assumption fails is when the method is combined with the boundary handling of Akinci et al. which we use in our code.

AtheMathmo commented 4 years ago

Ah okay, thank you!