ebirenbaum / ParticleSolver

CPU and GPU implementations of a particle-based physics simulation based on Macklin et. al's "Unified Particle Physics for Real-Time Application".
MIT License
176 stars 18 forks source link

Particle struct not as in paper? #1

Open iperov opened 1 year ago

iperov commented 1 year ago

in paper

s t r u c t  P a r t i c l e
{
f l o a t  x [ 3 ] ;
f l o a t  v [ 3 ] ;
f l o a t  i n v m a s s ;
i n t  p h a s e ;
} ;

in your code

struct Particle
{
    glm::dvec2 p, ep, v, f; // position, guess position, and velocity
    double imass, tmass, sFriction, kFriction, t; // inverse mass, temporary height-scaled mass, coeffs of friction
    int bod; // body (if any) this particle belongs to, for disabling collisions
    Phase ph; // phase of this particle

why all of these additional vars needed?

LoganBarnes commented 1 year ago

Disclaimer: we wrote this 8 years ago as a fairly rushed school project. This probably isn't the best example of how to implement this paper.

The struct Particle mentioned in the paper only shows the "core" properties of a particle. To implement more complex dynamics you will likely need more fields or additional external state. I don't remember exactly what all the fields here do but I think some of them had to do with different types of fluids and some of them added stability to stacked rigid body systems.

It is possible some of these could be handled better if we revisited the project now.