Thank you for your help.
I finally make it work perfectly all in runtime without exporting/importing xml files or manual property painting.
My concern, at this moment, is that I may have problem when obi simulation keeps going and moves particles away while the AutoStitcher.cs is trying to find out particle pairs within the range of designated distance.
Let me know your thought. Should I set stitches before starting (building) a game?
I finally make it work perfectly all in runtime without exporting/importing xml files or manual property painting.
My concern, at this moment, is that I may have problem when obi simulation keeps going and moves particles away while the AutoStitcher.cs is trying to find out particle pairs within the range of designated distance.
Let me know your thought. Should I set stitches before starting (building) a game?
Code:
public void StitchActorsRuntime()
{
ObiStitcher obiStitcher = gameObject.AddComponent<ObiStitcher>();
obiStitcher.Actor1 = actor1;
obiStitcher.Actor2 = actor2;
int mask = 0;
int category = 0;
int filter = ObiUtils.MakeFilter(mask, category);
for (int i = 0; i < actor1.particleCount; i++)
{
int index1 = actor1.GetParticleRuntimeIndex(i);
Vector3 pos1 = actor1.GetParticlePosition(index1);
for (int l = 0; l < actor2.particleCount; l++)
{
int index2 = actor2.GetParticleRuntimeIndex(l);
Vector3 pos2 = actor2.GetParticlePosition(index2);
float distance = Vector3.Distance(pos1, pos2);
if (distance < stitchMergin)
{
obiStitcher.AddStitch(i, l);
int solverIndex = actor1.solverIndices[i];
solver.filters[index1] = filter;
}
}
}
obiStitcher.PushDataToSolver();
}