diff options
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 128 |
1 files changed, 126 insertions, 2 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 4a48a80..cddafc5 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | |||
@@ -340,6 +340,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
340 | private Prioritizer m_prioritizer; | 340 | private Prioritizer m_prioritizer; |
341 | private bool m_disableFacelights = false; | 341 | private bool m_disableFacelights = false; |
342 | 342 | ||
343 | // needs optimazation | ||
344 | private HashSet<SceneObjectGroup> GroupsInView = new HashSet<SceneObjectGroup>(); | ||
345 | |||
343 | private bool m_VelocityInterpolate = false; | 346 | private bool m_VelocityInterpolate = false; |
344 | private const uint MaxTransferBytesPerPacket = 600; | 347 | private const uint MaxTransferBytesPerPacket = 600; |
345 | 348 | ||
@@ -3978,7 +3981,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
3978 | // float avgTimeDilation = 0.0f; | 3981 | // float avgTimeDilation = 0.0f; |
3979 | IEntityUpdate iupdate; | 3982 | IEntityUpdate iupdate; |
3980 | Int32 timeinqueue; // this is just debugging code & can be dropped later | 3983 | Int32 timeinqueue; // this is just debugging code & can be dropped later |
3981 | 3984 | ||
3985 | bool doCulling = m_scene.ObjectsCullingByDistance; | ||
3986 | float cullingrange = 64.0f; | ||
3987 | HashSet<SceneObjectGroup> GroupsNeedFullUpdate = new HashSet<SceneObjectGroup>(); | ||
3988 | Vector3 mycamera = Vector3.Zero; | ||
3989 | Vector3 mypos = Vector3.Zero; | ||
3990 | ScenePresence mysp = (ScenePresence)SceneAgent; | ||
3991 | if(mysp != null && !mysp.IsDeleted) | ||
3992 | { | ||
3993 | cullingrange = mysp.DrawDistance + m_scene.ReprioritizationDistance +16f; | ||
3994 | mycamera = mysp.CameraPosition; | ||
3995 | mypos = mysp.AbsolutePosition; | ||
3996 | } | ||
3997 | else | ||
3998 | doCulling = false; | ||
3999 | |||
3982 | while (updatesThisCall < maxUpdates) | 4000 | while (updatesThisCall < maxUpdates) |
3983 | { | 4001 | { |
3984 | lock (m_entityUpdates.SyncRoot) | 4002 | lock (m_entityUpdates.SyncRoot) |
@@ -4059,6 +4077,28 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4059 | } | 4077 | } |
4060 | } | 4078 | } |
4061 | 4079 | ||
4080 | if(doCulling && !part.ParentGroup.IsAttachment) | ||
4081 | { | ||
4082 | lock(GroupsInView) | ||
4083 | { | ||
4084 | if(!GroupsInView.Contains(part.ParentGroup)) | ||
4085 | { | ||
4086 | Vector3 partpos = part.ParentGroup.AbsolutePosition; | ||
4087 | float dcam = (partpos - mycamera).LengthSquared(); | ||
4088 | float dpos = (partpos - mypos).LengthSquared(); | ||
4089 | if(dcam < dpos) | ||
4090 | dpos = dcam; | ||
4091 | dpos = (float)Math.Sqrt(dpos) + part.ParentGroup.GetBoundsRadius(); | ||
4092 | if(dpos > cullingrange) | ||
4093 | continue; | ||
4094 | |||
4095 | if(!GroupsNeedFullUpdate.Contains(part.ParentGroup)) | ||
4096 | GroupsNeedFullUpdate.Add(part.ParentGroup); | ||
4097 | continue; | ||
4098 | } | ||
4099 | } | ||
4100 | } | ||
4101 | |||
4062 | if (part.Shape != null && (part.Shape.SculptType == (byte)SculptType.Mesh)) | 4102 | if (part.Shape != null && (part.Shape.SculptType == (byte)SculptType.Mesh)) |
4063 | { | 4103 | { |
4064 | // Ensure that mesh has at least 8 valid faces | 4104 | // Ensure that mesh has at least 8 valid faces |
@@ -4247,8 +4287,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4247 | SendKillObject(m_killRecord); | 4287 | SendKillObject(m_killRecord); |
4248 | m_killRecord.Clear(); | 4288 | m_killRecord.Clear(); |
4249 | } | 4289 | } |
4250 | #endregion | ||
4251 | 4290 | ||
4291 | lock(GroupsNeedFullUpdate) | ||
4292 | { | ||
4293 | if(GroupsNeedFullUpdate.Count > 0) | ||
4294 | { | ||
4295 | foreach(SceneObjectGroup grp in GroupsNeedFullUpdate) | ||
4296 | { | ||
4297 | grp.ScheduleGroupForFullUpdate(); | ||
4298 | lock(GroupsInView) | ||
4299 | GroupsInView.Add(grp); | ||
4300 | } | ||
4301 | GroupsNeedFullUpdate.Clear(); | ||
4302 | } | ||
4303 | } | ||
4304 | #endregion | ||
4252 | 4305 | ||
4253 | } | 4306 | } |
4254 | 4307 | ||
@@ -4282,10 +4335,81 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4282 | 4335 | ||
4283 | public void ReprioritizeUpdates() | 4336 | public void ReprioritizeUpdates() |
4284 | { | 4337 | { |
4338 | CheckGroupsInView(); | ||
4285 | lock (m_entityUpdates.SyncRoot) | 4339 | lock (m_entityUpdates.SyncRoot) |
4286 | m_entityUpdates.Reprioritize(UpdatePriorityHandler); | 4340 | m_entityUpdates.Reprioritize(UpdatePriorityHandler); |
4287 | } | 4341 | } |
4288 | 4342 | ||
4343 | public void CheckGroupsInView() | ||
4344 | { | ||
4345 | bool doCulling = m_scene.ObjectsCullingByDistance; | ||
4346 | if(!doCulling) | ||
4347 | return; | ||
4348 | float cullingrange = 64.0f; | ||
4349 | Vector3 mycamera = Vector3.Zero; | ||
4350 | Vector3 mypos = Vector3.Zero; | ||
4351 | ScenePresence mysp = (ScenePresence)SceneAgent; | ||
4352 | if(mysp != null && !mysp.IsDeleted) | ||
4353 | { | ||
4354 | cullingrange = mysp.DrawDistance + m_scene.ReprioritizationDistance + 16f; | ||
4355 | mycamera = mysp.CameraPosition; | ||
4356 | mypos = mysp.AbsolutePosition; | ||
4357 | } | ||
4358 | else | ||
4359 | return; | ||
4360 | |||
4361 | HashSet<SceneObjectGroup> NewGroupsInView = new HashSet<SceneObjectGroup>(); | ||
4362 | HashSet<SceneObjectGroup> GroupsNeedFullUpdate = new HashSet<SceneObjectGroup>(); | ||
4363 | |||
4364 | lock(GroupsInView) | ||
4365 | { | ||
4366 | EntityBase[] entities = m_scene.Entities.GetEntities(); | ||
4367 | foreach (EntityBase e in entities) | ||
4368 | { | ||
4369 | if (e != null && e is SceneObjectGroup && !((SceneObjectGroup)e).IsAttachment) | ||
4370 | { | ||
4371 | SceneObjectGroup grp = (SceneObjectGroup)e; | ||
4372 | Vector3 grppos = grp.AbsolutePosition; | ||
4373 | float dcam = (grppos - mycamera).LengthSquared(); | ||
4374 | float dpos = (grppos - mypos).LengthSquared(); | ||
4375 | if(dcam < dpos) | ||
4376 | dpos = dcam; | ||
4377 | dpos = (float)Math.Sqrt(dpos) + grp.GetBoundsRadius(); | ||
4378 | if(dpos > cullingrange) | ||
4379 | { | ||
4380 | if(GroupsInView.Contains(grp)) | ||
4381 | { | ||
4382 | GroupsInView.Remove(grp); | ||
4383 | if (!m_killRecord.Contains(grp.LocalId)) | ||
4384 | m_killRecord.Add(grp.LocalId); | ||
4385 | } | ||
4386 | } | ||
4387 | else | ||
4388 | { | ||
4389 | if(!GroupsInView.Contains(grp) && !GroupsNeedFullUpdate.Contains(grp)) | ||
4390 | GroupsNeedFullUpdate.Add(grp); | ||
4391 | NewGroupsInView.Add(grp); | ||
4392 | } | ||
4393 | } | ||
4394 | } | ||
4395 | } | ||
4396 | |||
4397 | GroupsInView = NewGroupsInView; | ||
4398 | |||
4399 | if (m_killRecord.Count > 0) | ||
4400 | { | ||
4401 | SendKillObject(m_killRecord); | ||
4402 | m_killRecord.Clear(); | ||
4403 | } | ||
4404 | |||
4405 | if(GroupsNeedFullUpdate.Count > 0) | ||
4406 | { | ||
4407 | foreach(SceneObjectGroup grp in GroupsNeedFullUpdate) | ||
4408 | grp.ScheduleGroupForFullUpdate(); | ||
4409 | } | ||
4410 | GroupsNeedFullUpdate.Clear(); | ||
4411 | } | ||
4412 | |||
4289 | private bool UpdatePriorityHandler(ref uint priority, ISceneEntity entity) | 4413 | private bool UpdatePriorityHandler(ref uint priority, ISceneEntity entity) |
4290 | { | 4414 | { |
4291 | if (entity != null) | 4415 | if (entity != null) |