Merge branch 'master' of opensimulator.org:/var/git/opensim
commit
07b78a68fc
|
@ -418,17 +418,6 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
private float terrainMS;
|
||||
private float landMS;
|
||||
|
||||
// A temporary configuration flag to enable using FireAndForget to process
|
||||
// collisions from the physics engine. There is a problem with collisions
|
||||
// stopping sometimes and MB's suspicion is some race condition passing
|
||||
// collisions from the physics engine callback to the script engine.
|
||||
// This causes the collision events to be passed with a FireAndForget
|
||||
// call which should eliminate that linkage. Testers can turn this on
|
||||
// and see if collisions stop. If they don't, the problem is somewhere else.
|
||||
// This feature defaults to 'off' so, by default, the simulator operation
|
||||
// is not changed.
|
||||
public bool ShouldUseFireAndForgetForCollisions = false;
|
||||
|
||||
/// <summary>
|
||||
/// Tick at which the last frame was processed.
|
||||
/// </summary>
|
||||
|
@ -1147,10 +1136,6 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
m_update_terrain = startupConfig.GetInt("UpdateTerrainEveryNFrames", m_update_terrain);
|
||||
m_update_temp_cleaning = startupConfig.GetInt("UpdateTempCleaningEveryNSeconds", m_update_temp_cleaning);
|
||||
|
||||
if (startupConfig.Contains("ShouldUseFireAndForgetForCollisions"))
|
||||
{
|
||||
ShouldUseFireAndForgetForCollisions = startupConfig.GetBoolean("ShouldUseFireAndForgetForCollisions", false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -3571,6 +3571,9 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)
|
||||
|| !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE)
|
||||
|| !m_pos.ApproxEquals(m_lastPosition, POSITION_LARGETOLERANCE)
|
||||
// if velocity is zero and it wasn't zero last time, send the update
|
||||
|| (Velocity == Vector3.Zero && m_lastVelocity != Vector3.Zero)
|
||||
// if position has moved just a little and velocity is very low, send the update
|
||||
|| (!m_pos.ApproxEquals(m_lastPosition, POSITION_SMALLTOLERANCE) && Velocity.LengthSquared() < LOWVELOCITYSQ )
|
||||
) )
|
||||
{
|
||||
|
|
|
@ -40,7 +40,6 @@ public sealed class BSCharacter : BSPhysObject
|
|||
private static readonly string LogHeader = "[BULLETS CHAR]";
|
||||
|
||||
// private bool _stopped;
|
||||
private OMV.Vector3 _size;
|
||||
private bool _grabbed;
|
||||
private bool _selected;
|
||||
private float _mass;
|
||||
|
@ -57,6 +56,9 @@ public sealed class BSCharacter : BSPhysObject
|
|||
private bool _kinematic;
|
||||
private float _buoyancy;
|
||||
|
||||
private OMV.Vector3 _size;
|
||||
private float _footOffset;
|
||||
|
||||
private BSActorAvatarMove m_moveActor;
|
||||
private const string AvatarMoveActorName = "BSCharacter.AvatarMove";
|
||||
|
||||
|
@ -76,7 +78,7 @@ public sealed class BSCharacter : BSPhysObject
|
|||
public override bool IsIncomplete { get { return false; } }
|
||||
|
||||
public BSCharacter(
|
||||
uint localID, String avName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 vel, OMV.Vector3 size, bool isFlying)
|
||||
uint localID, String avName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 vel, OMV.Vector3 size, float footOffset, bool isFlying)
|
||||
|
||||
: base(parent_scene, localID, avName, "BSCharacter")
|
||||
{
|
||||
|
@ -91,21 +93,13 @@ public sealed class BSCharacter : BSPhysObject
|
|||
Density = BSParam.AvatarDensity;
|
||||
_isPhysical = true;
|
||||
|
||||
// Old versions of ScenePresence passed only the height. If width and/or depth are zero,
|
||||
// replace with the default values.
|
||||
_size = size;
|
||||
if (_size.X == 0f) _size.X = BSParam.AvatarCapsuleDepth;
|
||||
if (_size.Y == 0f) _size.Y = BSParam.AvatarCapsuleWidth;
|
||||
|
||||
// The dimensions of the physical capsule are kept in the scale.
|
||||
// Physics creates a unit capsule which is scaled by the physics engine.
|
||||
Scale = ComputeAvatarScale(_size);
|
||||
// set _avatarVolume and _mass based on capsule size, _density and Scale
|
||||
ComputeAvatarVolumeAndMass();
|
||||
// Adjustments for zero X and Y made in Size()
|
||||
// This also computes avatar scale, volume, and mass
|
||||
SetAvatarSize(size, footOffset, true /* initializing */);
|
||||
|
||||
DetailLog(
|
||||
"{0},BSCharacter.create,call,size={1},scale={2},density={3},volume={4},mass={5},pos={6},vel={7}",
|
||||
LocalID, _size, Scale, Density, _avatarVolume, RawMass, pos, vel);
|
||||
LocalID, Size, Scale, Density, _avatarVolume, RawMass, pos, vel);
|
||||
|
||||
// do actual creation in taint time
|
||||
PhysScene.TaintedObject(LocalID, "BSCharacter.create", delegate()
|
||||
|
@ -209,22 +203,47 @@ public sealed class BSCharacter : BSPhysObject
|
|||
public override OMV.Vector3 Size {
|
||||
get
|
||||
{
|
||||
// Avatar capsule size is kept in the scale parameter.
|
||||
return _size;
|
||||
}
|
||||
|
||||
set {
|
||||
// This is how much the avatar size is changing. Positive means getting bigger.
|
||||
// The avatar altitude must be adjusted for this change.
|
||||
float heightChange = value.Z - _size.Z;
|
||||
setAvatarSize(value, _footOffset);
|
||||
}
|
||||
}
|
||||
|
||||
_size = value;
|
||||
// OpenSim 0.9 introduces a common avatar size computation
|
||||
public override void setAvatarSize(OMV.Vector3 size, float feetOffset)
|
||||
{
|
||||
SetAvatarSize(size, feetOffset, false /* initializing */);
|
||||
}
|
||||
|
||||
// Internal version that, if initializing, doesn't do all the updating of the physics engine
|
||||
public void SetAvatarSize(OMV.Vector3 size, float feetOffset, bool initializing)
|
||||
{
|
||||
OMV.Vector3 newSize = size;
|
||||
if (newSize.IsFinite())
|
||||
{
|
||||
// Old versions of ScenePresence passed only the height. If width and/or depth are zero,
|
||||
// replace with the default values.
|
||||
if (_size.X == 0f) _size.X = BSParam.AvatarCapsuleDepth;
|
||||
if (_size.Y == 0f) _size.Y = BSParam.AvatarCapsuleWidth;
|
||||
if (newSize.X == 0f) newSize.X = BSParam.AvatarCapsuleDepth;
|
||||
if (newSize.Y == 0f) newSize.Y = BSParam.AvatarCapsuleWidth;
|
||||
|
||||
Scale = ComputeAvatarScale(_size);
|
||||
if (newSize.X < 0.01f) newSize.X = 0.01f;
|
||||
if (newSize.Y < 0.01f) newSize.Y = 0.01f;
|
||||
if (newSize.Z < 0.01f) newSize.Z = BSParam.AvatarCapsuleHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
newSize = new OMV.Vector3(BSParam.AvatarCapsuleDepth, BSParam.AvatarCapsuleWidth, BSParam.AvatarCapsuleHeight);
|
||||
}
|
||||
|
||||
// This is how much the avatar size is changing. Positive means getting bigger.
|
||||
// The avatar altitude must be adjusted for this change.
|
||||
float heightChange = newSize.Z - Size.Z;
|
||||
|
||||
_size = newSize;
|
||||
|
||||
Scale = ComputeAvatarScale(Size);
|
||||
ComputeAvatarVolumeAndMass();
|
||||
DetailLog("{0},BSCharacter.setSize,call,size={1},scale={2},density={3},volume={4},mass={5}",
|
||||
LocalID, _size, Scale, Density, _avatarVolume, RawMass);
|
||||
|
@ -243,8 +262,6 @@ public sealed class BSCharacter : BSPhysObject
|
|||
PhysScene.PE.PushUpdate(PhysBody);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public override PrimitiveBaseShape Shape
|
||||
|
@ -702,10 +719,15 @@ public sealed class BSCharacter : BSPhysObject
|
|||
public override void SetMomentum(OMV.Vector3 momentum) {
|
||||
}
|
||||
|
||||
// The avatar's physical shape (whether capsule or cube) is unit sized. BulletSim sets
|
||||
// the scale of that unit shape to create the avatars full size.
|
||||
private OMV.Vector3 ComputeAvatarScale(OMV.Vector3 size)
|
||||
{
|
||||
OMV.Vector3 newScale = size;
|
||||
|
||||
if (BSParam.AvatarUseBefore09SizeComputation)
|
||||
{
|
||||
|
||||
// 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 number we pass in for 'scaling' is the multiplier to get that base
|
||||
|
@ -754,14 +776,22 @@ public sealed class BSCharacter : BSPhysObject
|
|||
if (newScale.Z < 0)
|
||||
newScale.Z = 0.1f;
|
||||
|
||||
DetailLog("{0},BSCharacter.ComputerAvatarScale,size={1},lowF={2},midF={3},hiF={4},adj={5},newScale={6}",
|
||||
DetailLog("{0},BSCharacter.ComputeAvatarScale,size={1},lowF={2},midF={3},hiF={4},adj={5},newScale={6}",
|
||||
LocalID, size, BSParam.AvatarHeightLowFudge, BSParam.AvatarHeightMidFudge, BSParam.AvatarHeightHighFudge, heightAdjust, newScale);
|
||||
}
|
||||
else
|
||||
{
|
||||
newScale.Z = size.Z + _footOffset;
|
||||
DetailLog("{0},BSCharacter.ComputeAvatarScale,using newScale={1}, footOffset={2}", LocalID, newScale, _footOffset);
|
||||
}
|
||||
|
||||
return newScale;
|
||||
}
|
||||
|
||||
// set _avatarVolume and _mass based on capsule size, _density and Scale
|
||||
private void ComputeAvatarVolumeAndMass()
|
||||
{
|
||||
if (BSParam.AvatarShape == BSShapeCollection.AvatarShapeCapsule)
|
||||
{
|
||||
_avatarVolume = (float)(
|
||||
Math.PI
|
||||
|
@ -774,6 +804,11 @@ public sealed class BSCharacter : BSPhysObject
|
|||
* Math.Min(Size.X, Size.Y) / 2
|
||||
* Size.Y / 2f // plus the volume of the capsule end caps
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
_avatarVolume = Size.X * Size.Y * Size.Z;
|
||||
}
|
||||
_mass = Density * BSParam.DensityScaleFactor * _avatarVolume;
|
||||
}
|
||||
|
||||
|
|
|
@ -142,6 +142,7 @@ public static class BSParam
|
|||
public static float AvatarCapsuleWidth { get; private set; }
|
||||
public static float AvatarCapsuleDepth { get; private set; }
|
||||
public static float AvatarCapsuleHeight { get; private set; }
|
||||
public static bool AvatarUseBefore09SizeComputation { get; private set; }
|
||||
public static float AvatarHeightLowFudge { get; private set; }
|
||||
public static float AvatarHeightMidFudge { get; private set; }
|
||||
public static float AvatarHeightHighFudge { get; private set; }
|
||||
|
@ -616,6 +617,8 @@ public static class BSParam
|
|||
0.45f ),
|
||||
new ParameterDefn<float>("AvatarCapsuleHeight", "Default height of space around avatar",
|
||||
1.5f ),
|
||||
new ParameterDefn<bool>("AvatarUseBefore09SizeComputation", "Use the old fudge method of computing avatar capsule size",
|
||||
true ),
|
||||
new ParameterDefn<float>("AvatarHeightLowFudge", "A fudge factor to make small avatars stand on the ground",
|
||||
0f ),
|
||||
new ParameterDefn<float>("AvatarHeightMidFudge", "A fudge distance to adjust average sized avatars to be standing on ground",
|
||||
|
@ -633,7 +636,7 @@ public static class BSParam
|
|||
new ParameterDefn<float>("AvatarAddForcePushFactor", "BSCharacter.AddForce is multiplied by this and mass to be like other physics engines",
|
||||
0.315f ),
|
||||
new ParameterDefn<float>("AvatarStopZeroThreshold", "Movement velocity below which avatar is assumed to be stopped",
|
||||
0.4f,
|
||||
0.45f,
|
||||
(s) => { return (float)AvatarStopZeroThreshold; },
|
||||
(s,v) => { AvatarStopZeroThreshold = v; AvatarStopZeroThresholdSquared = v * v; } ),
|
||||
new ParameterDefn<float>("AvatarBelowGroundUpCorrectionMeters", "Meters to move avatar up if it seems to be below ground",
|
||||
|
|
|
@ -523,13 +523,13 @@ namespace OpenSim.Region.PhysicsModule.BulletS
|
|||
return null;
|
||||
}
|
||||
|
||||
public override PhysicsActor AddAvatar(uint localID, string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying)
|
||||
public override PhysicsActor AddAvatar(uint localID, string avName, Vector3 position, Vector3 size, float footOffset, bool isFlying)
|
||||
{
|
||||
// m_log.DebugFormat("{0}: AddAvatar: {1}", LogHeader, avName);
|
||||
|
||||
if (!m_initialized) return null;
|
||||
|
||||
BSCharacter actor = new BSCharacter(localID, avName, this, position, velocity, size, isFlying);
|
||||
BSCharacter actor = new BSCharacter(localID, avName, this, position, Vector3.Zero, size, footOffset, isFlying);
|
||||
lock (PhysObjects)
|
||||
PhysObjects.Add(localID, actor);
|
||||
|
||||
|
|
Loading…
Reference in New Issue