Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tear Issue
#3
(27-04-2022, 07:42 AM)josemendez Wrote: Hi!

Your code has many bugs:

- You're iterating trough actor constraints (whose indices reference actor particles), but you're passing a "collisionParticleIndex" which quite probably is solver index, if you're retrieving it directly from the solver.OnCollision event.

- You're passing batch.GetConstraintIndex(i) to the StructuralConstraint constructor, but "i" is already a constraint index (remember that you're iterating trough all constraints from 0 to activeConstraintCount). GetConstraintIndex() takes a constraint id and returns the index of the constraint in the internal arrays. You already have the constraint index "i", so no need to call GetConstraintIndex().

- You're calling flag.solver.PushSolverParameters(); but haven't modified any solver parameter. This call does nothing - except negatively affect performance.

- You're missing a call to cloth.UpdateDeformableTriangles(); after all Tear() operations. The mesh topology isn't be updated at all right now, so any tears will turn the cloth into a triangle mess since particles/constraints are updated but the mesh is not.

I'd recommend taking a look at ObiTearableCloth.cs ApplyTearing() method as reference. You can basically copy/paste all of it and repurpose some bits.

Let me know if I can be of further help,
Thanks a lot for your help :)

I was actually converting solver index to particle index in a loop so i don't think the problem arised from that:

int solverIndex = flag.solver.simplices[contact.bodyA];
ObiSolver.ParticleInActor pa = flag.solver.particleToActor[solverIndex];
int collisionParticleIndex = pa.indexInActor;


But changing the "GetConstraintIndex(i)" to simpy "i" and calling "cloth.UpdateDeformableTriangles()" seems to fix my issue.
Reply


Messages In This Thread
Tear Issue - by charlotte - 26-04-2022, 03:54 PM
RE: Tear Issue - by josemendez - 27-04-2022, 07:42 AM
RE: Tear Issue - by charlotte - 27-04-2022, 09:10 AM
RE: Tear Issue - by josemendez - 27-04-2022, 09:12 AM
RE: Tear Issue - by charlotte - 27-04-2022, 03:25 PM
RE: Tear Issue - by josemendez - 27-04-2022, 03:46 PM
RE: Tear Issue - by charlotte - 27-04-2022, 03:49 PM
RE: Tear Issue - by josemendez - 27-04-2022, 04:08 PM
RE: Tear Issue - by charlotte - 29-04-2022, 12:22 PM