From 0d17ba2a76d4eb01f0bd6097c3974cd9d9fb2061 Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Thu, 6 Nov 2008 22:21:25 +0000
Subject: * refactor: Attach a scene object to a scene separately from its
construction
---
OpenSim/Region/Environment/Scenes/InnerScene.cs | 8 +---
OpenSim/Region/Environment/Scenes/Scene.cs | 3 +-
.../Region/Environment/Scenes/SceneObjectGroup.cs | 49 +++++++++++++--------
.../Region/Environment/Scenes/SceneObjectPart.cs | 51 +++++++++-------------
OpenSim/Region/Environment/Scenes/ScenePresence.cs | 24 +++++-----
.../Region/Environment/Scenes/Tests/SceneTests.cs | 4 +-
.../Region/Examples/SimpleModule/ComplexObject.cs | 24 +++++-----
.../Examples/SimpleModule/CpuCounterObject.cs | 4 +-
.../Examples/SimpleModule/FileSystemObject.cs | 2 +-
9 files changed, 84 insertions(+), 85 deletions(-)
(limited to 'OpenSim')
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
protected internal bool AddRestoredSceneObject(
SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted)
{
- sceneObject.RegionHandle = m_regInfo.RegionHandle;
- sceneObject.SetScene(m_parentScene);
-
foreach (SceneObjectPart part in sceneObject.Children.Values)
{
part.LocalId = m_parentScene.PrimIDAllocate();
@@ -251,9 +248,8 @@ namespace OpenSim.Region.Environment.Scenes
{
if (sceneObject == null || sceneObject.RootPart == null || sceneObject.RootPart.UUID == UUID.Zero)
return false;
-
- sceneObject.ApplyPhysics(m_parentScene.m_physicalPrim);
- sceneObject.ScheduleGroupForFullUpdate();
+
+ sceneObject.AttachToScene(m_parentScene);
lock (Entities)
{
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
//m_log.DebugFormat(
// "[SCENE]: Scene.AddNewPrim() called for agent {0} in {1}", ownerID, RegionInfo.RegionName);
- SceneObjectGroup sceneOb =
- new SceneObjectGroup(this, m_regionHandle, ownerID, PrimIDAllocate(), pos, rot, shape);
+ SceneObjectGroup sceneOb = new SceneObjectGroup(ownerID, PrimIDAllocate(), pos, rot, shape);
SceneObjectPart rootPart = sceneOb.GetChildPart(sceneOb.UUID);
// 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
}
///
- ///
+ /// Constructor. This object is added to the scene later via AttachToScene()
///
- public SceneObjectGroup(Scene scene, ulong regionHandle, UUID ownerID, uint localID, Vector3 pos,
- Quaternion rot, PrimitiveBaseShape shape)
+ public SceneObjectGroup(UUID ownerID, uint localID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape)
{
- m_regionHandle = regionHandle;
- m_scene = scene;
-
- // this.Pos = pos;
Vector3 rootOffset = new Vector3(0, 0, 0);
SceneObjectPart newPart =
- new SceneObjectPart(m_regionHandle, this, ownerID, localID, shape, pos, rot, rootOffset);
+ new SceneObjectPart(this, ownerID, localID, shape, pos, rot, rootOffset);
newPart.LinkNum = 0;
m_parts.Add(newPart.UUID, newPart);
SetPartAsRoot(newPart);
-
- // one of these is a proxy.
- if (shape.PCode != (byte)PCode.None && shape.PCode != (byte)PCode.ParticleSystem)
- AttachToBackup();
-
- //ApplyPhysics(scene.m_physicalPrim);
}
///
- ///
+ /// Constructor.
///
- public SceneObjectGroup(Scene scene, ulong regionHandle, UUID ownerID, uint localID, Vector3 pos,
- PrimitiveBaseShape shape)
- : this(scene, regionHandle, ownerID, localID, pos, Quaternion.Identity, shape)
+ public SceneObjectGroup(UUID ownerID, uint localID, Vector3 pos, PrimitiveBaseShape shape)
+ : this(ownerID, localID, pos, Quaternion.Identity, shape)
{
}
@@ -575,6 +563,31 @@ namespace OpenSim.Region.Environment.Scenes
m_isBackedUp = true;
}
}
+
+ ///
+ /// Attach the given group to a scene. It will appear to agents.
+ ///
+ ///
+ public void AttachToScene(Scene scene)
+ {
+ m_scene = scene;
+
+ ApplyPhysics(m_scene.m_physicalPrim);
+
+ lock (m_parts)
+ {
+ foreach (SceneObjectPart part in m_parts.Values)
+ {
+ part.AttachToScene(scene.RegionInfo.RegionHandle);
+ }
+ }
+
+ // one of these is a proxy.
+ if (m_rootPart.Shape.PCode != (byte)PCode.None && m_rootPart.Shape.PCode != (byte)PCode.ParticleSystem)
+ AttachToBackup();
+
+ ScheduleGroupForFullUpdate();
+ }
public Vector3 GroupScale()
{
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
Rezzed = DateTime.Now;
}
- public SceneObjectPart(ulong regionHandle, SceneObjectGroup parent, UUID ownerID, uint localID,
+ public SceneObjectPart(SceneObjectGroup parent, UUID ownerID, uint localID,
PrimitiveBaseShape shape, Vector3 groupPosition, Vector3 offsetPosition)
- : this(regionHandle, parent, ownerID, localID, shape, groupPosition, Quaternion.Identity, offsetPosition)
+ : this(parent, ownerID, localID, shape, groupPosition, Quaternion.Identity, offsetPosition)
{
}
@@ -231,12 +231,13 @@ namespace OpenSim.Region.Environment.Scenes
///
///
///
- public SceneObjectPart(ulong regionHandle, SceneObjectGroup parent, UUID ownerID, uint localID,
+ ///
+ ///
+ public SceneObjectPart(SceneObjectGroup parent, UUID ownerID, uint localID,
PrimitiveBaseShape shape, Vector3 groupPosition, Quaternion rotationOffset,
Vector3 offsetPosition)
{
m_name = "Primitive";
- m_regionHandle = regionHandle;
m_parentGroup = parent;
Rezzed = DateTime.Now;
@@ -259,14 +260,9 @@ namespace OpenSim.Region.Environment.Scenes
RotationOffset = rotationOffset;
Velocity = new Vector3(0, 0, 0);
AngularVelocity = new Vector3(0, 0, 0);
- Acceleration = new Vector3(0, 0, 0);
-
-
-
+ Acceleration = new Vector3(0, 0, 0);
m_TextureAnimation = new byte[0];
- m_particleSystem = new byte[0];
-
-
+ m_particleSystem = new byte[0];
// Prims currently only contain a single folder (Contents). From looking at the Second Life protocol,
// 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
TrimPermissions();
//m_undo = new UndoStack(ParentGroup.GetSceneMaxUndo());
-
- ScheduleFullUpdate();
}
///
@@ -291,11 +285,10 @@ namespace OpenSim.Region.Environment.Scenes
///
///
///
- public SceneObjectPart(ulong regionHandle, SceneObjectGroup parent, int creationDate, UUID ownerID,
+ public SceneObjectPart(SceneObjectGroup parent, int creationDate, UUID ownerID,
UUID creatorID, UUID lastOwnerID, uint localID, PrimitiveBaseShape shape,
Vector3 position, Quaternion rotation, uint flags)
{
- m_regionHandle = regionHandle;
m_parentGroup = parent;
TimeStampTerse = (uint) Util.UnixTimeSinceEpoch();
_creationDate = creationDate;
@@ -324,8 +317,6 @@ namespace OpenSim.Region.Environment.Scenes
TrimPermissions();
// ApplyPhysics();
-
- ScheduleFullUpdate();
}
protected SceneObjectPart(SerializationInfo info, StreamingContext context)
@@ -370,7 +361,8 @@ namespace OpenSim.Region.Environment.Scenes
private DateTime m_expires;
private DateTime m_rezzed;
- public UUID CreatorID {
+ public UUID CreatorID
+ {
get
{
return _creatorID;
@@ -553,17 +545,6 @@ namespace OpenSim.Region.Environment.Scenes
{
StoreUndoState();
m_offsetPosition = value;
- //try
- //{
- // Hack to get the child prim to update world positions in the physics engine
- // ParentGroup.ResetChildPrimPhysicsPositions();
-
- //}
- //catch (NullReferenceException)
- //{
- // Ignore, and skip over.
- //}
- //m_log.Info("[PART]: OFFSET:" + m_offsetPosition.ToString());
if (ParentGroup != null && ParentGroup.RootPart != null)
{
@@ -778,6 +759,7 @@ namespace OpenSim.Region.Environment.Scenes
TriggerScriptChangedEvent(Changed.SHAPE);
}
}
+
public Vector3 Scale
{
get { return m_shape.Scale; }
@@ -813,7 +795,6 @@ if (m_shape != null) {
//---------------
#region Public Properties with only Get
-
public Vector3 AbsolutePosition
{
get {
@@ -3418,6 +3399,16 @@ if (m_shape != null) {
}
#endregion Public Methods
+
+ ///
+ /// Attach this part to a scene such that it appears to avatars
+ ///
+ protected internal void AttachToScene(ulong regionHandle)
+ {
+ m_regionHandle = regionHandle;
+
+ ScheduleFullUpdate();
+ }
private byte GetAttachPointEncoded()
{
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
//proxy.PCode = (byte)PCode.ParticleSystem;
uint nextUUID = m_scene.NextLocalId;
- proxyObjectGroup = new SceneObjectGroup(m_scene, m_scene.RegionInfo.RegionHandle, UUID, nextUUID, Pos, Rotation, proxy);
- if (proxyObjectGroup != null)
- {
+ proxyObjectGroup = new SceneObjectGroup(UUID, nextUUID, Pos, Rotation, proxy);
+ proxyObjectGroup.AttachToScene(m_scene);
+
+ // Commented out this code since it could never have executed, but might still be informative.
+// if (proxyObjectGroup != null)
+// {
proxyObjectGroup.SendGroupFullUpdate();
remote_client.SendSitResponse(proxyObjectGroup.UUID, Vector3.Zero, Quaternion.Identity, true, Vector3.Zero, Vector3.Zero, false);
m_scene.DeleteSceneObject(proxyObjectGroup);
- }
- else
- {
- m_autopilotMoving = false;
- m_autoPilotTarget = Vector3.Zero;
- ControllingClient.SendAlertMessage("Autopilot cancelled");
- }
-
+// }
+// else
+// {
+// m_autopilotMoving = false;
+// m_autoPilotTarget = Vector3.Zero;
+// ControllingClient.SendAlertMessage("Autopilot cancelled");
+// }
}
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 @@
using System;
using Nini.Config;
using NUnit.Framework;
+using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
using OpenSim.Region.Environment.Scenes;
@@ -73,8 +74,7 @@ namespace OpenSim.Region.Environment.Scenes.Tests
= new Scene(regInfo, acm, cm, scs, null, sm, null, null, false, false, false, configSource, null);
SceneObjectGroup sceneObject = new SceneObjectGroup();
- SceneObjectPart part = new SceneObjectPart();
- sceneObject.AddPart(part);
+ new SceneObjectPart(sceneObject, UUID.Zero, 1, null, Vector3.Zero, Quaternion.Identity, Vector3.Zero);
scene.AddNewSceneObject(sceneObject, false);
}
diff --git a/OpenSim/Region/Examples/SimpleModule/ComplexObject.cs b/OpenSim/Region/Examples/SimpleModule/ComplexObject.cs
index 3b776e7..9ad4897 100644
--- a/OpenSim/Region/Examples/SimpleModule/ComplexObject.cs
+++ b/OpenSim/Region/Examples/SimpleModule/ComplexObject.cs
@@ -51,11 +51,9 @@ namespace OpenSim.Region.Examples.SimpleModule
{
}
- public RotatingWheel(ulong regionHandle, SceneObjectGroup parent, UUID ownerID, uint localID,
+ public RotatingWheel(SceneObjectGroup parent, UUID ownerID, uint localID,
Vector3 groupPosition, Vector3 offsetPosition, Quaternion rotationDirection)
- : base(
- regionHandle, parent, ownerID, localID, PrimitiveBaseShape.Default, groupPosition, offsetPosition
- )
+ : base(parent, ownerID, localID, PrimitiveBaseShape.Default, groupPosition, offsetPosition)
{
m_rotationDirection = rotationDirection;
@@ -64,13 +62,13 @@ namespace OpenSim.Region.Examples.SimpleModule
public override void UpdateMovement()
{
- UpdateRotation(RotationOffset*m_rotationDirection);
+ UpdateRotation(RotationOffset * m_rotationDirection);
}
}
public override void UpdateMovement()
{
- UpdateGroupRotation(GroupRotation*m_rotationDirection);
+ UpdateGroupRotation(GroupRotation * m_rotationDirection);
base.UpdateMovement();
}
@@ -80,29 +78,29 @@ namespace OpenSim.Region.Examples.SimpleModule
}
public ComplexObject(Scene scene, ulong regionHandle, UUID ownerID, uint localID, Vector3 pos)
- : base(scene, regionHandle, ownerID, localID, pos, PrimitiveBaseShape.Default)
+ : base(ownerID, localID, pos, PrimitiveBaseShape.Default)
{
m_rotationDirection = new Quaternion(0.05f, 0.1f, 0.15f);
AddPart(
- new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new Vector3(0, 0, 0.75f),
+ new RotatingWheel(this, ownerID, scene.PrimIDAllocate(), pos, new Vector3(0, 0, 0.75f),
new Quaternion(0.05f, 0, 0)));
AddPart(
- new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new Vector3(0, 0, -0.75f),
+ new RotatingWheel(this, ownerID, scene.PrimIDAllocate(), pos, new Vector3(0, 0, -0.75f),
new Quaternion(-0.05f, 0, 0)));
AddPart(
- new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new Vector3(0, 0.75f, 0),
+ new RotatingWheel(this, ownerID, scene.PrimIDAllocate(), pos, new Vector3(0, 0.75f, 0),
new Quaternion(0.5f, 0, 0.05f)));
AddPart(
- new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new Vector3(0, -0.75f, 0),
+ new RotatingWheel(this, ownerID, scene.PrimIDAllocate(), pos, new Vector3(0, -0.75f, 0),
new Quaternion(-0.5f, 0, -0.05f)));
AddPart(
- new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new Vector3(0.75f, 0, 0),
+ new RotatingWheel(this, ownerID, scene.PrimIDAllocate(), pos, new Vector3(0.75f, 0, 0),
new Quaternion(0, 0.5f, 0.05f)));
AddPart(
- new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new Vector3(-0.75f, 0, 0),
+ new RotatingWheel(this, ownerID, scene.PrimIDAllocate(), pos, new Vector3(-0.75f, 0, 0),
new Quaternion(0, -0.5f, -0.05f)));
RootPart.Flags |= PrimFlags.Touch;
diff --git a/OpenSim/Region/Examples/SimpleModule/CpuCounterObject.cs b/OpenSim/Region/Examples/SimpleModule/CpuCounterObject.cs
index 126ccd3..83bced5 100644
--- a/OpenSim/Region/Examples/SimpleModule/CpuCounterObject.cs
+++ b/OpenSim/Region/Examples/SimpleModule/CpuCounterObject.cs
@@ -45,8 +45,8 @@ namespace OpenSim.Region.Examples.SimpleModule
private PerformanceCounter m_counter;
- public CpuCounterObject(Scene world, ulong regionHandle, UUID ownerID, uint localID, Vector3 pos)
- : base(world, regionHandle, ownerID, localID, pos, PrimitiveBaseShape.Default)
+ public CpuCounterObject(UUID ownerID, uint localID, Vector3 pos)
+ : base(ownerID, localID, pos, PrimitiveBaseShape.Default)
{
String objectName = "Processor";
String counterName = "% Processor Time";
diff --git a/OpenSim/Region/Examples/SimpleModule/FileSystemObject.cs b/OpenSim/Region/Examples/SimpleModule/FileSystemObject.cs
index 3b43c7a..0903edd 100644
--- a/OpenSim/Region/Examples/SimpleModule/FileSystemObject.cs
+++ b/OpenSim/Region/Examples/SimpleModule/FileSystemObject.cs
@@ -35,7 +35,7 @@ namespace OpenSim.Region.Examples.SimpleModule
public class FileSystemObject : SceneObjectGroup
{
public FileSystemObject(Scene world, FileInfo fileInfo, Vector3 pos)
- : base(world, world.RegionInfo.RegionHandle, UUID.Zero, world.NextLocalId, pos, PrimitiveBaseShape.Default)
+ : base(UUID.Zero, world.NextLocalId, pos, PrimitiveBaseShape.Default)
{
Text = fileInfo.Name;
}
--
cgit v1.1