diff options
author | Teravus Ovares | 2008-02-11 01:43:54 +0000 |
---|---|---|
committer | Teravus Ovares | 2008-02-11 01:43:54 +0000 |
commit | a56664cf5910876b8ab7ca175bdb88918ec15280 (patch) | |
tree | 15dc2b901d24968170890c9c68db5f16d47149b4 /OpenSim/Region/Environment | |
parent | state_entry is now executed on state change. (diff) | |
download | opensim-SC_OLD-a56664cf5910876b8ab7ca175bdb88918ec15280.zip opensim-SC_OLD-a56664cf5910876b8ab7ca175bdb88918ec15280.tar.gz opensim-SC_OLD-a56664cf5910876b8ab7ca175bdb88918ec15280.tar.bz2 opensim-SC_OLD-a56664cf5910876b8ab7ca175bdb88918ec15280.tar.xz |
* um, Prim crossings? Experimental.
* Backup your database just in case.
Diffstat (limited to 'OpenSim/Region/Environment')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.cs | 114 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs | 19 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs | 23 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs | 27 |
4 files changed, 119 insertions, 64 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 015ba12..999de9c 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -1089,50 +1089,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1089 | if (target != null) | 1089 | if (target != null) |
1090 | { | 1090 | { |
1091 | pos = target.AbsolutePosition; | 1091 | pos = target.AbsolutePosition; |
1092 | 1092 | // TODO: Raytrace here | |
1093 | //m_log.Info("[RAYTRACE]: " + pos.ToString()); | ||
1094 | //EntityIntersection rayTracing = null; | ||
1095 | //ScenePresence presence = ((ScenePresence)GetScenePresence(ownerID)); | ||
1096 | //if (presence != null) | ||
1097 | //{ | ||
1098 | //Vector3 CameraPosition = presence.CameraPosition; | ||
1099 | //Vector3 rayEnd = new Vector3(pos.X, pos.Y, pos.Z); | ||
1100 | |||
1101 | //float rayMag = m_innerScene.Vector3Distance(CameraPosition, rayEnd); | ||
1102 | //LLVector3 rayDirectionLL = Util.GetNormal(pos); | ||
1103 | |||
1104 | //Vector3 rayDirection = new Vector3(rayDirectionLL.X, rayDirectionLL.Y, rayDirectionLL.Z); | ||
1105 | |||
1106 | //Ray rezRay = new Ray(CameraPosition, rayDirection); | ||
1107 | |||
1108 | //Vector3 RezDirectionFromCamera = rezRay.Direction; | ||
1109 | |||
1110 | //rayTracing = m_innerScene.GetClosestIntersectingPrim(rezRay); | ||
1111 | //} | ||
1112 | |||
1113 | //if ((rayTracing != null) && (rayTracing.HitTF)) | ||
1114 | //{ | ||
1115 | // We raytraced and found a prim in the way of the ground.. so | ||
1116 | // We will rez the object somewhere close to the prim. Better math needed. This is a Stub | ||
1117 | //Vector3 Newpos = new Vector3(rayTracing.obj.AbsolutePosition.X,rayTracing.obj.AbsolutePosition.Y,rayTracing.obj.AbsolutePosition.Z); | ||
1118 | //Vector3 Newpos = rayTracing.ipoint; | ||
1119 | //Vector3 NewScale = | ||
1120 | //new Vector3(rayTracing.obj.Scale.X, rayTracing.obj.Scale.Y, rayTracing.obj.Scale.Z); | ||
1121 | |||
1122 | //Quaternion ParentRot = rayTracing.obj.ParentGroup.Rotation; | ||
1123 | //Quaternion ParentRot = new Quaternion(primParentRot.W,primParentRot.X,primParentRot.Y,primParentRot.Z); | ||
1124 | |||
1125 | //LLQuaternion primLocalRot = rayTracing.obj.RotationOffset; | ||
1126 | //Quaternion LocalRot = new Quaternion(primLocalRot.W, primLocalRot.X, primLocalRot.Y, primLocalRot.Z); | ||
1127 | |||
1128 | //Quaternion NewRot = LocalRot * ParentRot; | ||
1129 | |||
1130 | //Vector3 RezPoint = Newpos; | ||
1131 | |||
1132 | //m_log.Info("[REZINFO]: Possible Rez Point:" + RezPoint.ToString()); | ||
1133 | //pos = new LLVector3(RezPoint.x, RezPoint.y, RezPoint.z); | ||
1134 | //} | ||
1135 | |||
1136 | return pos; | 1093 | return pos; |
1137 | } | 1094 | } |
1138 | else | 1095 | else |
@@ -1253,6 +1210,73 @@ namespace OpenSim.Region.Environment.Scenes | |||
1253 | m_sceneXmlLoader.SavePrimsToXml2(fileName); | 1210 | m_sceneXmlLoader.SavePrimsToXml2(fileName); |
1254 | } | 1211 | } |
1255 | 1212 | ||
1213 | public void CrossPrimGroupIntoNewRegion(LLVector3 position, SceneObjectGroup grp) | ||
1214 | { | ||
1215 | m_log.Warn("Prim crossing: " + grp.UUID.ToString()); | ||
1216 | int thisx = (int)RegionInfo.RegionLocX; | ||
1217 | int thisy = (int)RegionInfo.RegionLocY; | ||
1218 | ulong newRegionHandle = 0; | ||
1219 | LLVector3 pos = grp.AbsolutePosition; | ||
1220 | |||
1221 | if (position.X > 255.6f) | ||
1222 | { | ||
1223 | pos.X = ((pos.X - 256) + 10); | ||
1224 | |||
1225 | newRegionHandle = Util.UIntsToLong((uint)((thisx + 1) * 256), (uint)(thisy * 256)); | ||
1226 | |||
1227 | // x + 1 | ||
1228 | } | ||
1229 | else if (position.X < 0.4f) | ||
1230 | { | ||
1231 | pos.X = ((pos.X + 256) - 10); | ||
1232 | newRegionHandle = Util.UIntsToLong((uint)((thisx - 1) * 256), (uint)(thisy * 256)); | ||
1233 | // x - 1 | ||
1234 | } | ||
1235 | |||
1236 | if (position.Y > 255.6f) | ||
1237 | { | ||
1238 | pos.Y = ((pos.Y - 256) + 10); | ||
1239 | newRegionHandle = Util.UIntsToLong((uint)(thisx * 256), (uint)((thisy + 1) * 256)); | ||
1240 | // y + 1 | ||
1241 | } | ||
1242 | else if (position.Y < 0.4f) | ||
1243 | { | ||
1244 | pos.Y = ((pos.Y + 256) - 10); | ||
1245 | newRegionHandle = Util.UIntsToLong((uint)(thisx * 256), (uint)((thisy - 1) * 256)); | ||
1246 | // y - 1 | ||
1247 | } | ||
1248 | |||
1249 | // Offset the positions for the new region across the border | ||
1250 | grp.OffsetForNewRegion(pos); | ||
1251 | |||
1252 | if (newRegionHandle != 0) | ||
1253 | { | ||
1254 | bool successYN = false; | ||
1255 | successYN = m_sceneGridService.PrimCrossToNeighboringRegion(newRegionHandle, grp.UUID, m_sceneXmlLoader.SavePrimGroupToXML2String(grp)); | ||
1256 | if (successYN) | ||
1257 | { | ||
1258 | // We remove the object here | ||
1259 | try | ||
1260 | { | ||
1261 | DeleteSceneObjectGroup(grp); | ||
1262 | } | ||
1263 | catch (System.Exception) | ||
1264 | { | ||
1265 | m_log.Warn("[DATABASE]: exception when trying to remove the prim that crossed the border."); | ||
1266 | } | ||
1267 | } | ||
1268 | else | ||
1269 | { | ||
1270 | m_log.Warn("[INTERREGION]: Prim Crossing Failed!"); | ||
1271 | } | ||
1272 | } | ||
1273 | } | ||
1274 | public void IncomingInterRegionPrimGroup(ulong regionHandle, LLUUID primID, string objXMLData) | ||
1275 | { | ||
1276 | m_log.Warn("{[INTERREGION]: OMG! A new prim arrived from a neighbor!.. Kyill eeehht! before it corrupts my entire database! AHHH! I feel so dirty now! yuck! ack! arg!"); | ||
1277 | m_sceneXmlLoader.LoadGroupFromXml2String(objXMLData); | ||
1278 | |||
1279 | } | ||
1256 | #endregion | 1280 | #endregion |
1257 | 1281 | ||
1258 | #region Add/Remove Avatar Methods | 1282 | #region Add/Remove Avatar Methods |
@@ -1527,6 +1551,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1527 | m_sceneGridService.OnCloseAgentConnection += CloseConnection; | 1551 | m_sceneGridService.OnCloseAgentConnection += CloseConnection; |
1528 | m_sceneGridService.OnRegionUp += OtherRegionUp; | 1552 | m_sceneGridService.OnRegionUp += OtherRegionUp; |
1529 | m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; | 1553 | m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; |
1554 | m_sceneGridService.OnExpectPrim += IncomingInterRegionPrimGroup; | ||
1530 | 1555 | ||
1531 | 1556 | ||
1532 | 1557 | ||
@@ -1540,6 +1565,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1540 | /// </summary> | 1565 | /// </summary> |
1541 | public void UnRegisterReginWithComms() | 1566 | public void UnRegisterReginWithComms() |
1542 | { | 1567 | { |
1568 | m_sceneGridService.OnExpectPrim -= IncomingInterRegionPrimGroup; | ||
1543 | m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; | 1569 | m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; |
1544 | m_sceneGridService.OnRegionUp -= OtherRegionUp; | 1570 | m_sceneGridService.OnRegionUp -= OtherRegionUp; |
1545 | m_sceneGridService.OnExpectUser -= NewUserConnection; | 1571 | m_sceneGridService.OnExpectUser -= NewUserConnection; |
diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs index a89b52c..482701b 100644 --- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs | |||
@@ -49,6 +49,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
49 | 49 | ||
50 | public event AgentCrossing OnAvatarCrossingIntoRegion; | 50 | public event AgentCrossing OnAvatarCrossingIntoRegion; |
51 | public event ExpectUserDelegate OnExpectUser; | 51 | public event ExpectUserDelegate OnExpectUser; |
52 | public event ExpectPrimDelegate OnExpectPrim; | ||
52 | public event CloseAgentConnection OnCloseAgentConnection; | 53 | public event CloseAgentConnection OnCloseAgentConnection; |
53 | public event PrimCrossing OnPrimCrossingIntoRegion; | 54 | public event PrimCrossing OnPrimCrossingIntoRegion; |
54 | public event RegionUp OnRegionUp; | 55 | public event RegionUp OnRegionUp; |
@@ -82,10 +83,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
82 | //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got" + regionCommsHost.ToString()); | 83 | //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got" + regionCommsHost.ToString()); |
83 | 84 | ||
84 | regionCommsHost.debugRegionName = _debugRegionName; | 85 | regionCommsHost.debugRegionName = _debugRegionName; |
85 | 86 | regionCommsHost.OnExpectPrim += IncomingPrimCrossing; | |
86 | regionCommsHost.OnExpectUser += NewUserConnection; | 87 | regionCommsHost.OnExpectUser += NewUserConnection; |
87 | regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing; | 88 | regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing; |
88 | regionCommsHost.OnPrimCrossingIntoRegion += PrimCrossing; | ||
89 | regionCommsHost.OnCloseAgentConnection += CloseConnection; | 89 | regionCommsHost.OnCloseAgentConnection += CloseConnection; |
90 | regionCommsHost.OnRegionUp += newRegionUp; | 90 | regionCommsHost.OnRegionUp += newRegionUp; |
91 | regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate; | 91 | regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate; |
@@ -104,8 +104,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
104 | regionCommsHost.OnChildAgentUpdate -= ChildAgentUpdate; | 104 | regionCommsHost.OnChildAgentUpdate -= ChildAgentUpdate; |
105 | regionCommsHost.OnRegionUp -= newRegionUp; | 105 | regionCommsHost.OnRegionUp -= newRegionUp; |
106 | regionCommsHost.OnExpectUser -= NewUserConnection; | 106 | regionCommsHost.OnExpectUser -= NewUserConnection; |
107 | regionCommsHost.OnExpectPrim -= IncomingPrimCrossing; | ||
107 | regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing; | 108 | regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing; |
108 | regionCommsHost.OnPrimCrossingIntoRegion -= PrimCrossing; | ||
109 | regionCommsHost.OnCloseAgentConnection -= CloseConnection; | 109 | regionCommsHost.OnCloseAgentConnection -= CloseConnection; |
110 | m_commsProvider.GridService.DeregisterRegion(m_regionInfo); | 110 | m_commsProvider.GridService.DeregisterRegion(m_regionInfo); |
111 | regionCommsHost = null; | 111 | regionCommsHost = null; |
@@ -156,6 +156,15 @@ namespace OpenSim.Region.Environment.Scenes | |||
156 | } | 156 | } |
157 | } | 157 | } |
158 | 158 | ||
159 | protected void IncomingPrimCrossing(ulong regionHandle, LLUUID primID, String objXMLData) | ||
160 | { | ||
161 | if (OnExpectPrim != null) | ||
162 | { | ||
163 | OnExpectPrim(regionHandle, primID, objXMLData); | ||
164 | } | ||
165 | |||
166 | } | ||
167 | |||
159 | protected void PrimCrossing(ulong regionHandle, LLUUID primID, LLVector3 position, bool isPhysical) | 168 | protected void PrimCrossing(ulong regionHandle, LLUUID primID, LLVector3 position, bool isPhysical) |
160 | { | 169 | { |
161 | if (OnPrimCrossingIntoRegion != null) | 170 | if (OnPrimCrossingIntoRegion != null) |
@@ -535,9 +544,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
535 | return m_commsProvider.InterRegion.ExpectAvatarCrossing(regionhandle, agentID, position, isFlying); | 544 | return m_commsProvider.InterRegion.ExpectAvatarCrossing(regionhandle, agentID, position, isFlying); |
536 | } | 545 | } |
537 | 546 | ||
538 | public bool PrimCrossToNeighboringRegion(ulong regionhandle, LLUUID primID, LLVector3 position, bool isPhysical) | 547 | public bool PrimCrossToNeighboringRegion(ulong regionhandle, LLUUID primID, string objData) |
539 | { | 548 | { |
540 | return m_commsProvider.InterRegion.ExpectPrimCrossing(regionhandle, primID, position, isPhysical); | 549 | return m_commsProvider.InterRegion.InformRegionOfPrimCrossing(regionhandle, primID, objData); |
541 | } | 550 | } |
542 | 551 | ||
543 | 552 | ||
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 2917056..05b9014 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs | |||
@@ -126,23 +126,11 @@ namespace OpenSim.Region.Environment.Scenes | |||
126 | set | 126 | set |
127 | { | 127 | { |
128 | LLVector3 val = value; | 128 | LLVector3 val = value; |
129 | if (val.X > 255.6f) | 129 | if (val.X > 255.6f || val.X < 0.4f || val.Y > 255.6f || val.Y < 0.4f) |
130 | { | 130 | { |
131 | val.X = 255.6f; | 131 | m_scene.CrossPrimGroupIntoNewRegion(val, this); |
132 | } | ||
133 | else if (val.X < 0.4f) | ||
134 | { | ||
135 | val.X = 0.4f; | ||
136 | } | ||
137 | |||
138 | if (val.Y > 255.6f) | ||
139 | { | ||
140 | val.Y = 255.6f; | ||
141 | } | ||
142 | else if (val.Y < 0.4f) | ||
143 | { | ||
144 | val.Y = 0.4f; | ||
145 | } | 132 | } |
133 | |||
146 | 134 | ||
147 | lock (m_parts) | 135 | lock (m_parts) |
148 | { | 136 | { |
@@ -1378,6 +1366,11 @@ namespace OpenSim.Region.Environment.Scenes | |||
1378 | ScheduleGroupForTerseUpdate(); | 1366 | ScheduleGroupForTerseUpdate(); |
1379 | } | 1367 | } |
1380 | 1368 | ||
1369 | public void OffsetForNewRegion(LLVector3 offset) | ||
1370 | { | ||
1371 | m_rootPart.GroupPosition = offset; | ||
1372 | } | ||
1373 | |||
1381 | #endregion | 1374 | #endregion |
1382 | 1375 | ||
1383 | #region Rotation | 1376 | #region Rotation |
diff --git a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs index 3b4deaf..6d911f1 100644 --- a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs +++ b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs | |||
@@ -123,6 +123,33 @@ namespace OpenSim.Region.Environment.Scenes | |||
123 | file.Close(); | 123 | file.Close(); |
124 | } | 124 | } |
125 | 125 | ||
126 | public string SavePrimGroupToXML2String(SceneObjectGroup grp) | ||
127 | { | ||
128 | string returnstring = ""; | ||
129 | returnstring += "<scene>\n"; | ||
130 | returnstring += grp.ToXmlString2(); | ||
131 | returnstring += "</scene>\n"; | ||
132 | return returnstring; | ||
133 | |||
134 | } | ||
135 | |||
136 | public void LoadGroupFromXml2String(string xmlString) | ||
137 | { | ||
138 | XmlDocument doc = new XmlDocument(); | ||
139 | XmlNode rootNode; | ||
140 | |||
141 | XmlTextReader reader = new XmlTextReader(new StringReader(xmlString)); | ||
142 | reader.WhitespaceHandling = WhitespaceHandling.None; | ||
143 | doc.Load(reader); | ||
144 | reader.Close(); | ||
145 | rootNode = doc.FirstChild; | ||
146 | foreach (XmlNode aPrimNode in rootNode.ChildNodes) | ||
147 | { | ||
148 | CreatePrimFromXml(aPrimNode.OuterXml); | ||
149 | } | ||
150 | |||
151 | } | ||
152 | |||
126 | public void LoadPrimsFromXml2(string fileName) | 153 | public void LoadPrimsFromXml2(string fileName) |
127 | { | 154 | { |
128 | XmlDocument doc = new XmlDocument(); | 155 | XmlDocument doc = new XmlDocument(); |