19-12-2022, 12:19 PM
There was 2 problem:
1.How do you get a constraint between two particles?
Are P1 and P2 just two particles of the same constraint?
2.solverBatch.RemoveParticleFromConstraint
What does it do?
1.How do you get a constraint between two particles?
Are P1 and P2 just two particles of the same constraint?
Code:
var dc = softbody.GetConstraintsByType(Oni.ConstraintType.ShapeMatching) as ObiConstraints<ObiShapeMatchingConstraintsBatch>;
var sc = softbody.solver.GetConstraintsByType(Oni.ConstraintType.ShapeMatching) as ObiConstraints<ObiShapeMatchingConstraintsBatch>;
sc.RemoveFromSolver();
for (int j = 0; j < dc.batches.Count; ++j)
{
var batch = dc.batches[j];
Debug.Log("The number of particles in each bound batch:" + j + "/" + batch.numIndices.count);
var solverBatch = sc.batches[j];
int offset = softbody.solverBatchOffsets[(int)Oni.ConstraintType.ShapeMatching][j];
for (int i = 0; i < batch.activeConstraintCount; i++)
{
int index = i + offset;
int p1 = batch.particleIndices[i * 2];
int p2 = batch.particleIndices[i * 2 + 1];
int or1 = softbody.solverIndices[p1];
int or2 = softbody.solverIndices[p2];
//Get particle position
Vector3 pos1 = softbody.solver.positions[or1];
Vector3 pos2 = softbody.solver.positions[or2];
....
}
}
sc.AddToSolver(softbody.solver);
2.solverBatch.RemoveParticleFromConstraint
What does it do?