* Implemented the actual ObjectUpdate network optimizations. Sends single prim updates instead of group updates in most cases and avoids sending unnecessary or duplicate ObjectUpdate packets

slimupdates
John Hurliman 2010-05-05 18:07:09 -07:00
parent 95130df78a
commit 93469d3d58
7 changed files with 46 additions and 70 deletions

View File

@ -207,8 +207,6 @@ namespace OpenSim.Region.Framework.Scenes
if (part.ParentGroup.IsAttachment) if (part.ParentGroup.IsAttachment)
isAttachment = true; isAttachment = true;
else
part.ParentGroup.ScheduleGroupForUpdate(PrimUpdateFlags.FullUpdate);
// If it's not an attachment, and we are allowed to move it, // If it's not an attachment, and we are allowed to move it,
// then we might have done so. If we moved across a parcel // then we might have done so. If we moved across a parcel

View File

@ -2051,8 +2051,6 @@ namespace OpenSim.Region.Framework.Scenes
sceneObject.SetGroup(groupID, null); sceneObject.SetGroup(groupID, null);
} }
sceneObject.ScheduleGroupForUpdate(PrimUpdateFlags.FullUpdate);
return sceneObject; return sceneObject;
} }

View File

@ -1512,7 +1512,7 @@ namespace OpenSim.Region.Framework.Scenes
parentGroup.RootPart.AddFlag(PrimFlags.CreateSelected); parentGroup.RootPart.AddFlag(PrimFlags.CreateSelected);
parentGroup.TriggerScriptChangedEvent(Changed.LINK); parentGroup.TriggerScriptChangedEvent(Changed.LINK);
parentGroup.HasGroupChanged = true; parentGroup.HasGroupChanged = true;
parentGroup.ScheduleGroupForUpdate(PrimUpdateFlags.FullUpdate); parentGroup.ScheduleGroupForUpdate(PrimUpdateFlags.ParentID);
} }
finally finally
@ -1627,7 +1627,7 @@ namespace OpenSim.Region.Framework.Scenes
{ {
g.TriggerScriptChangedEvent(Changed.LINK); g.TriggerScriptChangedEvent(Changed.LINK);
g.HasGroupChanged = true; // Persist g.HasGroupChanged = true; // Persist
g.ScheduleGroupForUpdate(PrimUpdateFlags.FullUpdate); g.ScheduleGroupForUpdate(PrimUpdateFlags.ParentID);
} }
} }
finally finally

View File

@ -1001,7 +1001,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
IsSelected = false; // fudge.... IsSelected = false; // fudge....
ScheduleGroupForUpdate(PrimUpdateFlags.FullUpdate); RootPart.ScheduleUpdate(PrimUpdateFlags.ParentID);
} }
} }
else else
@ -2902,7 +2902,6 @@ namespace OpenSim.Region.Framework.Scenes
part.IgnoreUndoUpdate = false; part.IgnoreUndoUpdate = false;
part.StoreUndoState(); part.StoreUndoState();
HasGroupChanged = true; HasGroupChanged = true;
ScheduleGroupForUpdate(PrimUpdateFlags.Position);
} }
} }
@ -2939,11 +2938,12 @@ namespace OpenSim.Region.Framework.Scenes
AbsolutePosition = pos; AbsolutePosition = pos;
HasGroupChanged = true; HasGroupChanged = true;
} }
//we need to do a terse update even if the move wasn't allowed //we need to do a terse update even if the move wasn't allowed
// so that the position is reset in the client (the object snaps back) // so that the position is reset in the client (the object snaps back)
ScheduleGroupForUpdate(PrimUpdateFlags.Position); m_rootPart.ScheduleUpdate(PrimUpdateFlags.Position);
} }
/// <summary> /// <summary>
@ -3008,7 +3008,7 @@ namespace OpenSim.Region.Framework.Scenes
AbsolutePosition = newPos; AbsolutePosition = newPos;
HasGroupChanged = true; HasGroupChanged = true;
ScheduleGroupForUpdate(PrimUpdateFlags.Position); ScheduleGroupForUpdate(PrimUpdateFlags.Position | PrimUpdateFlags.Rotation);
} }
public void OffsetForNewRegion(Vector3 offset) public void OffsetForNewRegion(Vector3 offset)
@ -3040,7 +3040,6 @@ namespace OpenSim.Region.Framework.Scenes
} }
HasGroupChanged = true; HasGroupChanged = true;
ScheduleGroupForUpdate(PrimUpdateFlags.Position | PrimUpdateFlags.Rotation);
} }
/// <summary> /// <summary>
@ -3066,7 +3065,6 @@ namespace OpenSim.Region.Framework.Scenes
AbsolutePosition = pos; AbsolutePosition = pos;
HasGroupChanged = true; HasGroupChanged = true;
ScheduleGroupForUpdate(PrimUpdateFlags.Position | PrimUpdateFlags.Rotation);
} }
/// <summary> /// <summary>

