12-05-2021, 04:39 PM
(This post was last modified: 13-05-2021, 08:01 AM by DenisBlack.)
Hi, mb anybody can help me.
I try to make tearing cloth by some collision (like scissors).
I get Particle id from collision detect : 900 id; But dont understand how to correctly get current batch and constaint index.
In ObiTearableCloth.cs i saw ApplyTearing method with calculate by force and get some code from there.
How to i can iterating check current active constreint wich collect my particle id?
UPD:
Ok, next time first need to write on note my task - that help to collect thoughts ))
I try to make tearing cloth by some collision (like scissors).
I get Particle id from collision detect : 900 id; But dont understand how to correctly get current batch and constaint index.
In ObiTearableCloth.cs i saw ApplyTearing method with calculate by force and get some code from there.
Code:
List<StructuralConstraint> tornEdges = new List<StructuralConstraint>();
var distanceConstraints = Cloth.GetConstraintsByType(Oni.ConstraintType.Distance) as ObiConstraints<ObiDistanceConstraintsBatch>;
var solverConstraints = Solver.GetConstraintsByType(Oni.ConstraintType.Distance) as ObiConstraints<ObiDistanceConstraintsBatch>;
if (distanceConstraints != null && solverConstraints != null)
{
Debug.LogError("distanceConstraints.batches.Count "+ distanceConstraints.batches.Count());
for (int j = 0; j < distanceConstraints.batches.Count; ++j)
{
var batch = distanceConstraints.batches[j] as ObiDistanceConstraintsBatch;
var solverBatch = solverConstraints.batches[j] as ObiDistanceConstraintsBatch;
Debug.LogError("batch.activeConstraintCount "+ batch.activeConstraintCount.ToString());
for (int i = 0; i < batch.activeConstraintCount; i++)
{
}
}
}
How to i can iterating check current active constreint wich collect my particle id?
UPD:
Ok, next time first need to write on note my task - that help to collect thoughts ))
Code:
for (int i = 0; i < batch.activeConstraintCount; i++)
{
if(batch.GetParticleIndices(i).first.Equals(particleIndex) || batch.GetParticleIndices(i).second.Equals(particleIndex))
tornEdges.Add(new StructuralConstraint(batch, i, 0));
}