Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Random instantiating at old particle positions
#2
Hi there!

Your code is mixing up particle and simplex indices. All data arrays in the solver must be acessed using particle indices. For instance, you're accessing the particleToActor array using a particle index:

Code:
solver.particleToActor[solver.simplices[contact.bodyA]];

Which is correct. But you're accessing the positions array using a simplex index:

Code:
Vector3 particlePosition = solver.positions[contact.bodyA];

Which will return essentially random data. contact.bodyA is always a simplex index. You can retrieve the particle index like this:

Code:
int particleIndex = solver.simplices[contact.bodyA];

Then use this index to access positions, velocities, userData, particleToActor, or any other array in the solver. For instance:
Code:
int particleIndex = solver.simplices[contact.bodyA];
Vector3 particlePosition = solver.positions[particleIndex];

See:
http://obi.virtualmethodstudio.com/manua...sions.html
Reply


Messages In This Thread
RE: Random instantiating at old particle positions - by josemendez - 07-07-2021, 08:19 AM