diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 93 |
1 files changed, 63 insertions, 30 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index a9edf08..da4c1fb 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | |||
@@ -4120,10 +4120,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4120 | float cullingrange = 64.0f; | 4120 | float cullingrange = 64.0f; |
4121 | Vector3 mypos = Vector3.Zero; | 4121 | Vector3 mypos = Vector3.Zero; |
4122 | 4122 | ||
4123 | bool orderedDequeue = m_scene.UpdatePrioritizationScheme == UpdatePrioritizationSchemes.SimpleAngularDistance; | 4123 | //bool orderedDequeue = m_scene.UpdatePrioritizationScheme == UpdatePrioritizationSchemes.SimpleAngularDistance; |
4124 | bool orderedDequeue = false; // temporary off | ||
4124 | 4125 | ||
4125 | HashSet<SceneObjectGroup> GroupsNeedFullUpdate = new HashSet<SceneObjectGroup>(); | 4126 | HashSet<SceneObjectGroup> GroupsNeedFullUpdate = new HashSet<SceneObjectGroup>(); |
4126 | 4127 | ||
4128 | |||
4127 | if (doCulling) | 4129 | if (doCulling) |
4128 | { | 4130 | { |
4129 | cullingrange = mysp.DrawDistance + m_scene.ReprioritizationDistance + 16f; | 4131 | cullingrange = mysp.DrawDistance + m_scene.ReprioritizationDistance + 16f; |
@@ -4304,7 +4306,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4304 | PrimUpdateFlags.Velocity | | 4306 | PrimUpdateFlags.Velocity | |
4305 | PrimUpdateFlags.Acceleration | | 4307 | PrimUpdateFlags.Acceleration | |
4306 | PrimUpdateFlags.AngularVelocity | | 4308 | PrimUpdateFlags.AngularVelocity | |
4307 | PrimUpdateFlags.CollisionPlane | 4309 | PrimUpdateFlags.CollisionPlane | |
4310 | PrimUpdateFlags.Textures | ||
4308 | ); | 4311 | ); |
4309 | 4312 | ||
4310 | #endregion UpdateFlags to packet type conversion | 4313 | #endregion UpdateFlags to packet type conversion |
@@ -4347,7 +4350,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4347 | maxUpdatesBytes -= 18; | 4350 | maxUpdatesBytes -= 18; |
4348 | } | 4351 | } |
4349 | terseUpdates.Add(update); | 4352 | terseUpdates.Add(update); |
4350 | maxUpdatesBytes -= 47; // no texture entry | 4353 | maxUpdatesBytes -= 47; |
4354 | if ((updateFlags & PrimUpdateFlags.Textures) != 0) | ||
4355 | maxUpdatesBytes -= 100; // aprox | ||
4351 | } | 4356 | } |
4352 | } | 4357 | } |
4353 | else | 4358 | else |
@@ -4390,7 +4395,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4390 | UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); | 4395 | UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); |
4391 | 4396 | ||
4392 | //setup header and regioninfo block | 4397 | //setup header and regioninfo block |
4393 | Array.Copy(terseUpdateHeader, buf.Data, 7); | 4398 | Buffer.BlockCopy(terseUpdateHeader, 0, buf.Data, 0, 7); |
4394 | Utils.UInt64ToBytesSafepos(m_scene.RegionInfo.RegionHandle, buf.Data, 7); | 4399 | Utils.UInt64ToBytesSafepos(m_scene.RegionInfo.RegionHandle, buf.Data, 7); |
4395 | Utils.UInt16ToBytes(timeDilation, buf.Data, 15); | 4400 | Utils.UInt16ToBytes(timeDilation, buf.Data, 15); |
4396 | buf.Data[17] = (byte)curNBlocks; | 4401 | buf.Data[17] = (byte)curNBlocks; |
@@ -4399,7 +4404,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4399 | int count = 0; | 4404 | int count = 0; |
4400 | foreach (EntityUpdate eu in terseAgentUpdates) | 4405 | foreach (EntityUpdate eu in terseAgentUpdates) |
4401 | { | 4406 | { |
4402 | CreateImprovedTerseBlock(eu.Entity, buf.Data, ref pos); | 4407 | CreateImprovedTerseBlock(eu.Entity, buf.Data, ref pos, false); |
4403 | tau.Add(eu); | 4408 | tau.Add(eu); |
4404 | ++count; | 4409 | ++count; |
4405 | --blocks; | 4410 | --blocks; |
@@ -4407,7 +4412,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4407 | { | 4412 | { |
4408 | // we need more packets | 4413 | // we need more packets |
4409 | UDPPacketBuffer newbuf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); | 4414 | UDPPacketBuffer newbuf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); |
4410 | Array.Copy(buf.Data, newbuf.Data, 17); // start is the same | 4415 | Buffer.BlockCopy(buf.Data, 0, newbuf.Data, 0, 17); // start is the same |
4411 | 4416 | ||
4412 | buf.DataLength = pos; | 4417 | buf.DataLength = pos; |
4413 | m_udpServer.SendUDPPacket(m_udpClient, buf, ThrottleOutPacketType.Unknown, | 4418 | m_udpServer.SendUDPPacket(m_udpClient, buf, ThrottleOutPacketType.Unknown, |
@@ -4455,49 +4460,57 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4455 | */ | 4460 | */ |
4456 | if (terseUpdates != null) | 4461 | if (terseUpdates != null) |
4457 | { | 4462 | { |
4458 | const int maxNBlocks = (LLUDPServer.MTU - 18) / 47; // no texture entry | ||
4459 | int blocks = terseUpdates.Count; | 4463 | int blocks = terseUpdates.Count; |
4460 | int curNBlocks = blocks > maxNBlocks ? maxNBlocks : blocks; | 4464 | List<EntityUpdate> tau = new List<EntityUpdate>(30); |
4461 | List<EntityUpdate> tau = new List<EntityUpdate>(curNBlocks); | ||
4462 | 4465 | ||
4463 | UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); | 4466 | UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); |
4464 | 4467 | ||
4465 | //setup header and regioninfo block | 4468 | //setup header and regioninfo block |
4466 | Array.Copy(terseUpdateHeader, buf.Data, 7); | 4469 | Buffer.BlockCopy(terseUpdateHeader, 0, buf.Data, 0, 7); |
4467 | Utils.UInt64ToBytesSafepos(m_scene.RegionInfo.RegionHandle, buf.Data, 7); | 4470 | Utils.UInt64ToBytesSafepos(m_scene.RegionInfo.RegionHandle, buf.Data, 7); |
4468 | Utils.UInt16ToBytes(timeDilation, buf.Data, 15); | 4471 | Utils.UInt16ToBytes(timeDilation, buf.Data, 15); |
4469 | buf.Data[17] = (byte)curNBlocks; | ||
4470 | int pos = 18; | 4472 | int pos = 18; |
4473 | int lastpos = 0; | ||
4471 | 4474 | ||
4472 | int count = 0; | 4475 | int count = 0; |
4473 | foreach (EntityUpdate eu in terseUpdates) | 4476 | foreach (EntityUpdate eu in terseUpdates) |
4474 | { | 4477 | { |
4475 | CreateImprovedTerseBlock(eu.Entity, buf.Data, ref pos); | 4478 | lastpos = pos; |
4476 | tau.Add(eu); | 4479 | CreateImprovedTerseBlock(eu.Entity, buf.Data, ref pos, (eu.Flags & PrimUpdateFlags.Textures) != 0); |
4477 | ++count; | 4480 | if (pos <= LLUDPServer.MTU) |
4478 | --blocks; | 4481 | { |
4479 | if (count == curNBlocks && blocks > 0) | 4482 | tau.Add(eu); |
4483 | ++count; | ||
4484 | --blocks; | ||
4485 | } | ||
4486 | else if (blocks > 0) | ||
4480 | { | 4487 | { |
4481 | // we need more packets | 4488 | // we need more packets |
4482 | UDPPacketBuffer newbuf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); | 4489 | UDPPacketBuffer newbuf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); |
4483 | Array.Copy(buf.Data, newbuf.Data, 17); // start is the same | 4490 | Buffer.BlockCopy(buf.Data, 0, newbuf.Data, 0, 17); // start is the same |
4491 | // copy what we done in excess | ||
4492 | int extralen = pos - lastpos; | ||
4493 | if(extralen > 0) | ||
4494 | Buffer.BlockCopy(newbuf.Data, 18, buf.Data, lastpos, extralen); | ||
4484 | 4495 | ||
4485 | buf.DataLength = pos; | 4496 | pos = 18 + extralen; |
4497 | |||
4498 | buf.Data[17] = (byte)count; | ||
4499 | buf.DataLength = lastpos; | ||
4486 | m_udpServer.SendUDPPacket(m_udpClient, buf, ThrottleOutPacketType.Task, | 4500 | m_udpServer.SendUDPPacket(m_udpClient, buf, ThrottleOutPacketType.Task, |
4487 | delegate (OutgoingPacket oPacket) { ResendPrimUpdates(tau, oPacket); }, false); | 4501 | delegate (OutgoingPacket oPacket) { ResendPrimUpdates(tau, oPacket); }, false); |
4488 | 4502 | ||
4489 | curNBlocks = blocks > maxNBlocks ? maxNBlocks : blocks; | 4503 | tau = new List<EntityUpdate>(30); |
4490 | tau = new List<EntityUpdate>(curNBlocks); | 4504 | tau.Add(eu); |
4491 | count = 0; | 4505 | count = 1; |
4492 | 4506 | --blocks; | |
4493 | buf = newbuf; | 4507 | buf = newbuf; |
4494 | buf.Data[17] = (byte)curNBlocks; | ||
4495 | pos = 18; | ||
4496 | } | 4508 | } |
4497 | } | 4509 | } |
4498 | 4510 | ||
4499 | if (count > 0) | 4511 | if (count > 0) |
4500 | { | 4512 | { |
4513 | buf.Data[17] = (byte)count; | ||
4501 | buf.DataLength = pos; | 4514 | buf.DataLength = pos; |
4502 | m_udpServer.SendUDPPacket(m_udpClient, buf, ThrottleOutPacketType.Task, | 4515 | m_udpServer.SendUDPPacket(m_udpClient, buf, ThrottleOutPacketType.Task, |
4503 | delegate (OutgoingPacket oPacket) { ResendPrimUpdates(tau, oPacket); }, false); | 4516 | delegate (OutgoingPacket oPacket) { ResendPrimUpdates(tau, oPacket); }, false); |
@@ -5720,7 +5733,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5720 | } | 5733 | } |
5721 | 5734 | ||
5722 | 5735 | ||
5723 | protected void CreateImprovedTerseBlock(ISceneEntity entity, byte[] data, ref int pos) | 5736 | protected void CreateImprovedTerseBlock(ISceneEntity entity, byte[] data, ref int pos, bool includeTexture) |
5724 | { | 5737 | { |
5725 | #region ScenePresence/SOP Handling | 5738 | #region ScenePresence/SOP Handling |
5726 | 5739 | ||
@@ -5731,6 +5744,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5731 | Vector3 position, velocity, acceleration, angularVelocity; | 5744 | Vector3 position, velocity, acceleration, angularVelocity; |
5732 | Quaternion rotation; | 5745 | Quaternion rotation; |
5733 | byte datasize; | 5746 | byte datasize; |
5747 | byte[] te = null; | ||
5734 | 5748 | ||
5735 | if (avatar) | 5749 | if (avatar) |
5736 | { | 5750 | { |
@@ -5775,6 +5789,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5775 | rotation = part.RotationOffset; | 5789 | rotation = part.RotationOffset; |
5776 | 5790 | ||
5777 | datasize = 44; | 5791 | datasize = 44; |
5792 | if(includeTexture) | ||
5793 | te = part.Shape.TextureEntry; | ||
5778 | } | 5794 | } |
5779 | 5795 | ||
5780 | #endregion ScenePresence/SOP Handling | 5796 | #endregion ScenePresence/SOP Handling |
@@ -5785,8 +5801,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5785 | Utils.UIntToBytes(localID, data, pos); | 5801 | Utils.UIntToBytes(localID, data, pos); |
5786 | pos += 4; | 5802 | pos += 4; |
5787 | 5803 | ||
5788 | // Avatar/CollisionPlane | ||
5789 | data[pos++] = (byte)attachPoint; | 5804 | data[pos++] = (byte)attachPoint; |
5805 | |||
5806 | // Avatar/CollisionPlane | ||
5790 | if (avatar) | 5807 | if (avatar) |
5791 | { | 5808 | { |
5792 | data[pos++] = 1; | 5809 | data[pos++] = 1; |
@@ -5829,11 +5846,27 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5829 | Utils.FloatToUInt16Bytes(angularVelocity.X, 64.0f, data, pos); pos += 2; | 5846 | Utils.FloatToUInt16Bytes(angularVelocity.X, 64.0f, data, pos); pos += 2; |
5830 | Utils.FloatToUInt16Bytes(angularVelocity.Y, 64.0f, data, pos); pos += 2; | 5847 | Utils.FloatToUInt16Bytes(angularVelocity.Y, 64.0f, data, pos); pos += 2; |
5831 | Utils.FloatToUInt16Bytes(angularVelocity.Z, 64.0f, data, pos); pos += 2; | 5848 | Utils.FloatToUInt16Bytes(angularVelocity.Z, 64.0f, data, pos); pos += 2; |
5832 | 5849 | ||
5833 | // texture entry block size | 5850 | // texture entry block size |
5834 | data[pos++] = 0; | 5851 | if(te == null) |
5835 | data[pos++] = 0; | 5852 | { |
5836 | // total size 63 or 47 | 5853 | data[pos++] = 0; |
5854 | data[pos++] = 0; | ||
5855 | } | ||
5856 | else | ||
5857 | { | ||
5858 | int len = te.Length & 0x7fff; | ||
5859 | int totlen = len + 4; | ||
5860 | data[pos++] = (byte)totlen; | ||
5861 | data[pos++] = (byte)(totlen >> 8); | ||
5862 | data[pos++] = (byte)len; // wtf ??? | ||
5863 | data[pos++] = (byte)(len >> 8); | ||
5864 | data[pos++] = 0; | ||
5865 | data[pos++] = 0; | ||
5866 | Buffer.BlockCopy(te, 0, data, pos, len); | ||
5867 | pos += len; | ||
5868 | } | ||
5869 | // total size 63 or 47 + (texture size + 4) | ||
5837 | } | 5870 | } |
5838 | 5871 | ||
5839 | protected ObjectUpdatePacket.ObjectDataBlock CreateAvatarUpdateBlock(ScenePresence data) | 5872 | protected ObjectUpdatePacket.ObjectDataBlock CreateAvatarUpdateBlock(ScenePresence data) |