Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Trying to add DistanceConstraint for my TearableCloth but getting IndexOutOfRange
#2
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,
Reply


Messages In This Thread
RE: Trying to add DistanceConstraint for my TearableCloth but getting IndexOutOfRange - by josemendez - 27-07-2022, 07:20 AM