View File

@ -1240,7 +1240,7 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary> /// </summary>
public void ClearPendingUpdate() public void ClearPendingUpdate()
{ {
m_pendingUpdateFlags = 0; m_pendingUpdateFlags = PrimUpdateFlags.None;
} }
public void ResetExpire() public void ResetExpire()
@ -2856,23 +2856,23 @@ namespace OpenSim.Region.Framework.Scenes
else else
updateFlags &= ~PrimUpdateFlags.AngularVelocity; updateFlags &= ~PrimUpdateFlags.AngularVelocity;
if (!OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) if (!RelativePosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE))
updateFlags |= PrimUpdateFlags.Position; updateFlags |= PrimUpdateFlags.Position;
else else
updateFlags &= ~PrimUpdateFlags.Position; updateFlags &= ~PrimUpdateFlags.Position;
// For good measure // For good measure
if (Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) //if (Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE)
updateFlags |= PrimUpdateFlags.Position; // updateFlags |= PrimUpdateFlags.Position;
#endregion PrimUpdateFlags Management #endregion PrimUpdateFlags Management
if (updateFlags != 0) if (updateFlags != PrimUpdateFlags.None)
{ {
AddUpdateToAllAvatars(updateFlags); AddUpdateToAllAvatars(updateFlags);
// Update the "last" values // Update the "last" values
m_lastPosition = OffsetPosition; m_lastPosition = RelativePosition;
m_lastRotation = RotationOffset; m_lastRotation = RotationOffset;
m_lastVelocity = Velocity; m_lastVelocity = Velocity;
m_lastAcceleration = Acceleration; m_lastAcceleration = Acceleration;
@ -3342,8 +3342,7 @@ namespace OpenSim.Region.Framework.Scenes
public void StopLookAt() public void StopLookAt()
{ {
m_parentGroup.stopLookAt(); m_parentGroup.stopLookAt();
m_parentGroup.RootPart.ScheduleUpdate(PrimUpdateFlags.Rotation);
m_parentGroup.ScheduleGroupForUpdate(PrimUpdateFlags.Position | PrimUpdateFlags.Rotation);
} }
/// <summary> /// <summary>
@ -3364,8 +3363,7 @@ namespace OpenSim.Region.Framework.Scenes
public void StopMoveToTarget() public void StopMoveToTarget()
{ {
m_parentGroup.stopMoveToTarget(); m_parentGroup.stopMoveToTarget();
m_parentGroup.RootPart.ScheduleUpdate(PrimUpdateFlags.Position | PrimUpdateFlags.Rotation);
m_parentGroup.ScheduleGroupForUpdate(PrimUpdateFlags.Position | PrimUpdateFlags.Rotation);
} }
public void StoreUndoState() public void StoreUndoState()
@ -3941,20 +3939,18 @@ namespace OpenSim.Region.Framework.Scenes
(pos.Y != OffsetPosition.Y) || (pos.Y != OffsetPosition.Y) ||
(pos.Z != OffsetPosition.Z)) (pos.Z != OffsetPosition.Z))
{ {
Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z);
if (ParentGroup.RootPart.GetStatusSandbox()) if (ParentGroup.RootPart.GetStatusSandbox())
{ {
if (Util.GetDistanceTo(ParentGroup.RootPart.StatusSandboxPos, newPos) > 10) if (Util.GetDistanceTo(ParentGroup.RootPart.StatusSandboxPos, pos) > 10)
{ {
ParentGroup.RootPart.ScriptSetPhysicsStatus(false); ParentGroup.RootPart.ScriptSetPhysicsStatus(false);
newPos = OffsetPosition; pos = OffsetPosition;
ParentGroup.Scene.SimChat(Utils.StringToBytes("Hit Sandbox Limit"), ParentGroup.Scene.SimChat(Utils.StringToBytes("Hit Sandbox Limit"),
ChatTypeEnum.DebugChannel, 0x7FFFFFFF, ParentGroup.RootPart.AbsolutePosition, Name, UUID, false); ChatTypeEnum.DebugChannel, 0x7FFFFFFF, ParentGroup.RootPart.AbsolutePosition, Name, UUID, false);
} }
} }
OffsetPosition = newPos; OffsetPosition = pos;
ScheduleUpdate(PrimUpdateFlags.Position); ScheduleUpdate(PrimUpdateFlags.Position);
} }
} }

View File

