RegionCombinerIndividualEventForwarder.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using OpenMetaverse;
  29. using OpenSim.Framework;
  30. using OpenSim.Region.Framework.Scenes;
  31. namespace OpenSim.Region.RegionCombinerModule
  32. {
  33. public class RegionCombinerIndividualEventForwarder
  34. {
  35. private Scene m_rootScene;
  36. private Scene m_virtScene;
  37. public RegionCombinerIndividualEventForwarder(Scene rootScene, Scene virtScene)
  38. {
  39. m_rootScene = rootScene;
  40. m_virtScene = virtScene;
  41. }
  42. public void ClientConnect(IClientAPI client)
  43. {
  44. m_virtScene.UnSubscribeToClientPrimEvents(client);
  45. m_virtScene.UnSubscribeToClientPrimRezEvents(client);
  46. m_virtScene.UnSubscribeToClientInventoryEvents(client);
  47. m_virtScene.UnSubscribeToClientAttachmentEvents(client);
  48. //m_virtScene.UnSubscribeToClientTeleportEvents(client);
  49. m_virtScene.UnSubscribeToClientScriptEvents(client);
  50. m_virtScene.UnSubscribeToClientGodEvents(client);
  51. m_virtScene.UnSubscribeToClientNetworkEvents(client);
  52. m_rootScene.SubscribeToClientPrimEvents(client);
  53. client.OnAddPrim += LocalAddNewPrim;
  54. client.OnRezObject += LocalRezObject;
  55. m_rootScene.SubscribeToClientInventoryEvents(client);
  56. m_rootScene.SubscribeToClientAttachmentEvents(client);
  57. //m_rootScene.SubscribeToClientTeleportEvents(client);
  58. m_rootScene.SubscribeToClientScriptEvents(client);
  59. m_rootScene.SubscribeToClientGodEvents(client);
  60. m_rootScene.SubscribeToClientNetworkEvents(client);
  61. }
  62. public void ClientClosed(UUID clientid, Scene scene)
  63. {
  64. }
  65. /// <summary>
  66. /// Fixes position based on the region the Rez event came in on
  67. /// </summary>
  68. /// <param name="remoteclient"></param>
  69. /// <param name="itemid"></param>
  70. /// <param name="rayend"></param>
  71. /// <param name="raystart"></param>
  72. /// <param name="raytargetid"></param>
  73. /// <param name="bypassraycast"></param>
  74. /// <param name="rayendisintersection"></param>
  75. /// <param name="rezselected"></param>
  76. /// <param name="removeitem"></param>
  77. /// <param name="fromtaskid"></param>
  78. private void LocalRezObject(IClientAPI remoteclient, UUID itemid, Vector3 rayend, Vector3 raystart,
  79. UUID raytargetid, byte bypassraycast, bool rayendisintersection, bool rezselected, bool removeitem,
  80. UUID fromtaskid)
  81. {
  82. int differenceX = (int)m_virtScene.RegionInfo.RegionLocX - (int)m_rootScene.RegionInfo.RegionLocX;
  83. int differenceY = (int)m_virtScene.RegionInfo.RegionLocY - (int)m_rootScene.RegionInfo.RegionLocY;
  84. rayend.X += differenceX * (int)Constants.RegionSize;
  85. rayend.Y += differenceY * (int)Constants.RegionSize;
  86. raystart.X += differenceX * (int)Constants.RegionSize;
  87. raystart.Y += differenceY * (int)Constants.RegionSize;
  88. m_rootScene.RezObject(remoteclient, itemid, rayend, raystart, raytargetid, bypassraycast,
  89. rayendisintersection, rezselected, removeitem, fromtaskid);
  90. }
  91. /// <summary>
  92. /// Fixes position based on the region the AddPrimShape event came in on
  93. /// </summary>
  94. /// <param name="ownerid"></param>
  95. /// <param name="groupid"></param>
  96. /// <param name="rayend"></param>
  97. /// <param name="rot"></param>
  98. /// <param name="shape"></param>
  99. /// <param name="bypassraycast"></param>
  100. /// <param name="raystart"></param>
  101. /// <param name="raytargetid"></param>
  102. /// <param name="rayendisintersection"></param>
  103. private void LocalAddNewPrim(UUID ownerid, UUID groupid, Vector3 rayend, Quaternion rot,
  104. PrimitiveBaseShape shape, byte bypassraycast, Vector3 raystart, UUID raytargetid,
  105. byte rayendisintersection)
  106. {
  107. int differenceX = (int)m_virtScene.RegionInfo.RegionLocX - (int)m_rootScene.RegionInfo.RegionLocX;
  108. int differenceY = (int)m_virtScene.RegionInfo.RegionLocY - (int)m_rootScene.RegionInfo.RegionLocY;
  109. rayend.X += differenceX * (int)Constants.RegionSize;
  110. rayend.Y += differenceY * (int)Constants.RegionSize;
  111. raystart.X += differenceX * (int)Constants.RegionSize;
  112. raystart.Y += differenceY * (int)Constants.RegionSize;
  113. m_rootScene.AddNewPrim(ownerid, groupid, rayend, rot, shape, bypassraycast, raystart, raytargetid,
  114. rayendisintersection);
  115. }
  116. }
  117. }