iMSTK-Unity DynamicalModelEditor bug on handle colliders

Don’t know why, but in DynamicalModelEditor.HandleColliders there are duplicated DynamicalModels being showed for setting the collisions.

EDIT: Not only not working in DynamicalModelEditor, the line that gives us the duplicated objects is the next one, that generates the same “duplicated objects” error in all the scripts that use it.

_allDeformables = (Resources.FindObjectsOfTypeAll(typeof(DynamicalModel)) as DynamicalModel[]).ToList<DynamicalModel>();

My temporal fix is just adding each DynamicalModel to a “usedDynamicalModels” list, and comparing them at the begining of each loop iteration.

if (!_allUsedDeformables.Contains(item.gameObject.name))
      _allUsedDeformables.Add(item.gameObject.name);
else
      continue;  //to go to the next iteration and ignore the 
                 //lines below for this iteration

The bug:
image

What happens when trying to use a duplicated DynamicalModel:

Better fix:

var item = _allDeformables[i];
if (item.GetPhysicsGeometry() == null)
      continue;

and, in GeomUtils, change the line that before was simply printing and error,and add a null return


if (geom == null)
{
       Debug.LogError("ToImstkgeometry called with null");
       return null;
}

It would really be great if you could put some of these changes up as Pull requests on gitlab, ImstkUnity is a public project and any contributions are appreciated

I would like to do that but the code isn’t the iMSTK-Unity original one. I’m changing a lot of things to adapt it to my project, so that’s why I write here the fixes that are related with the “original” iMSTK-Unity code. When I finish my project I will be glad to upload all the useful changes to the repository.

That’s a shame, it’s going to get increasingly harder to port back changes the further the two branches diverge from each other.

I will work on it, is just making “Diff” between the original files and mines, and get the relevant changes. After my end of the project I will do it, now I can’t, I have no time, I just write the relevant code like this. If it’s bad for you I can wait to upload them, I thought it wold be better than nothing.