Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Is constraintIndex same thing as the particle index?
#1
In the scene, I have a tearable cloth and a rod that will be piercing the cloth. But because I'm changing the position of the rod instead of applying physics to it, the cloth won't recognize the rod to tear. But collision detection works as intended. So, I'm trying to tear the cloth at the point of collision by calling Tear(contact.particle). But it doesn't seem to do anything. Is the constraintIndex same as the particle index? If it's not, how would we find the constraintIndex at the point of collision? 


Thank you,
Reply
#2
(12-10-2018, 02:11 AM)jb88886 Wrote: In the scene, I have a tearable cloth and a rod that will be piercing the cloth. But because I'm changing the position of the rod instead of applying physics to it, the cloth won't recognize the rod to tear. But collision detection works as intended. So, I'm trying to tear the cloth at the point of collision by calling Tear(contact.particle). But it doesn't seem to do anything. Is the constraintIndex same as the particle index? If it's not, how would we find the constraintIndex at the point of collision? 


Thank you,

Hi,

No, they're two completely different things. Constraints are "springs" holding the particles together. There are generally many more constraints than particles. Also, there's usually more than 1 constraint affecting each particle. You can get their indices by calling the GetConstraintsInvolvingParticle(particleIndex) in any constraint batch. Like so:

Code:
foreach (ObiConstraintBatch batch in DistanceConstraints.GetBatches()){
    List<int> affectedConstraints = batch.GetConstraintsInvolvingParticle(i);
    // tear some of the constraints here
}
Reply