@ -42,19 +42,14 @@ namespace OpenSim.Region.Framework.Scenes
if (part != null) if (part != null)
{ {
if (part.ParentID == 0) if (part.ParentID == 0)
{
Position = part.ParentGroup.AbsolutePosition; Position = part.ParentGroup.AbsolutePosition;
Rotation = part.RotationOffset;
Scale = part.Shape.Scale;
}
else else
{
Position = part.OffsetPosition; Position = part.OffsetPosition;
Rotation = part.RotationOffset; Rotation = part.RotationOffset;
Scale = part.Shape.Scale; Scale = part.Shape.Scale;
} }
} }
}
public bool Compare(SceneObjectPart part) public bool Compare(SceneObjectPart part)
{ {
@ -84,57 +79,48 @@ namespace OpenSim.Region.Framework.Scenes
if (part != null) if (part != null)
{ {
part.Undoing = true; part.Undoing = true;
PrimUpdateFlags updateFlags = PrimUpdateFlags.Position | PrimUpdateFlags.Rotation;
if (part.ParentID == 0) if (part.ParentID == 0)
{
if (Position != Vector3.Zero)
part.ParentGroup.AbsolutePosition = Position; part.ParentGroup.AbsolutePosition = Position;
part.RotationOffset = Rotation;
if (Scale != Vector3.Zero)
part.Resize(Scale);
part.ParentGroup.ScheduleGroupForUpdate(PrimUpdateFlags.Position | PrimUpdateFlags.Rotation);
}
else else
{
if (Position != Vector3.Zero)
part.OffsetPosition = Position; part.OffsetPosition = Position;
part.UpdateRotation(Rotation);
if (Scale != Vector3.Zero) part.RotationOffset = Rotation;
part.Resize(Scale);
part.ScheduleUpdate(PrimUpdateFlags.Position | PrimUpdateFlags.Rotation); if (Scale != part.Scale)
{
part.Scale = Scale;
updateFlags |= PrimUpdateFlags.Scale;
} }
part.Undoing = false; part.Undoing = false;
part.ScheduleUpdate(updateFlags);
} }
} }
public void PlayfwdState(SceneObjectPart part) public void PlayfwdState(SceneObjectPart part)
{ {
if (part != null) if (part != null)
{ {
part.Undoing = true; part.Undoing = true;
PrimUpdateFlags updateFlags = PrimUpdateFlags.Position | PrimUpdateFlags.Rotation;
if (part.ParentID == 0) if (part.ParentID == 0)
{
if (Position != Vector3.Zero)
part.ParentGroup.AbsolutePosition = Position; part.ParentGroup.AbsolutePosition = Position;
if (Rotation != Quaternion.Identity)
part.UpdateRotation(Rotation);
if (Scale != Vector3.Zero)
part.Resize(Scale);
part.ParentGroup.ScheduleGroupForUpdate(PrimUpdateFlags.Position | PrimUpdateFlags.Rotation);
}
else else
{
if (Position != Vector3.Zero)
part.OffsetPosition = Position; part.OffsetPosition = Position;
if (Rotation != Quaternion.Identity)
part.UpdateRotation(Rotation);
if (Scale != Vector3.Zero)
part.Resize(Scale);
part.ScheduleUpdate(PrimUpdateFlags.Position | PrimUpdateFlags.Rotation);
}
part.Undoing = false;
part.RotationOffset = Rotation;
if (Scale != part.Scale)
{
part.Scale = Scale;
updateFlags |= PrimUpdateFlags.Scale;
}
part.Undoing = false;
part.ScheduleUpdate(updateFlags);
} }
} }
} }

View File

@ -1913,7 +1913,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
part.OffsetPosition = new Vector3((float)targetPos.x, (float)targetPos.y, (float)targetPos.z); part.OffsetPosition = new Vector3((float)targetPos.x, (float)targetPos.y, (float)targetPos.z);
SceneObjectGroup parent = part.ParentGroup; SceneObjectGroup parent = part.ParentGroup;
parent.HasGroupChanged = true; parent.HasGroupChanged = true;
parent.ScheduleGroupForUpdate(PrimUpdateFlags.Position); part.ScheduleUpdate(PrimUpdateFlags.Position);
} }
} }
} }
@ -3866,7 +3866,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
Util.Clip((float)color.z, 0.0f, 1.0f)); Util.Clip((float)color.z, 0.0f, 1.0f));
m_host.SetText(text, av3, Util.Clip((float)alpha, 0.0f, 1.0f)); m_host.SetText(text, av3, Util.Clip((float)alpha, 0.0f, 1.0f));
m_host.ParentGroup.HasGroupChanged = true; m_host.ParentGroup.HasGroupChanged = true;
m_host.ParentGroup.ScheduleGroupForUpdate(PrimUpdateFlags.Text); m_host.ScheduleUpdate(PrimUpdateFlags.Text);
} }
public LSL_Float llWater(LSL_Vector offset) public LSL_Float llWater(LSL_Vector offset)