NVIDIAGameWorks / NvCloth

300 stars 53 forks source link

How recover simulation when cloth disappear. #41

Closed a908778387 closed 5 years ago

a908778387 commented 5 years ago

Hi, recently I make an editor for nvCloth. I give a very strong wind to the cloth, and the cloth disappears. Then I shut down the wind, and I want to reset the cloth back, so I set cloth particle's positions to animation position preposition, clearParticleAccelerations(),clearInterpolation(),clearInertia(),clearMotionConstraints(),clearSeparationConstraints(). But it not works. So is there any method to reset the cloth particle to the normal simulation state. And any method I can detect this at runtime (I want to auto reset cloth if this happens).

mtamis-NV commented 5 years ago

Did you reset both the current and previous particle positions? cloth.getCurrentParticles(); and cloth.getPreviousParticles(); If so it might be a bug. Check if there are any floating point NAN or INF values in the simulation after resetting. A work around would be to recreate the cloth. But I don't think that this is necessary.

You may be able to detect this failure case by checking the bounding box of the cloth.

a908778387 commented 5 years ago

Yes,I reset both current and previous particles. I can check the NAN to find this situation. Thank you very much!