Universe.Physics.BulletSPlugin.BSCharacter.ComputeAvatarScale C# (CSharp) Method

ComputeAvatarScale() private method

private ComputeAvatarScale ( OpenMetaverse size ) : OpenMetaverse.Vector3
size OpenMetaverse
return OpenMetaverse.Vector3
        OMV.Vector3 ComputeAvatarScale(OMV.Vector3 size)
        {
            OMV.Vector3 newScale;

            // Bullet's capsule total height is the "passed height + radius * 2";
            // The base capsule is 1 diameter and 2 height (passed radius=0.5, passed height = 1)
            // The number we pass in for 'scaling' is the multiplier to get that base
            //     shape to be the size desired.
            // So, when creating the scale for the avatar height, we take the passed height
            //     (size.Z) and remove the caps.
            // Another oddity of the Bullet capsule implementation is that it presumes the Y
            //     dimension is the radius of the capsule. Even though some of the code allows
            //     for a asymmetrical capsule, other parts of the code presume it is cylindrical.

            // Scale is multiplier of radius with one of "0.5"
  		float heightAdjust = BSParam.AvatarHeightMidFudge;
			if (BSParam.AvatarHeightLowFudge != 0f || BSParam.AvatarHeightHighFudge != 0f) {
				const float AVATAR_LOW = 1.1f;
				const float AVATAR_MID = 1.775f; // 1.87f
				const float AVATAR_HI = 2.45f;
				// An avatar is between 1.1 and 2.45 meters. Midpoint is 1.775m.
				float midHeightOffset = size.Z - AVATAR_MID;
				if (midHeightOffset < 0f) {
					// Small avatar. Add the adjustment based on the distance from midheight
					heightAdjust += ((-1f * midHeightOffset) / (AVATAR_MID - AVATAR_LOW)) * BSParam.AvatarHeightLowFudge;
				} else {
					// Large avatar. Add the adjustment based on the distance from midheight
					heightAdjust += ((midHeightOffset) / (AVATAR_HI - AVATAR_MID)) * BSParam.AvatarHeightHighFudge;
				}
			}

            newScale.X = size.X / 2f;
            newScale.Y = size.Y / 2f;

            // The total scale height is the central cylindar plus the caps on the two ends.
            //newScale.Z = (size.Z + (Math.Min(size.X, size.Y) * 2)) / 2f;
            newScale.Z = (size.Z + (Math.Min(size.X, size.Y) * 2) + heightAdjust) / 2f;
          // If smaller than the endcaps, just fake like we're almost that small
            if (newScale.Z < 0)
                newScale.Z = 0.1f;

            return newScale;
        }