07-09-2020, 11:47 AM
(This post was last modified: 07-09-2020, 11:48 AM by josemendez.)
(07-09-2020, 11:36 AM)emz06 Wrote: Hi,
-I have fluid particles (shampoo-type of liquid) resting on a platform.
-Suddenly this platform shifts downward, and to the side.
But the problem is the particles can't keep up with the high speed of the platform.
I tried to increase the friction, but it did not help.
Is it possible to loop through all the particles and, on every frame, translate their position by the same amount as the platform movement?
Yes, you can. Make sure to also translate their previousPosition, as this is PBD (and velocities are calculated as (position - prevPosition) / dt). If you only change their current position, they will gain a lot of velocity.
See:
http://obi.virtualmethodstudio.com/tutor...icles.html
Example:
Code:
for (int i = 0; i < actor.solverIndices.Length; ++i){
// retrieve the particle index in the solver:
int solverIndex = actor.solverIndices[i];
actor.solver.positions[solverIndex] += translation;
actor.solver.prevPositions[solverIndex] += translation;
}