Skip to content

Commit

Permalink
Do not add duplicate joints to KJRMultiJointManager dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
siimav committed Mar 18, 2024
1 parent 664a215 commit a3f1beb
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,18 @@ public void RegisterMultiJoint(Part testPart, ConfigurableJoint multiJoint)
List<ConfigurableJoint> configJointList;
if (multiJointDict.TryGetValue(testPart, out configJointList))
{
bool alreadyExists = false;
for (int i = configJointList.Count - 1; i >= 0; --i)
if (configJointList[i] == null)
{
ConfigurableJoint joint = configJointList[i];
if (joint == null)
configJointList.RemoveAt(i);

configJointList.Add(multiJoint);
alreadyExists |= joint == multiJoint;
}

if (!alreadyExists)
configJointList.Add(multiJoint);
}
else
{
Expand Down

0 comments on commit a3f1beb

Please sign in to comment.