Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Index was outside the bounds of the array
#1
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,


Attached Files Thumbnail(s)
   
Reply
#2
(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.
Reply
#3
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.


Attached Files
.cs   ObiSkinnedCloth.cs (Size: 7.36 KB / Downloads: 3)
Reply