diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Land/PhysicsCombiner.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Land/PhysicsCombiner.cs | 379 |
1 files changed, 379 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/World/Land/PhysicsCombiner.cs b/OpenSim/Region/CoreModules/World/Land/PhysicsCombiner.cs new file mode 100644 index 0000000..3a4a17b --- /dev/null +++ b/OpenSim/Region/CoreModules/World/Land/PhysicsCombiner.cs | |||
@@ -0,0 +1,379 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Reflection; | ||
4 | using log4net; | ||
5 | using Nini.Config; | ||
6 | using OpenMetaverse; | ||
7 | using OpenSim.Framework; | ||
8 | using OpenSim.Region.Framework.Interfaces; | ||
9 | using OpenSim.Region.Framework.Scenes; | ||
10 | |||
11 | namespace OpenSim.Region.CoreModules.World.Land | ||
12 | { | ||
13 | public class PhysicsCombiner : ISharedRegionModule | ||
14 | { | ||
15 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
16 | |||
17 | public string Name { get { return "PhysicsCombiner";} } | ||
18 | public Type ReplaceableInterface | ||
19 | { | ||
20 | get { return null; } | ||
21 | } | ||
22 | |||
23 | public Type ReplacableInterface { get { return null; } } | ||
24 | |||
25 | private Dictionary<UUID, RegionConnections> m_regions = new Dictionary<UUID, RegionConnections>(); | ||
26 | private bool enabledYN = true; | ||
27 | public void Initialise(IConfigSource source) | ||
28 | { | ||
29 | |||
30 | } | ||
31 | |||
32 | public void Close() | ||
33 | { | ||
34 | |||
35 | } | ||
36 | |||
37 | public void AddRegion(Scene scene) | ||
38 | { | ||
39 | if (!enabledYN) | ||
40 | return; | ||
41 | |||
42 | RegionConnections regionConnections = new RegionConnections(); | ||
43 | regionConnections.ConnectedRegions = new List<RegionData>(); | ||
44 | regionConnections.RegionScene = scene; | ||
45 | regionConnections.RegionId = scene.RegionInfo.originRegionID; | ||
46 | regionConnections.X = scene.RegionInfo.RegionLocX; | ||
47 | regionConnections.Y = scene.RegionInfo.RegionLocY; | ||
48 | regionConnections.XEnd = (int)Constants.RegionSize; | ||
49 | regionConnections.YEnd = (int)Constants.RegionSize; | ||
50 | lock (m_regions) | ||
51 | { | ||
52 | bool connectedYN = false; | ||
53 | |||
54 | foreach (RegionConnections conn in m_regions.Values) | ||
55 | { | ||
56 | #region commented | ||
57 | /* | ||
58 | // If we're one region over +x +y | ||
59 | //xxy | ||
60 | //xxx | ||
61 | //xxx | ||
62 | if ((((int)conn.X * (int)Constants.RegionSize) + conn.XEnd | ||
63 | == (regionConnections.X * (int)Constants.RegionSize)) | ||
64 | && (((int)conn.Y * (int)Constants.RegionSize) - conn.YEnd | ||
65 | == (regionConnections.Y * (int)Constants.RegionSize))) | ||
66 | { | ||
67 | Vector3 offset = Vector3.Zero; | ||
68 | offset.X = (((regionConnections.X * (int) Constants.RegionSize)) - | ||
69 | ((conn.X * (int) Constants.RegionSize))); | ||
70 | offset.Y = (((regionConnections.Y * (int) Constants.RegionSize)) - | ||
71 | ((conn.Y * (int) Constants.RegionSize))); | ||
72 | |||
73 | Vector3 extents = Vector3.Zero; | ||
74 | extents.Y = regionConnections.YEnd + conn.YEnd; | ||
75 | extents.X = conn.XEnd + conn.XEnd; | ||
76 | |||
77 | m_log.DebugFormat("Scene: {0} to the northwest of Scene{1}. Offset: {2}. Extents:{3}", | ||
78 | conn.RegionScene.RegionInfo.RegionName, | ||
79 | regionConnections.RegionScene.RegionInfo.RegionName, | ||
80 | offset, extents); | ||
81 | |||
82 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents); | ||
83 | |||
84 | connectedYN = true; | ||
85 | break; | ||
86 | } | ||
87 | */ | ||
88 | |||
89 | /* | ||
90 | //If we're one region over x +y | ||
91 | //xxx | ||
92 | //xxx | ||
93 | //xyx | ||
94 | if ((((int)conn.X * (int)Constants.RegionSize) | ||
95 | == (regionConnections.X * (int)Constants.RegionSize)) | ||
96 | && (((int)conn.Y * (int)Constants.RegionSize) - conn.YEnd | ||
97 | == (regionConnections.Y * (int)Constants.RegionSize))) | ||
98 | { | ||
99 | Vector3 offset = Vector3.Zero; | ||
100 | offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - | ||
101 | ((conn.X * (int)Constants.RegionSize))); | ||
102 | offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - | ||
103 | ((conn.Y * (int)Constants.RegionSize))); | ||
104 | |||
105 | Vector3 extents = Vector3.Zero; | ||
106 | extents.Y = regionConnections.YEnd + conn.YEnd; | ||
107 | extents.X = conn.XEnd; | ||
108 | |||
109 | m_log.DebugFormat("Scene: {0} to the north of Scene{1}. Offset: {2}. Extents:{3}", | ||
110 | conn.RegionScene.RegionInfo.RegionName, | ||
111 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); | ||
112 | |||
113 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents); | ||
114 | connectedYN = true; | ||
115 | break; | ||
116 | } | ||
117 | */ | ||
118 | |||
119 | /* | ||
120 | // If we're one region over -x +y | ||
121 | //xxx | ||
122 | //xxx | ||
123 | //yxx | ||
124 | if ((((int)conn.X * (int)Constants.RegionSize) - conn.XEnd | ||
125 | == (regionConnections.X * (int)Constants.RegionSize)) | ||
126 | && (((int)conn.Y * (int)Constants.RegionSize) - conn.YEnd | ||
127 | == (regionConnections.Y * (int)Constants.RegionSize))) | ||
128 | { | ||
129 | Vector3 offset = Vector3.Zero; | ||
130 | offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - | ||
131 | ((conn.X * (int)Constants.RegionSize))); | ||
132 | offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - | ||
133 | ((conn.Y * (int)Constants.RegionSize))); | ||
134 | |||
135 | Vector3 extents = Vector3.Zero; | ||
136 | extents.Y = regionConnections.YEnd + conn.YEnd; | ||
137 | extents.X = conn.XEnd + conn.XEnd; | ||
138 | |||
139 | m_log.DebugFormat("Scene: {0} to the northeast of Scene. Offset: {2}. Extents:{3}", | ||
140 | conn.RegionScene.RegionInfo.RegionName, | ||
141 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); | ||
142 | |||
143 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents); | ||
144 | |||
145 | |||
146 | connectedYN = true; | ||
147 | break; | ||
148 | } | ||
149 | */ | ||
150 | |||
151 | /* | ||
152 | // If we're one region over -x y | ||
153 | //xxx | ||
154 | //yxx | ||
155 | //xxx | ||
156 | if ((((int)conn.X * (int)Constants.RegionSize) - conn.XEnd | ||
157 | == (regionConnections.X * (int)Constants.RegionSize)) | ||
158 | && (((int)conn.Y * (int)Constants.RegionSize) | ||
159 | == (regionConnections.Y * (int)Constants.RegionSize))) | ||
160 | { | ||
161 | Vector3 offset = Vector3.Zero; | ||
162 | offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - | ||
163 | ((conn.X * (int)Constants.RegionSize))); | ||
164 | offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - | ||
165 | ((conn.Y * (int)Constants.RegionSize))); | ||
166 | |||
167 | Vector3 extents = Vector3.Zero; | ||
168 | extents.Y = regionConnections.YEnd; | ||
169 | extents.X = conn.XEnd + conn.XEnd; | ||
170 | |||
171 | m_log.DebugFormat("Scene: {0} to the east of Scene{1} Offset: {2}. Extents:{3}", | ||
172 | conn.RegionScene.RegionInfo.RegionName, | ||
173 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); | ||
174 | |||
175 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents); | ||
176 | |||
177 | connectedYN = true; | ||
178 | break; | ||
179 | } | ||
180 | */ | ||
181 | |||
182 | /* | ||
183 | // If we're one region over -x -y | ||
184 | //yxx | ||
185 | //xxx | ||
186 | //xxx | ||
187 | if ((((int)conn.X * (int)Constants.RegionSize) - conn.XEnd | ||
188 | == (regionConnections.X * (int)Constants.RegionSize)) | ||
189 | && (((int)conn.Y * (int)Constants.RegionSize) + conn.YEnd | ||
190 | == (regionConnections.Y * (int)Constants.RegionSize))) | ||
191 | { | ||
192 | Vector3 offset = Vector3.Zero; | ||
193 | offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - | ||
194 | ((conn.X * (int)Constants.RegionSize))); | ||
195 | offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - | ||
196 | ((conn.Y * (int)Constants.RegionSize))); | ||
197 | |||
198 | Vector3 extents = Vector3.Zero; | ||
199 | extents.Y = regionConnections.YEnd + conn.YEnd; | ||
200 | extents.X = conn.XEnd + conn.XEnd; | ||
201 | |||
202 | m_log.DebugFormat("Scene: {0} to the northeast of Scene{1} Offset: {2}. Extents:{3}", | ||
203 | conn.RegionScene.RegionInfo.RegionName, | ||
204 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); | ||
205 | |||
206 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents); | ||
207 | |||
208 | connectedYN = true; | ||
209 | break; | ||
210 | } | ||
211 | */ | ||
212 | #endregion | ||
213 | |||
214 | // If we're one region over +x y | ||
215 | //xxx | ||
216 | //xxy | ||
217 | //xxx | ||
218 | if ((((int)conn.X * (int)Constants.RegionSize) + conn.XEnd | ||
219 | == (regionConnections.X * (int)Constants.RegionSize)) | ||
220 | && (((int)conn.Y * (int)Constants.RegionSize) | ||
221 | == (regionConnections.Y * (int)Constants.RegionSize))) | ||
222 | { | ||
223 | Vector3 offset = Vector3.Zero; | ||
224 | offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - | ||
225 | ((conn.X * (int)Constants.RegionSize))); | ||
226 | offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - | ||
227 | ((conn.Y * (int)Constants.RegionSize))); | ||
228 | |||
229 | Vector3 extents = Vector3.Zero; | ||
230 | extents.Y = conn.YEnd; | ||
231 | extents.X = conn.XEnd + regionConnections.XEnd; | ||
232 | |||
233 | conn.UpdateExtents(extents); | ||
234 | |||
235 | |||
236 | m_log.DebugFormat("Scene: {0} to the west of Scene{1} Offset: {2}. Extents:{3}", | ||
237 | conn.RegionScene.RegionInfo.RegionName, | ||
238 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); | ||
239 | |||
240 | conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); | ||
241 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); | ||
242 | |||
243 | conn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; | ||
244 | conn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
245 | conn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
246 | |||
247 | scene.WestBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport West | ||
248 | |||
249 | // Reset Terrain.. since terrain normally loads first. | ||
250 | // | ||
251 | scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); | ||
252 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); | ||
253 | |||
254 | connectedYN = true; | ||
255 | break; | ||
256 | } | ||
257 | |||
258 | |||
259 | |||
260 | // If we're one region over x +y | ||
261 | //xyx | ||
262 | //xxx | ||
263 | //xxx | ||
264 | if ((((int)conn.X * (int)Constants.RegionSize) | ||
265 | == (regionConnections.X * (int)Constants.RegionSize)) | ||
266 | && (((int)conn.Y * (int)Constants.RegionSize) + conn.YEnd | ||
267 | == (regionConnections.Y * (int)Constants.RegionSize))) | ||
268 | { | ||
269 | Vector3 offset = Vector3.Zero; | ||
270 | offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - | ||
271 | ((conn.X * (int)Constants.RegionSize))); | ||
272 | offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - | ||
273 | ((conn.Y * (int)Constants.RegionSize))); | ||
274 | |||
275 | Vector3 extents = Vector3.Zero; | ||
276 | extents.Y = regionConnections.YEnd + conn.YEnd; | ||
277 | extents.X = conn.XEnd; | ||
278 | conn.UpdateExtents(extents); | ||
279 | |||
280 | m_log.DebugFormat("Scene: {0} to the northeast of Scene{1} Offset: {2}. Extents:{3}", | ||
281 | conn.RegionScene.RegionInfo.RegionName, | ||
282 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); | ||
283 | conn.RegionScene.PhysicsScene.Combine(null,Vector3.Zero,extents); | ||
284 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); | ||
285 | |||
286 | conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; | ||
287 | conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
288 | conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
289 | |||
290 | scene.SouthBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport south | ||
291 | |||
292 | // Reset Terrain.. since terrain normally loads first. | ||
293 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); | ||
294 | scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); | ||
295 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); | ||
296 | |||
297 | connectedYN = true; | ||
298 | break; | ||
299 | } | ||
300 | |||
301 | // If we're one region over +x +y | ||
302 | //xxy | ||
303 | //xxx | ||
304 | //xxx | ||
305 | if ((((int)conn.X * (int)Constants.RegionSize) + conn.YEnd | ||
306 | == (regionConnections.X * (int)Constants.RegionSize)) | ||
307 | && (((int)conn.Y * (int)Constants.RegionSize) + conn.YEnd | ||
308 | == (regionConnections.Y * (int)Constants.RegionSize))) | ||
309 | { | ||
310 | Vector3 offset = Vector3.Zero; | ||
311 | offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - | ||
312 | ((conn.X * (int)Constants.RegionSize))); | ||
313 | offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - | ||
314 | ((conn.Y * (int)Constants.RegionSize))); | ||
315 | |||
316 | Vector3 extents = Vector3.Zero; | ||
317 | extents.Y = regionConnections.YEnd + conn.YEnd; | ||
318 | extents.X = conn.XEnd + conn.XEnd; | ||
319 | |||
320 | m_log.DebugFormat("Scene: {0} to the south of Scene{1} Offset: {2}. Extents:{3}", | ||
321 | conn.RegionScene.RegionInfo.RegionName, | ||
322 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); | ||
323 | |||
324 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset,extents); | ||
325 | |||
326 | break; | ||
327 | } | ||
328 | |||
329 | |||
330 | } | ||
331 | if (!connectedYN) | ||
332 | m_regions.Add(scene.RegionInfo.originRegionID,regionConnections); | ||
333 | } | ||
334 | } | ||
335 | |||
336 | public void RemoveRegion(Scene scene) | ||
337 | { | ||
338 | |||
339 | } | ||
340 | |||
341 | public void RegionLoaded(Scene scene) | ||
342 | { | ||
343 | |||
344 | } | ||
345 | |||
346 | public void PostInitialise() | ||
347 | { | ||
348 | |||
349 | } | ||
350 | public void OnFrame() | ||
351 | { | ||
352 | |||
353 | } | ||
354 | } | ||
355 | |||
356 | public class RegionConnections | ||
357 | { | ||
358 | public UUID RegionId; | ||
359 | public Scene RegionScene; | ||
360 | public uint X; | ||
361 | public uint Y; | ||
362 | public int XEnd; | ||
363 | public int YEnd; | ||
364 | public List<RegionData> ConnectedRegions; | ||
365 | public void UpdateExtents(Vector3 extents) | ||
366 | { | ||
367 | XEnd = (int)extents.X; | ||
368 | YEnd = (int)extents.Y; | ||
369 | } | ||
370 | |||
371 | } | ||
372 | |||
373 | public struct RegionData | ||
374 | { | ||
375 | public UUID RegionId; | ||
376 | public Scene RegionScene; | ||
377 | public Vector3 Offset; | ||
378 | } | ||
379 | } | ||