diff options
author | MW | 2007-11-03 19:14:22 +0000 |
---|---|---|
committer | MW | 2007-11-03 19:14:22 +0000 |
commit | dabbdec2cdf2c1056e4ebb8aec38302a1fa9eba4 (patch) | |
tree | ee886c072810521bd56b7124d53e093a8bc9cbf8 | |
parent | tiny commit to prepare for the first proper part of Scene.cs refactoring. (diff) | |
download | opensim-SC_OLD-dabbdec2cdf2c1056e4ebb8aec38302a1fa9eba4.zip opensim-SC_OLD-dabbdec2cdf2c1056e4ebb8aec38302a1fa9eba4.tar.gz opensim-SC_OLD-dabbdec2cdf2c1056e4ebb8aec38302a1fa9eba4.tar.bz2 opensim-SC_OLD-dabbdec2cdf2c1056e4ebb8aec38302a1fa9eba4.tar.xz |
First part of Scene refactoring:
Started the move of some of the methods from scene into a inner class (currently called InnerScene.cs), the idea being that the code related to the 3d scene (primitive/entities/Avatars etc) will be in this inner class, then what is now Scene.cs will be left as a kind of wrapper class around it. And once the spilt is complete can be renamed to something like RegionInstance (or any name that sounds good and ids it as the Region layer class that "has" a scene).
Added SceneCommunicationService which at the moment is a kind of high level wrapper around commsManager. The idea being that it has a higher level API for the Region/Scene to send messages to the other regions on the grid. a Example of the API is that instead of having sendXmessage methods, it has more functional level method like PassAvatarToNeighbour. Hopefully this will allow more freedom to do changes in communications that doesn't break other things.
-rw-r--r-- | OpenSim/Region/Application/OpenSimMain.cs | 3 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/InnerScene.cs | 657 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs | 367 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.cs | 583 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneBase.cs | 5 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs | 212 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneObjectPart.cs | 1 | ||||
-rw-r--r-- | OpenSim/Region/Examples/SimpleApp/MyWorld.cs | 4 | ||||
-rw-r--r-- | OpenSim/Region/Examples/SimpleApp/Program.cs | 3 |
9 files changed, 1075 insertions, 760 deletions
diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index e9151b5..b8a8f42 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs | |||
@@ -370,8 +370,9 @@ namespace OpenSim | |||
370 | protected override Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager, | 370 | protected override Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager, |
371 | AgentCircuitManager circuitManager) | 371 | AgentCircuitManager circuitManager) |
372 | { | 372 | { |
373 | SceneCommunicationService sceneGridService = new SceneCommunicationService(m_commsManager); | ||
373 | return | 374 | return |
374 | new Scene(regionInfo, circuitManager, m_commsManager, m_assetCache, storageManager, m_httpServer, | 375 | new Scene(regionInfo, circuitManager, m_commsManager, sceneGridService, m_assetCache, storageManager, m_httpServer, |
375 | m_moduleLoader, m_dumpAssetsToFile); | 376 | m_moduleLoader, m_dumpAssetsToFile); |
376 | } | 377 | } |
377 | 378 | ||
diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs new file mode 100644 index 0000000..325153f --- /dev/null +++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs | |||
@@ -0,0 +1,657 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using libsecondlife; | ||
5 | using libsecondlife.Packets; | ||
6 | using OpenSim.Framework; | ||
7 | using OpenSim.Framework.Console; | ||
8 | using OpenSim.Region.Environment.Types; | ||
9 | using OpenSim.Region.Physics.Manager; | ||
10 | |||
11 | namespace OpenSim.Region.Environment.Scenes | ||
12 | { | ||
13 | public class InnerScene | ||
14 | { | ||
15 | public Dictionary<LLUUID, ScenePresence> ScenePresences; | ||
16 | public Dictionary<LLUUID, SceneObjectGroup> SceneObjects; | ||
17 | public Dictionary<LLUUID, EntityBase> Entities; | ||
18 | |||
19 | public BasicQuadTreeNode QuadTree; | ||
20 | |||
21 | protected RegionInfo m_regInfo; | ||
22 | |||
23 | protected Scene m_parentScene; | ||
24 | public PhysicsScene PhyScene; | ||
25 | |||
26 | private PermissionManager PermissionsMngr; | ||
27 | |||
28 | public InnerScene(Scene parent, RegionInfo regInfo, PermissionManager permissionsMngr) | ||
29 | { | ||
30 | m_parentScene = parent; | ||
31 | m_regInfo = regInfo; | ||
32 | PermissionsMngr = permissionsMngr; | ||
33 | QuadTree = new BasicQuadTreeNode(null, "/0/", 0, 0, 256, 256); | ||
34 | QuadTree.Subdivide(); | ||
35 | QuadTree.Subdivide(); | ||
36 | } | ||
37 | |||
38 | public void Close() | ||
39 | { | ||
40 | ScenePresences.Clear(); | ||
41 | SceneObjects.Clear(); | ||
42 | Entities.Clear(); | ||
43 | } | ||
44 | |||
45 | public void AddEntityFromStorage(SceneObjectGroup sceneObject) | ||
46 | { | ||
47 | sceneObject.RegionHandle = m_regInfo.RegionHandle; | ||
48 | sceneObject.SetScene(m_parentScene); | ||
49 | foreach (SceneObjectPart part in sceneObject.Children.Values) | ||
50 | { | ||
51 | part.LocalID = m_parentScene.PrimIDAllocate(); | ||
52 | } | ||
53 | sceneObject.UpdateParentIDs(); | ||
54 | AddEntity(sceneObject); | ||
55 | } | ||
56 | |||
57 | public void AddEntity(SceneObjectGroup sceneObject) | ||
58 | { | ||
59 | if (!Entities.ContainsKey(sceneObject.UUID)) | ||
60 | { | ||
61 | // QuadTree.AddObject(sceneObject); | ||
62 | Entities.Add(sceneObject.UUID, sceneObject); | ||
63 | } | ||
64 | } | ||
65 | |||
66 | public void RemovePrim(uint localID, LLUUID avatar_deleter) | ||
67 | { | ||
68 | foreach (EntityBase obj in Entities.Values) | ||
69 | { | ||
70 | if (obj is SceneObjectGroup) | ||
71 | { | ||
72 | if (((SceneObjectGroup)obj).LocalId == localID) | ||
73 | { | ||
74 | m_parentScene.RemoveEntity((SceneObjectGroup)obj); | ||
75 | return; | ||
76 | } | ||
77 | } | ||
78 | } | ||
79 | } | ||
80 | |||
81 | public ScenePresence CreateAndAddScenePresence(IClientAPI client, bool child, AvatarWearable[] wearables, byte[] visualParams) | ||
82 | { | ||
83 | ScenePresence newAvatar = null; | ||
84 | |||
85 | newAvatar = new ScenePresence(client, m_parentScene, m_regInfo, visualParams, wearables); | ||
86 | newAvatar.IsChildAgent = child; | ||
87 | |||
88 | if (child) | ||
89 | { | ||
90 | MainLog.Instance.Verbose("SCENE", m_regInfo.RegionName + ": Creating new child agent."); | ||
91 | } | ||
92 | else | ||
93 | { | ||
94 | //newAvatar.OnSignificantClientMovement += m_LandManager.handleSignificantClientMovement; | ||
95 | |||
96 | MainLog.Instance.Verbose("SCENE", m_regInfo.RegionName + ": Creating new root agent."); | ||
97 | MainLog.Instance.Verbose("SCENE", m_regInfo.RegionName + ": Adding Physical agent."); | ||
98 | |||
99 | newAvatar.AddToPhysicalScene(); | ||
100 | } | ||
101 | |||
102 | lock (Entities) | ||
103 | { | ||
104 | if (!Entities.ContainsKey(client.AgentId)) | ||
105 | { | ||
106 | Entities.Add(client.AgentId, newAvatar); | ||
107 | } | ||
108 | else | ||
109 | { | ||
110 | Entities[client.AgentId] = newAvatar; | ||
111 | } | ||
112 | } | ||
113 | lock (ScenePresences) | ||
114 | { | ||
115 | if (ScenePresences.ContainsKey(client.AgentId)) | ||
116 | { | ||
117 | ScenePresences[client.AgentId] = newAvatar; | ||
118 | } | ||
119 | else | ||
120 | { | ||
121 | ScenePresences.Add(client.AgentId, newAvatar); | ||
122 | } | ||
123 | } | ||
124 | |||
125 | return newAvatar; | ||
126 | } | ||
127 | |||
128 | /// <summary> | ||
129 | /// Request a List of all m_scenePresences in this World | ||
130 | /// </summary> | ||
131 | /// <returns></returns> | ||
132 | public List<ScenePresence> GetScenePresences() | ||
133 | { | ||
134 | List<ScenePresence> result = new List<ScenePresence>(ScenePresences.Values); | ||
135 | |||
136 | return result; | ||
137 | } | ||
138 | |||
139 | public List<ScenePresence> GetAvatars() | ||
140 | { | ||
141 | List<ScenePresence> result = | ||
142 | GetScenePresences(delegate(ScenePresence scenePresence) { return !scenePresence.IsChildAgent; }); | ||
143 | |||
144 | return result; | ||
145 | } | ||
146 | |||
147 | /// <summary> | ||
148 | /// Request a filtered list of m_scenePresences in this World | ||
149 | /// </summary> | ||
150 | /// <returns></returns> | ||
151 | public List<ScenePresence> GetScenePresences(FilterAvatarList filter) | ||
152 | { | ||
153 | List<ScenePresence> result = new List<ScenePresence>(); | ||
154 | |||
155 | foreach (ScenePresence avatar in ScenePresences.Values) | ||
156 | { | ||
157 | if (filter(avatar)) | ||
158 | { | ||
159 | result.Add(avatar); | ||
160 | } | ||
161 | } | ||
162 | |||
163 | return result; | ||
164 | } | ||
165 | |||
166 | /// <summary> | ||
167 | /// Request a Avatar by UUID | ||
168 | /// </summary> | ||
169 | /// <param name="avatarID"></param> | ||
170 | /// <returns></returns> | ||
171 | public ScenePresence GetScenePresence(LLUUID avatarID) | ||
172 | { | ||
173 | if (ScenePresences.ContainsKey(avatarID)) | ||
174 | { | ||
175 | return ScenePresences[avatarID]; | ||
176 | } | ||
177 | return null; | ||
178 | } | ||
179 | |||
180 | |||
181 | public LLUUID ConvertLocalIDToFullID(uint localID) | ||
182 | { | ||
183 | bool hasPrim = false; | ||
184 | foreach (EntityBase ent in Entities.Values) | ||
185 | { | ||
186 | if (ent is SceneObjectGroup) | ||
187 | { | ||
188 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); | ||
189 | if (hasPrim != false) | ||
190 | { | ||
191 | return ((SceneObjectGroup)ent).GetPartsFullID(localID); | ||
192 | } | ||
193 | } | ||
194 | } | ||
195 | return LLUUID.Zero; | ||
196 | } | ||
197 | |||
198 | public void SendAllSceneObjectsToClient(ScenePresence presence) | ||
199 | { | ||
200 | foreach (EntityBase ent in Entities.Values) | ||
201 | { | ||
202 | if (ent is SceneObjectGroup) | ||
203 | { | ||
204 | ((SceneObjectGroup)ent).ScheduleFullUpdateToAvatar(presence); | ||
205 | } | ||
206 | } | ||
207 | } | ||
208 | |||
209 | public SceneObjectPart GetSceneObjectPart(uint localID) | ||
210 | { | ||
211 | bool hasPrim = false; | ||
212 | foreach (EntityBase ent in Entities.Values) | ||
213 | { | ||
214 | if (ent is SceneObjectGroup) | ||
215 | { | ||
216 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); | ||
217 | if (hasPrim != false) | ||
218 | { | ||
219 | return ((SceneObjectGroup)ent).GetChildPart(localID); | ||
220 | } | ||
221 | } | ||
222 | } | ||
223 | return null; | ||
224 | } | ||
225 | |||
226 | public SceneObjectPart GetSceneObjectPart(LLUUID fullID) | ||
227 | { | ||
228 | bool hasPrim = false; | ||
229 | foreach (EntityBase ent in Entities.Values) | ||
230 | { | ||
231 | if (ent is SceneObjectGroup) | ||
232 | { | ||
233 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(fullID); | ||
234 | if (hasPrim != false) | ||
235 | { | ||
236 | return ((SceneObjectGroup)ent).GetChildPart(fullID); | ||
237 | } | ||
238 | } | ||
239 | } | ||
240 | return null; | ||
241 | } | ||
242 | |||
243 | internal bool TryGetAvatar(LLUUID avatarId, out ScenePresence avatar) | ||
244 | { | ||
245 | ScenePresence presence; | ||
246 | if (ScenePresences.TryGetValue(avatarId, out presence)) | ||
247 | { | ||
248 | if (!presence.IsChildAgent) | ||
249 | { | ||
250 | avatar = presence; | ||
251 | return true; | ||
252 | } | ||
253 | } | ||
254 | |||
255 | avatar = null; | ||
256 | return false; | ||
257 | } | ||
258 | |||
259 | internal bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) | ||
260 | { | ||
261 | foreach (ScenePresence presence in ScenePresences.Values) | ||
262 | { | ||
263 | if (!presence.IsChildAgent) | ||
264 | { | ||
265 | string name = presence.ControllingClient.FirstName + " " + presence.ControllingClient.LastName; | ||
266 | |||
267 | if (String.Compare(avatarName, name, true) == 0) | ||
268 | { | ||
269 | avatar = presence; | ||
270 | return true; | ||
271 | } | ||
272 | } | ||
273 | } | ||
274 | |||
275 | avatar = null; | ||
276 | return false; | ||
277 | } | ||
278 | |||
279 | |||
280 | internal void ForEachClient(Action<IClientAPI> action) | ||
281 | { | ||
282 | foreach (ScenePresence presence in ScenePresences.Values) | ||
283 | { | ||
284 | action(presence.ControllingClient); | ||
285 | } | ||
286 | } | ||
287 | |||
288 | #region Client Event handlers | ||
289 | /// <summary> | ||
290 | /// | ||
291 | /// </summary> | ||
292 | /// <param name="localID"></param> | ||
293 | /// <param name="scale"></param> | ||
294 | /// <param name="remoteClient"></param> | ||
295 | public void UpdatePrimScale(uint localID, LLVector3 scale, IClientAPI remoteClient) | ||
296 | { | ||
297 | bool hasPrim = false; | ||
298 | foreach (EntityBase ent in Entities.Values) | ||
299 | { | ||
300 | if (ent is SceneObjectGroup) | ||
301 | { | ||
302 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); | ||
303 | if (hasPrim != false) | ||
304 | { | ||
305 | ((SceneObjectGroup)ent).Resize(scale, localID); | ||
306 | break; | ||
307 | } | ||
308 | } | ||
309 | } | ||
310 | } | ||
311 | |||
312 | |||
313 | /// <summary> | ||
314 | /// | ||
315 | /// </summary> | ||
316 | /// <param name="localID"></param> | ||
317 | /// <param name="rot"></param> | ||
318 | /// <param name="remoteClient"></param> | ||
319 | public void UpdatePrimSingleRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient) | ||
320 | { | ||
321 | bool hasPrim = false; | ||
322 | foreach (EntityBase ent in Entities.Values) | ||
323 | { | ||
324 | if (ent is SceneObjectGroup) | ||
325 | { | ||
326 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); | ||
327 | if (hasPrim != false) | ||
328 | { | ||
329 | ((SceneObjectGroup)ent).UpdateSingleRotation(rot, localID); | ||
330 | break; | ||
331 | } | ||
332 | } | ||
333 | } | ||
334 | } | ||
335 | |||
336 | /// <summary> | ||
337 | /// | ||
338 | /// </summary> | ||
339 | /// <param name="localID"></param> | ||
340 | /// <param name="rot"></param> | ||
341 | /// <param name="remoteClient"></param> | ||
342 | public void UpdatePrimRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient) | ||
343 | { | ||
344 | bool hasPrim = false; | ||
345 | foreach (EntityBase ent in Entities.Values) | ||
346 | { | ||
347 | if (ent is SceneObjectGroup) | ||
348 | { | ||
349 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); | ||
350 | if (hasPrim != false) | ||
351 | { | ||
352 | ((SceneObjectGroup)ent).UpdateGroupRotation(rot); | ||
353 | break; | ||
354 | } | ||
355 | } | ||
356 | } | ||
357 | } | ||
358 | |||
359 | /// <summary> | ||
360 | /// | ||
361 | /// </summary> | ||
362 | /// <param name="localID"></param> | ||
363 | /// <param name="pos"></param> | ||
364 | /// <param name="rot"></param> | ||
365 | /// <param name="remoteClient"></param> | ||
366 | public void UpdatePrimRotation(uint localID, LLVector3 pos, LLQuaternion rot, IClientAPI remoteClient) | ||
367 | { | ||
368 | bool hasPrim = false; | ||
369 | foreach (EntityBase ent in Entities.Values) | ||
370 | { | ||
371 | if (ent is SceneObjectGroup) | ||
372 | { | ||
373 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); | ||
374 | if (hasPrim != false) | ||
375 | { | ||
376 | ((SceneObjectGroup)ent).UpdateGroupRotation(pos, rot); | ||
377 | break; | ||
378 | } | ||
379 | } | ||
380 | } | ||
381 | } | ||
382 | |||
383 | public void UpdatePrimSinglePosition(uint localID, LLVector3 pos, IClientAPI remoteClient) | ||
384 | { | ||
385 | bool hasPrim = false; | ||
386 | foreach (EntityBase ent in Entities.Values) | ||
387 | { | ||
388 | if (ent is SceneObjectGroup) | ||
389 | { | ||
390 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); | ||
391 | if (hasPrim != false) | ||
392 | { | ||
393 | ((SceneObjectGroup)ent).UpdateSinglePosition(pos, localID); | ||
394 | break; | ||
395 | } | ||
396 | } | ||
397 | } | ||
398 | } | ||
399 | |||
400 | |||
401 | /// <summary> | ||
402 | /// | ||
403 | /// </summary> | ||
404 | /// <param name="localID"></param> | ||
405 | /// <param name="pos"></param> | ||
406 | /// <param name="remoteClient"></param> | ||
407 | public void UpdatePrimPosition(uint localID, LLVector3 pos, IClientAPI remoteClient) | ||
408 | { | ||
409 | bool hasPrim = false; | ||
410 | foreach (EntityBase ent in Entities.Values) | ||
411 | { | ||
412 | if (ent is SceneObjectGroup) | ||
413 | { | ||
414 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); | ||
415 | if (hasPrim != false) | ||
416 | { | ||
417 | ((SceneObjectGroup)ent).UpdateGroupPosition(pos); | ||
418 | break; | ||
419 | } | ||
420 | } | ||
421 | } | ||
422 | } | ||
423 | |||
424 | /// <summary> | ||
425 | /// | ||
426 | /// </summary> | ||
427 | /// <param name="localID"></param> | ||
428 | /// <param name="texture"></param> | ||
429 | /// <param name="remoteClient"></param> | ||
430 | public void UpdatePrimTexture(uint localID, byte[] texture, IClientAPI remoteClient) | ||
431 | { | ||
432 | bool hasPrim = false; | ||
433 | foreach (EntityBase ent in Entities.Values) | ||
434 | { | ||
435 | if (ent is SceneObjectGroup) | ||
436 | { | ||
437 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); | ||
438 | if (hasPrim != false) | ||
439 | { | ||
440 | ((SceneObjectGroup)ent).UpdateTextureEntry(localID, texture); | ||
441 | break; | ||
442 | } | ||
443 | } | ||
444 | } | ||
445 | } | ||
446 | |||
447 | /// <summary> | ||
448 | /// | ||
449 | /// </summary> | ||
450 | /// <param name="localID"></param> | ||
451 | /// <param name="packet"></param> | ||
452 | /// <param name="remoteClient"></param> | ||
453 | public void UpdatePrimFlags(uint localID, Packet packet, IClientAPI remoteClient) | ||
454 | { | ||
455 | bool hasprim = false; | ||
456 | foreach (EntityBase ent in Entities.Values) | ||
457 | { | ||
458 | if (ent is SceneObjectGroup) | ||
459 | { | ||
460 | hasprim = ((SceneObjectGroup)ent).HasChildPrim(localID); | ||
461 | if (hasprim != false) | ||
462 | { | ||
463 | ((SceneObjectGroup)ent).UpdatePrimFlags(localID, (ushort)packet.Type, true, packet.ToBytes()); | ||
464 | } | ||
465 | } | ||
466 | } | ||
467 | |||
468 | //System.Console.WriteLine("Got primupdate packet: " + packet.UsePhysics.ToString()); | ||
469 | } | ||
470 | |||
471 | public void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) | ||
472 | { | ||
473 | if (PermissionsMngr.CanEditObject(remoteClient.AgentId, objectID)) | ||
474 | { | ||
475 | bool hasPrim = false; | ||
476 | foreach (EntityBase ent in Entities.Values) | ||
477 | { | ||
478 | if (ent is SceneObjectGroup) | ||
479 | { | ||
480 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(objectID); | ||
481 | if (hasPrim != false) | ||
482 | { | ||
483 | ((SceneObjectGroup)ent).GrabMovement(offset, pos, remoteClient); | ||
484 | break; | ||
485 | } | ||
486 | } | ||
487 | } | ||
488 | } | ||
489 | } | ||
490 | |||
491 | /// <summary> | ||
492 | /// | ||
493 | /// </summary> | ||
494 | /// <param name="primLocalID"></param> | ||
495 | /// <param name="description"></param> | ||
496 | public void PrimName(uint primLocalID, string name) | ||
497 | { | ||
498 | bool hasPrim = false; | ||
499 | foreach (EntityBase ent in Entities.Values) | ||
500 | { | ||
501 | if (ent is SceneObjectGroup) | ||
502 | { | ||
503 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID); | ||
504 | if (hasPrim != false) | ||
505 | { | ||
506 | ((SceneObjectGroup)ent).SetPartName(name, primLocalID); | ||
507 | break; | ||
508 | } | ||
509 | } | ||
510 | } | ||
511 | } | ||
512 | |||
513 | /// <summary> | ||
514 | /// | ||
515 | /// </summary> | ||
516 | /// <param name="primLocalID"></param> | ||
517 | /// <param name="description"></param> | ||
518 | public void PrimDescription(uint primLocalID, string description) | ||
519 | { | ||
520 | bool hasPrim = false; | ||
521 | foreach (EntityBase ent in Entities.Values) | ||
522 | { | ||
523 | if (ent is SceneObjectGroup) | ||
524 | { | ||
525 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID); | ||
526 | if (hasPrim != false) | ||
527 | { | ||
528 | ((SceneObjectGroup)ent).SetPartDescription(description, primLocalID); | ||
529 | break; | ||
530 | } | ||
531 | } | ||
532 | } | ||
533 | } | ||
534 | |||
535 | public void UpdateExtraParam(uint primLocalID, ushort type, bool inUse, byte[] data) | ||
536 | { | ||
537 | bool hasPrim = false; | ||
538 | foreach (EntityBase ent in Entities.Values) | ||
539 | { | ||
540 | if (ent is SceneObjectGroup) | ||
541 | { | ||
542 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID); | ||
543 | if (hasPrim != false) | ||
544 | { | ||
545 | ((SceneObjectGroup)ent).UpdateExtraParam(primLocalID, type, inUse, data); | ||
546 | break; | ||
547 | } | ||
548 | } | ||
549 | } | ||
550 | } | ||
551 | |||
552 | /// <summary> | ||
553 | /// | ||
554 | /// </summary> | ||
555 | /// <param name="primLocalID"></param> | ||
556 | /// <param name="shapeBlock"></param> | ||
557 | public void UpdatePrimShape(uint primLocalID, ObjectShapePacket.ObjectDataBlock shapeBlock) | ||
558 | { | ||
559 | bool hasPrim = false; | ||
560 | foreach (EntityBase ent in Entities.Values) | ||
561 | { | ||
562 | if (ent is SceneObjectGroup) | ||
563 | { | ||
564 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID); | ||
565 | if (hasPrim != false) | ||
566 | { | ||
567 | ((SceneObjectGroup)ent).UpdateShape(shapeBlock, primLocalID); | ||
568 | break; | ||
569 | } | ||
570 | } | ||
571 | } | ||
572 | } | ||
573 | |||
574 | /// <summary> | ||
575 | /// | ||
576 | /// </summary> | ||
577 | /// <param name="parentPrim"></param> | ||
578 | /// <param name="childPrims"></param> | ||
579 | public void LinkObjects(uint parentPrim, List<uint> childPrims) | ||
580 | { | ||
581 | SceneObjectGroup parenPrim = null; | ||
582 | foreach (EntityBase ent in Entities.Values) | ||
583 | { | ||
584 | if (ent is SceneObjectGroup) | ||
585 | { | ||
586 | if (((SceneObjectGroup)ent).LocalId == parentPrim) | ||
587 | { | ||
588 | parenPrim = (SceneObjectGroup)ent; | ||
589 | break; | ||
590 | } | ||
591 | } | ||
592 | } | ||
593 | |||
594 | List<SceneObjectGroup> children = new List<SceneObjectGroup>(); | ||
595 | if (parenPrim != null) | ||
596 | { | ||
597 | for (int i = 0; i < childPrims.Count; i++) | ||
598 | { | ||
599 | foreach (EntityBase ent in Entities.Values) | ||
600 | { | ||
601 | if (ent is SceneObjectGroup) | ||
602 | { | ||
603 | if (((SceneObjectGroup)ent).LocalId == childPrims[i]) | ||
604 | { | ||
605 | children.Add((SceneObjectGroup)ent); | ||
606 | } | ||
607 | } | ||
608 | } | ||
609 | } | ||
610 | } | ||
611 | |||
612 | foreach (SceneObjectGroup sceneObj in children) | ||
613 | { | ||
614 | parenPrim.LinkToGroup(sceneObj); | ||
615 | } | ||
616 | } | ||
617 | |||
618 | /// <summary> | ||
619 | /// | ||
620 | /// </summary> | ||
621 | /// <param name="originalPrim"></param> | ||
622 | /// <param name="offset"></param> | ||
623 | /// <param name="flags"></param> | ||
624 | public void DuplicateObject(uint originalPrim, LLVector3 offset, uint flags) | ||
625 | { | ||
626 | SceneObjectGroup originPrim = null; | ||
627 | foreach (EntityBase ent in Entities.Values) | ||
628 | { | ||
629 | if (ent is SceneObjectGroup) | ||
630 | { | ||
631 | if (((SceneObjectGroup)ent).LocalId == originalPrim) | ||
632 | { | ||
633 | originPrim = (SceneObjectGroup)ent; | ||
634 | break; | ||
635 | } | ||
636 | } | ||
637 | } | ||
638 | |||
639 | if (originPrim != null) | ||
640 | { | ||
641 | SceneObjectGroup copy = originPrim.Copy(); | ||
642 | copy.AbsolutePosition = copy.AbsolutePosition + offset; | ||
643 | Entities.Add(copy.UUID, copy); | ||
644 | |||
645 | copy.ScheduleGroupForFullUpdate(); | ||
646 | |||
647 | } | ||
648 | else | ||
649 | { | ||
650 | MainLog.Instance.Warn("client", "Attempted to duplicate nonexistant prim"); | ||
651 | } | ||
652 | } | ||
653 | |||
654 | |||
655 | #endregion | ||
656 | } | ||
657 | } | ||
diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs index 73d317a..a9f6991 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs | |||
@@ -92,129 +92,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
92 | /// <summary> | 92 | /// <summary> |
93 | /// | 93 | /// |
94 | /// </summary> | 94 | /// </summary> |
95 | /// <param name="originalPrim"></param> | ||
96 | /// <param name="offset"></param> | ||
97 | /// <param name="flags"></param> | ||
98 | public void DuplicateObject(uint originalPrim, LLVector3 offset, uint flags) | ||
99 | { | ||
100 | SceneObjectGroup originPrim = null; | ||
101 | foreach (EntityBase ent in Entities.Values) | ||
102 | { | ||
103 | if (ent is SceneObjectGroup) | ||
104 | { | ||
105 | if (((SceneObjectGroup) ent).LocalId == originalPrim) | ||
106 | { | ||
107 | originPrim = (SceneObjectGroup) ent; | ||
108 | break; | ||
109 | } | ||
110 | } | ||
111 | } | ||
112 | |||
113 | if (originPrim != null) | ||
114 | { | ||
115 | SceneObjectGroup copy = originPrim.Copy(); | ||
116 | copy.AbsolutePosition = copy.AbsolutePosition + offset; | ||
117 | Entities.Add(copy.UUID, copy); | ||
118 | |||
119 | copy.ScheduleGroupForFullUpdate(); | ||
120 | /* List<ScenePresence> avatars = this.GetScenePresences(); | ||
121 | for (int i = 0; i < avatars.Count; i++) | ||
122 | { | ||
123 | // copy.SendAllChildPrimsToClient(avatars[i].ControllingClient); | ||
124 | }*/ | ||
125 | } | ||
126 | else | ||
127 | { | ||
128 | MainLog.Instance.Warn("client", "Attempted to duplicate nonexistant prim"); | ||
129 | } | ||
130 | } | ||
131 | |||
132 | /// <summary> | ||
133 | /// | ||
134 | /// </summary> | ||
135 | /// <param name="parentPrim"></param> | ||
136 | /// <param name="childPrims"></param> | ||
137 | public void LinkObjects(uint parentPrim, List<uint> childPrims) | ||
138 | { | ||
139 | SceneObjectGroup parenPrim = null; | ||
140 | foreach (EntityBase ent in Entities.Values) | ||
141 | { | ||
142 | if (ent is SceneObjectGroup) | ||
143 | { | ||
144 | if (((SceneObjectGroup) ent).LocalId == parentPrim) | ||
145 | { | ||
146 | parenPrim = (SceneObjectGroup) ent; | ||
147 | break; | ||
148 | } | ||
149 | } | ||
150 | } | ||
151 | |||
152 | List<SceneObjectGroup> children = new List<SceneObjectGroup>(); | ||
153 | if (parenPrim != null) | ||
154 | { | ||
155 | for (int i = 0; i < childPrims.Count; i++) | ||
156 | { | ||
157 | foreach (EntityBase ent in Entities.Values) | ||
158 | { | ||
159 | if (ent is SceneObjectGroup) | ||
160 | { | ||
161 | if (((SceneObjectGroup) ent).LocalId == childPrims[i]) | ||
162 | { | ||
163 | children.Add((SceneObjectGroup) ent); | ||
164 | } | ||
165 | } | ||
166 | } | ||
167 | } | ||
168 | } | ||
169 | |||
170 | foreach (SceneObjectGroup sceneObj in children) | ||
171 | { | ||
172 | parenPrim.LinkToGroup(sceneObj); | ||
173 | } | ||
174 | } | ||
175 | |||
176 | /// <summary> | ||
177 | /// | ||
178 | /// </summary> | ||
179 | /// <param name="primLocalID"></param> | ||
180 | /// <param name="shapeBlock"></param> | ||
181 | public void UpdatePrimShape(uint primLocalID, ObjectShapePacket.ObjectDataBlock shapeBlock) | ||
182 | { | ||
183 | bool hasPrim = false; | ||
184 | foreach (EntityBase ent in Entities.Values) | ||
185 | { | ||
186 | if (ent is SceneObjectGroup) | ||
187 | { | ||
188 | hasPrim = ((SceneObjectGroup) ent).HasChildPrim(primLocalID); | ||
189 | if (hasPrim != false) | ||
190 | { | ||
191 | ((SceneObjectGroup) ent).UpdateShape(shapeBlock, primLocalID); | ||
192 | break; | ||
193 | } | ||
194 | } | ||
195 | } | ||
196 | } | ||
197 | |||
198 | public void UpdateExtraParam(uint primLocalID, ushort type, bool inUse, byte[] data) | ||
199 | { | ||
200 | bool hasPrim = false; | ||
201 | foreach (EntityBase ent in Entities.Values) | ||
202 | { | ||
203 | if (ent is SceneObjectGroup) | ||
204 | { | ||
205 | hasPrim = ((SceneObjectGroup) ent).HasChildPrim(primLocalID); | ||
206 | if (hasPrim != false) | ||
207 | { | ||
208 | ((SceneObjectGroup) ent).UpdateExtraParam(primLocalID, type, inUse, data); | ||
209 | break; | ||
210 | } | ||
211 | } | ||
212 | } | ||
213 | } | ||
214 | |||
215 | /// <summary> | ||
216 | /// | ||
217 | /// </summary> | ||
218 | /// <param name="primLocalID"></param> | 95 | /// <param name="primLocalID"></param> |
219 | /// <param name="remoteClient"></param> | 96 | /// <param name="remoteClient"></param> |
220 | public void SelectPrim(uint primLocalID, IClientAPI remoteClient) | 97 | public void SelectPrim(uint primLocalID, IClientAPI remoteClient) |
@@ -255,250 +132,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
255 | } | 132 | } |
256 | } | 133 | } |
257 | 134 | ||
258 | /// <summary> | ||
259 | /// | ||
260 | /// </summary> | ||
261 | /// <param name="primLocalID"></param> | ||
262 | /// <param name="description"></param> | ||
263 | public void PrimDescription(uint primLocalID, string description) | ||
264 | { | ||
265 | bool hasPrim = false; | ||
266 | foreach (EntityBase ent in Entities.Values) | ||
267 | { | ||
268 | if (ent is SceneObjectGroup) | ||
269 | { | ||
270 | hasPrim = ((SceneObjectGroup) ent).HasChildPrim(primLocalID); | ||
271 | if (hasPrim != false) | ||
272 | { | ||
273 | ((SceneObjectGroup) ent).SetPartDescription(description, primLocalID); | ||
274 | break; | ||
275 | } | ||
276 | } | ||
277 | } | ||
278 | } | ||
279 | |||
280 | /// <summary> | ||
281 | /// | ||
282 | /// </summary> | ||
283 | /// <param name="primLocalID"></param> | ||
284 | /// <param name="description"></param> | ||
285 | public void PrimName(uint primLocalID, string name) | ||
286 | { | ||
287 | bool hasPrim = false; | ||
288 | foreach (EntityBase ent in Entities.Values) | ||
289 | { | ||
290 | if (ent is SceneObjectGroup) | ||
291 | { | ||
292 | hasPrim = ((SceneObjectGroup) ent).HasChildPrim(primLocalID); | ||
293 | if (hasPrim != false) | ||
294 | { | ||
295 | ((SceneObjectGroup) ent).SetPartName(name, primLocalID); | ||
296 | break; | ||
297 | } | ||
298 | } | ||
299 | } | ||
300 | } | ||
301 | |||
302 | public void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) | ||
303 | { | ||
304 | if (PermissionsMngr.CanEditObject(remoteClient.AgentId, objectID)) | ||
305 | { | ||
306 | bool hasPrim = false; | ||
307 | foreach (EntityBase ent in Entities.Values) | ||
308 | { | ||
309 | if (ent is SceneObjectGroup) | ||
310 | { | ||
311 | hasPrim = ((SceneObjectGroup) ent).HasChildPrim(objectID); | ||
312 | if (hasPrim != false) | ||
313 | { | ||
314 | ((SceneObjectGroup) ent).GrabMovement(offset, pos, remoteClient); | ||
315 | break; | ||
316 | } | ||
317 | } | ||
318 | } | ||
319 | } | ||
320 | } | ||
321 | |||
322 | /// <summary> | ||
323 | /// | ||
324 | /// </summary> | ||
325 | /// <param name="localID"></param> | ||
326 | /// <param name="packet"></param> | ||
327 | /// <param name="remoteClient"></param> | ||
328 | public void UpdatePrimFlags(uint localID, Packet packet, IClientAPI remoteClient) | ||
329 | { | ||
330 | bool hasprim = false; | ||
331 | foreach (EntityBase ent in Entities.Values) | ||
332 | { | ||
333 | if (ent is SceneObjectGroup) | ||
334 | { | ||
335 | hasprim = ((SceneObjectGroup) ent).HasChildPrim(localID); | ||
336 | if (hasprim != false) | ||
337 | { | ||
338 | ((SceneObjectGroup) ent).UpdatePrimFlags(localID, (ushort) packet.Type, true, packet.ToBytes()); | ||
339 | } | ||
340 | } | ||
341 | } | ||
342 | |||
343 | //System.Console.WriteLine("Got primupdate packet: " + packet.UsePhysics.ToString()); | ||
344 | } | ||
345 | |||
346 | /// <summary> | ||
347 | /// | ||
348 | /// </summary> | ||
349 | /// <param name="localID"></param> | ||
350 | /// <param name="texture"></param> | ||
351 | /// <param name="remoteClient"></param> | ||
352 | public void UpdatePrimTexture(uint localID, byte[] texture, IClientAPI remoteClient) | ||
353 | { | ||
354 | bool hasPrim = false; | ||
355 | foreach (EntityBase ent in Entities.Values) | ||
356 | { | ||
357 | if (ent is SceneObjectGroup) | ||
358 | { | ||
359 | hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID); | ||
360 | if (hasPrim != false) | ||
361 | { | ||
362 | ((SceneObjectGroup) ent).UpdateTextureEntry(localID, texture); | ||
363 | break; | ||
364 | } | ||
365 | } | ||
366 | } | ||
367 | } | ||
368 | |||
369 | /// <summary> | ||
370 | /// | ||
371 | /// </summary> | ||
372 | /// <param name="localID"></param> | ||
373 | /// <param name="pos"></param> | ||
374 | /// <param name="remoteClient"></param> | ||
375 | public void UpdatePrimPosition(uint localID, LLVector3 pos, IClientAPI remoteClient) | ||
376 | { | ||
377 | bool hasPrim = false; | ||
378 | foreach (EntityBase ent in Entities.Values) | ||
379 | { | ||
380 | if (ent is SceneObjectGroup) | ||
381 | { | ||
382 | hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID); | ||
383 | if (hasPrim != false) | ||
384 | { | ||
385 | ((SceneObjectGroup) ent).UpdateGroupPosition(pos); | ||
386 | break; | ||
387 | } | ||
388 | } | ||
389 | } | ||
390 | } | ||
391 | |||
392 | public void UpdatePrimSinglePosition(uint localID, LLVector3 pos, IClientAPI remoteClient) | ||
393 | { | ||
394 | bool hasPrim = false; | ||
395 | foreach (EntityBase ent in Entities.Values) | ||
396 | { | ||
397 | if (ent is SceneObjectGroup) | ||
398 | { | ||
399 | hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID); | ||
400 | if (hasPrim != false) | ||
401 | { | ||
402 | ((SceneObjectGroup) ent).UpdateSinglePosition(pos, localID); | ||
403 | break; | ||
404 | } | ||
405 | } | ||
406 | } | ||
407 | } | ||
408 | |||
409 | /// <summary> | ||
410 | /// | ||
411 | /// </summary> | ||
412 | /// <param name="localID"></param> | ||
413 | /// <param name="pos"></param> | ||
414 | /// <param name="rot"></param> | ||
415 | /// <param name="remoteClient"></param> | ||
416 | public void UpdatePrimRotation(uint localID, LLVector3 pos, LLQuaternion rot, IClientAPI remoteClient) | ||
417 | { | ||
418 | bool hasPrim = false; | ||
419 | foreach (EntityBase ent in Entities.Values) | ||
420 | { | ||
421 | if (ent is SceneObjectGroup) | ||
422 | { | ||
423 | hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID); | ||
424 | if (hasPrim != false) | ||
425 | { | ||
426 | ((SceneObjectGroup) ent).UpdateGroupRotation(pos, rot); | ||
427 | break; | ||
428 | } | ||
429 | } | ||
430 | } | ||
431 | } | ||
432 | |||
433 | /// <summary> | ||
434 | /// | ||
435 | /// </summary> | ||
436 | /// <param name="localID"></param> | ||
437 | /// <param name="rot"></param> | ||
438 | /// <param name="remoteClient"></param> | ||
439 | public void UpdatePrimRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient) | ||
440 | { | ||
441 | bool hasPrim = false; | ||
442 | foreach (EntityBase ent in Entities.Values) | ||
443 | { | ||
444 | if (ent is SceneObjectGroup) | ||
445 | { | ||
446 | hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID); | ||
447 | if (hasPrim != false) | ||
448 | { | ||
449 | ((SceneObjectGroup) ent).UpdateGroupRotation(rot); | ||
450 | break; | ||
451 | } | ||
452 | } | ||
453 | } | ||
454 | } | ||
455 | |||
456 | /// <summary> | ||
457 | /// | ||
458 | /// </summary> | ||
459 | /// <param name="localID"></param> | ||
460 | /// <param name="rot"></param> | ||
461 | /// <param name="remoteClient"></param> | ||
462 | public void UpdatePrimSingleRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient) | ||
463 | { | ||
464 | bool hasPrim = false; | ||
465 | foreach (EntityBase ent in Entities.Values) | ||
466 | { | ||
467 | if (ent is SceneObjectGroup) | ||
468 | { | ||
469 | hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID); | ||
470 | if (hasPrim != false) | ||
471 | { | ||
472 | ((SceneObjectGroup) ent).UpdateSingleRotation(rot, localID); | ||
473 | break; | ||
474 | } | ||
475 | } | ||
476 | } | ||
477 | } | ||
478 | |||
479 | /// <summary> | ||
480 | /// | ||
481 | /// </summary> | ||
482 | /// <param name="localID"></param> | ||
483 | /// <param name="scale"></param> | ||
484 | /// <param name="remoteClient"></param> | ||
485 | public void UpdatePrimScale(uint localID, LLVector3 scale, IClientAPI remoteClient) | ||
486 | { | ||
487 | bool hasPrim = false; | ||
488 | foreach (EntityBase ent in Entities.Values) | ||
489 | { | ||
490 | if (ent is SceneObjectGroup) | ||
491 | { | ||
492 | hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID); | ||
493 | if (hasPrim != false) | ||
494 | { | ||
495 | ((SceneObjectGroup) ent).Resize(scale, localID); | ||
496 | break; | ||
497 | } | ||
498 | } | ||
499 | } | ||
500 | } | ||
501 | |||
502 | public void StartAnimation(LLUUID animID, int seq, LLUUID agentId) | 135 | public void StartAnimation(LLUUID animID, int seq, LLUUID agentId) |
503 | { | 136 | { |
504 | Broadcast(delegate(IClientAPI client) { client.SendAnimation(animID, seq, agentId); }); | 137 | Broadcast(delegate(IClientAPI client) { client.SendAnimation(animID, seq, agentId); }); |
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 9eb3a71..a956eb2 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -51,13 +51,14 @@ using Timer=System.Timers.Timer; | |||
51 | 51 | ||
52 | namespace OpenSim.Region.Environment.Scenes | 52 | namespace OpenSim.Region.Environment.Scenes |
53 | { | 53 | { |
54 | public delegate bool FilterAvatarList(ScenePresence avatar); | ||
55 | |||
54 | public partial class Scene : SceneBase | 56 | public partial class Scene : SceneBase |
55 | { | 57 | { |
56 | public delegate bool FilterAvatarList(ScenePresence avatar); | 58 | #region Fields |
57 | |||
58 | protected Timer m_heartbeatTimer = new Timer(); | 59 | protected Timer m_heartbeatTimer = new Timer(); |
59 | protected Dictionary<LLUUID, ScenePresence> m_scenePresences; | 60 | |
60 | protected Dictionary<LLUUID, SceneObjectGroup> m_sceneObjects; | 61 | public InnerScene m_innerScene; |
61 | 62 | ||
62 | private Random Rand = new Random(); | 63 | private Random Rand = new Random(); |
63 | private uint _primCount = 702000; | 64 | private uint _primCount = 702000; |
@@ -66,16 +67,14 @@ namespace OpenSim.Region.Environment.Scenes | |||
66 | private int m_timePhase = 24; | 67 | private int m_timePhase = 24; |
67 | private int m_timeUpdateCount; | 68 | private int m_timeUpdateCount; |
68 | 69 | ||
69 | public BasicQuadTreeNode QuadTree; | ||
70 | |||
71 | private readonly Mutex updateLock; | 70 | private readonly Mutex updateLock; |
72 | 71 | ||
73 | protected ModuleLoader m_moduleLoader; | 72 | protected ModuleLoader m_moduleLoader; |
74 | protected StorageManager storageManager; | 73 | protected StorageManager storageManager; |
75 | protected AgentCircuitManager authenticateHandler; | 74 | protected AgentCircuitManager authenticateHandler; |
76 | protected RegionCommsListener regionCommsHost; | ||
77 | public CommunicationsManager commsManager; | 75 | public CommunicationsManager commsManager; |
78 | // protected XferManager xferManager; | 76 | // protected XferManager xferManager; |
77 | protected SceneCommunicationService m_sceneGridService; | ||
79 | 78 | ||
80 | protected Dictionary<LLUUID, Caps> capsHandlers = new Dictionary<LLUUID, Caps>(); | 79 | protected Dictionary<LLUUID, Caps> capsHandlers = new Dictionary<LLUUID, Caps>(); |
81 | protected BaseHttpServer httpListener; | 80 | protected BaseHttpServer httpListener; |
@@ -111,6 +110,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
111 | private int m_update_terrain = 50; | 110 | private int m_update_terrain = 50; |
112 | private int m_update_land = 1; | 111 | private int m_update_land = 1; |
113 | private int m_update_avatars = 1; | 112 | private int m_update_avatars = 1; |
113 | #endregion | ||
114 | 114 | ||
115 | #region Properties | 115 | #region Properties |
116 | 116 | ||
@@ -128,12 +128,16 @@ namespace OpenSim.Region.Environment.Scenes | |||
128 | 128 | ||
129 | private readonly EstateManager m_estateManager; | 129 | private readonly EstateManager m_estateManager; |
130 | 130 | ||
131 | private PhysicsScene phyScene; | 131 | private PhysicsScene phyScene |
132 | { | ||
133 | set { m_innerScene.PhyScene = value; } | ||
134 | get { return (m_innerScene.PhyScene); } | ||
135 | } | ||
132 | 136 | ||
133 | public PhysicsScene PhysScene | 137 | public PhysicsScene PhysScene |
134 | { | 138 | { |
135 | set { phyScene = value; } | 139 | set { m_innerScene.PhyScene = value; } |
136 | get { return (phyScene); } | 140 | get { return (m_innerScene.PhyScene); } |
137 | } | 141 | } |
138 | 142 | ||
139 | public EstateManager EstateManager | 143 | public EstateManager EstateManager |
@@ -148,29 +152,48 @@ namespace OpenSim.Region.Environment.Scenes | |||
148 | get { return m_permissionManager; } | 152 | get { return m_permissionManager; } |
149 | } | 153 | } |
150 | 154 | ||
155 | public int TimePhase | ||
156 | { | ||
157 | get { return m_timePhase; } | ||
158 | } | ||
159 | |||
151 | public Dictionary<LLUUID, SceneObjectGroup> Objects | 160 | public Dictionary<LLUUID, SceneObjectGroup> Objects |
152 | { | 161 | { |
153 | get { return m_sceneObjects; } | 162 | get { return m_innerScene.SceneObjects; } |
154 | } | 163 | } |
155 | 164 | ||
156 | public int TimePhase | 165 | protected Dictionary<LLUUID, ScenePresence> m_scenePresences |
157 | { | 166 | { |
158 | get { return m_timePhase; } | 167 | get { return m_innerScene.ScenePresences; } |
168 | set { m_innerScene.ScenePresences = value; } | ||
169 | } | ||
170 | |||
171 | protected Dictionary<LLUUID, SceneObjectGroup> m_sceneObjects | ||
172 | { | ||
173 | get { return m_innerScene.SceneObjects; } | ||
174 | set { m_innerScene.SceneObjects = value; } | ||
175 | } | ||
176 | |||
177 | public Dictionary<LLUUID, EntityBase> Entities | ||
178 | { | ||
179 | get { return m_innerScene.Entities; } | ||
180 | set { m_innerScene.Entities = value; } | ||
159 | } | 181 | } |
160 | 182 | ||
161 | #endregion | 183 | #endregion |
162 | 184 | ||
163 | #region Constructors | 185 | #region Constructors |
164 | 186 | ||
165 | public Scene(RegionInfo regInfo, AgentCircuitManager authen, CommunicationsManager commsMan, | 187 | public Scene(RegionInfo regInfo, AgentCircuitManager authen, CommunicationsManager commsMan, SceneCommunicationService sceneGridService, |
166 | AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer, | 188 | AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer, |
167 | ModuleLoader moduleLoader, bool dumpAssetsToFile) | 189 | ModuleLoader moduleLoader, bool dumpAssetsToFile) |
168 | { | 190 | { |
169 | updateLock = new Mutex(false); | 191 | updateLock = new Mutex(false); |
170 | 192 | ||
171 | m_moduleLoader = moduleLoader; | 193 | m_moduleLoader = moduleLoader; |
172 | authenticateHandler = authen; | 194 | authenticateHandler = authen; |
173 | commsManager = commsMan; | 195 | commsManager = commsMan; |
196 | m_sceneGridService = sceneGridService; | ||
174 | storageManager = storeManager; | 197 | storageManager = storeManager; |
175 | assetCache = assetCach; | 198 | assetCache = assetCach; |
176 | m_regInfo = regInfo; | 199 | m_regInfo = regInfo; |
@@ -184,15 +207,13 @@ namespace OpenSim.Region.Environment.Scenes | |||
184 | m_eventManager = new EventManager(); | 207 | m_eventManager = new EventManager(); |
185 | m_permissionManager = new PermissionManager(this); | 208 | m_permissionManager = new PermissionManager(this); |
186 | 209 | ||
210 | m_innerScene = new InnerScene(this, regInfo, m_permissionManager); | ||
211 | |||
187 | m_eventManager.OnParcelPrimCountAdd += | 212 | m_eventManager.OnParcelPrimCountAdd += |
188 | m_LandManager.addPrimToLandPrimCounts; | 213 | m_LandManager.addPrimToLandPrimCounts; |
189 | 214 | ||
190 | m_eventManager.OnPermissionError += SendPermissionAlert; | 215 | m_eventManager.OnPermissionError += SendPermissionAlert; |
191 | 216 | ||
192 | QuadTree = new BasicQuadTreeNode(null, "/0/", 0, 0, 256, 256); | ||
193 | QuadTree.Subdivide(); | ||
194 | QuadTree.Subdivide(); | ||
195 | |||
196 | MainLog.Instance.Verbose("Creating new entitities instance"); | 217 | MainLog.Instance.Verbose("Creating new entitities instance"); |
197 | Entities = new Dictionary<LLUUID, EntityBase>(); | 218 | Entities = new Dictionary<LLUUID, EntityBase>(); |
198 | m_scenePresences = new Dictionary<LLUUID, ScenePresence>(); | 219 | m_scenePresences = new Dictionary<LLUUID, ScenePresence>(); |
@@ -209,34 +230,37 @@ namespace OpenSim.Region.Environment.Scenes | |||
209 | 230 | ||
210 | #endregion | 231 | #endregion |
211 | 232 | ||
212 | public void SetModuleInterfaces() | 233 | #region Startup / Close Methods |
234 | public override void Close() | ||
213 | { | 235 | { |
214 | m_simChatModule = RequestModuleInterface<ISimChat>(); | 236 | m_heartbeatTimer.Close(); |
215 | m_httpRequestModule = RequestModuleInterface<IHttpRequests>(); | 237 | m_innerScene.Close(); |
216 | m_xmlrpcModule = RequestModuleInterface<IXMLRPC>(); | 238 | m_sceneGridService.Close(); |
217 | m_worldCommModule = RequestModuleInterface<IWorldComm>(); | ||
218 | XferManager = RequestModuleInterface<IXfer>(); | ||
219 | } | ||
220 | |||
221 | #region Script Handling Methods | ||
222 | 239 | ||
223 | public void SendCommandToPlugins(string[] args) | 240 | base.Close(); |
224 | { | ||
225 | m_eventManager.TriggerOnPluginConsole(args); | ||
226 | } | 241 | } |
227 | 242 | ||
228 | #endregion | ||
229 | |||
230 | /// <summary> | 243 | /// <summary> |
231 | /// | 244 | /// |
232 | /// </summary> | 245 | /// </summary> |
233 | public void StartTimer() | 246 | public void StartTimer() |
234 | { | 247 | { |
235 | m_heartbeatTimer.Enabled = true; | 248 | m_heartbeatTimer.Enabled = true; |
236 | m_heartbeatTimer.Interval = (int) (m_timespan*1000); | 249 | m_heartbeatTimer.Interval = (int)(m_timespan * 1000); |
237 | m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 250 | m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
238 | } | 251 | } |
239 | 252 | ||
253 | public void SetModuleInterfaces() | ||
254 | { | ||
255 | m_simChatModule = RequestModuleInterface<ISimChat>(); | ||
256 | m_httpRequestModule = RequestModuleInterface<IHttpRequests>(); | ||
257 | m_xmlrpcModule = RequestModuleInterface<IXMLRPC>(); | ||
258 | m_worldCommModule = RequestModuleInterface<IWorldComm>(); | ||
259 | XferManager = RequestModuleInterface<IXfer>(); | ||
260 | } | ||
261 | |||
262 | #endregion | ||
263 | |||
240 | #region Update Methods | 264 | #region Update Methods |
241 | 265 | ||
242 | /// <summary> | 266 | /// <summary> |
@@ -597,38 +621,17 @@ namespace OpenSim.Region.Environment.Scenes | |||
597 | 621 | ||
598 | public void RemovePrim(uint localID, LLUUID avatar_deleter) | 622 | public void RemovePrim(uint localID, LLUUID avatar_deleter) |
599 | { | 623 | { |
600 | foreach (EntityBase obj in Entities.Values) | 624 | m_innerScene.RemovePrim(localID, avatar_deleter); |
601 | { | ||
602 | if (obj is SceneObjectGroup) | ||
603 | { | ||
604 | if (((SceneObjectGroup) obj).LocalId == localID) | ||
605 | { | ||
606 | RemoveEntity((SceneObjectGroup) obj); | ||
607 | return; | ||
608 | } | ||
609 | } | ||
610 | } | ||
611 | } | 625 | } |
612 | 626 | ||
613 | public void AddEntityFromStorage(SceneObjectGroup sceneObject) | 627 | public void AddEntityFromStorage(SceneObjectGroup sceneObject) |
614 | { | 628 | { |
615 | sceneObject.RegionHandle = m_regionHandle; | 629 | m_innerScene.AddEntityFromStorage(sceneObject); |
616 | sceneObject.SetScene(this); | ||
617 | foreach (SceneObjectPart part in sceneObject.Children.Values) | ||
618 | { | ||
619 | part.LocalID = PrimIDAllocate(); | ||
620 | } | ||
621 | sceneObject.UpdateParentIDs(); | ||
622 | AddEntity(sceneObject); | ||
623 | } | 630 | } |
624 | 631 | ||
625 | public void AddEntity(SceneObjectGroup sceneObject) | 632 | public void AddEntity(SceneObjectGroup sceneObject) |
626 | { | 633 | { |
627 | if (!Entities.ContainsKey(sceneObject.UUID)) | 634 | m_innerScene.AddEntity(sceneObject); |
628 | { | ||
629 | // QuadTree.AddObject(sceneObject); | ||
630 | Entities.Add(sceneObject.UUID, sceneObject); | ||
631 | } | ||
632 | } | 635 | } |
633 | 636 | ||
634 | public void RemoveEntity(SceneObjectGroup sceneObject) | 637 | public void RemoveEntity(SceneObjectGroup sceneObject) |
@@ -797,31 +800,30 @@ namespace OpenSim.Region.Environment.Scenes | |||
797 | client.OnRegionHandShakeReply += SendLayerData; | 800 | client.OnRegionHandShakeReply += SendLayerData; |
798 | //remoteClient.OnRequestWearables += new GenericCall(this.GetInitialPrims); | 801 | //remoteClient.OnRequestWearables += new GenericCall(this.GetInitialPrims); |
799 | client.OnModifyTerrain += ModifyTerrain; | 802 | client.OnModifyTerrain += ModifyTerrain; |
800 | //client.OnChatFromViewer += SimChat; | 803 | // client.OnRequestWearables += InformClientOfNeighbours; |
801 | client.OnRequestWearables += InformClientOfNeighbours; | ||
802 | client.OnAddPrim += AddNewPrim; | 804 | client.OnAddPrim += AddNewPrim; |
803 | client.OnUpdatePrimGroupPosition += UpdatePrimPosition; | 805 | client.OnUpdatePrimGroupPosition += m_innerScene.UpdatePrimPosition; |
804 | client.OnUpdatePrimSinglePosition += UpdatePrimSinglePosition; | 806 | client.OnUpdatePrimSinglePosition += m_innerScene.UpdatePrimSinglePosition; |
805 | client.OnUpdatePrimGroupRotation += UpdatePrimRotation; | 807 | client.OnUpdatePrimGroupRotation += m_innerScene.UpdatePrimRotation; |
806 | client.OnUpdatePrimGroupMouseRotation += UpdatePrimRotation; | 808 | client.OnUpdatePrimGroupMouseRotation += m_innerScene.UpdatePrimRotation; |
807 | client.OnUpdatePrimSingleRotation += UpdatePrimSingleRotation; | 809 | client.OnUpdatePrimSingleRotation += m_innerScene.UpdatePrimSingleRotation; |
808 | client.OnUpdatePrimScale += UpdatePrimScale; | 810 | client.OnUpdatePrimScale += m_innerScene.UpdatePrimScale; |
809 | client.OnUpdateExtraParams += UpdateExtraParam; | 811 | client.OnUpdateExtraParams += m_innerScene.UpdateExtraParam; |
810 | client.OnUpdatePrimShape += UpdatePrimShape; | 812 | client.OnUpdatePrimShape += m_innerScene.UpdatePrimShape; |
811 | client.OnRequestMapBlocks += RequestMapBlocks; | 813 | client.OnRequestMapBlocks += RequestMapBlocks; |
812 | client.OnUpdatePrimTexture += UpdatePrimTexture; | 814 | client.OnUpdatePrimTexture += m_innerScene.UpdatePrimTexture; |
813 | client.OnTeleportLocationRequest += RequestTeleportLocation; | 815 | client.OnTeleportLocationRequest += RequestTeleportLocation; |
814 | client.OnObjectSelect += SelectPrim; | 816 | client.OnObjectSelect += SelectPrim; |
815 | client.OnObjectDeselect += DeselectPrim; | 817 | client.OnObjectDeselect += DeselectPrim; |
816 | client.OnGrabUpdate += MoveObject; | 818 | client.OnGrabUpdate += m_innerScene.MoveObject; |
817 | client.OnDeRezObject += DeRezObject; | 819 | client.OnDeRezObject += DeRezObject; |
818 | client.OnRezObject += RezObject; | 820 | client.OnRezObject += RezObject; |
819 | client.OnNameFromUUIDRequest += commsManager.HandleUUIDNameRequest; | 821 | client.OnNameFromUUIDRequest += commsManager.HandleUUIDNameRequest; |
820 | client.OnObjectDescription += PrimDescription; | 822 | client.OnObjectDescription += m_innerScene.PrimDescription; |
821 | client.OnObjectName += PrimName; | 823 | client.OnObjectName += m_innerScene.PrimName; |
822 | client.OnLinkObjects += LinkObjects; | 824 | client.OnLinkObjects += m_innerScene.LinkObjects; |
823 | client.OnObjectDuplicate += DuplicateObject; | 825 | client.OnObjectDuplicate += m_innerScene.DuplicateObject; |
824 | client.OnUpdatePrimFlags += UpdatePrimFlags; | 826 | client.OnUpdatePrimFlags += m_innerScene.UpdatePrimFlags; |
825 | 827 | ||
826 | client.OnParcelPropertiesRequest += new ParcelPropertiesRequest(m_LandManager.handleParcelPropertiesRequest); | 828 | client.OnParcelPropertiesRequest += new ParcelPropertiesRequest(m_LandManager.handleParcelPropertiesRequest); |
827 | client.OnParcelDivideRequest += new ParcelDivideRequest(m_LandManager.handleParcelDivideRequest); | 829 | client.OnParcelDivideRequest += new ParcelDivideRequest(m_LandManager.handleParcelDivideRequest); |
@@ -845,8 +847,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
845 | client.OnRezScript += RezScript; | 847 | client.OnRezScript += RezScript; |
846 | client.OnRemoveTaskItem += RemoveTaskInventory; | 848 | client.OnRemoveTaskItem += RemoveTaskInventory; |
847 | 849 | ||
848 | // client.OnRequestAvatarProperties += RequestAvatarProperty; | ||
849 | |||
850 | client.OnGrabObject += ProcessObjectGrab; | 850 | client.OnGrabObject += ProcessObjectGrab; |
851 | 851 | ||
852 | EventManager.TriggerOnNewClient(client); | 852 | EventManager.TriggerOnNewClient(client); |
@@ -865,44 +865,11 @@ namespace OpenSim.Region.Environment.Scenes | |||
865 | AvatarFactoryModule.GetDefaultAvatarAppearance(out wearables, out visualParams); | 865 | AvatarFactoryModule.GetDefaultAvatarAppearance(out wearables, out visualParams); |
866 | } | 866 | } |
867 | 867 | ||
868 | newAvatar = new ScenePresence(client, this, m_regInfo, visualParams, wearables); | 868 | newAvatar = m_innerScene.CreateAndAddScenePresence(client, child, wearables, visualParams); |
869 | newAvatar.IsChildAgent = child; | ||
870 | 869 | ||
871 | if (child) | 870 | if (!newAvatar.IsChildAgent) |
872 | { | ||
873 | MainLog.Instance.Verbose("SCENE", RegionInfo.RegionName + ": Creating new child agent."); | ||
874 | } | ||
875 | else | ||
876 | { | 871 | { |
877 | newAvatar.OnSignificantClientMovement += m_LandManager.handleSignificantClientMovement; | 872 | newAvatar.OnSignificantClientMovement += m_LandManager.handleSignificantClientMovement; |
878 | |||
879 | MainLog.Instance.Verbose("SCENE", RegionInfo.RegionName + ": Creating new root agent."); | ||
880 | MainLog.Instance.Verbose("SCENE", RegionInfo.RegionName + ": Adding Physical agent."); | ||
881 | |||
882 | newAvatar.AddToPhysicalScene(); | ||
883 | } | ||
884 | |||
885 | lock (Entities) | ||
886 | { | ||
887 | if (!Entities.ContainsKey(client.AgentId)) | ||
888 | { | ||
889 | Entities.Add(client.AgentId, newAvatar); | ||
890 | } | ||
891 | else | ||
892 | { | ||
893 | Entities[client.AgentId] = newAvatar; | ||
894 | } | ||
895 | } | ||
896 | lock (m_scenePresences) | ||
897 | { | ||
898 | if (m_scenePresences.ContainsKey(client.AgentId)) | ||
899 | { | ||
900 | m_scenePresences[client.AgentId] = newAvatar; | ||
901 | } | ||
902 | else | ||
903 | { | ||
904 | m_scenePresences.Add(client.AgentId, newAvatar); | ||
905 | } | ||
906 | } | 873 | } |
907 | 874 | ||
908 | return newAvatar; | 875 | return newAvatar; |
@@ -942,87 +909,13 @@ namespace OpenSim.Region.Environment.Scenes | |||
942 | return; | 909 | return; |
943 | } | 910 | } |
944 | 911 | ||
945 | #endregion | 912 | public void NotifyMyCoarseLocationChange() |
946 | |||
947 | #region Request m_scenePresences List Methods | ||
948 | |||
949 | //The idea is to have a group of method that return a list of avatars meeting some requirement | ||
950 | // ie it could be all m_scenePresences within a certain range of the calling prim/avatar. | ||
951 | |||
952 | /// <summary> | ||
953 | /// Request a List of all m_scenePresences in this World | ||
954 | /// </summary> | ||
955 | /// <returns></returns> | ||
956 | public List<ScenePresence> GetScenePresences() | ||
957 | { | ||
958 | List<ScenePresence> result = new List<ScenePresence>(m_scenePresences.Values); | ||
959 | |||
960 | return result; | ||
961 | } | ||
962 | |||
963 | public List<ScenePresence> GetAvatars() | ||
964 | { | ||
965 | List<ScenePresence> result = | ||
966 | GetScenePresences(delegate(ScenePresence scenePresence) { return !scenePresence.IsChildAgent; }); | ||
967 | |||
968 | return result; | ||
969 | } | ||
970 | |||
971 | /// <summary> | ||
972 | /// Request a filtered list of m_scenePresences in this World | ||
973 | /// </summary> | ||
974 | /// <returns></returns> | ||
975 | public List<ScenePresence> GetScenePresences(FilterAvatarList filter) | ||
976 | { | ||
977 | List<ScenePresence> result = new List<ScenePresence>(); | ||
978 | |||
979 | foreach (ScenePresence avatar in m_scenePresences.Values) | ||
980 | { | ||
981 | if (filter(avatar)) | ||
982 | { | ||
983 | result.Add(avatar); | ||
984 | } | ||
985 | } | ||
986 | |||
987 | return result; | ||
988 | } | ||
989 | |||
990 | /// <summary> | ||
991 | /// Request a Avatar by UUID | ||
992 | /// </summary> | ||
993 | /// <param name="avatarID"></param> | ||
994 | /// <returns></returns> | ||
995 | public ScenePresence GetScenePresence(LLUUID avatarID) | ||
996 | { | ||
997 | if (m_scenePresences.ContainsKey(avatarID)) | ||
998 | { | ||
999 | return m_scenePresences[avatarID]; | ||
1000 | } | ||
1001 | return null; | ||
1002 | } | ||
1003 | |||
1004 | /// <summary> | ||
1005 | /// | ||
1006 | /// </summary> | ||
1007 | /// <param name="action"></param> | ||
1008 | public void ForEachScenePresence(Action<ScenePresence> action) | ||
1009 | { | ||
1010 | foreach (ScenePresence presence in m_scenePresences.Values) | ||
1011 | { | ||
1012 | action(presence); | ||
1013 | } | ||
1014 | } | ||
1015 | |||
1016 | public void ForEachObject(Action<SceneObjectGroup> action) | ||
1017 | { | 913 | { |
1018 | foreach (SceneObjectGroup presence in m_sceneObjects.Values) | 914 | ForEachScenePresence(delegate(ScenePresence presence) { presence.CoarseLocationChange(); }); |
1019 | { | ||
1020 | action(presence); | ||
1021 | } | ||
1022 | } | 915 | } |
1023 | |||
1024 | #endregion | 916 | #endregion |
1025 | 917 | ||
918 | #region Entities | ||
1026 | /// <summary> | 919 | /// <summary> |
1027 | /// | 920 | /// |
1028 | /// </summary> | 921 | /// </summary> |
@@ -1044,36 +937,18 @@ namespace OpenSim.Region.Environment.Scenes | |||
1044 | Broadcast(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); }); | 937 | Broadcast(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); }); |
1045 | } | 938 | } |
1046 | 939 | ||
1047 | public void NotifyMyCoarseLocationChange() | 940 | #endregion |
1048 | { | ||
1049 | ForEachScenePresence(delegate(ScenePresence presence) { presence.CoarseLocationChange(); }); | ||
1050 | } | ||
1051 | |||
1052 | public void SendAllSceneObjectsToClient(ScenePresence presence) | ||
1053 | { | ||
1054 | foreach (EntityBase ent in Entities.Values) | ||
1055 | { | ||
1056 | if (ent is SceneObjectGroup) | ||
1057 | { | ||
1058 | // ((SceneObjectGroup)ent).SendFullUpdateToClient(client); | ||
1059 | ((SceneObjectGroup) ent).ScheduleFullUpdateToAvatar(presence); | ||
1060 | } | ||
1061 | } | ||
1062 | } | ||
1063 | 941 | ||
1064 | #region RegionCommsHost | 942 | #region RegionComms |
1065 | 943 | ||
1066 | /// <summary> | 944 | /// <summary> |
1067 | /// | 945 | /// |
1068 | /// </summary> | 946 | /// </summary> |
1069 | public void RegisterRegionWithComms() | 947 | public void RegisterRegionWithComms() |
1070 | { | 948 | { |
1071 | regionCommsHost = commsManager.GridService.RegisterRegion(m_regInfo); | 949 | m_sceneGridService.RegisterRegion(m_regInfo); |
1072 | if (regionCommsHost != null) | 950 | m_sceneGridService.OnExpectUser += NewUserConnection; |
1073 | { | 951 | m_sceneGridService.OnAvatarCrossingIntoRegion += AgentCrossing; |
1074 | regionCommsHost.OnExpectUser += NewUserConnection; | ||
1075 | regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing; | ||
1076 | } | ||
1077 | } | 952 | } |
1078 | 953 | ||
1079 | /// <summary> | 954 | /// <summary> |
@@ -1083,27 +958,23 @@ namespace OpenSim.Region.Environment.Scenes | |||
1083 | /// <param name="agent"></param> | 958 | /// <param name="agent"></param> |
1084 | public void NewUserConnection(ulong regionHandle, AgentCircuitData agent) | 959 | public void NewUserConnection(ulong regionHandle, AgentCircuitData agent) |
1085 | { | 960 | { |
1086 | // Console.WriteLine("Scene.cs - add new user connection"); | ||
1087 | //should just check that its meant for this region | ||
1088 | if (regionHandle == m_regInfo.RegionHandle) | 961 | if (regionHandle == m_regInfo.RegionHandle) |
1089 | { | 962 | { |
1090 | if (agent.CapsPath != "") | 963 | if (agent.CapsPath != "") |
1091 | { | 964 | { |
1092 | //Console.WriteLine("new user, so creating caps handler for it"); | ||
1093 | Caps cap = | 965 | Caps cap = |
1094 | new Caps(commsManager.AssetCache, httpListener, m_regInfo.ExternalHostName, httpListener.Port, | 966 | new Caps(commsManager.AssetCache, httpListener, m_regInfo.ExternalHostName, httpListener.Port, |
1095 | agent.CapsPath, agent.AgentID, m_dumpAssetsToFile); | 967 | agent.CapsPath, agent.AgentID, m_dumpAssetsToFile); |
1096 | 968 | ||
1097 | Util.SetCapsURL(agent.AgentID, | 969 | Util.SetCapsURL(agent.AgentID, "http://" + m_regInfo.ExternalHostName + ":" + httpListener.Port.ToString() + |
1098 | "http://" + m_regInfo.ExternalHostName + ":" + httpListener.Port.ToString() + | ||
1099 | "/CAPS/" + agent.CapsPath + "0000/"); | 970 | "/CAPS/" + agent.CapsPath + "0000/"); |
1100 | cap.RegisterHandlers(); | 971 | cap.RegisterHandlers(); |
1101 | cap.AddNewInventoryItem = AddInventoryItem; | 972 | cap.AddNewInventoryItem = AddInventoryItem; |
1102 | cap.ItemUpdatedCall = CapsUpdateInventoryItemAsset; | 973 | cap.ItemUpdatedCall = CapsUpdateInventoryItemAsset; |
1103 | if (capsHandlers.ContainsKey(agent.AgentID)) | 974 | if (capsHandlers.ContainsKey(agent.AgentID)) |
1104 | { | 975 | { |
1105 | MainLog.Instance.Warn("client", "Adding duplicate CAPS entry for user " + | 976 | //MainLog.Instance.Warn("client", "Adding duplicate CAPS entry for user " + |
1106 | agent.AgentID.ToStringHyphenated()); | 977 | // agent.AgentID.ToStringHyphenated()); |
1107 | capsHandlers[agent.AgentID] = cap; | 978 | capsHandlers[agent.AgentID] = cap; |
1108 | } | 979 | } |
1109 | else | 980 | else |
@@ -1126,61 +997,13 @@ namespace OpenSim.Region.Environment.Scenes | |||
1126 | } | 997 | } |
1127 | } | 998 | } |
1128 | 999 | ||
1129 | private delegate void InformClientOfNeighbourDelegate( | 1000 | |
1130 | IClientAPI remoteClient, AgentCircuitData a, ulong regionHandle, IPEndPoint endPoint); | ||
1131 | |||
1132 | private void InformClientOfNeighbourCompleted(IAsyncResult iar) | ||
1133 | { | ||
1134 | InformClientOfNeighbourDelegate icon = (InformClientOfNeighbourDelegate) iar.AsyncState; | ||
1135 | |||
1136 | |||
1137 | icon.EndInvoke(iar); | ||
1138 | } | ||
1139 | |||
1140 | /// <summary> | ||
1141 | /// Async compnent for informing client of which neighbours exists | ||
1142 | /// </summary> | ||
1143 | /// <remarks> | ||
1144 | /// This needs to run asynchronesously, as a network timeout may block the thread for a long while | ||
1145 | /// </remarks> | ||
1146 | /// <param name="remoteClient"></param> | ||
1147 | /// <param name="a"></param> | ||
1148 | /// <param name="regionHandle"></param> | ||
1149 | /// <param name="endPoint"></param> | ||
1150 | private void InformClientOfNeighbourAsync(IClientAPI remoteClient, AgentCircuitData a, ulong regionHandle, | ||
1151 | IPEndPoint endPoint) | ||
1152 | { | ||
1153 | MainLog.Instance.Notice("INTERGRID", "Starting to inform client about neighbours"); | ||
1154 | bool regionAccepted = commsManager.InterRegion.InformRegionOfChildAgent(regionHandle, a); | ||
1155 | |||
1156 | if (regionAccepted) | ||
1157 | remoteClient.InformClientOfNeighbour(regionHandle, endPoint); | ||
1158 | MainLog.Instance.Notice("INTERGRID", "Completed inform client about neighbours"); | ||
1159 | } | ||
1160 | |||
1161 | /// <summary> | 1001 | /// <summary> |
1162 | /// | 1002 | /// |
1163 | /// </summary> | 1003 | /// </summary> |
1164 | public void InformClientOfNeighbours(IClientAPI remoteClient) | 1004 | public void InformClientOfNeighbours(ScenePresence presence) |
1165 | { | 1005 | { |
1166 | List<SimpleRegionInfo> neighbours = | 1006 | m_sceneGridService.InformClientOfNeighbours(presence); |
1167 | commsManager.GridService.RequestNeighbours(m_regInfo.RegionLocX, m_regInfo.RegionLocY); | ||
1168 | if (neighbours != null) | ||
1169 | { | ||
1170 | for (int i = 0; i < neighbours.Count; i++) | ||
1171 | { | ||
1172 | AgentCircuitData agent = remoteClient.RequestClientInfo(); | ||
1173 | agent.BaseFolder = LLUUID.Zero; | ||
1174 | agent.InventoryFolder = LLUUID.Zero; | ||
1175 | agent.startpos = new LLVector3(128, 128, 70); | ||
1176 | agent.child = true; | ||
1177 | |||
1178 | InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; | ||
1179 | d.BeginInvoke(remoteClient, agent, neighbours[i].RegionHandle, neighbours[i].ExternalEndPoint, | ||
1180 | InformClientOfNeighbourCompleted, | ||
1181 | d); | ||
1182 | } | ||
1183 | } | ||
1184 | } | 1007 | } |
1185 | 1008 | ||
1186 | /// <summary> | 1009 | /// <summary> |
@@ -1190,7 +1013,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1190 | /// <returns></returns> | 1013 | /// <returns></returns> |
1191 | public RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle) | 1014 | public RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle) |
1192 | { | 1015 | { |
1193 | return commsManager.GridService.RequestNeighbourInfo(regionHandle); | 1016 | return m_sceneGridService.RequestNeighbouringRegionInfo(regionHandle); |
1194 | } | 1017 | } |
1195 | 1018 | ||
1196 | /// <summary> | 1019 | /// <summary> |
@@ -1202,9 +1025,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1202 | /// <param name="maxY"></param> | 1025 | /// <param name="maxY"></param> |
1203 | public void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY) | 1026 | public void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY) |
1204 | { | 1027 | { |
1205 | List<MapBlockData> mapBlocks; | 1028 | m_sceneGridService.RequestMapBlocks(remoteClient, minX, minY, maxX, maxX); |
1206 | mapBlocks = commsManager.GridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY); | ||
1207 | remoteClient.SendMapBlock(mapBlocks); | ||
1208 | } | 1029 | } |
1209 | 1030 | ||
1210 | /// <summary> | 1031 | /// <summary> |
@@ -1218,34 +1039,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
1218 | public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, LLVector3 position, | 1039 | public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, LLVector3 position, |
1219 | LLVector3 lookAt, uint flags) | 1040 | LLVector3 lookAt, uint flags) |
1220 | { | 1041 | { |
1221 | if (regionHandle == m_regionHandle) | 1042 | if (m_scenePresences.ContainsKey(remoteClient.AgentId)) |
1222 | { | ||
1223 | if (m_scenePresences.ContainsKey(remoteClient.AgentId)) | ||
1224 | { | ||
1225 | remoteClient.SendTeleportLocationStart(); | ||
1226 | remoteClient.SendLocalTeleport(position, lookAt, flags); | ||
1227 | m_scenePresences[remoteClient.AgentId].Teleport(position); | ||
1228 | } | ||
1229 | } | ||
1230 | else | ||
1231 | { | 1043 | { |
1232 | RegionInfo reg = RequestNeighbouringRegionInfo(regionHandle); | 1044 | m_sceneGridService.RequestTeleportLocation(m_scenePresences[remoteClient.AgentId], regionHandle, position, lookAt, flags); |
1233 | if (reg != null) | ||
1234 | { | ||
1235 | remoteClient.SendTeleportLocationStart(); | ||
1236 | AgentCircuitData agent = remoteClient.RequestClientInfo(); | ||
1237 | agent.BaseFolder = LLUUID.Zero; | ||
1238 | agent.InventoryFolder = LLUUID.Zero; | ||
1239 | // agent.startpos = new LLVector3(128, 128, 70); | ||
1240 | agent.startpos = position; | ||
1241 | agent.child = true; | ||
1242 | m_scenePresences[remoteClient.AgentId].Close(); | ||
1243 | commsManager.InterRegion.InformRegionOfChildAgent(regionHandle, agent); | ||
1244 | commsManager.InterRegion.ExpectAvatarCrossing(regionHandle, remoteClient.AgentId, position, false); | ||
1245 | AgentCircuitData circuitdata = remoteClient.RequestClientInfo(); | ||
1246 | string capsPath = Util.GetCapsURL(remoteClient.AgentId); | ||
1247 | remoteClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4), capsPath); | ||
1248 | } | ||
1249 | } | 1045 | } |
1250 | } | 1046 | } |
1251 | 1047 | ||
@@ -1257,19 +1053,12 @@ namespace OpenSim.Region.Environment.Scenes | |||
1257 | /// <param name="position"></param> | 1053 | /// <param name="position"></param> |
1258 | public bool InformNeighbourOfCrossing(ulong regionhandle, LLUUID agentID, LLVector3 position, bool isFlying) | 1054 | public bool InformNeighbourOfCrossing(ulong regionhandle, LLUUID agentID, LLVector3 position, bool isFlying) |
1259 | { | 1055 | { |
1260 | return commsManager.InterRegion.ExpectAvatarCrossing(regionhandle, agentID, position, isFlying); | 1056 | return m_sceneGridService.InformNeighbourOfCrossing(regionhandle, agentID, position, isFlying); |
1261 | } | ||
1262 | |||
1263 | public void performParcelPrimCountUpdate() | ||
1264 | { | ||
1265 | m_LandManager.resetAllLandPrimCounts(); | ||
1266 | m_eventManager.TriggerParcelPrimCountUpdate(); | ||
1267 | m_LandManager.finalizeLandPrimCountUpdate(); | ||
1268 | m_LandManager.landPrimCountTainted = false; | ||
1269 | } | 1057 | } |
1270 | 1058 | ||
1271 | #endregion | 1059 | #endregion |
1272 | 1060 | ||
1061 | #region Module Methods | ||
1273 | public void AddModule(string name, IRegionModule module) | 1062 | public void AddModule(string name, IRegionModule module) |
1274 | { | 1063 | { |
1275 | if (!Modules.ContainsKey(name)) | 1064 | if (!Modules.ContainsKey(name)) |
@@ -1297,7 +1086,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
1297 | return default(T); | 1086 | return default(T); |
1298 | } | 1087 | } |
1299 | } | 1088 | } |
1089 | #endregion | ||
1300 | 1090 | ||
1091 | #region Other Methods | ||
1301 | public void SetTimePhase(int phase) | 1092 | public void SetTimePhase(int phase) |
1302 | { | 1093 | { |
1303 | m_timePhase = phase; | 1094 | m_timePhase = phase; |
@@ -1313,6 +1104,26 @@ namespace OpenSim.Region.Environment.Scenes | |||
1313 | } | 1104 | } |
1314 | } | 1105 | } |
1315 | 1106 | ||
1107 | public LLUUID MakeHttpRequest(string url, string type, string body) | ||
1108 | { | ||
1109 | if (m_httpRequestModule != null) | ||
1110 | { | ||
1111 | return m_httpRequestModule.MakeHttpRequest(url, type, body); | ||
1112 | } | ||
1113 | return LLUUID.Zero; | ||
1114 | } | ||
1115 | |||
1116 | public void performParcelPrimCountUpdate() | ||
1117 | { | ||
1118 | m_LandManager.resetAllLandPrimCounts(); | ||
1119 | m_eventManager.TriggerParcelPrimCountUpdate(); | ||
1120 | m_LandManager.finalizeLandPrimCountUpdate(); | ||
1121 | m_LandManager.landPrimCountTainted = false; | ||
1122 | } | ||
1123 | |||
1124 | #endregion | ||
1125 | |||
1126 | #region Console Commands | ||
1316 | #region Alert Methods | 1127 | #region Alert Methods |
1317 | 1128 | ||
1318 | private void SendPermissionAlert(LLUUID user, string reason) | 1129 | private void SendPermissionAlert(LLUUID user, string reason) |
@@ -1444,15 +1255,17 @@ namespace OpenSim.Region.Environment.Scenes | |||
1444 | } | 1255 | } |
1445 | } | 1256 | } |
1446 | 1257 | ||
1447 | public LLUUID MakeHttpRequest(string url, string type, string body) | 1258 | #endregion |
1259 | |||
1260 | #region Script Handling Methods | ||
1261 | |||
1262 | public void SendCommandToPlugins(string[] args) | ||
1448 | { | 1263 | { |
1449 | if (m_httpRequestModule != null) | 1264 | m_eventManager.TriggerOnPluginConsole(args); |
1450 | { | ||
1451 | return m_httpRequestModule.MakeHttpRequest(url, type, body); | ||
1452 | } | ||
1453 | return LLUUID.Zero; | ||
1454 | } | 1265 | } |
1455 | 1266 | ||
1267 | #endregion | ||
1268 | |||
1456 | #region Script Engine | 1269 | #region Script Engine |
1457 | 1270 | ||
1458 | private List<ScriptEngineInterface> ScriptEngines = new List<ScriptEngineInterface>(); | 1271 | private List<ScriptEngineInterface> ScriptEngines = new List<ScriptEngineInterface>(); |
@@ -1467,106 +1280,100 @@ namespace OpenSim.Region.Environment.Scenes | |||
1467 | 1280 | ||
1468 | #endregion | 1281 | #endregion |
1469 | 1282 | ||
1283 | #region InnerScene wrapper methods | ||
1284 | |||
1470 | public LLUUID ConvertLocalIDToFullID(uint localID) | 1285 | public LLUUID ConvertLocalIDToFullID(uint localID) |
1471 | { | 1286 | { |
1472 | bool hasPrim = false; | 1287 | return m_innerScene.ConvertLocalIDToFullID(localID); |
1473 | foreach (EntityBase ent in Entities.Values) | ||
1474 | { | ||
1475 | if (ent is SceneObjectGroup) | ||
1476 | { | ||
1477 | hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID); | ||
1478 | if (hasPrim != false) | ||
1479 | { | ||
1480 | return ((SceneObjectGroup) ent).GetPartsFullID(localID); | ||
1481 | } | ||
1482 | } | ||
1483 | } | ||
1484 | return LLUUID.Zero; | ||
1485 | } | 1288 | } |
1486 | 1289 | ||
1487 | public SceneObjectPart GetSceneObjectPart(uint localID) | 1290 | public void SendAllSceneObjectsToClient(ScenePresence presence) |
1488 | { | 1291 | { |
1489 | bool hasPrim = false; | 1292 | m_innerScene.SendAllSceneObjectsToClient(presence); |
1490 | foreach (EntityBase ent in Entities.Values) | ||
1491 | { | ||
1492 | if (ent is SceneObjectGroup) | ||
1493 | { | ||
1494 | hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID); | ||
1495 | if (hasPrim != false) | ||
1496 | { | ||
1497 | return ((SceneObjectGroup) ent).GetChildPart(localID); | ||
1498 | } | ||
1499 | } | ||
1500 | } | ||
1501 | return null; | ||
1502 | } | 1293 | } |
1503 | 1294 | ||
1504 | public SceneObjectPart GetSceneObjectPart(LLUUID fullID) | 1295 | //The idea is to have a group of method that return a list of avatars meeting some requirement |
1296 | // ie it could be all m_scenePresences within a certain range of the calling prim/avatar. | ||
1297 | |||
1298 | public List<ScenePresence> GetAvatars() | ||
1505 | { | 1299 | { |
1506 | bool hasPrim = false; | 1300 | return m_innerScene.GetAvatars(); |
1507 | foreach (EntityBase ent in Entities.Values) | 1301 | } |
1302 | |||
1303 | /// <summary> | ||
1304 | /// Request a List of all m_scenePresences in this World | ||
1305 | /// </summary> | ||
1306 | /// <returns></returns> | ||
1307 | public List<ScenePresence> GetScenePresences() | ||
1308 | { | ||
1309 | return m_innerScene.GetScenePresences(); | ||
1310 | } | ||
1311 | |||
1312 | /// <summary> | ||
1313 | /// Request a filtered list of m_scenePresences in this World | ||
1314 | /// </summary> | ||
1315 | /// <returns></returns> | ||
1316 | public List<ScenePresence> GetScenePresences(FilterAvatarList filter) | ||
1317 | { | ||
1318 | return m_innerScene.GetScenePresences(filter); | ||
1319 | } | ||
1320 | |||
1321 | /// <summary> | ||
1322 | /// Request a Avatar by UUID | ||
1323 | /// </summary> | ||
1324 | /// <param name="avatarID"></param> | ||
1325 | /// <returns></returns> | ||
1326 | public ScenePresence GetScenePresence(LLUUID avatarID) | ||
1327 | { | ||
1328 | return m_innerScene.GetScenePresence(avatarID); | ||
1329 | } | ||
1330 | |||
1331 | /// <summary> | ||
1332 | /// | ||
1333 | /// </summary> | ||
1334 | /// <param name="action"></param> | ||
1335 | public void ForEachScenePresence(Action<ScenePresence> action) | ||
1336 | { | ||
1337 | foreach (ScenePresence presence in m_scenePresences.Values) | ||
1508 | { | 1338 | { |
1509 | if (ent is SceneObjectGroup) | 1339 | action(presence); |
1510 | { | ||
1511 | hasPrim = ((SceneObjectGroup) ent).HasChildPrim(fullID); | ||
1512 | if (hasPrim != false) | ||
1513 | { | ||
1514 | return ((SceneObjectGroup) ent).GetChildPart(fullID); | ||
1515 | } | ||
1516 | } | ||
1517 | } | 1340 | } |
1518 | return null; | ||
1519 | } | 1341 | } |
1520 | 1342 | ||
1521 | internal bool TryGetAvatar(LLUUID avatarId, out ScenePresence avatar) | 1343 | public void ForEachObject(Action<SceneObjectGroup> action) |
1522 | { | 1344 | { |
1523 | ScenePresence presence; | 1345 | foreach (SceneObjectGroup presence in m_sceneObjects.Values) |
1524 | if (m_scenePresences.TryGetValue(avatarId, out presence)) | ||
1525 | { | 1346 | { |
1526 | if (!presence.IsChildAgent) | 1347 | action(presence); |
1527 | { | ||
1528 | avatar = presence; | ||
1529 | return true; | ||
1530 | } | ||
1531 | } | 1348 | } |
1532 | |||
1533 | avatar = null; | ||
1534 | return false; | ||
1535 | } | 1349 | } |
1536 | 1350 | ||
1537 | public override void Close() | 1351 | public SceneObjectPart GetSceneObjectPart(uint localID) |
1538 | { | 1352 | { |
1539 | m_heartbeatTimer.Close(); | 1353 | return m_innerScene.GetSceneObjectPart(localID); |
1354 | } | ||
1540 | 1355 | ||
1541 | base.Close(); | 1356 | public SceneObjectPart GetSceneObjectPart(LLUUID fullID) |
1357 | { | ||
1358 | return m_innerScene.GetSceneObjectPart(fullID); | ||
1542 | } | 1359 | } |
1543 | 1360 | ||
1544 | internal bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) | 1361 | internal bool TryGetAvatar(LLUUID avatarId, out ScenePresence avatar) |
1545 | { | 1362 | { |
1546 | foreach (ScenePresence presence in m_scenePresences.Values) | 1363 | return m_innerScene.TryGetAvatar(avatarId, out avatar); |
1547 | { | 1364 | } |
1548 | if (!presence.IsChildAgent) | ||
1549 | { | ||
1550 | string name = presence.ControllingClient.FirstName + " " + presence.ControllingClient.LastName; | ||
1551 | 1365 | ||
1552 | if (String.Compare(avatarName, name, true) == 0) | ||
1553 | { | ||
1554 | avatar = presence; | ||
1555 | return true; | ||
1556 | } | ||
1557 | } | ||
1558 | } | ||
1559 | 1366 | ||
1560 | avatar = null; | 1367 | internal bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) |
1561 | return false; | 1368 | { |
1369 | return m_innerScene.TryGetAvatarByName(avatarName, out avatar); | ||
1562 | } | 1370 | } |
1563 | 1371 | ||
1564 | internal void ForEachClient(Action<IClientAPI> action) | 1372 | internal void ForEachClient(Action<IClientAPI> action) |
1565 | { | 1373 | { |
1566 | foreach (ScenePresence presence in m_scenePresences.Values) | 1374 | m_innerScene.ForEachClient(action); |
1567 | { | ||
1568 | action(presence.ControllingClient); | ||
1569 | } | ||
1570 | } | 1375 | } |
1376 | |||
1377 | #endregion | ||
1571 | } | 1378 | } |
1572 | } \ No newline at end of file | 1379 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs index ba4c40e..1494437 100644 --- a/OpenSim/Region/Environment/Scenes/SceneBase.cs +++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs | |||
@@ -37,6 +37,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
37 | { | 37 | { |
38 | public abstract class SceneBase : IScene | 38 | public abstract class SceneBase : IScene |
39 | { | 39 | { |
40 | #region Fields | ||
40 | private readonly ClientManager m_clientManager = new ClientManager(); | 41 | private readonly ClientManager m_clientManager = new ClientManager(); |
41 | 42 | ||
42 | public ClientManager ClientManager | 43 | public ClientManager ClientManager |
@@ -44,7 +45,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
44 | get { return m_clientManager; } | 45 | get { return m_clientManager; } |
45 | } | 46 | } |
46 | 47 | ||
47 | public Dictionary<LLUUID, EntityBase> Entities; | 48 | // public Dictionary<LLUUID, EntityBase> Entities; |
48 | protected ulong m_regionHandle; | 49 | protected ulong m_regionHandle; |
49 | protected string m_regionName; | 50 | protected string m_regionName; |
50 | protected RegionInfo m_regInfo; | 51 | protected RegionInfo m_regInfo; |
@@ -69,6 +70,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
69 | private uint m_nextLocalId = 8880000; | 70 | private uint m_nextLocalId = 8880000; |
70 | protected AssetCache assetCache; | 71 | protected AssetCache assetCache; |
71 | 72 | ||
73 | #endregion | ||
74 | |||
72 | #region Update Methods | 75 | #region Update Methods |
73 | 76 | ||
74 | /// <summary> | 77 | /// <summary> |
diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs new file mode 100644 index 0000000..2ade989 --- /dev/null +++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs | |||
@@ -0,0 +1,212 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Net; | ||
4 | using System.Text; | ||
5 | using libsecondlife; | ||
6 | using OpenSim.Framework; | ||
7 | using OpenSim.Framework.Console; | ||
8 | using OpenSim.Framework.Communications; | ||
9 | |||
10 | |||
11 | namespace OpenSim.Region.Environment.Scenes | ||
12 | { | ||
13 | public class SceneCommunicationService //one instance per region | ||
14 | { | ||
15 | protected CommunicationsManager m_commsProvider; | ||
16 | protected RegionInfo m_regionInfo; | ||
17 | |||
18 | protected RegionCommsListener regionCommsHost; | ||
19 | |||
20 | public event AgentCrossing OnAvatarCrossingIntoRegion; | ||
21 | public event ExpectUserDelegate OnExpectUser; | ||
22 | |||
23 | |||
24 | public SceneCommunicationService(CommunicationsManager commsMan) | ||
25 | { | ||
26 | m_commsProvider = commsMan; | ||
27 | } | ||
28 | |||
29 | public void RegisterRegion(RegionInfo regionInfos) | ||
30 | { | ||
31 | m_regionInfo = regionInfos; | ||
32 | regionCommsHost = m_commsProvider.GridService.RegisterRegion(m_regionInfo); | ||
33 | if (regionCommsHost != null) | ||
34 | { | ||
35 | regionCommsHost.OnExpectUser += NewUserConnection; | ||
36 | regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing; | ||
37 | } | ||
38 | } | ||
39 | |||
40 | public void Close() | ||
41 | { | ||
42 | regionCommsHost.OnExpectUser -= NewUserConnection; | ||
43 | regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing; | ||
44 | //regionCommsHost.RemoveRegion(m_regionInfo); //TODO add to method to commsManager | ||
45 | regionCommsHost = null; | ||
46 | } | ||
47 | |||
48 | #region CommsManager Event handlers | ||
49 | /// <summary> | ||
50 | /// | ||
51 | /// </summary> | ||
52 | /// <param name="regionHandle"></param> | ||
53 | /// <param name="agent"></param> | ||
54 | public void NewUserConnection(ulong regionHandle, AgentCircuitData agent) | ||
55 | { | ||
56 | if (OnExpectUser != null) | ||
57 | { | ||
58 | OnExpectUser(regionHandle, agent); | ||
59 | } | ||
60 | } | ||
61 | |||
62 | public void AgentCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying) | ||
63 | { | ||
64 | if (OnAvatarCrossingIntoRegion != null) | ||
65 | { | ||
66 | OnAvatarCrossingIntoRegion(regionHandle, agentID, position, isFlying); | ||
67 | } | ||
68 | } | ||
69 | #endregion | ||
70 | |||
71 | #region Inform Client of Neighbours | ||
72 | private delegate void InformClientOfNeighbourDelegate( | ||
73 | ScenePresence avatar, AgentCircuitData a, ulong regionHandle, IPEndPoint endPoint); | ||
74 | |||
75 | private void InformClientOfNeighbourCompleted(IAsyncResult iar) | ||
76 | { | ||
77 | InformClientOfNeighbourDelegate icon = (InformClientOfNeighbourDelegate)iar.AsyncState; | ||
78 | icon.EndInvoke(iar); | ||
79 | } | ||
80 | |||
81 | /// <summary> | ||
82 | /// Async compnent for informing client of which neighbours exists | ||
83 | /// </summary> | ||
84 | /// <remarks> | ||
85 | /// This needs to run asynchronesously, as a network timeout may block the thread for a long while | ||
86 | /// </remarks> | ||
87 | /// <param name="remoteClient"></param> | ||
88 | /// <param name="a"></param> | ||
89 | /// <param name="regionHandle"></param> | ||
90 | /// <param name="endPoint"></param> | ||
91 | private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, ulong regionHandle, | ||
92 | IPEndPoint endPoint) | ||
93 | { | ||
94 | MainLog.Instance.Notice("INTERGRID", "Starting to inform client about neighbours"); | ||
95 | bool regionAccepted = m_commsProvider.InterRegion.InformRegionOfChildAgent(regionHandle, a); | ||
96 | |||
97 | if (regionAccepted) | ||
98 | { | ||
99 | avatar.ControllingClient.InformClientOfNeighbour(regionHandle, endPoint); | ||
100 | avatar.AddNeighbourRegion(regionHandle); | ||
101 | MainLog.Instance.Notice("INTERGRID", "Completed inform client about neighbours"); | ||
102 | } | ||
103 | } | ||
104 | |||
105 | /// <summary> | ||
106 | /// | ||
107 | /// </summary> | ||
108 | public void InformClientOfNeighbours(ScenePresence avatar) | ||
109 | { | ||
110 | List<SimpleRegionInfo> neighbours = | ||
111 | m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); | ||
112 | if (neighbours != null) | ||
113 | { | ||
114 | for (int i = 0; i < neighbours.Count; i++) | ||
115 | { | ||
116 | AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo(); | ||
117 | agent.BaseFolder = LLUUID.Zero; | ||
118 | agent.InventoryFolder = LLUUID.Zero; | ||
119 | agent.startpos = new LLVector3(128, 128, 70); | ||
120 | agent.child = true; | ||
121 | |||
122 | InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; | ||
123 | d.BeginInvoke(avatar, agent, neighbours[i].RegionHandle, neighbours[i].ExternalEndPoint, | ||
124 | InformClientOfNeighbourCompleted, | ||
125 | d); | ||
126 | } | ||
127 | } | ||
128 | } | ||
129 | #endregion | ||
130 | |||
131 | /// <summary> | ||
132 | /// | ||
133 | /// </summary> | ||
134 | /// <param name="regionHandle"></param> | ||
135 | /// <returns></returns> | ||
136 | public virtual RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle) | ||
137 | { | ||
138 | return m_commsProvider.GridService.RequestNeighbourInfo(regionHandle); | ||
139 | } | ||
140 | |||
141 | /// <summary> | ||
142 | /// | ||
143 | /// </summary> | ||
144 | /// <param name="minX"></param> | ||
145 | /// <param name="minY"></param> | ||
146 | /// <param name="maxX"></param> | ||
147 | /// <param name="maxY"></param> | ||
148 | public virtual void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY) | ||
149 | { | ||
150 | List<MapBlockData> mapBlocks; | ||
151 | mapBlocks = m_commsProvider.GridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY); | ||
152 | remoteClient.SendMapBlock(mapBlocks); | ||
153 | } | ||
154 | |||
155 | /// <summary> | ||
156 | /// | ||
157 | /// </summary> | ||
158 | /// <param name="remoteClient"></param> | ||
159 | /// <param name="RegionHandle"></param> | ||
160 | /// <param name="position"></param> | ||
161 | /// <param name="lookAt"></param> | ||
162 | /// <param name="flags"></param> | ||
163 | public virtual void RequestTeleportLocation(ScenePresence avatar, ulong regionHandle, LLVector3 position, | ||
164 | LLVector3 lookAt, uint flags) | ||
165 | { | ||
166 | if (regionHandle == m_regionInfo.RegionHandle) | ||
167 | { | ||
168 | |||
169 | avatar.ControllingClient.SendTeleportLocationStart(); | ||
170 | avatar.ControllingClient.SendLocalTeleport(position, lookAt, flags); | ||
171 | avatar.Teleport(position); | ||
172 | |||
173 | } | ||
174 | else | ||
175 | { | ||
176 | RegionInfo reg = RequestNeighbouringRegionInfo(regionHandle); | ||
177 | if (reg != null) | ||
178 | { | ||
179 | avatar.ControllingClient.SendTeleportLocationStart(); | ||
180 | AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo(); | ||
181 | agent.BaseFolder = LLUUID.Zero; | ||
182 | agent.InventoryFolder = LLUUID.Zero; | ||
183 | agent.startpos = position; | ||
184 | agent.child = true; | ||
185 | avatar.Close(); | ||
186 | m_commsProvider.InterRegion.InformRegionOfChildAgent(regionHandle, agent); | ||
187 | m_commsProvider.InterRegion.ExpectAvatarCrossing(regionHandle, avatar.ControllingClient.AgentId, position, false); | ||
188 | AgentCircuitData circuitdata = avatar.ControllingClient.RequestClientInfo(); | ||
189 | string capsPath = Util.GetCapsURL(avatar.ControllingClient.AgentId); | ||
190 | avatar.ControllingClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4), capsPath); | ||
191 | avatar.MakeChildAgent(); | ||
192 | } | ||
193 | } | ||
194 | } | ||
195 | |||
196 | /// <summary> | ||
197 | /// | ||
198 | /// </summary> | ||
199 | /// <param name="regionhandle"></param> | ||
200 | /// <param name="agentID"></param> | ||
201 | /// <param name="position"></param> | ||
202 | public bool InformNeighbourOfCrossing(ulong regionhandle, LLUUID agentID, LLVector3 position, bool isFlying) | ||
203 | { | ||
204 | return m_commsProvider.InterRegion.ExpectAvatarCrossing(regionhandle, agentID, position, isFlying); | ||
205 | } | ||
206 | |||
207 | public void CloseAgentConnection(ScenePresence presence) | ||
208 | { | ||
209 | throw new Exception("The method or operation is not implemented."); | ||
210 | } | ||
211 | } | ||
212 | } | ||
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index d0edff3..637e090 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs | |||
@@ -260,6 +260,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
260 | public SceneObjectGroup ParentGroup | 260 | public SceneObjectGroup ParentGroup |
261 | { | 261 | { |
262 | get { return m_parentGroup; } | 262 | get { return m_parentGroup; } |
263 | |||
263 | } | 264 | } |
264 | 265 | ||
265 | #region Constructors | 266 | #region Constructors |
diff --git a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs index c616f6a..e658688 100644 --- a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs +++ b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs | |||
@@ -42,10 +42,10 @@ namespace SimpleApp | |||
42 | { | 42 | { |
43 | private List<ScenePresence> m_avatars; | 43 | private List<ScenePresence> m_avatars; |
44 | 44 | ||
45 | public MyWorld(RegionInfo regionInfo, AgentCircuitManager authen, CommunicationsManager commsMan, | 45 | public MyWorld(RegionInfo regionInfo, AgentCircuitManager authen, CommunicationsManager commsMan, SceneCommunicationService sceneGridService, |
46 | AssetCache assetCach, StorageManager storeMan, BaseHttpServer httpServer, | 46 | AssetCache assetCach, StorageManager storeMan, BaseHttpServer httpServer, |
47 | ModuleLoader moduleLoader) | 47 | ModuleLoader moduleLoader) |
48 | : base(regionInfo, authen, commsMan, assetCach, storeMan, httpServer, moduleLoader, false) | 48 | : base(regionInfo, authen, commsMan, sceneGridService, assetCach, storeMan, httpServer, moduleLoader, false) |
49 | { | 49 | { |
50 | m_avatars = new List<Avatar>(); | 50 | m_avatars = new List<Avatar>(); |
51 | } | 51 | } |
diff --git a/OpenSim/Region/Examples/SimpleApp/Program.cs b/OpenSim/Region/Examples/SimpleApp/Program.cs index b37c2ee..6c54d52 100644 --- a/OpenSim/Region/Examples/SimpleApp/Program.cs +++ b/OpenSim/Region/Examples/SimpleApp/Program.cs | |||
@@ -169,8 +169,9 @@ namespace SimpleApp | |||
169 | protected override Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager, | 169 | protected override Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager, |
170 | AgentCircuitManager circuitManager) | 170 | AgentCircuitManager circuitManager) |
171 | { | 171 | { |
172 | SceneCommunicationService sceneGridService = new SceneCommunicationService(m_commsManager); | ||
172 | return | 173 | return |
173 | new MyWorld(regionInfo, circuitManager, m_commsManager, m_assetCache, storageManager, m_httpServer, | 174 | new MyWorld(regionInfo, circuitManager, m_commsManager, sceneGridService, m_assetCache, storageManager, m_httpServer, |
174 | new ModuleLoader(m_log, m_config)); | 175 | new ModuleLoader(m_log, m_config)); |
175 | } | 176 | } |
176 | 177 | ||