27-07-2022, 09:54 PM
(27-07-2022, 07:20 AM)josemendez Wrote: Hi!
When you add an actor to a solver, all its particle and constraint data are copied into the solver. Each particle in the actor -numbered from 0 to the amount of particles in the actor- is assigned a position in the solver's arrays, its position in the solver is its solver index. The range of a solver index is from 0 to the combined amount of all particles being simulated by the solver.
In your code, "colon" is probably an actor (cloth or softbody), not a solver. Is this correct?
If that's the case, you're retrieving the actor's constraints (whose particle indices run from 0 to the amount of particles in the actor):
Code:var distanceConstraints = colon.GetConstraintsByType(Oni.ConstraintType.Distance) as ObiConstraints<ObiDistanceConstraintsBatch>;
But then you're passing indices of particles in the entire solver (which run from 0 to the total amount of particles in the solver):
Code:// Add a constraint for the pair
batch.AddConstraint(new Vector2Int(particleSolverIndexA, particleSolverIndexB), 0);
which will result in an out of index access since particleSolverIndexA and B are probably much larger than the amount of particles in that actor.
Either use actor indices, or access the solver's batches (instead of the actor batches).
kind regards,
Ohhhhh, that was very dumb of me.
I think it get it to work now, no errors anymore, however I can't tell the difference after DistanceConstraints are added. AddConstraint() for DistanceConstraint only takes two parameters, are there more for me to tweak after adding one? Like strength or something?