Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Problem with importing ropes
#3
(20-10-2020, 12:24 PM)josemendez Wrote:
Code:
for (int i = 0; i < rope.elements.Count && i < data.particles.Count; i++) {
      solver.positions[rope.elements[i].particle1] = data.particles[i];
      solver.invMasses[rope.elements[i].particle1] = data.invMasses[i];
 }

This code doesn't make much sense. There's always more particles than there are elements in a rope (at least one more), so if you stop iterating when you hit the amount of elements, you're missing particles.

No need to use elements for this at all, as you don't care about the order in which data is stored. Simply iterate over all particles in the rope instead, I believe this will fix your issue Sonrisa. Let me know if you need further help!

I am now using :
Code:
for (int i = 0; i < rope.solverIndices.Length && i < data.particles.Count; i++) {
      solver.positions[rope.solverIndices[i]] = data.particles[i];
      solver.invMasses[rope.solverIndices[i]] = data.invMasses[i];
 }
For both import and export, but I still encounter the same issue.  Triste
Reply


Messages In This Thread
Problem with importing ropes - by slugGoddess - 20-10-2020, 11:10 AM
RE: Problem with importing ropes - by josemendez - 20-10-2020, 12:24 PM
RE: Problem with importing ropes - by slugGoddess - 20-10-2020, 01:19 PM
RE: Problem with importing ropes - by josemendez - 20-10-2020, 01:38 PM
RE: Problem with importing ropes - by slugGoddess - 20-10-2020, 01:56 PM
RE: Problem with importing ropes - by josemendez - 20-10-2020, 01:59 PM