22-10-2018, 11:25 AM
(This post was last modified: 22-10-2018, 11:26 AM by josemendez.)
(22-10-2018, 10:58 AM)mmortall Wrote: Thanks for help.
I am currently using handler for Solver.OnCollision
and each frame I call Oni.GetParticleVelocities to find out that all particles are in the sleep state to detect that simulation is done.
This probably triggers marshaling, is it? Is there a way to detect that all particles are in sleep without using marshaling? Maybe do it in C++ side.
If you don't need to get per-contact collision information, do not subscribe to OnCollision. Each contact is a fairly large struct that needs to be marshaled, whereas velocities are blittable types and won't trigger marshaling.
Simply use GetParticleVelocities during LateUpdate, that should be enough to detect if particles are asleep.
In the upcoming Obi 4.0, all solver buffers are memory mapped so there's no need to call Get/Set methods for particle properties. All values are directly accessible from the C# side of things.