Obi Official Forum
Help Index was outside the bounds of the array - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Cloth (https://obi.virtualmethodstudio.com/forum/forum-2.html)
+--- Thread: Help Index was outside the bounds of the array (/thread-1625.html)



Index was outside the bounds of the array - arthamas - 20-01-2020

Hi,

I'm trying to add simulation to a character but I'm having an issue when I have two actors for one solver. (See Attachment)

Hierarchy(Only the important part):

ClothSolver (ObiLateFixedUpdater + ObiSolver)
----> Character (Animator on Fixed Update)
--------->Jersey (ObiSkinnedCloth + ObiSkinnedClothRenderer)
--------->Pants  (ObiSkinnedCloth + ObiSkinnedClothRenderer)

So if I only have the ObiSkinnedCloth on the Jersey or the Pants it works but when its applied on both I'm getting "Index was outside the bounds of the array".

I can have two actors for one solver right?

Cheers,


RE: Index was outside the bounds of the array - josemendez - 21-01-2020

(20-01-2020, 09:51 PM)arthamas Wrote: Hi,

I'm trying to add simulation to a character but I'm having an issue when I have two actors for one solver. (See Attachment)

Hierarchy(Only the important part):

ClothSolver (ObiLateFixedUpdater + ObiSolver)
----> Character (Animator on Fixed Update)
--------->Jersey (ObiSkinnedCloth + ObiSkinnedClothRenderer)
--------->Pants  (ObiSkinnedCloth + ObiSkinnedClothRenderer)

So if I only have the ObiSkinnedCloth on the Jersey or the Pants it works but when its applied on both I'm getting "Index was outside the bounds of the array".

I can have two actors for one solver right?

Cheers,

Hi!

Had a similar from another user report yesterday. This seems like a bug, and yes, you're supposed to be able to use more than one actor per solver. Will take a look at it this morning and get back to you asap.


RE: Index was outside the bounds of the array - josemendez - 21-01-2020

Indeed, it was a bug. Thanks you both for finding and reporting it.

Change lines 153-162 of ObiSkinnedCloth.cs with this:

Code:
int solverIndex = batch.particleIndices[i];
int actorIndex = solver.particleToActor[solverIndex].indexInActor;

batch.skinPoints[i] = skinToSolver.MultiplyPoint3x4(sortedPoints[actorIndex]);
batch.skinNormals[i] = skinToSolver.MultiplyVector(sortedNormals[actorIndex]);

// Rigidly transform particles with zero skin radius and zero compliance:
if (Mathf.Approximately(batch.skinRadiiBackstop[i * 3], 0) & Mathf.Approximately(batch.skinCompliance[i], 0))
{
     solver.invMasses[solverIndex] = 0;
     solver.positions[solverIndex] = batch.skinPoints[i];
}

That should fix it. I'm attaching the entire corrected file for convenience.

Let me know how it goes.