Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get current batch index and a constraint index in oby tear cloth
#1
Triste 
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.

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));
                }
Reply
#2
Glad you beat me to the answer Guiño. Good job in figuring it out!

Let me know if I can help anytime.
Reply