}
// first pass, indep joints
int cnt = 0;
for (int i = 0; i < pbWorld.getJointsCount(); i++) {
PbJoint pbJoint = pbWorld.getJoints(i);
if (isIndependentJoint(pbJoint.getType())) {
Joint joint = deserializeJoint(world, pbJoint, bodyMap, jointMap);
jointMap.put(cnt, joint);
cnt++;
}
}
// second pass, dep joints
for (int i = 0; i < pbWorld.getJointsCount(); i++) {
PbJoint pbJoint = pbWorld.getJoints(i);
if (!isIndependentJoint(pbJoint.getType())) {
Joint joint = deserializeJoint(world, pbJoint, bodyMap, jointMap);
jointMap.put(cnt, joint);
cnt++;
}
}