BulletSim: add adjustment for avatar capsule height scaling. Makes

avatar standing on ground view better and enables tuning.
user_profiles
Robert Adams 2013-05-13 13:03:13 -07:00
parent 45f37e11ad
commit 15360cbb6b
2 changed files with 32 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* /*
* Copyright (c) Contributors, http://opensimulator.org/ * Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders. * See CONTRIBUTORS.TXT for a full list of copyright holders.
* *
@ -649,12 +649,12 @@ public sealed class BSCharacter : BSPhysObject
OMV.Vector3 newScale; OMV.Vector3 newScale;
// Bullet's capsule total height is the "passed height + radius * 2"; // 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 base capsule is 1 unit in diameter and 2 units in height (passed radius=0.5, passed height = 1)
// The number we pass in for 'scaling' is the multiplier to get that base // The number we pass in for 'scaling' is the multiplier to get that base
// shape to be the size desired. // shape to be the size desired.
// So, when creating the scale for the avatar height, we take the passed height // So, when creating the scale for the avatar height, we take the passed height
// (size.Z) and remove the caps. // (size.Z) and remove the caps.
// Another oddity of the Bullet capsule implementation is that it presumes the Y // An 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 // 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. // for a asymmetrical capsule, other parts of the code presume it is cylindrical.
@ -662,8 +662,27 @@ public sealed class BSCharacter : BSPhysObject
newScale.X = size.X / 2f; newScale.X = size.X / 2f;
newScale.Y = size.Y / 2f; newScale.Y = size.Y / 2f;
float heightAdjust = BSParam.AvatarHeightMidFudge;
if (BSParam.AvatarHeightLowFudge != 0f || BSParam.AvatarHeightHighFudge != 0f)
{
// An avatar is between 1.61 and 2.12 meters. Midpoint is 1.87m.
// The "times 4" relies on the fact that the difference from the midpoint to the extremes is exactly 0.25
float midHeightOffset = size.Z - 1.87f;
if (midHeightOffset < 0f)
{
// Small avatar. Add the adjustment based on the distance from midheight
heightAdjust += -1f * midHeightOffset * 4f * BSParam.AvatarHeightLowFudge;
}
else
{
// Large avatar. Add the adjustment based on the distance from midheight
heightAdjust += midHeightOffset * 4f * BSParam.AvatarHeightHighFudge;
}
}
// The total scale height is the central cylindar plus the caps on the two ends. // 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;
// m_log.DebugFormat("{0} ComputeAvatarScale: size={1},adj={2},scale={3}", LogHeader, size, heightAdjust, newScale);
// If smaller than the endcaps, just fake like we're almost that small // If smaller than the endcaps, just fake like we're almost that small
if (newScale.Z < 0) if (newScale.Z < 0)
newScale.Z = 0.1f; newScale.Z = 0.1f;

View File

@ -125,6 +125,9 @@ public static class BSParam
public static float AvatarCapsuleWidth { get; private set; } public static float AvatarCapsuleWidth { get; private set; }
public static float AvatarCapsuleDepth { get; private set; } public static float AvatarCapsuleDepth { get; private set; }
public static float AvatarCapsuleHeight { get; private set; } public static float AvatarCapsuleHeight { get; private set; }
public static float AvatarHeightLowFudge { get; private set; }
public static float AvatarHeightMidFudge { get; private set; }
public static float AvatarHeightHighFudge { get; private set; }
public static float AvatarContactProcessingThreshold { get; private set; } public static float AvatarContactProcessingThreshold { get; private set; }
public static float AvatarBelowGroundUpCorrectionMeters { get; private set; } public static float AvatarBelowGroundUpCorrectionMeters { get; private set; }
public static float AvatarStepHeight { get; private set; } public static float AvatarStepHeight { get; private set; }
@ -539,6 +542,12 @@ public static class BSParam
0.45f ), 0.45f ),
new ParameterDefn<float>("AvatarCapsuleHeight", "Default height of space around avatar", new ParameterDefn<float>("AvatarCapsuleHeight", "Default height of space around avatar",
1.5f ), 1.5f ),
new ParameterDefn<float>("AvatarHeightLowFudge", "A fudge factor to make small avatars stand on the ground",
-0.2f ),
new ParameterDefn<float>("AvatarHeightMidFudge", "A fudge distance to adjust average sized avatars to be standing on ground",
0.1f ),
new ParameterDefn<float>("AvatarHeightHighFudge", "A fudge factor to make tall avatars stand on the ground",
0.1f ),
new ParameterDefn<float>("AvatarContactProcessingThreshold", "Distance from capsule to check for collisions", new ParameterDefn<float>("AvatarContactProcessingThreshold", "Distance from capsule to check for collisions",
0.1f ), 0.1f ),
new ParameterDefn<float>("AvatarBelowGroundUpCorrectionMeters", "Meters to move avatar up if it seems to be below ground", new ParameterDefn<float>("AvatarBelowGroundUpCorrectionMeters", "Meters to move avatar up if it seems to be below ground",