(13-08-2021, 08:16 AM)josemendez Wrote: I've never had any similar reports, or experienced this myself. The indices passed to the contacts you get in the callback are the exact same ones used for collision response (in fact, the engine simply exposes the exact same contact list used for solving physics) so if the indices are wrong, collisions shouldn't work either.Thank you so much!
Would it be possible for you to provide a repro scene/project so that I can take a closer look? If so, send it to support(at)virtualmethodstudio.com
Edit: just noticed this bit:
If you're using surface collisions, then your code won't work! It's written for particles, not simplices. As explained in the manual, surface collisions are simplex-based, not particle-based. I was assuming you were using particles for collision detection. Copypasting form the docs:
http://obi.virtualmethodstudio.com/manua...sions.html
"Contacts will contain slightly different information for actors using surface collisions, this is worth noting if you're using contact callbacks."
The contact callbacks page goes into details regarding how to deal with simplices:
http://obi.virtualmethodstudio.com/manua...sions.html
Retrieving the particle involved in a contact
In Obi 6.X, collision detection is simplex-based. A simplex can be a triangle (3 particles), an edge (2 particles) or a single particle. The solver.simplices array stores simplices as particle index tuples (see surface collisions for more info). To retrieve the solver indices of the particles in a simplex, you can do the following:
Code:// retrieve the offset and size of the simplex in the solver.simplices array:
int simplexStart = solver.simplexCounts.GetSimplexStartAndSize(contact.bodyA, out int simplexSize);
// starting at simplexStart, iterate over all particles in the simplex:
for (int i = 0; i < simplexSize; ++i)
{
int particleIndex = solver.simplices[simplexStart + i];
// do something with each particle, for instance get its position:
var position = solver.positions[particleIndex];
}
In case there isn't any actor using surface collisions in your solver, all simplices will have size 1 and the code above can be simplified to:
Code:// get the particle index directly, as all simplices are guaranteed to have size 1:
int particleIndex = solver.simplices[contact.bodyA];
// do something with the particle, for instance get its position:
var position = solver.positions[particleIndex];
You are using surface contacts, so your code can't assume each simplex is composed of 1 particle. In particular, rope simplices have 2 particles each. So you *must* use the first snippet, the one that iterates trough all particles in each simplex. You're currently using simplex indices as if they were particle indices, so your values will be off by a factor of roughly 2 and this "offset" in the indices will increase the further away down the rope you test collisions, just like you describe.
Sorry I never discovered this page after upgrading to 6.0. If I can give any feedback it would be to have a more dedicated page for new features of different obi versions linking to these new documentation sites. Right now I can only find info about new features on the blog
*EDIT:*
Also a side question;
Is it possible to "subscribe" to an external force per particle? Like lets say I want particles in water to experience "water-current" forces while the above water should experience "wind". I know I could do this manually, but I like the built-in force system as it's easy to manipulate.