diff options
author | Justin Clarke Casey | 2008-11-06 22:21:25 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-11-06 22:21:25 +0000 |
commit | 0d17ba2a76d4eb01f0bd6097c3974cd9d9fb2061 (patch) | |
tree | 82fc3cdd059f30d72407875a69ff662bb5747e41 /OpenSim/Region/Environment/Scenes | |
parent | add create_time and access_time to asset db for mysql, as well (diff) | |
download | opensim-SC-0d17ba2a76d4eb01f0bd6097c3974cd9d9fb2061.zip opensim-SC-0d17ba2a76d4eb01f0bd6097c3974cd9d9fb2061.tar.gz opensim-SC-0d17ba2a76d4eb01f0bd6097c3974cd9d9fb2061.tar.bz2 opensim-SC-0d17ba2a76d4eb01f0bd6097c3974cd9d9fb2061.tar.xz |
* refactor: Attach a scene object to a scene separately from its construction
Diffstat (limited to 'OpenSim/Region/Environment/Scenes')
6 files changed, 70 insertions, 69 deletions
diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs index 435ce77..4e7494e 100644 --- a/OpenSim/Region/Environment/Scenes/InnerScene.cs +++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs | |||
@@ -197,9 +197,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
197 | protected internal bool AddRestoredSceneObject( | 197 | protected internal bool AddRestoredSceneObject( |
198 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted) | 198 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted) |
199 | { | 199 | { |
200 | sceneObject.RegionHandle = m_regInfo.RegionHandle; | ||
201 | sceneObject.SetScene(m_parentScene); | ||
202 | |||
203 | foreach (SceneObjectPart part in sceneObject.Children.Values) | 200 | foreach (SceneObjectPart part in sceneObject.Children.Values) |
204 | { | 201 | { |
205 | part.LocalId = m_parentScene.PrimIDAllocate(); | 202 | part.LocalId = m_parentScene.PrimIDAllocate(); |
@@ -251,9 +248,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
251 | { | 248 | { |
252 | if (sceneObject == null || sceneObject.RootPart == null || sceneObject.RootPart.UUID == UUID.Zero) | 249 | if (sceneObject == null || sceneObject.RootPart == null || sceneObject.RootPart.UUID == UUID.Zero) |
253 | return false; | 250 | return false; |
254 | 251 | ||
255 | sceneObject.ApplyPhysics(m_parentScene.m_physicalPrim); | 252 | sceneObject.AttachToScene(m_parentScene); |
256 | sceneObject.ScheduleGroupForFullUpdate(); | ||
257 | 253 | ||
258 | lock (Entities) | 254 | lock (Entities) |
259 | { | 255 | { |
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 4621422..cee183c 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -1735,8 +1735,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1735 | //m_log.DebugFormat( | 1735 | //m_log.DebugFormat( |
1736 | // "[SCENE]: Scene.AddNewPrim() called for agent {0} in {1}", ownerID, RegionInfo.RegionName); | 1736 | // "[SCENE]: Scene.AddNewPrim() called for agent {0} in {1}", ownerID, RegionInfo.RegionName); |
1737 | 1737 | ||
1738 | SceneObjectGroup sceneOb = | 1738 | SceneObjectGroup sceneOb = new SceneObjectGroup(ownerID, PrimIDAllocate(), pos, rot, shape); |
1739 | new SceneObjectGroup(this, m_regionHandle, ownerID, PrimIDAllocate(), pos, rot, shape); | ||
1740 | 1739 | ||
1741 | SceneObjectPart rootPart = sceneOb.GetChildPart(sceneOb.UUID); | 1740 | SceneObjectPart rootPart = sceneOb.GetChildPart(sceneOb.UUID); |
1742 | // if grass or tree, make phantom | 1741 | // if grass or tree, make phantom |
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index bb0bf9a..9fd4728 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs | |||
@@ -508,35 +508,23 @@ namespace OpenSim.Region.Environment.Scenes | |||
508 | } | 508 | } |
509 | 509 | ||
510 | /// <summary> | 510 | /// <summary> |
511 | /// | 511 | /// Constructor. This object is added to the scene later via AttachToScene() |
512 | /// </summary> | 512 | /// </summary> |
513 | public SceneObjectGroup(Scene scene, ulong regionHandle, UUID ownerID, uint localID, Vector3 pos, | 513 | public SceneObjectGroup(UUID ownerID, uint localID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) |
514 | Quaternion rot, PrimitiveBaseShape shape) | ||
515 | { | 514 | { |
516 | m_regionHandle = regionHandle; | ||
517 | m_scene = scene; | ||
518 | |||
519 | // this.Pos = pos; | ||
520 | Vector3 rootOffset = new Vector3(0, 0, 0); | 515 | Vector3 rootOffset = new Vector3(0, 0, 0); |
521 | SceneObjectPart newPart = | 516 | SceneObjectPart newPart = |
522 | new SceneObjectPart(m_regionHandle, this, ownerID, localID, shape, pos, rot, rootOffset); | 517 | new SceneObjectPart(this, ownerID, localID, shape, pos, rot, rootOffset); |
523 | newPart.LinkNum = 0; | 518 | newPart.LinkNum = 0; |
524 | m_parts.Add(newPart.UUID, newPart); | 519 | m_parts.Add(newPart.UUID, newPart); |
525 | SetPartAsRoot(newPart); | 520 | SetPartAsRoot(newPart); |
526 | |||
527 | // one of these is a proxy. | ||
528 | if (shape.PCode != (byte)PCode.None && shape.PCode != (byte)PCode.ParticleSystem) | ||
529 | AttachToBackup(); | ||
530 | |||
531 | //ApplyPhysics(scene.m_physicalPrim); | ||
532 | } | 521 | } |
533 | 522 | ||
534 | /// <summary> | 523 | /// <summary> |
535 | /// | 524 | /// Constructor. |
536 | /// </summary> | 525 | /// </summary> |
537 | public SceneObjectGroup(Scene scene, ulong regionHandle, UUID ownerID, uint localID, Vector3 pos, | 526 | public SceneObjectGroup(UUID ownerID, uint localID, Vector3 pos, PrimitiveBaseShape shape) |
538 | PrimitiveBaseShape shape) | 527 | : this(ownerID, localID, pos, Quaternion.Identity, shape) |
539 | : this(scene, regionHandle, ownerID, localID, pos, Quaternion.Identity, shape) | ||
540 | { | 528 | { |
541 | } | 529 | } |
542 | 530 | ||
@@ -575,6 +563,31 @@ namespace OpenSim.Region.Environment.Scenes | |||
575 | m_isBackedUp = true; | 563 | m_isBackedUp = true; |
576 | } | 564 | } |
577 | } | 565 | } |
566 | |||
567 | /// <summary> | ||
568 | /// Attach the given group to a scene. It will appear to agents. | ||
569 | /// </summary> | ||
570 | /// <param name="scene"></param> | ||
571 | public void AttachToScene(Scene scene) | ||
572 | { | ||
573 | m_scene = scene; | ||
574 | |||
575 | ApplyPhysics(m_scene.m_physicalPrim); | ||
576 | |||
577 | lock (m_parts) | ||
578 | { | ||
579 | foreach (SceneObjectPart part in m_parts.Values) | ||
580 | { | ||
581 | part.AttachToScene(scene.RegionInfo.RegionHandle); | ||
582 | } | ||
583 | } | ||
584 | |||
585 | // one of these is a proxy. | ||
586 | if (m_rootPart.Shape.PCode != (byte)PCode.None && m_rootPart.Shape.PCode != (byte)PCode.ParticleSystem) | ||
587 | AttachToBackup(); | ||
588 | |||
589 | ScheduleGroupForFullUpdate(); | ||
590 | } | ||
578 | 591 | ||
579 | public Vector3 GroupScale() | 592 | public Vector3 GroupScale() |
580 | { | 593 | { |
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index be37352..9577bf6 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs | |||
@@ -216,9 +216,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
216 | Rezzed = DateTime.Now; | 216 | Rezzed = DateTime.Now; |
217 | } | 217 | } |
218 | 218 | ||
219 | public SceneObjectPart(ulong regionHandle, SceneObjectGroup parent, UUID ownerID, uint localID, | 219 | public SceneObjectPart(SceneObjectGroup parent, UUID ownerID, uint localID, |
220 | PrimitiveBaseShape shape, Vector3 groupPosition, Vector3 offsetPosition) | 220 | PrimitiveBaseShape shape, Vector3 groupPosition, Vector3 offsetPosition) |
221 | : this(regionHandle, parent, ownerID, localID, shape, groupPosition, Quaternion.Identity, offsetPosition) | 221 | : this(parent, ownerID, localID, shape, groupPosition, Quaternion.Identity, offsetPosition) |
222 | { | 222 | { |
223 | } | 223 | } |
224 | 224 | ||
@@ -231,12 +231,13 @@ namespace OpenSim.Region.Environment.Scenes | |||
231 | /// <param name="localID"></param> | 231 | /// <param name="localID"></param> |
232 | /// <param name="shape"></param> | 232 | /// <param name="shape"></param> |
233 | /// <param name="position"></param> | 233 | /// <param name="position"></param> |
234 | public SceneObjectPart(ulong regionHandle, SceneObjectGroup parent, UUID ownerID, uint localID, | 234 | /// <param name="rotationOffset"></param> |
235 | /// <param name="offsetPosition"></param> | ||
236 | public SceneObjectPart(SceneObjectGroup parent, UUID ownerID, uint localID, | ||
235 | PrimitiveBaseShape shape, Vector3 groupPosition, Quaternion rotationOffset, | 237 | PrimitiveBaseShape shape, Vector3 groupPosition, Quaternion rotationOffset, |
236 | Vector3 offsetPosition) | 238 | Vector3 offsetPosition) |
237 | { | 239 | { |
238 | m_name = "Primitive"; | 240 | m_name = "Primitive"; |
239 | m_regionHandle = regionHandle; | ||
240 | m_parentGroup = parent; | 241 | m_parentGroup = parent; |
241 | 242 | ||
242 | Rezzed = DateTime.Now; | 243 | Rezzed = DateTime.Now; |
@@ -259,14 +260,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
259 | RotationOffset = rotationOffset; | 260 | RotationOffset = rotationOffset; |
260 | Velocity = new Vector3(0, 0, 0); | 261 | Velocity = new Vector3(0, 0, 0); |
261 | AngularVelocity = new Vector3(0, 0, 0); | 262 | AngularVelocity = new Vector3(0, 0, 0); |
262 | Acceleration = new Vector3(0, 0, 0); | 263 | Acceleration = new Vector3(0, 0, 0); |
263 | |||
264 | |||
265 | |||
266 | m_TextureAnimation = new byte[0]; | 264 | m_TextureAnimation = new byte[0]; |
267 | m_particleSystem = new byte[0]; | 265 | m_particleSystem = new byte[0]; |
268 | |||
269 | |||
270 | 266 | ||
271 | // Prims currently only contain a single folder (Contents). From looking at the Second Life protocol, | 267 | // Prims currently only contain a single folder (Contents). From looking at the Second Life protocol, |
272 | // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from | 268 | // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from |
@@ -277,8 +273,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
277 | 273 | ||
278 | TrimPermissions(); | 274 | TrimPermissions(); |
279 | //m_undo = new UndoStack<UndoState>(ParentGroup.GetSceneMaxUndo()); | 275 | //m_undo = new UndoStack<UndoState>(ParentGroup.GetSceneMaxUndo()); |
280 | |||
281 | ScheduleFullUpdate(); | ||
282 | } | 276 | } |
283 | 277 | ||
284 | /// <summary> | 278 | /// <summary> |
@@ -291,11 +285,10 @@ namespace OpenSim.Region.Environment.Scenes | |||
291 | /// <param name="localID"></param> | 285 | /// <param name="localID"></param> |
292 | /// <param name="shape"></param> | 286 | /// <param name="shape"></param> |
293 | /// <param name="position"></param> | 287 | /// <param name="position"></param> |
294 | public SceneObjectPart(ulong regionHandle, SceneObjectGroup parent, int creationDate, UUID ownerID, | 288 | public SceneObjectPart(SceneObjectGroup parent, int creationDate, UUID ownerID, |
295 | UUID creatorID, UUID lastOwnerID, uint localID, PrimitiveBaseShape shape, | 289 | UUID creatorID, UUID lastOwnerID, uint localID, PrimitiveBaseShape shape, |
296 | Vector3 position, Quaternion rotation, uint flags) | 290 | Vector3 position, Quaternion rotation, uint flags) |
297 | { | 291 | { |
298 | m_regionHandle = regionHandle; | ||
299 | m_parentGroup = parent; | 292 | m_parentGroup = parent; |
300 | TimeStampTerse = (uint) Util.UnixTimeSinceEpoch(); | 293 | TimeStampTerse = (uint) Util.UnixTimeSinceEpoch(); |
301 | _creationDate = creationDate; | 294 | _creationDate = creationDate; |
@@ -324,8 +317,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
324 | 317 | ||
325 | TrimPermissions(); | 318 | TrimPermissions(); |
326 | // ApplyPhysics(); | 319 | // ApplyPhysics(); |
327 | |||
328 | ScheduleFullUpdate(); | ||
329 | } | 320 | } |
330 | 321 | ||
331 | protected SceneObjectPart(SerializationInfo info, StreamingContext context) | 322 | protected SceneObjectPart(SerializationInfo info, StreamingContext context) |
@@ -370,7 +361,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
370 | private DateTime m_expires; | 361 | private DateTime m_expires; |
371 | private DateTime m_rezzed; | 362 | private DateTime m_rezzed; |
372 | 363 | ||
373 | public UUID CreatorID { | 364 | public UUID CreatorID |
365 | { | ||
374 | get | 366 | get |
375 | { | 367 | { |
376 | return _creatorID; | 368 | return _creatorID; |
@@ -553,17 +545,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
553 | { | 545 | { |
554 | StoreUndoState(); | 546 | StoreUndoState(); |
555 | m_offsetPosition = value; | 547 | m_offsetPosition = value; |
556 | //try | ||
557 | //{ | ||
558 | // Hack to get the child prim to update world positions in the physics engine | ||
559 | // ParentGroup.ResetChildPrimPhysicsPositions(); | ||
560 | |||
561 | //} | ||
562 | //catch (NullReferenceException) | ||
563 | //{ | ||
564 | // Ignore, and skip over. | ||
565 | //} | ||
566 | //m_log.Info("[PART]: OFFSET:" + m_offsetPosition.ToString()); | ||
567 | 548 | ||
568 | if (ParentGroup != null && ParentGroup.RootPart != null) | 549 | if (ParentGroup != null && ParentGroup.RootPart != null) |
569 | { | 550 | { |
@@ -778,6 +759,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
778 | TriggerScriptChangedEvent(Changed.SHAPE); | 759 | TriggerScriptChangedEvent(Changed.SHAPE); |
779 | } | 760 | } |
780 | } | 761 | } |
762 | |||
781 | public Vector3 Scale | 763 | public Vector3 Scale |
782 | { | 764 | { |
783 | get { return m_shape.Scale; } | 765 | get { return m_shape.Scale; } |
@@ -813,7 +795,6 @@ if (m_shape != null) { | |||
813 | //--------------- | 795 | //--------------- |
814 | #region Public Properties with only Get | 796 | #region Public Properties with only Get |
815 | 797 | ||
816 | |||
817 | public Vector3 AbsolutePosition | 798 | public Vector3 AbsolutePosition |
818 | { | 799 | { |
819 | get { | 800 | get { |
@@ -3418,6 +3399,16 @@ if (m_shape != null) { | |||
3418 | } | 3399 | } |
3419 | 3400 | ||
3420 | #endregion Public Methods | 3401 | #endregion Public Methods |
3402 | |||
3403 | /// <summary> | ||
3404 | /// Attach this part to a scene such that it appears to avatars | ||
3405 | /// </summary> | ||
3406 | protected internal void AttachToScene(ulong regionHandle) | ||
3407 | { | ||
3408 | m_regionHandle = regionHandle; | ||
3409 | |||
3410 | ScheduleFullUpdate(); | ||
3411 | } | ||
3421 | 3412 | ||
3422 | private byte GetAttachPointEncoded() | 3413 | private byte GetAttachPointEncoded() |
3423 | { | 3414 | { |
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index fb9c29c..db4ab52 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs | |||
@@ -1107,20 +1107,22 @@ namespace OpenSim.Region.Environment.Scenes | |||
1107 | //proxy.PCode = (byte)PCode.ParticleSystem; | 1107 | //proxy.PCode = (byte)PCode.ParticleSystem; |
1108 | uint nextUUID = m_scene.NextLocalId; | 1108 | uint nextUUID = m_scene.NextLocalId; |
1109 | 1109 | ||
1110 | proxyObjectGroup = new SceneObjectGroup(m_scene, m_scene.RegionInfo.RegionHandle, UUID, nextUUID, Pos, Rotation, proxy); | 1110 | proxyObjectGroup = new SceneObjectGroup(UUID, nextUUID, Pos, Rotation, proxy); |
1111 | if (proxyObjectGroup != null) | 1111 | proxyObjectGroup.AttachToScene(m_scene); |
1112 | { | 1112 | |
1113 | // Commented out this code since it could never have executed, but might still be informative. | ||
1114 | // if (proxyObjectGroup != null) | ||
1115 | // { | ||
1113 | proxyObjectGroup.SendGroupFullUpdate(); | 1116 | proxyObjectGroup.SendGroupFullUpdate(); |
1114 | remote_client.SendSitResponse(proxyObjectGroup.UUID, Vector3.Zero, Quaternion.Identity, true, Vector3.Zero, Vector3.Zero, false); | 1117 | remote_client.SendSitResponse(proxyObjectGroup.UUID, Vector3.Zero, Quaternion.Identity, true, Vector3.Zero, Vector3.Zero, false); |
1115 | m_scene.DeleteSceneObject(proxyObjectGroup); | 1118 | m_scene.DeleteSceneObject(proxyObjectGroup); |
1116 | } | 1119 | // } |
1117 | else | 1120 | // else |
1118 | { | 1121 | // { |
1119 | m_autopilotMoving = false; | 1122 | // m_autopilotMoving = false; |
1120 | m_autoPilotTarget = Vector3.Zero; | 1123 | // m_autoPilotTarget = Vector3.Zero; |
1121 | ControllingClient.SendAlertMessage("Autopilot cancelled"); | 1124 | // ControllingClient.SendAlertMessage("Autopilot cancelled"); |
1122 | } | 1125 | // } |
1123 | |||
1124 | } | 1126 | } |
1125 | 1127 | ||
1126 | private void CheckAtSitTarget() | 1128 | private void CheckAtSitTarget() |
diff --git a/OpenSim/Region/Environment/Scenes/Tests/SceneTests.cs b/OpenSim/Region/Environment/Scenes/Tests/SceneTests.cs index 3576594..0b0f606 100644 --- a/OpenSim/Region/Environment/Scenes/Tests/SceneTests.cs +++ b/OpenSim/Region/Environment/Scenes/Tests/SceneTests.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | using System; | 28 | using System; |
29 | using Nini.Config; | 29 | using Nini.Config; |
30 | using NUnit.Framework; | 30 | using NUnit.Framework; |
31 | using OpenMetaverse; | ||
31 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
32 | using OpenSim.Framework.Communications; | 33 | using OpenSim.Framework.Communications; |
33 | using OpenSim.Region.Environment.Scenes; | 34 | using OpenSim.Region.Environment.Scenes; |
@@ -73,8 +74,7 @@ namespace OpenSim.Region.Environment.Scenes.Tests | |||
73 | = new Scene(regInfo, acm, cm, scs, null, sm, null, null, false, false, false, configSource, null); | 74 | = new Scene(regInfo, acm, cm, scs, null, sm, null, null, false, false, false, configSource, null); |
74 | 75 | ||
75 | SceneObjectGroup sceneObject = new SceneObjectGroup(); | 76 | SceneObjectGroup sceneObject = new SceneObjectGroup(); |
76 | SceneObjectPart part = new SceneObjectPart(); | 77 | new SceneObjectPart(sceneObject, UUID.Zero, 1, null, Vector3.Zero, Quaternion.Identity, Vector3.Zero); |
77 | sceneObject.AddPart(part); | ||
78 | 78 | ||
79 | scene.AddNewSceneObject(sceneObject, false); | 79 | scene.AddNewSceneObject(sceneObject, false); |
80 | } | 80 | } |