BulletSim: make avatar physical shape to be a rectangle rather than

a capsule. Set the default to be the rectangle shape and adjust the
parameters in OpenSimDefaults.ini for the new shape.

The rectangle shape will perform better and avatar height can be
computed more accurately.
0.8.0.3
Robert Adams 2014-04-02 21:53:58 -07:00
parent 9406db3047
commit 65c4cb48ac
5 changed files with 51 additions and 19 deletions

View File

@ -1765,11 +1765,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
// Next, let's close the child agent connections that are too far away. // Next, let's close the child agent connections that are too far away.
uint neighbourx; uint neighbourx;
uint neighboury; uint neighboury;
Util.RegionHandleToRegionLoc(neighbourRegion.RegionHandle, out neighbourx, out neighboury);
Utils.LongToUInts(neighbourRegion.RegionHandle, out neighbourx, out neighboury);
neighbourx /= Constants.RegionSize;
neighboury /= Constants.RegionSize;
agent.CloseChildAgents(neighbourx, neighboury); agent.CloseChildAgents(neighbourx, neighboury);

View File

@ -657,7 +657,7 @@ public sealed class BSCharacter : BSPhysObject
private OMV.Vector3 ComputeAvatarScale(OMV.Vector3 size) private OMV.Vector3 ComputeAvatarScale(OMV.Vector3 size)
{ {
OMV.Vector3 newScale; OMV.Vector3 newScale = size;
// 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 unit in diameter and 2 units in 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)
@ -670,8 +670,6 @@ public sealed class BSCharacter : BSPhysObject
// 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.
// Scale is multiplier of radius with one of "0.5" // Scale is multiplier of radius with one of "0.5"
newScale.X = size.X / 2f;
newScale.Y = size.Y / 2f;
float heightAdjust = BSParam.AvatarHeightMidFudge; float heightAdjust = BSParam.AvatarHeightMidFudge;
if (BSParam.AvatarHeightLowFudge != 0f || BSParam.AvatarHeightHighFudge != 0f) if (BSParam.AvatarHeightLowFudge != 0f || BSParam.AvatarHeightHighFudge != 0f)
@ -692,8 +690,17 @@ public sealed class BSCharacter : BSPhysObject
heightAdjust += ((midHeightOffset) / (AVATAR_HI - AVATAR_MID)) * BSParam.AvatarHeightHighFudge; heightAdjust += ((midHeightOffset) / (AVATAR_HI - AVATAR_MID)) * BSParam.AvatarHeightHighFudge;
} }
} }
if (BSParam.AvatarShape == BSShapeCollection.AvatarShapeCapsule)
{
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. // 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) + heightAdjust) / 2f; newScale.Z = (size.Z + (Math.Min(size.X, size.Y) * 2) + heightAdjust) / 2f;
}
else
{
newScale.Z = size.Z + heightAdjust;
}
// m_log.DebugFormat("{0} ComputeAvatarScale: size={1},adj={2},scale={3}", LogHeader, size, heightAdjust, newScale); // 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

View File

