13-01-2022, 10:31 AM
(13-01-2022, 09:37 AM)josemendez Wrote: Hi there!
ObiSolver.simplices contains simplex indices. A simplex is a convex shape made up of 1, 2, or 3 particles (point, edge, or triangle respectively). In the case of cloth, a simplex is always 1 particle (if not using surface collisions) or 3 particles (if using surface collisions).
Once you get a simplex index, you need to retrieve the particle indices in it. This is done using ObiSolver.simplexCounts.GetSimplexStartAndSize(simplexIndex, simplexSize);
This is all thoroughly documented and explained here with sample code (see "Retrieving the particle involved in a contact"):
http://obi.virtualmethodstudio.com/manua...sions.html
There's no direct map from a particle index to a batch and constraint index, because one particle might be involved in an arbitrary number of constraints. It's not a 1-1 relationship. The only way to find a constraint given a particle index is to iterate trough all constraints until you find the one(s) that involve that particle. See:
http://obi.virtualmethodstudio.com/manua...aints.html
let me know if I can be of further help.
Ok let's say I have
int startPatical = solver.simplexCounts.GetSimplexStartAndSize(results.simplexIndex, out int simplexSize);
I'm assuming I can use "startPatical" as a reference to compare with all the particles in a constraint? So first, I just wanna confirm if "startPatical" is the correct parameter I can use?
Then let's say I get the batches
var dc = GetConstraintsByType(Oni.ConstraintType.Distance) as ObiConstraints<ObiDistanceConstraintsBatch>;
var theFirstBatch = dc.batches[0] as ObiDistanceConstraintsBatch;
There I want to find if "startPatical" is in one of the constraint in "theFirstBatch" right? OK, let's iterate through it.
for (int i = 0; i < theFirstBatch.constraintCount; i++){
//here how do I get a constraint?
//and how do I check if startPatical is in that constraint?
}
OK how do I get a constraint from the batch? There's no "theFirstBatch.ActiveConstraints[i]" or "theFirstBatch.GetConstraint(int index)", so how do I get each constraint object from the batch by iteration? And after that, how do I test if "startPatical" is in a constraint?
Please advice, thx.