10-01-2023, 09:49 AM
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)
But no error was reported when I tried to delete the batch, and the deletion was successful.
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);