@ -128,6 +128,7 @@ public static class BSParam
public static float AvatarAlwaysRunFactor { get; private set; } public static float AvatarAlwaysRunFactor { get; private set; }
public static float AvatarDensity { get; private set; } public static float AvatarDensity { get; private set; }
public static float AvatarRestitution { get; private set; } public static float AvatarRestitution { get; private set; }
public static int AvatarShape { get; private set; }
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; }
@ -565,6 +566,8 @@ public static class BSParam
3500f) , // 3.5 * 100 3500f) , // 3.5 * 100
new ParameterDefn<float>("AvatarRestitution", "Bouncyness. Changed on avatar recreation.", new ParameterDefn<float>("AvatarRestitution", "Bouncyness. Changed on avatar recreation.",
0f ), 0f ),
new ParameterDefn<int>("AvatarShape", "Code for avatar physical shape: 0:capsule, 1:cube, 2:ovoid, 2:mesh",
BSShapeCollection.AvatarShapeCube ) ,
new ParameterDefn<float>("AvatarCapsuleWidth", "The distance between the sides of the avatar capsule", new ParameterDefn<float>("AvatarCapsuleWidth", "The distance between the sides of the avatar capsule",
0.6f ) , 0.6f ) ,
new ParameterDefn<float>("AvatarCapsuleDepth", "The distance between the front and back of the avatar capsule", new ParameterDefn<float>("AvatarCapsuleDepth", "The distance between the front and back of the avatar capsule",
@ -572,11 +575,11 @@ public static class BSParam
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", new ParameterDefn<float>("AvatarHeightLowFudge", "A fudge factor to make small avatars stand on the ground",
-0.2f ), 0f ),
new ParameterDefn<float>("AvatarHeightMidFudge", "A fudge distance to adjust average sized avatars to be standing on ground", new ParameterDefn<float>("AvatarHeightMidFudge", "A fudge distance to adjust average sized avatars to be standing on ground",
0.1f ), -0.1f ),
new ParameterDefn<float>("AvatarHeightHighFudge", "A fudge factor to make tall avatars stand on the ground", new ParameterDefn<float>("AvatarHeightHighFudge", "A fudge factor to make tall avatars stand on the ground",
0.1f ), 0f ),
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>("AvatarStopZeroThreshold", "Movement velocity below which avatar is assumed to be stopped", new ParameterDefn<float>("AvatarStopZeroThreshold", "Movement velocity below which avatar is assumed to be stopped",

View File

@ -124,6 +124,10 @@ public sealed class BSShapeCollection : IDisposable
// Info in prim.BSShape is updated to the new shape. // Info in prim.BSShape is updated to the new shape.
// Returns 'true' if the geometry was rebuilt. // Returns 'true' if the geometry was rebuilt.
// Called at taint-time! // Called at taint-time!
public const int AvatarShapeCapsule = 0;
public const int AvatarShapeCube = 1;
public const int AvatarShapeOvoid = 2;
public const int AvatarShapeMesh = 3;
private bool CreateGeom(bool forceRebuild, BSPhysObject prim, PhysicalDestructionCallback shapeCallback) private bool CreateGeom(bool forceRebuild, BSPhysObject prim, PhysicalDestructionCallback shapeCallback)
{ {
bool ret = false; bool ret = false;
@ -137,10 +141,32 @@ public sealed class BSShapeCollection : IDisposable
if (theChar != null) if (theChar != null)
{ {
DereferenceExistingShape(prim, shapeCallback); DereferenceExistingShape(prim, shapeCallback);
switch (BSParam.AvatarShape)
{
case AvatarShapeCapsule:
prim.PhysShape = BSShapeNative.GetReference(m_physicsScene, prim, prim.PhysShape = BSShapeNative.GetReference(m_physicsScene, prim,
BSPhysicsShapeType.SHAPE_CAPSULE, FixedShapeKey.KEY_CAPSULE); BSPhysicsShapeType.SHAPE_CAPSULE, FixedShapeKey.KEY_CAPSULE);
ret = true; ret = true;
haveShape = true; haveShape = true;
break;
case AvatarShapeCube:
prim.PhysShape = BSShapeNative.GetReference(m_physicsScene, prim,
BSPhysicsShapeType.SHAPE_BOX, FixedShapeKey.KEY_CAPSULE);
ret = true;
haveShape = true;
break;
case AvatarShapeOvoid:
// Saddly, Bullet doesn't scale spheres so this doesn't work as an avatar shape
prim.PhysShape = BSShapeNative.GetReference(m_physicsScene, prim,
BSPhysicsShapeType.SHAPE_SPHERE, FixedShapeKey.KEY_CAPSULE);
ret = true;
haveShape = true;
break;
case AvatarShapeMesh:
break;
default:
break;
}
} }
// If the prim attributes are simple, this could be a simple Bullet native shape // If the prim attributes are simple, this could be a simple Bullet native shape

View File

@ -1015,9 +1015,9 @@
; Avatar physics height adjustments. ; Avatar physics height adjustments.
; http://opensimulator.org/wiki/BulletSim#Adjusting_Avatar_Height ; http://opensimulator.org/wiki/BulletSim#Adjusting_Avatar_Height
AvatarHeightLowFudge = -0.2 ; Adjustment at low end of height range AvatarHeightLowFudge = 0 ; Adjustment at low end of height range
AvatarHeightMidFudge = 0.1 ; Adjustment at mid point of avatar height range AvatarHeightMidFudge = -0.1 ; Adjustment at mid point of avatar height range
AvatarHeightHighFudge = 0.1 ; Adjustment at high end of height range AvatarHeightHighFudge = 0 ; Adjustment at high end of height range
; Default linkset implmentation ; Default linkset implmentation
; 'Constraint' uses physics constraints to hold linkset together. 'Compound' ; 'Constraint' uses physics constraints to hold linkset together. 'Compound'