Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
RemoveConstraint error
#1
version: 6.5

I tested the runtime delete Constraint,The m_IDs of solverBatch is empty. Why?
Error message:


ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

System.Collections.Generic.List`1[T].RemoveAt (System.Int32 index) (at <6073cf49ed704e958b8a66d540dea948>:0)
Obi.ObiConstraintsBatch.RemoveConstraint (System.Int32 constraintIndex) (at Assets/Obi/Scripts/Common/Blueprints/Constraints/Batches/ObiConstraintsBatch.cs:183)




Code:
        var dc = m_Actor.GetConstraintsByType(Oni.ConstraintType.ShapeMatching) as ObiConstraints<ObiShapeMatchingConstraintsBatch>;
        var sc = m_Actor.solver.GetConstraintsByType(Oni.ConstraintType.ShapeMatching) as ObiConstraints<ObiShapeMatchingConstraintsBatch>;

        for (int j = 0; j < dc.GetBatchCount(); j++)
        {
            var batch = dc.batches[j];
            var solverBatch = sc.batches[j];
            int offset = m_Actor.solverBatchOffsets[(int)Oni.ConstraintType.ShapeMatching][j];
            for (int i = 0; i < batch.activeConstraintCount; ++i)
            {
                for (int k = 0; k < batch.numIndices[i]; ++k)
                {
                    int p = batch.particleIndices[batch.firstIndex[i] + k];
                    int or = m_Actor.solverIndices[p];
                    Vector3 shapePos = m_Actor.solver.positions[or];
                    if (box.bounds.Contains(shapePos))
                    {
                       
                        solverBatch.RemoveConstraint(i);
                        //batch.RemoveConstraint(i);
                    }
                }

            }
        }
        m_Actor.SetConstraintsDirty(Oni.ConstraintType.ShapeMatching);
But no error was reported when I tried to delete the batch, and the deletion was successful.
Reply


Messages In This Thread
RemoveConstraint error - by Seahorse - 10-01-2023, 09:49 AM
RE: RemoveConstraint error - by josemendez - 10-01-2023, 10:26 AM
RE: RemoveConstraint error - by Seahorse - 10-01-2023, 11:53 AM
RE: RemoveConstraint error - by josemendez - 10-01-2023, 12:00 PM
RE: RemoveConstraint error - by Seahorse - 10-01-2023, 12:48 PM
RE: RemoveConstraint error - by josemendez - 10-01-2023, 02:05 PM
RE: RemoveConstraint error - by Seahorse - 10-01-2023, 02:24 PM