* A bunch of updates to make things more smooth.

** Sending the actual TimeDilation to the client now instead of the 62455 constant.  The client is *supposed* to use that value to sync with the simulator.    (actually sending ushort.maxvalue * TimeDilation)
** Disabling prim that inter-penetrate instead of just not attaching a joint
** Reduced prim spin a 'little' bit, but not *enough* 
** Tweaked the TimeDilation algorithm to be closer to 1.0 by default and various changes to the sim stats reporter 
** Created a .SetValues method to PhysicsVector so we can simply call the setvalues function instead of .x, .y, .z sets.
** Experimented with a .GetBytes Method on PhysicsActor to be able to use the LLVector3.FromBytes() method.   
** Upped the Inter-penetration depth to 0.25 instead of .08.
ThreadPoolClientBranch
Teravus Ovares 2008-02-12 04:27:20 +00:00
parent fdc42481ed
commit 6e01769bcf
10 changed files with 133 additions and 34 deletions

View File

@ -1567,7 +1567,7 @@ namespace OpenSim.Region.ClientStack
ObjectUpdatePacket objupdate = (ObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdate);
// TODO: don't create new blocks if recycling an old packet
objupdate.RegionData.RegionHandle = regionHandle;
objupdate.RegionData.TimeDilation = 64096;
objupdate.RegionData.TimeDilation = ushort.MaxValue;
objupdate.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
objupdate.ObjectData[0] = CreateDefaultAvatarPacket(textureEntry);

View File

@ -240,7 +240,7 @@ namespace OpenSim.Region.Environment.Scenes
if (TryGetAvatar(remoteClient.AgentId, out av)) {
ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
objupdate.RegionData.RegionHandle = m_regInfo.RegionHandle;
objupdate.RegionData.TimeDilation = 64096;
objupdate.RegionData.TimeDilation = ushort.MaxValue;
objupdate.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[2];
// avatar stuff - horrible group copypaste

View File

@ -69,7 +69,7 @@ namespace OpenSim.Region.Environment.Scenes
public InnerScene m_innerScene;
private Random Rand = new Random();
private uint _primCount = 702000;
private uint _primCount = 720000;
private readonly Mutex _primAllocateMutex = new Mutex(false);
private int m_timePhase = 24;
@ -113,7 +113,7 @@ namespace OpenSim.Region.Environment.Scenes
protected int m_fps = 10;
protected int m_frame = 0;
protected float m_timespan = 0.1f;
protected float m_timespan = 0.089f;
protected DateTime m_lastupdate = DateTime.Now;
protected float m_timedilation = 1.0f;
@ -750,8 +750,17 @@ namespace OpenSim.Region.Environment.Scenes
finally
{
updateLock.ReleaseMutex();
// Get actual time dilation
float tmpval = (m_timespan / (float)SinceLastFrame.TotalSeconds);
m_timedilation = m_timespan / (float)SinceLastFrame.TotalSeconds;
// If actual time dilation is greater then one, we're catching up, so subtract
// the amount that's greater then 1 from the time dilation
if (tmpval > 1.0)
{
tmpval = tmpval - (tmpval - 1.0f);
}
m_timedilation = tmpval;
m_lastupdate = DateTime.Now;
}
}

View File

@ -1593,7 +1593,10 @@ namespace OpenSim.Region.Environment.Scenes
part.UpdateMovement();
}
}
public float GetTimeDilation()
{
return m_scene.TimeDilation;
}
/// <summary>
/// Added as a way for the storage provider to reset the scene,
/// most likely a better way to do this sort of thing but for now...

View File

