a few changes to culling

LSLKeyTest
UbitUmarov 2016-07-13 02:07:07 +01:00
parent abf423e361
commit 2220ceb522
1 changed files with 28 additions and 26 deletions

View File

@ -4011,23 +4011,23 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (update.Entity is SceneObjectPart) if (update.Entity is SceneObjectPart)
{ {
SceneObjectPart part = (SceneObjectPart)update.Entity; SceneObjectPart part = (SceneObjectPart)update.Entity;
SceneObjectGroup grp = part.ParentGroup;
if (part.ParentGroup.inTransit) if (grp.inTransit)
continue; continue;
if (part.ParentGroup.IsDeleted) if (grp.IsDeleted)
{ {
// Don't send updates for objects that have been marked deleted. // Don't send updates for objects that have been marked deleted.
// Instead send another kill object, because the first one may have gotten // Instead send another kill object, because the first one may have gotten
// into a race condition // into a race condition
if (!m_killRecord.Contains(part.ParentGroup.LocalId)) if (!m_killRecord.Contains(grp.LocalId))
m_killRecord.Add(part.ParentGroup.LocalId); m_killRecord.Add(grp.LocalId);
continue; continue;
} }
if (part.ParentGroup.IsAttachment) if (grp.IsAttachment)
{ // Someone else's HUD, why are we getting these? { // Someone else's HUD, why are we getting these?
if (part.ParentGroup.OwnerID != AgentId && part.ParentGroup.HasPrivateAttachmentPoint) if (grp.OwnerID != AgentId && grp.HasPrivateAttachmentPoint)
continue; continue;
ScenePresence sp; ScenePresence sp;
// Owner is not in the sim, don't update it to // Owner is not in the sim, don't update it to
@ -4039,7 +4039,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
bool found = false; bool found = false;
foreach (SceneObjectGroup att in atts) foreach (SceneObjectGroup att in atts)
{ {
if (att == part.ParentGroup) if (att == grp)
{ {
found = true; found = true;
break; break;
@ -4061,10 +4061,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
} }
if (part.ParentGroup.IsAttachment && m_disableFacelights) if (grp.IsAttachment && m_disableFacelights)
{ {
if (part.ParentGroup.RootPart.Shape.State != (byte)AttachmentPoint.LeftHand && if (grp.RootPart.Shape.State != (byte)AttachmentPoint.LeftHand &&
part.ParentGroup.RootPart.Shape.State != (byte)AttachmentPoint.RightHand) grp.RootPart.Shape.State != (byte)AttachmentPoint.RightHand)
{ {
part.Shape.LightEntry = false; part.Shape.LightEntry = false;
} }
@ -4078,26 +4078,28 @@ namespace OpenSim.Region.ClientStack.LindenUDP
} }
} }
if(doCulling && !part.ParentGroup.IsAttachment) if(doCulling && !grp.IsAttachment)
{ {
if(GroupsNeedFullUpdate.Contains(grp))
continue;
bool inview = false; bool inview = false;
lock(GroupsInView) lock(GroupsInView)
inview = GroupsInView.Contains(part.ParentGroup); inview = GroupsInView.Contains(grp);
if(!inview) if(!inview)
{ {
Vector3 partpos = part.ParentGroup.AbsolutePosition; Vector3 partpos = grp.AbsolutePosition;
float dcam = (partpos - mycamera).LengthSquared(); float dcam = (partpos - mycamera).LengthSquared();
float dpos = (partpos - mypos).LengthSquared(); float dpos = (partpos - mypos).LengthSquared();
if(dcam < dpos) if(dcam < dpos)
dpos = dcam; dpos = dcam;
dpos = (float)Math.Sqrt(dpos) - part.ParentGroup.GetBoundsRadius(); dpos = (float)Math.Sqrt(dpos) - grp.GetBoundsRadius();
if(dpos > cullingrange) if(dpos > cullingrange)
continue; continue;
if(!GroupsNeedFullUpdate.Contains(part.ParentGroup)) GroupsNeedFullUpdate.Add(grp);
GroupsNeedFullUpdate.Add(part.ParentGroup); continue;
continue;
} }
} }
@ -4362,7 +4364,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
HashSet<SceneObjectGroup> NewGroupsInView = new HashSet<SceneObjectGroup>(); HashSet<SceneObjectGroup> NewGroupsInView = new HashSet<SceneObjectGroup>();
HashSet<SceneObjectGroup> GroupsNeedFullUpdate = new HashSet<SceneObjectGroup>(); HashSet<SceneObjectGroup> GroupsNeedFullUpdate = new HashSet<SceneObjectGroup>();
List<uint> kills = new List<uint>();
// will this take for ever ? // will this take for ever ?
EntityBase[] entities = m_scene.Entities.GetEntities(); EntityBase[] entities = m_scene.Entities.GetEntities();
foreach (EntityBase e in entities) foreach (EntityBase e in entities)
@ -4383,14 +4385,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{ {
if(inview) if(inview)
{ {
GroupsInView.Remove(grp); // GroupsInView.Remove(grp);
if (!m_killRecord.Contains(grp.LocalId)) if (!kills.Contains(grp.LocalId))
m_killRecord.Add(grp.LocalId); kills.Add(grp.LocalId);
} }
} }
else else
{ {
if(!inview && !GroupsNeedFullUpdate.Contains(grp)) if(!inview)
GroupsNeedFullUpdate.Add(grp); GroupsNeedFullUpdate.Add(grp);
NewGroupsInView.Add(grp); NewGroupsInView.Add(grp);
} }
@ -4400,10 +4402,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
lock(GroupsInView) lock(GroupsInView)
GroupsInView = NewGroupsInView; GroupsInView = NewGroupsInView;
if (m_killRecord.Count > 0) if (kills.Count > 0)
{ {
SendKillObject(m_killRecord); SendKillObject(kills);
m_killRecord.Clear(); kills.Clear();
} }
if(GroupsNeedFullUpdate.Count > 0) if(GroupsNeedFullUpdate.Count > 0)