reduce some locks on culling checks

LSLKeyTest
UbitUmarov 2016-07-12 22:15:39 +01:00
parent bc6c342d01
commit 3507566692
1 changed files with 38 additions and 36 deletions

View File

@ -4080,23 +4080,24 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if(doCulling && !part.ParentGroup.IsAttachment) if(doCulling && !part.ParentGroup.IsAttachment)
{ {
bool inview = false;
lock(GroupsInView) lock(GroupsInView)
{ inview = GroupsInView.Contains(part.ParentGroup);
if(!GroupsInView.Contains(part.ParentGroup))
{
Vector3 partpos = part.ParentGroup.AbsolutePosition;
float dcam = (partpos - mycamera).LengthSquared();
float dpos = (partpos - mypos).LengthSquared();
if(dcam < dpos)
dpos = dcam;
dpos = (float)Math.Sqrt(dpos) - part.ParentGroup.GetBoundsRadius();
if(dpos > cullingrange)
continue;
if(!GroupsNeedFullUpdate.Contains(part.ParentGroup)) if(!inview)
GroupsNeedFullUpdate.Add(part.ParentGroup); {
Vector3 partpos = part.ParentGroup.AbsolutePosition;
float dcam = (partpos - mycamera).LengthSquared();
float dpos = (partpos - mypos).LengthSquared();
if(dcam < dpos)
dpos = dcam;
dpos = (float)Math.Sqrt(dpos) - part.ParentGroup.GetBoundsRadius();
if(dpos > cullingrange)
continue;
if(!GroupsNeedFullUpdate.Contains(part.ParentGroup))
GroupsNeedFullUpdate.Add(part.ParentGroup);
continue; continue;
}
} }
} }
@ -4363,40 +4364,41 @@ namespace OpenSim.Region.ClientStack.LindenUDP
HashSet<SceneObjectGroup> GroupsNeedFullUpdate = new HashSet<SceneObjectGroup>(); HashSet<SceneObjectGroup> GroupsNeedFullUpdate = new HashSet<SceneObjectGroup>();
// will this take for ever ? // will this take for ever ?
lock(GroupsInView) EntityBase[] entities = m_scene.Entities.GetEntities();
foreach (EntityBase e in entities)
{ {
EntityBase[] entities = m_scene.Entities.GetEntities(); if (e != null && e is SceneObjectGroup && !((SceneObjectGroup)e).IsAttachment)
foreach (EntityBase e in entities)
{ {
if (e != null && e is SceneObjectGroup && !((SceneObjectGroup)e).IsAttachment) SceneObjectGroup grp = (SceneObjectGroup)e;
Vector3 grppos = grp.AbsolutePosition;
float dcam = (grppos - mycamera).LengthSquared();
float dpos = (grppos - mypos).LengthSquared();
if(dcam < dpos)
dpos = dcam;
dpos = (float)Math.Sqrt(dpos) - grp.GetBoundsRadius();
bool inview;
lock(GroupsInView)
inview = GroupsInView.Contains(grp);
if(dpos > cullingrange)
{ {
SceneObjectGroup grp = (SceneObjectGroup)e; if(inview)
Vector3 grppos = grp.AbsolutePosition;
float dcam = (grppos - mycamera).LengthSquared();
float dpos = (grppos - mypos).LengthSquared();
if(dcam < dpos)
dpos = dcam;
dpos = (float)Math.Sqrt(dpos) - grp.GetBoundsRadius();
if(dpos > cullingrange)
{ {
if(GroupsInView.Contains(grp)) GroupsInView.Remove(grp);
{ if (!m_killRecord.Contains(grp.LocalId))
GroupsInView.Remove(grp); m_killRecord.Add(grp.LocalId);
if (!m_killRecord.Contains(grp.LocalId))
m_killRecord.Add(grp.LocalId);
}
} }
}
else else
{ {
if(!GroupsInView.Contains(grp) && !GroupsNeedFullUpdate.Contains(grp)) if(!inview && !GroupsNeedFullUpdate.Contains(grp))
GroupsNeedFullUpdate.Add(grp); GroupsNeedFullUpdate.Add(grp);
NewGroupsInView.Add(grp); NewGroupsInView.Add(grp);
}
} }
} }
} }
GroupsInView = NewGroupsInView; lock(GroupsInView)
GroupsInView = NewGroupsInView;
if (m_killRecord.Count > 0) if (m_killRecord.Count > 0)
{ {