@ -94,10 +94,12 @@ namespace OpenSim.Region.Environment.Scenes
public byte ObjectSaleType;
public int SalePrice;
public uint Category;
public Int32 CreationDate;
public uint ParentID = 0;
private PhysicsVector m_lastRotationalVelocity = PhysicsVector.Zero;
private Vector3 m_sitTargetPosition = new Vector3(0, 0, 0);
private Quaternion m_sitTargetOrientation = new Quaternion(0, 0, 0, 1);
private LLUUID m_sitTargetAvatar = LLUUID.Zero;
@ -417,9 +419,7 @@ namespace OpenSim.Region.Environment.Scenes
{
if (PhysActor.IsPhysical)
{
m_rotationalvelocity.X = PhysActor.RotationalVelocity.X;
m_rotationalvelocity.Y = PhysActor.RotationalVelocity.Y;
m_rotationalvelocity.Z = PhysActor.RotationalVelocity.Z;
m_rotationalvelocity.FromBytes(PhysActor.RotationalVelocity.GetBytes(),0);
}
}
@ -1693,7 +1693,7 @@ namespace OpenSim.Region.Environment.Scenes
byte[] color = new byte[] {m_color.R, m_color.G, m_color.B, m_color.A};
remoteClient.SendPrimitiveToClient(m_regionHandle, 64096, LocalID, m_shape, lPos, clientFlags, m_uuid,
remoteClient.SendPrimitiveToClient(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalID, m_shape, lPos, clientFlags, m_uuid,
OwnerID,
m_text, color, ParentID, m_particleSystem, lRot, m_clickAction, m_TextureAnimation);
}
@ -1741,12 +1741,13 @@ namespace OpenSim.Region.Environment.Scenes
LLQuaternion mRot = RotationOffset;
if ((ObjectFlags & (uint) LLObject.ObjectFlags.Physics) == 0)
{
remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot);
remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalID, lPos, mRot);
}
else
{
remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot, Velocity,
remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalID, lPos, mRot, Velocity,
RotationalVelocity);
//System.Console.WriteLine("LID: " + LocalID + " RVel:" + RotationalVelocity.ToString() + " TD: " + ((ushort)(m_parentGroup.Scene.TimeDilation * 500000f)).ToString() + ":" + m_parentGroup.Scene.TimeDilation.ToString());
}
}
@ -1755,13 +1756,13 @@ namespace OpenSim.Region.Environment.Scenes
LLQuaternion mRot = RotationOffset;
if ((ObjectFlags & (uint) LLObject.ObjectFlags.Physics) == 0)
{
remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot);
remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalID, lPos, mRot);
}
else
{
remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot, Velocity,
remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalID, lPos, mRot, Velocity,
RotationalVelocity);
//System.Console.WriteLine("RVel:" + RotationalVelocity);
//System.Console.WriteLine("LID: " + LocalID + "RVel:" + RotationalVelocity.ToString() + " TD: " + ((ushort)(m_parentGroup.Scene.TimeDilation * 500000f)).ToString() + ":" + m_parentGroup.Scene.TimeDilation.ToString());
}
}

View File

@ -1289,7 +1289,7 @@ namespace OpenSim.Region.Environment.Scenes
LLVector3 pos = m_pos;
LLVector3 vel = Velocity;
LLQuaternion rot = new LLQuaternion(m_bodyRot.x, m_bodyRot.y, m_bodyRot.z, m_bodyRot.w);
remoteClient.SendAvatarTerseUpdate(m_regionHandle, 64096, LocalId, new LLVector3(pos.X, pos.Y, pos.Z),
remoteClient.SendAvatarTerseUpdate(m_regionHandle, (ushort)(m_scene.TimeDilation * (float)ushort.MaxValue), LocalId, new LLVector3(pos.X, pos.Y, pos.Z),
new LLVector3(vel.X, vel.Y, vel.Z), rot);
m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS);

View File

@ -181,7 +181,7 @@ namespace OpenSim.Region.Environment.Scenes
// Then we divide the whole amount by the amount of seconds pass in between stats updates.
sb[0].StatID = (uint) Stats.TimeDilation;
sb[0].StatValue = ((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor));
sb[0].StatValue = m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor));
sb[1].StatID = (uint) Stats.SimFPS;
sb[1].StatValue = simfps/statsUpdateFactor;
@ -280,13 +280,13 @@ namespace OpenSim.Region.Environment.Scenes
public void AddTimeDilation(float td)
{
float tdsetting = td;
if (tdsetting > 1.0f)
tdsetting = (tdsetting - (tdsetting - 0.91f));
//float tdsetting = td;
//if (tdsetting > 1.0f)
//tdsetting = (tdsetting - (tdsetting - 0.91f));
if (tdsetting < 0)
tdsetting = 0.0f;
m_timeDilation += tdsetting;
//if (tdsetting < 0)
//tdsetting = 0.0f;
m_timeDilation = td;
}
public void SetRootAgents(int rootAgents)

View File

