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