07-07-2021, 08:19 AM
(This post was last modified: 07-07-2021, 08:21 AM by josemendez.)
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:
Which is correct. But you're accessing the positions array using a simplex index:
Which will return essentially random data. contact.bodyA is always a simplex index. You can retrieve the particle index like this:
Then use this index to access positions, velocities, userData, particleToActor, or any other array in the solver. For instance:
See:
http://obi.virtualmethodstudio.com/manua...sions.html
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