@ -46,7 +46,12 @@ namespace OpenSim.Region.Physics.Manager
Y = y;
Z = z;
}
public void setValues(float x, float y, float z)
{
X = x;
Y = y;
Z = z;
}
public static readonly PhysicsVector Zero = new PhysicsVector(0f, 0f, 0f);
public override string ToString()
@ -54,6 +59,56 @@ namespace OpenSim.Region.Physics.Manager
return "<" + X + "," + Y + "," + Z + ">";
}
/// <summary>
/// These routines are the easiest way to store XYZ values in an LLVector3 without requiring 3 calls.
/// </summary>
/// <returns></returns>
public byte[] GetBytes()
{
byte[] byteArray = new byte[12];
Buffer.BlockCopy(BitConverter.GetBytes(X), 0, byteArray, 0, 4);
Buffer.BlockCopy(BitConverter.GetBytes(Y), 0, byteArray, 4, 4);
Buffer.BlockCopy(BitConverter.GetBytes(Z), 0, byteArray, 8, 4);
if (!BitConverter.IsLittleEndian)
{
Array.Reverse(byteArray, 0, 4);
Array.Reverse(byteArray, 4, 4);
Array.Reverse(byteArray, 8, 4);
}
return byteArray;
}
public void FromBytes(byte[] byteArray, int pos)
{
byte[] conversionBuffer = null;
if (!BitConverter.IsLittleEndian)
{
// Big endian architecture
if (conversionBuffer == null)
conversionBuffer = new byte[12];
Buffer.BlockCopy(byteArray, pos, conversionBuffer, 0, 12);
Array.Reverse(conversionBuffer, 0, 4);
Array.Reverse(conversionBuffer, 4, 4);
Array.Reverse(conversionBuffer, 8, 4);
X = BitConverter.ToSingle(conversionBuffer, 0);
Y = BitConverter.ToSingle(conversionBuffer, 4);
Z = BitConverter.ToSingle(conversionBuffer, 8);
}
else
{
// Little endian architecture
X = BitConverter.ToSingle(byteArray, pos);
Y = BitConverter.ToSingle(byteArray, pos + 4);
Z = BitConverter.ToSingle(byteArray, pos + 8);
}
}
// Operations
public static PhysicsVector operator +(PhysicsVector a, PhysicsVector b)
{

View File

@ -53,6 +53,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private bool m_taintshape = false;
private bool m_taintPhysics = false;
public bool m_taintremove = false;
public bool m_taintdisable = false;
private bool m_taintforce = false;
private List<PhysicsVector> m_forcelist = new List<PhysicsVector>();
@ -451,6 +452,9 @@ namespace OpenSim.Region.Physics.OdePlugin
if (m_taintforce)
changeAddForce(timestep);
if (m_taintdisable)
changedisable(timestep);
}
public void Move(float timestep)
@ -494,6 +498,13 @@ namespace OpenSim.Region.Physics.OdePlugin
m_taintrot = _orientation;
}
public void changedisable(float timestep)
{
if (Body != (IntPtr) 0)
d.BodyDisable(Body);
m_taintdisable = false;
}
public void changePhysicsStatus(float timestap)
{
@ -862,7 +873,16 @@ namespace OpenSim.Region.Physics.OdePlugin
public override PhysicsVector RotationalVelocity
{
get { return m_rotationalVelocity; }
get {
if (_zeroFlag)
return PhysicsVector.Zero;
m_lastUpdateSent = false;
if (m_rotationalVelocity.IsIdentical(PhysicsVector.Zero, 0.2f))
return PhysicsVector.Zero;
return m_rotationalVelocity;
}
set { m_rotationalVelocity = value; }
}
@ -917,6 +937,7 @@ namespace OpenSim.Region.Physics.OdePlugin
&& (Math.Abs(m_lastposition.Z - l_position.Z) < 0.02))
{
_zeroFlag = true;
m_throttleUpdates = false;
}
else
{
@ -944,9 +965,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
m_throttleUpdates = false;
throttleCounter = 0;
m_rotationalVelocity.X = 0;
m_rotationalVelocity.Y = 0;
m_rotationalVelocity.Z = 0;
m_rotationalVelocity = PhysicsVector.Zero;
base.RequestPhysicsterseUpdate();
m_lastUpdateSent = true;
}
@ -960,10 +979,15 @@ namespace OpenSim.Region.Physics.OdePlugin
_velocity.X = vel.X;
_velocity.Y = vel.Y;
_velocity.Z = vel.Z;
m_rotationalVelocity.X = rotvel.X;
m_rotationalVelocity.Y = rotvel.Y;
m_rotationalVelocity.Z = rotvel.Z;
if (_velocity.IsIdentical(PhysicsVector.Zero, 0.5f))
{
m_rotationalVelocity = PhysicsVector.Zero;
}
else
{
m_rotationalVelocity.setValues(rotvel.X, rotvel.Y, rotvel.Z);
}
//System.Console.WriteLine("ODE: " + m_rotationalVelocity.ToString());
_orientation.w = ori.W;
_orientation.x = ori.X;

View File

@ -405,8 +405,15 @@ namespace OpenSim.Region.Physics.OdePlugin
// If you interpenetrate a prim with another prim
if (p1.PhysicsActorType == (int) ActorTypes.Prim && p2.PhysicsActorType == (int) ActorTypes.Prim)
{
// Don't collide, one or both prim will explode.
contacts[i].depth = 0f;
if (contacts[i].depth >= 0.25f)
{
// Don't collide, one or both prim will explode.
((OdePrim)p1).m_taintdisable = true;
AddPhysicsActorTaint(p1);
((OdePrim)p2).m_taintdisable = true;
AddPhysicsActorTaint(p2);
contacts[i].depth = 0f;
}
}
if (contacts[i].depth >= 1.00f)
{