mess around with prioritizer
parent
e3d0ec6f40
commit
3ee70aac0b
|
@ -587,7 +587,6 @@ namespace OpenSim.Framework
|
|||
{
|
||||
private ISceneEntity m_entity;
|
||||
private PrimUpdateFlags m_flags;
|
||||
private int m_updateTime;
|
||||
|
||||
public ISceneEntity Entity
|
||||
{
|
||||
|
@ -599,41 +598,29 @@ namespace OpenSim.Framework
|
|||
get { return m_flags; }
|
||||
}
|
||||
|
||||
public int UpdateTime
|
||||
public virtual void Update()
|
||||
{
|
||||
get { return m_updateTime; }
|
||||
// we are on the new one
|
||||
if (m_flags.HasFlag(PrimUpdateFlags.CancelKill))
|
||||
m_flags = PrimUpdateFlags.FullUpdatewithAnim;
|
||||
}
|
||||
|
||||
public virtual void Update(EntityUpdate oldupdate)
|
||||
{
|
||||
// we are on the new one
|
||||
PrimUpdateFlags updateFlags = oldupdate.Flags;
|
||||
if(m_flags.HasFlag(PrimUpdateFlags.CancelKill))
|
||||
if (m_flags.HasFlag(PrimUpdateFlags.CancelKill))
|
||||
{
|
||||
m_flags = PrimUpdateFlags.FullUpdatewithAnim;
|
||||
}
|
||||
else if(updateFlags.HasFlag(PrimUpdateFlags.Kill))
|
||||
return;
|
||||
else // kill case will just merge in
|
||||
else
|
||||
m_flags |= updateFlags;
|
||||
|
||||
// Use the older of the updates as the updateTime
|
||||
if (Util.EnvironmentTickCountCompare(UpdateTime, oldupdate.UpdateTime) > 0)
|
||||
m_updateTime = oldupdate.UpdateTime;
|
||||
}
|
||||
|
||||
public EntityUpdate(ISceneEntity entity, PrimUpdateFlags flags)
|
||||
{
|
||||
m_entity = entity;
|
||||
m_flags = flags;
|
||||
m_updateTime = Util.EnvironmentTickCount();
|
||||
}
|
||||
|
||||
public EntityUpdate(ISceneEntity entity, PrimUpdateFlags flags, Int32 updateTime)
|
||||
{
|
||||
m_entity = entity;
|
||||
m_flags = flags;
|
||||
m_updateTime = updateTime;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -694,7 +681,7 @@ namespace OpenSim.Framework
|
|||
FullUpdatewithAnim = FullUpdate | Animations,
|
||||
|
||||
SendInTransit = 0x20000000, // 1 << 29
|
||||
CancelKill = 0x41ffffff, // 1 << 30
|
||||
CancelKill = 0x40000000, // 1 << 30
|
||||
Kill = 0x80000000 // 1 << 31
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ using OpenSim.Region.Framework.Interfaces;
|
|||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Services.Interfaces;
|
||||
|
||||
|
||||
using AssetLandmark = OpenSim.Framework.AssetLandmark;
|
||||
using Caps = OpenSim.Framework.Capabilities.Caps;
|
||||
using PermissionMask = OpenSim.Framework.PermissionMask;
|
||||
|
@ -4097,6 +4098,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
if (!IsActive)
|
||||
return;
|
||||
|
||||
ScenePresence mysp = (ScenePresence)SceneAgent;
|
||||
if (mysp == null)
|
||||
return;
|
||||
|
||||
List<ObjectUpdatePacket.ObjectDataBlock> objectUpdateBlocks = null;
|
||||
List<ObjectUpdateCompressedPacket.ObjectDataBlock> compressedUpdateBlocks = null;
|
||||
List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> terseUpdateBlocks = null;
|
||||
|
@ -4114,39 +4119,36 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
}
|
||||
|
||||
EntityUpdate update;
|
||||
Int32 timeinqueue; // this is just debugging code & can be dropped later
|
||||
|
||||
bool doCulling = m_scene.ObjectsCullingByDistance;
|
||||
float cullingrange = 64.0f;
|
||||
HashSet<SceneObjectGroup> GroupsNeedFullUpdate = new HashSet<SceneObjectGroup>();
|
||||
// Vector3 mycamera = Vector3.Zero;
|
||||
Vector3 mypos = Vector3.Zero;
|
||||
ScenePresence mysp = (ScenePresence)SceneAgent;
|
||||
|
||||
bool orderedDequeue = m_scene.UpdatePrioritizationScheme == UpdatePrioritizationSchemes.SimpleAngularDistance;
|
||||
// we should have a presence
|
||||
if(mysp == null)
|
||||
return;
|
||||
|
||||
if(doCulling)
|
||||
HashSet<SceneObjectGroup> GroupsNeedFullUpdate = new HashSet<SceneObjectGroup>();
|
||||
|
||||
if (doCulling)
|
||||
{
|
||||
cullingrange = mysp.DrawDistance + m_scene.ReprioritizationDistance + 16f;
|
||||
// mycamera = mysp.CameraPosition;
|
||||
mypos = mysp.AbsolutePosition;
|
||||
}
|
||||
|
||||
while (maxUpdatesBytes > 0)
|
||||
{
|
||||
if (!IsActive)
|
||||
return;
|
||||
|
||||
lock (m_entityUpdates.SyncRoot)
|
||||
{
|
||||
if(orderedDequeue)
|
||||
{
|
||||
if (!m_entityUpdates.TryOrderedDequeue(out update, out timeinqueue))
|
||||
if (!m_entityUpdates.TryOrderedDequeue(out update))
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m_entityUpdates.TryDequeue(out update, out timeinqueue))
|
||||
if (!m_entityUpdates.TryDequeue(out update))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -4166,13 +4168,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
SceneObjectGroup grp = part.ParentGroup;
|
||||
if (grp.inTransit && !update.Flags.HasFlag(PrimUpdateFlags.SendInTransit))
|
||||
continue;
|
||||
/* debug
|
||||
if (update.Flags.HasFlag(PrimUpdateFlags.SendInTransit))
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
*/
|
||||
if (grp.IsDeleted)
|
||||
{
|
||||
// Don't send updates for objects that have been marked deleted.
|
||||
|
@ -4234,20 +4230,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
if(GroupsNeedFullUpdate.Contains(grp))
|
||||
continue;
|
||||
|
||||
bool inview = false;
|
||||
bool inViewGroups = false;
|
||||
lock(GroupsInView)
|
||||
inview = GroupsInView.Contains(grp);
|
||||
inViewGroups = GroupsInView.Contains(grp);
|
||||
|
||||
if(!inview)
|
||||
if(!inViewGroups)
|
||||
{
|
||||
float bradius = grp.GetBoundsRadius();
|
||||
Vector3 partpos = grp.AbsolutePosition + grp.getBoundsCenter();
|
||||
// float dcam = (partpos - mycamera).LengthSquared();
|
||||
Vector3 partpos = grp.getCenterOffset();
|
||||
float dpos = (partpos - mypos).LengthSquared();
|
||||
// if(dcam < dpos)
|
||||
// dpos = dcam;
|
||||
dpos = (float)Math.Sqrt(dpos) - bradius;
|
||||
if(dpos > cullingrange)
|
||||
float maxview = grp.GetBoundsRadius() + cullingrange;
|
||||
if (dpos > maxview * maxview)
|
||||
continue;
|
||||
|
||||
GroupsNeedFullUpdate.Add(grp);
|
||||
|
@ -4488,10 +4480,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
{
|
||||
foreach(SceneObjectGroup grp in GroupsNeedFullUpdate)
|
||||
{
|
||||
foreach(SceneObjectPart p in grp.Parts)
|
||||
SendEntityUpdate(p,PrimUpdateFlags.CancelKill);
|
||||
lock(GroupsInView)
|
||||
lock (GroupsInView)
|
||||
GroupsInView.Add(grp);
|
||||
foreach (SceneObjectPart p in grp.Parts)
|
||||
SendEntityUpdate(p, PrimUpdateFlags.CancelKill);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4542,26 +4534,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
if(!doCulling)
|
||||
return;
|
||||
|
||||
if(CheckGroupsInViewBusy)
|
||||
if (!IsActive)
|
||||
return;
|
||||
|
||||
if (CheckGroupsInViewBusy)
|
||||
return;
|
||||
|
||||
ScenePresence mysp = (ScenePresence)SceneAgent;
|
||||
if (mysp == null || mysp.IsDeleted)
|
||||
return;
|
||||
|
||||
CheckGroupsInViewBusy = true;
|
||||
|
||||
float cullingrange = 64.0f;
|
||||
// Vector3 mycamera = Vector3.Zero;
|
||||
Vector3 mypos = Vector3.Zero;
|
||||
ScenePresence mysp = (ScenePresence)SceneAgent;
|
||||
if(mysp != null && !mysp.IsDeleted)
|
||||
{
|
||||
cullingrange = mysp.DrawDistance + m_scene.ReprioritizationDistance + 16f;
|
||||
// mycamera = mysp.CameraPosition;
|
||||
mypos = mysp.AbsolutePosition;
|
||||
}
|
||||
else
|
||||
{
|
||||
CheckGroupsInViewBusy= false;
|
||||
return;
|
||||
}
|
||||
float cullingrange = mysp.DrawDistance + m_scene.ReprioritizationDistance + 16f;
|
||||
Vector3 mypos = mysp.AbsolutePosition;
|
||||
|
||||
HashSet<SceneObjectGroup> NewGroupsInView = new HashSet<SceneObjectGroup>();
|
||||
HashSet<SceneObjectGroup> GroupsNeedFullUpdate = new HashSet<SceneObjectGroup>();
|
||||
|
@ -4570,7 +4556,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
EntityBase[] entities = m_scene.Entities.GetEntities();
|
||||
foreach (EntityBase e in entities)
|
||||
{
|
||||
if(!IsActive)
|
||||
if (!IsActive)
|
||||
return;
|
||||
|
||||
if (e != null && e is SceneObjectGroup)
|
||||
|
@ -4579,27 +4565,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
if(grp.IsDeleted || grp.IsAttachment)
|
||||
continue;
|
||||
|
||||
float bradius = grp.GetBoundsRadius();
|
||||
Vector3 grppos = grp.AbsolutePosition + grp.getBoundsCenter();
|
||||
// float dcam = (grppos - mycamera).LengthSquared();
|
||||
bool inviewgroups;
|
||||
lock (GroupsInView)
|
||||
inviewgroups = GroupsInView.Contains(grp);
|
||||
|
||||
Vector3 grppos = grp.getCenterOffset();
|
||||
float dpos = (grppos - mypos).LengthSquared();
|
||||
// if(dcam < dpos)
|
||||
// dpos = dcam;
|
||||
|
||||
dpos = (float)Math.Sqrt(dpos) - bradius;
|
||||
|
||||
bool inview;
|
||||
lock(GroupsInView)
|
||||
inview = GroupsInView.Contains(grp);
|
||||
|
||||
if(dpos > cullingrange)
|
||||
float maxview = grp.GetBoundsRadius() + cullingrange;
|
||||
if (dpos > maxview * maxview)
|
||||
{
|
||||
if(inview)
|
||||
if(inviewgroups)
|
||||
kills.Add(grp);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!inview)
|
||||
if(!inviewgroups)
|
||||
GroupsNeedFullUpdate.Add(grp);
|
||||
NewGroupsInView.Add(grp);
|
||||
}
|
||||
|
@ -4614,7 +4595,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
List<uint> partIDs = new List<uint>();
|
||||
foreach(SceneObjectGroup grp in kills)
|
||||
{
|
||||
SendEntityUpdate(grp.RootPart,PrimUpdateFlags.Kill);
|
||||
SendEntityUpdate(grp.RootPart, PrimUpdateFlags.Kill);
|
||||
foreach(SceneObjectPart p in grp.Parts)
|
||||
{
|
||||
if(p != grp.RootPart)
|
||||
|
@ -4636,7 +4617,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
foreach(SceneObjectGroup grp in GroupsNeedFullUpdate)
|
||||
{
|
||||
foreach(SceneObjectPart p in grp.Parts)
|
||||
SendEntityUpdate(p,PrimUpdateFlags.CancelKill);
|
||||
SendEntityUpdate(p, PrimUpdateFlags.CancelKill);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4645,13 +4626,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
|
||||
private bool UpdatePriorityHandler(ref uint priority, ISceneEntity entity)
|
||||
{
|
||||
if (entity != null)
|
||||
{
|
||||
priority = m_prioritizer.GetUpdatePriority(this, entity);
|
||||
return true;
|
||||
}
|
||||
if (entity == null)
|
||||
return false;
|
||||
|
||||
return false;
|
||||
priority = m_prioritizer.GetUpdatePriority(this, entity);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void FlushPrimUpdates()
|
||||
|
@ -4831,7 +4810,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
{
|
||||
uint priority = 0; // time based ordering only
|
||||
lock (m_entityProps.SyncRoot)
|
||||
m_entityProps.Enqueue(priority, new ObjectPropertyUpdate(entity,requestFlags,true,false));
|
||||
m_entityProps.Enqueue(priority, new ObjectPropertyUpdate(entity, requestFlags, true, false));
|
||||
}
|
||||
|
||||
private void ResendPropertyUpdate(ObjectPropertyUpdate update)
|
||||
|
@ -4885,7 +4864,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
bool orderedDequeue = m_scene.UpdatePrioritizationScheme == UpdatePrioritizationSchemes.SimpleAngularDistance;
|
||||
|
||||
EntityUpdate iupdate;
|
||||
Int32 timeinqueue; // this is just debugging code & can be dropped later
|
||||
|
||||
while (maxUpdateBytes > 0)
|
||||
{
|
||||
|
@ -4893,12 +4871,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
{
|
||||
if(orderedDequeue)
|
||||
{
|
||||
if (!m_entityProps.TryOrderedDequeue(out iupdate, out timeinqueue))
|
||||
if (!m_entityProps.TryOrderedDequeue(out iupdate))
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m_entityProps.TryDequeue(out iupdate, out timeinqueue))
|
||||
if (!m_entityProps.TryDequeue(out iupdate))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
if(presence.ParentPart.ParentGroup == sog)
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
pqueue = ComputeDistancePriority(client, entity, false);
|
||||
|
||||
// Non physical prims are lower priority than physical prims
|
||||
|
@ -165,15 +165,6 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
// And convert the distance to a priority queue, this computation gives queues
|
||||
// at 10, 20, 40, 80, 160, 320, 640, and 1280m
|
||||
uint pqueue = PriorityQueue.NumberOfImmediateQueues + 1; // reserve attachments queue
|
||||
uint queues = PriorityQueue.NumberOfQueues - PriorityQueue.NumberOfImmediateQueues;
|
||||
/*
|
||||
for (int i = 0; i < queues - 1; i++)
|
||||
{
|
||||
if (distance < 30 * Math.Pow(2.0,i))
|
||||
break;
|
||||
pqueue++;
|
||||
}
|
||||
*/
|
||||
if (distance > 10f)
|
||||
{
|
||||
float tmp = (float)Math.Log((double)distance) * 1.442695f - 3.321928f;
|
||||
|
@ -182,8 +173,6 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
// 1st constant is 1/(log(2)) (natural log) so we get log2(distance)
|
||||
// 2st constant makes it be log2(distance/10)
|
||||
pqueue += (uint)tmp;
|
||||
if (pqueue > queues - 1)
|
||||
pqueue = queues - 1;
|
||||
}
|
||||
|
||||
// If this is a root agent, then determine front & back
|
||||
|
@ -216,11 +205,6 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
private uint ComputeAngleDistancePriority(ScenePresence presence, ISceneEntity entity)
|
||||
{
|
||||
// And convert the distance to a priority queue, this computation gives queues
|
||||
// at 10, 20, 40, 80, 160, 320, 640, and 1280m
|
||||
// uint minpqueue = PriorityQueue.NumberOfImmediateQueues;
|
||||
uint maxqueue = PriorityQueue.NumberOfQueues - PriorityQueue.NumberOfImmediateQueues -1;
|
||||
// uint pqueue = minpqueue;
|
||||
uint pqueue = PriorityQueue.NumberOfImmediateQueues;
|
||||
float distance;
|
||||
|
||||
|
@ -228,36 +212,49 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
if(entity is ScenePresence)
|
||||
{
|
||||
ScenePresence sp = entity as ScenePresence;
|
||||
distance = Vector3.Distance(presencePos, sp.AbsolutePosition);
|
||||
distance *= 0.5f;
|
||||
distance = Vector3.DistanceSquared(presencePos, sp.AbsolutePosition);
|
||||
if (distance > 400f)
|
||||
{
|
||||
float tmp = (float)Math.Log(distance) * 0.7213475f - 4.321928f;
|
||||
pqueue += (uint)tmp;
|
||||
}
|
||||
return pqueue;
|
||||
}
|
||||
else
|
||||
{
|
||||
SceneObjectGroup group = (entity as SceneObjectPart).ParentGroup;
|
||||
if(presence.ParentPart != null)
|
||||
{
|
||||
if(presence.ParentPart.ParentGroup == group)
|
||||
return pqueue;
|
||||
}
|
||||
if(group.IsAttachment)
|
||||
{
|
||||
if(group.RootPart.LocalId == presence.LocalId)
|
||||
return pqueue;
|
||||
}
|
||||
|
||||
float bradius = group.GetBoundsRadius();
|
||||
Vector3 grppos = group.AbsolutePosition + group.getBoundsCenter();
|
||||
distance = Vector3.Distance(presencePos, grppos);
|
||||
distance -= bradius;
|
||||
distance *= group.getAreaFactor();
|
||||
if(group.IsAttachment)
|
||||
distance *= 0.5f;
|
||||
else if(group.UsesPhysics)
|
||||
distance *= 0.6f;
|
||||
else if(group.GetSittingAvatarsCount() > 0)
|
||||
distance *= 0.5f;
|
||||
SceneObjectPart sop = entity as SceneObjectPart;
|
||||
SceneObjectGroup group = sop.ParentGroup;
|
||||
if(presence.ParentPart != null)
|
||||
{
|
||||
if(presence.ParentPart.ParentGroup == group)
|
||||
return pqueue;
|
||||
}
|
||||
|
||||
if (group.IsAttachment)
|
||||
{
|
||||
if(group.RootPart.LocalId == presence.LocalId)
|
||||
return pqueue;
|
||||
|
||||
distance = Vector3.DistanceSquared(presencePos, group.AbsolutePosition);
|
||||
if (distance > 400f)
|
||||
{
|
||||
float tmp = (float)Math.Log(distance) * 0.7213475f - 4.321928f;
|
||||
pqueue += (uint)tmp;
|
||||
}
|
||||
return pqueue;
|
||||
}
|
||||
|
||||
float bradius = group.GetBoundsRadius();
|
||||
Vector3 grppos = group.getCenterOffset();
|
||||
distance = Vector3.Distance(presencePos, grppos);
|
||||
distance -= bradius;
|
||||
distance *= group.getAreaFactor();
|
||||
if(group.IsAttachment)
|
||||
distance *= 0.5f;
|
||||
else if(group.UsesPhysics)
|
||||
distance *= 0.6f;
|
||||
else if(group.GetSittingAvatarsCount() > 0)
|
||||
distance *= 0.5f;
|
||||
|
||||
if (distance > 10f)
|
||||
{
|
||||
float tmp = (float)Math.Log(distance) * 1.442695f - 3.321928f;
|
||||
|
@ -265,10 +262,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
// now
|
||||
// 1st constant is 1/(log(2)) (natural log) so we get log2(distance)
|
||||
// 2st constant makes it be log2(distance/10)
|
||||
|
||||
pqueue += (uint)tmp;
|
||||
if (pqueue > maxqueue)
|
||||
pqueue = maxqueue;
|
||||
}
|
||||
|
||||
return pqueue;
|
||||
|
|
Loading…
Reference in New Issue