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
parent
9406db3047
commit
65c4cb48ac
|
@ -1765,11 +1765,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
|||
// Next, let's close the child agent connections that are too far away.
|
||||
uint neighbourx;
|
||||
uint neighboury;
|
||||
|
||||
Utils.LongToUInts(neighbourRegion.RegionHandle, out neighbourx, out neighboury);
|
||||
|
||||
neighbourx /= Constants.RegionSize;
|
||||
neighboury /= Constants.RegionSize;
|
||||
Util.RegionHandleToRegionLoc(neighbourRegion.RegionHandle, out neighbourx, out neighboury);
|
||||
|
||||
agent.CloseChildAgents(neighbourx, neighboury);
|
||||
|
||||
|
|
|
@ -657,7 +657,7 @@ public sealed class BSCharacter : BSPhysObject
|
|||
|
||||
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";
|
||||
// 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.
|
||||
|
||||
// Scale is multiplier of radius with one of "0.5"
|
||||
newScale.X = size.X / 2f;
|
||||
newScale.Y = size.Y / 2f;
|
||||
|
||||
float heightAdjust = BSParam.AvatarHeightMidFudge;
|
||||
if (BSParam.AvatarHeightLowFudge != 0f || BSParam.AvatarHeightHighFudge != 0f)
|
||||
|
@ -692,8 +690,17 @@ public sealed class BSCharacter : BSPhysObject
|
|||
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.
|
||||
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);
|
||||
|
||||
// If smaller than the endcaps, just fake like we're almost that small
|
||||
|
|
|
@ -128,6 +128,7 @@ public static class BSParam
|
|||
public static float AvatarAlwaysRunFactor { get; private set; }
|
||||
public static float AvatarDensity { 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 AvatarCapsuleDepth { get; private set; }
|
||||
public static float AvatarCapsuleHeight { get; private set; }
|
||||
|
@ -565,6 +566,8 @@ public static class BSParam
|
|||
3500f) , // 3.5 * 100
|
||||
new ParameterDefn<float>("AvatarRestitution", "Bouncyness. Changed on avatar recreation.",
|
||||
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",
|
||||
0.6f ) ,
|
||||
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",
|
||||
1.5f ),
|
||||
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",
|
||||
0.1f ),
|
||||
-0.1f ),
|
||||
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",
|
||||
0.1f ),
|
||||
new ParameterDefn<float>("AvatarStopZeroThreshold", "Movement velocity below which avatar is assumed to be stopped",
|
||||
|
|
|
@ -124,6 +124,10 @@ public sealed class BSShapeCollection : IDisposable
|
|||
// Info in prim.BSShape is updated to the new shape.
|
||||
// Returns 'true' if the geometry was rebuilt.
|
||||
// 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)
|
||||
{
|
||||
bool ret = false;
|
||||
|
@ -137,10 +141,32 @@ public sealed class BSShapeCollection : IDisposable
|
|||
if (theChar != null)
|
||||
{
|
||||
DereferenceExistingShape(prim, shapeCallback);
|
||||
switch (BSParam.AvatarShape)
|
||||
{
|
||||
case AvatarShapeCapsule:
|
||||
prim.PhysShape = BSShapeNative.GetReference(m_physicsScene, prim,
|
||||
BSPhysicsShapeType.SHAPE_CAPSULE, FixedShapeKey.KEY_CAPSULE);
|
||||
ret = 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
|
||||
|
|
|
@ -1015,9 +1015,9 @@
|
|||
|
||||
; Avatar physics height adjustments.
|
||||
; http://opensimulator.org/wiki/BulletSim#Adjusting_Avatar_Height
|
||||
AvatarHeightLowFudge = -0.2 ; Adjustment at low end of height range
|
||||
AvatarHeightMidFudge = 0.1 ; Adjustment at mid point of avatar height range
|
||||
AvatarHeightHighFudge = 0.1 ; Adjustment at high end of height range
|
||||
AvatarHeightLowFudge = 0 ; Adjustment at low end of height range
|
||||
AvatarHeightMidFudge = -0.1 ; Adjustment at mid point of avatar height range
|
||||
AvatarHeightHighFudge = 0 ; Adjustment at high end of height range
|
||||
|
||||
; Default linkset implmentation
|
||||
; 'Constraint' uses physics constraints to hold linkset together. 'Compound'
|
||||
|
|
Loading…
Reference in New Issue