11-04-2019, 06:39 AM
(This post was last modified: 11-04-2019, 06:39 AM by josemendez.)
(10-04-2019, 11:43 PM)apapaxionga Wrote: I tried to set the collided particle's invmass to 0 but it explode the softbody. I did it in the following way:
Code:void Solver_OnCollision(object sender, Obi.ObiSolver.ObiCollisionEventArgs e)
{
for (int i = 0; i < e.contacts.Count; ++i)
{
if (e.contacts.Data[i].distance < 0.001f)
{
Component collider;
if (ObiCollider.idToCollider.TryGetValue(e.contacts.Data[i].other, out collider))
{
solver.invMasses[e.contacts.Data[i].particle] = 0;
}
}
}
}
What is the correct way to achieve this ?
When changing the mass of softbody particles in the solver, you have to recalculate shape matching centers of mass. Like this:
Code:
foreach (ObiShapeMatchingConstraintBatch batch in softbody.ShapeMatchingConstraints.GetBatches())
Oni.CalculateRestShapeMatching(softbody.Solver.OniSolver,batch.OniBatch);
This is done automatically when you call PushDataToSolver() on a softbody, but not if you modify solver properties directly.