Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Define Particle Position without inertia
#2
(24-02-2022, 10:35 PM)promero Wrote: I try to generate a save and load function for softbody object.
For that, I save on json file all particle positions.

When I load it, I define the position of each particle with velocity to zero.
I know that to keep positions I must define invMasses to zero.

If I do it works, because softbody particles are fixed.

My problem is that I don't want to fix the particles, particles must move depending ObiParticleAttachment.

What I need is to open the softbody on same position that I save before, and particles must be without movement, until I interact with ObiParticleAttachment elements.

In theory if velocity is zero, particles must keep positions but my softbody particles move a lot until loose inertial energy.

Any advice or help is appreciated.

Thanks

Make sure that the "prevPositions" and "startPositions" arrays are set to the same values as "positions". Obi is a position-based dynamics engine, which means velocities are derived from positions. This happens at the end of each simulation step (pseudocode):

Code:
particle.velocity = (particle.position - particle.prevPosition) / deltaTime;

The values in "startPositions" are used to interpolate physics state, then velocities are used to update particle positions at the start of the next frame. If the initial particle position doesn't match is previous position, velocity will not be zero. Note this is only an issue during instantiation, generally when you set a custom particle velocity it overrides the one calculated by the engine at the end of each frame.

You can read more about how position-based dynamics (or PBD for short) work here:
https://matthias-research.github.io/page...sedDyn.pdf
Reply


Messages In This Thread
RE: Define Particle Position without inertia - by josemendez - 25-02-2022, 08:56 AM