void SaveBodyPositions()
    {
        Transform joint;

        //Calculate joint angles based on parent-child positions instead of custom definitions above.
        int numJoints = avatarSkeleton.boneIndexCount();

        //print("NumJoints=" + numJoints);
        for (int i = 0; i < numJoints; i++)
        {
            int boneIndex = i;
            joint = avatarSkeleton.boneIndex2Transform(boneIndex);
            string jointName = avatarSkeleton.boneIndex2Name(boneIndex);
            //print("boneIndex = " + boneIndex);
            //print(" joint = " + joint.name + ", body part=" + jointName);

            bonePos[i] = joint.position;
            if (i == 7)
            {
                //Debug.Log(bonePos[i]);
            }
            if (resetMinMax)
            {
                //                print("sbp:moved!");
                //                           print(" joint = " + joint.name + ", body part=" + jointName);
                initMinMaxV3(bonePos[boneIndex], ref bonePosMin[boneIndex], ref bonePosMax[boneIndex]);
            }
            else
            if (updateMinMax)
            {
                saveMinMaxV3(bonePos[boneIndex], ref bonePosMin[boneIndex], ref bonePosMax[boneIndex]);
            }
            //if (!was_moving && moving)  //something moved for first time, so record all positions as the new min and max
        }
    }