diff options
author | UbitUmarov | 2016-07-12 22:15:39 +0100 |
---|---|---|
committer | UbitUmarov | 2016-07-12 22:15:39 +0100 |
commit | 3507566692c45b15a35e3a01920df3423b4a051f (patch) | |
tree | eb54c3ba22b0f08a411c5f5af189ff56de4430a9 /OpenSim | |
parent | let radius be radius, not diameter (diff) | |
download | opensim-SC-3507566692c45b15a35e3a01920df3423b4a051f.zip opensim-SC-3507566692c45b15a35e3a01920df3423b4a051f.tar.gz opensim-SC-3507566692c45b15a35e3a01920df3423b4a051f.tar.bz2 opensim-SC-3507566692c45b15a35e3a01920df3423b4a051f.tar.xz |
reduce some locks on culling checks
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 76 |
1 files changed, 39 insertions, 37 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index a84d902..fc6aeb4 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | |||
@@ -4080,23 +4080,24 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4080 | 4080 | ||
4081 | if(doCulling && !part.ParentGroup.IsAttachment) | 4081 | if(doCulling && !part.ParentGroup.IsAttachment) |
4082 | { | 4082 | { |
4083 | bool inview = false; | ||
4083 | lock(GroupsInView) | 4084 | lock(GroupsInView) |
4085 | inview = GroupsInView.Contains(part.ParentGroup); | ||
4086 | |||
4087 | if(!inview) | ||
4084 | { | 4088 | { |
4085 | if(!GroupsInView.Contains(part.ParentGroup)) | 4089 | Vector3 partpos = part.ParentGroup.AbsolutePosition; |
4086 | { | 4090 | float dcam = (partpos - mycamera).LengthSquared(); |
4087 | Vector3 partpos = part.ParentGroup.AbsolutePosition; | 4091 | float dpos = (partpos - mypos).LengthSquared(); |
4088 | float dcam = (partpos - mycamera).LengthSquared(); | 4092 | if(dcam < dpos) |
4089 | float dpos = (partpos - mypos).LengthSquared(); | 4093 | dpos = dcam; |
4090 | if(dcam < dpos) | 4094 | dpos = (float)Math.Sqrt(dpos) - part.ParentGroup.GetBoundsRadius(); |
4091 | dpos = dcam; | 4095 | if(dpos > cullingrange) |
4092 | dpos = (float)Math.Sqrt(dpos) - part.ParentGroup.GetBoundsRadius(); | 4096 | continue; |
4093 | if(dpos > cullingrange) | ||
4094 | continue; | ||
4095 | 4097 | ||
4096 | if(!GroupsNeedFullUpdate.Contains(part.ParentGroup)) | 4098 | if(!GroupsNeedFullUpdate.Contains(part.ParentGroup)) |
4097 | GroupsNeedFullUpdate.Add(part.ParentGroup); | 4099 | GroupsNeedFullUpdate.Add(part.ParentGroup); |
4098 | continue; | 4100 | continue; |
4099 | } | ||
4100 | } | 4101 | } |
4101 | } | 4102 | } |
4102 | 4103 | ||
@@ -4363,40 +4364,41 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4363 | HashSet<SceneObjectGroup> GroupsNeedFullUpdate = new HashSet<SceneObjectGroup>(); | 4364 | HashSet<SceneObjectGroup> GroupsNeedFullUpdate = new HashSet<SceneObjectGroup>(); |
4364 | 4365 | ||
4365 | // will this take for ever ? | 4366 | // will this take for ever ? |
4366 | lock(GroupsInView) | 4367 | EntityBase[] entities = m_scene.Entities.GetEntities(); |
4367 | { | 4368 | foreach (EntityBase e in entities) |
4368 | EntityBase[] entities = m_scene.Entities.GetEntities(); | 4369 | { |
4369 | foreach (EntityBase e in entities) | 4370 | if (e != null && e is SceneObjectGroup && !((SceneObjectGroup)e).IsAttachment) |
4370 | { | 4371 | { |
4371 | if (e != null && e is SceneObjectGroup && !((SceneObjectGroup)e).IsAttachment) | 4372 | SceneObjectGroup grp = (SceneObjectGroup)e; |
4373 | Vector3 grppos = grp.AbsolutePosition; | ||
4374 | float dcam = (grppos - mycamera).LengthSquared(); | ||
4375 | float dpos = (grppos - mypos).LengthSquared(); | ||
4376 | if(dcam < dpos) | ||
4377 | dpos = dcam; | ||
4378 | dpos = (float)Math.Sqrt(dpos) - grp.GetBoundsRadius(); | ||
4379 | bool inview; | ||
4380 | lock(GroupsInView) | ||
4381 | inview = GroupsInView.Contains(grp); | ||
4382 | if(dpos > cullingrange) | ||
4372 | { | 4383 | { |
4373 | SceneObjectGroup grp = (SceneObjectGroup)e; | 4384 | if(inview) |
4374 | Vector3 grppos = grp.AbsolutePosition; | ||
4375 | float dcam = (grppos - mycamera).LengthSquared(); | ||
4376 | float dpos = (grppos - mypos).LengthSquared(); | ||
4377 | if(dcam < dpos) | ||
4378 | dpos = dcam; | ||
4379 | dpos = (float)Math.Sqrt(dpos) - grp.GetBoundsRadius(); | ||
4380 | if(dpos > cullingrange) | ||
4381 | { | 4385 | { |
4382 | if(GroupsInView.Contains(grp)) | 4386 | GroupsInView.Remove(grp); |
4383 | { | 4387 | if (!m_killRecord.Contains(grp.LocalId)) |
4384 | GroupsInView.Remove(grp); | 4388 | m_killRecord.Add(grp.LocalId); |
4385 | if (!m_killRecord.Contains(grp.LocalId)) | ||
4386 | m_killRecord.Add(grp.LocalId); | ||
4387 | } | ||
4388 | } | 4389 | } |
4390 | } | ||
4389 | else | 4391 | else |
4390 | { | 4392 | { |
4391 | if(!GroupsInView.Contains(grp) && !GroupsNeedFullUpdate.Contains(grp)) | 4393 | if(!inview && !GroupsNeedFullUpdate.Contains(grp)) |
4392 | GroupsNeedFullUpdate.Add(grp); | 4394 | GroupsNeedFullUpdate.Add(grp); |
4393 | NewGroupsInView.Add(grp); | 4395 | NewGroupsInView.Add(grp); |
4394 | } | ||
4395 | } | 4396 | } |
4396 | } | 4397 | } |
4397 | } | 4398 | } |
4398 | 4399 | ||
4399 | GroupsInView = NewGroupsInView; | 4400 | lock(GroupsInView) |
4401 | GroupsInView = NewGroupsInView; | ||
4400 | 4402 | ||
4401 | if (m_killRecord.Count > 0) | 4403 | if (m_killRecord.Count > 0) |
4402 | { | 4404 | { |