From 5d1d5a22a9590cf8a3475a0bf13a4613b6273bf4 Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Mon, 10 Nov 2008 18:10:00 +0000
Subject: * Extend basic scene test to retrieve the object from the scene and
match uuids * Decouple sog and sop by removing the need to pass the sog to
the sop when it is created - most of the code was doing this operation (and
hence duplicating it) anyway * Remove unused constructors
---
OpenSim/Region/Environment/Scenes/InnerScene.cs | 4 +-
OpenSim/Region/Environment/Scenes/Scene.cs | 6 +--
.../Region/Environment/Scenes/SceneObjectGroup.cs | 9 ++--
.../Region/Environment/Scenes/SceneObjectPart.cs | 57 +---------------------
.../Region/Environment/Scenes/Tests/SceneTests.cs | 15 +++++-
.../Region/Examples/SimpleModule/ComplexObject.cs | 18 +++----
6 files changed, 37 insertions(+), 72 deletions(-)
diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs
index aca82c3..508ddd4 100644
--- a/OpenSim/Region/Environment/Scenes/InnerScene.cs
+++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs
@@ -784,10 +784,11 @@ namespace OpenSim.Region.Environment.Scenes
/// null if no scene object group containing that prim is found
private SceneObjectGroup GetGroupByPrim(uint localID)
{
+ //m_log.DebugFormat("Entered GetGroupByPrim with localID {0}", localID);
List EntityList = GetEntities();
-
foreach (EntityBase ent in EntityList)
{
+ //m_log.DebugFormat("Looking at entity {0}", ent.UUID);
if (ent is SceneObjectGroup)
{
if (((SceneObjectGroup)ent).HasChildPrim(localID))
@@ -891,6 +892,7 @@ namespace OpenSim.Region.Environment.Scenes
protected internal SceneObjectPart GetSceneObjectPart(UUID fullID)
{
SceneObjectGroup group = GetGroupByPrim(fullID);
+
if (group != null)
return group.GetChildPart(fullID);
else
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index f1c4c6c..7de6fd1 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -164,7 +164,7 @@ namespace OpenSim.Region.Environment.Scenes
private Thread HeartbeatThread;
private volatile bool shuttingdown = false;
- private object m_deleting_scene_object = new object();
+ private object m_deleting_scene_object = new object();
#endregion
@@ -4009,7 +4009,7 @@ namespace OpenSim.Region.Environment.Scenes
}
///
- ///
+ /// Get a prim via its local id
///
///
///
@@ -4019,7 +4019,7 @@ namespace OpenSim.Region.Environment.Scenes
}
///
- ///
+ /// Get a prim via its UUID
///
///
///
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index 28fba65..39615c0 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -507,9 +507,9 @@ namespace OpenSim.Region.Environment.Scenes
public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape)
{
Vector3 rootOffset = new Vector3(0, 0, 0);
- SceneObjectPart newPart = new SceneObjectPart(this, ownerID, shape, pos, rot, rootOffset);
+ SceneObjectPart newPart = new SceneObjectPart(ownerID, shape, pos, rot, rootOffset);
newPart.LinkNum = 0;
- m_parts.Add(newPart.UUID, newPart);
+ AddPart(newPart);
SetPartAsRoot(newPart);
}
@@ -904,7 +904,6 @@ namespace OpenSim.Region.Environment.Scenes
try
{
m_parts.Add(part.UUID, part);
-
}
catch (Exception e)
{
@@ -1757,10 +1756,12 @@ namespace OpenSim.Region.Environment.Scenes
/// null if a child part with the local ID was not found
public SceneObjectPart GetChildPart(uint localID)
{
+ //m_log.DebugFormat("Entered looking for {0}", localID);
lock (m_parts)
{
foreach (SceneObjectPart part in m_parts.Values)
{
+ //m_log.DebugFormat("Found {0}", part.LocalId);
if (part.LocalId == localID)
{
return part;
@@ -1795,10 +1796,12 @@ namespace OpenSim.Region.Environment.Scenes
///
public bool HasChildPrim(uint localID)
{
+ //m_log.DebugFormat("Entered HasChildPrim looking for {0}", localID);
lock (m_parts)
{
foreach (SceneObjectPart part in m_parts.Values)
{
+ //m_log.DebugFormat("Found {0}", part.LocalId);
if (part.LocalId == localID)
{
return true;
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index 3501224..4d54634 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -216,28 +216,19 @@ namespace OpenSim.Region.Environment.Scenes
Rezzed = DateTime.Now;
}
- public SceneObjectPart(SceneObjectGroup parent, UUID ownerID,
- PrimitiveBaseShape shape, Vector3 groupPosition, Vector3 offsetPosition)
- : this(parent, ownerID, shape, groupPosition, Quaternion.Identity, offsetPosition)
- {
- }
-
///
- /// Create a completely new SceneObjectPart (prim)
+ /// Create a completely new SceneObjectPart (prim). This will need to be added separately to a SceneObjectGroup
///
- ///
- ///
///
///
///
///
///
public SceneObjectPart(
- SceneObjectGroup parent, UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition,
+ UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition,
Quaternion rotationOffset, Vector3 offsetPosition)
{
m_name = "Primitive";
- m_parentGroup = parent;
Rezzed = DateTime.Now;
_creationDate = (Int32) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
@@ -273,49 +264,6 @@ namespace OpenSim.Region.Environment.Scenes
//m_undo = new UndoStack(ParentGroup.GetSceneMaxUndo());
}
- ///
- /// Re/create a SceneObjectPart (prim)
- /// currently not used, and maybe won't be
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public SceneObjectPart(SceneObjectGroup parent, int creationDate, UUID ownerID,
- UUID creatorID, UUID lastOwnerID, PrimitiveBaseShape shape,
- Vector3 position, Quaternion rotation, uint flags)
- {
- m_parentGroup = parent;
- TimeStampTerse = (uint) Util.UnixTimeSinceEpoch();
- _creationDate = creationDate;
- _ownerID = ownerID;
- _creatorID = creatorID;
- _lastOwnerID = lastOwnerID;
- UUID = UUID.Random();
- Shape = shape;
- _ownershipCost = 0;
- _objectSaleType = (byte) 0;
- _salePrice = 0;
- _category = (uint) 0;
- _lastOwnerID = _creatorID;
- OffsetPosition = position;
- RotationOffset = rotation;
- ObjectFlags = flags;
-
- Rezzed = DateTime.Now;
-
- m_TextureAnimation = new byte[0];
- m_particleSystem = new byte[0];
- // Since we don't store script state, this is only a 'temporary' objectflag now
- // If the object is scripted, the script will get loaded and this will be set again
- ObjectFlags &= ~(uint)(PrimFlags.Scripted | PrimFlags.Touch);
-
- TrimPermissions();
- // ApplyPhysics();
- }
-
protected SceneObjectPart(SerializationInfo info, StreamingContext context)
{
//System.Console.WriteLine("SceneObjectPart Deserialize BGN");
@@ -3056,7 +3004,6 @@ if (m_shape != null) {
public void UpdatePrimFlags(bool UsePhysics, bool IsTemporary, bool IsPhantom)
{
-
bool wasUsingPhysics = ((ObjectFlags & (uint) PrimFlags.Physics) != 0);
bool wasTemporary = ((ObjectFlags & (uint)PrimFlags.TemporaryOnRez) != 0);
bool wasPhantom = ((ObjectFlags & (uint)PrimFlags.Phantom) != 0);
diff --git a/OpenSim/Region/Environment/Scenes/Tests/SceneTests.cs b/OpenSim/Region/Environment/Scenes/Tests/SceneTests.cs
index 9d48802..4a038e2 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 NUnit.Framework.SyntaxHelpers;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
@@ -74,9 +75,21 @@ 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();
- new SceneObjectPart(sceneObject, UUID.Zero, null, Vector3.Zero, Quaternion.Identity, Vector3.Zero);
+ SceneObjectPart part
+ = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero);
+ //part.UpdatePrimFlags(false, false, true);
+ part.ObjectFlags |= (uint)PrimFlags.Phantom;
+
+ sceneObject.RootPart = part;
+ sceneObject.AddPart(part);
scene.AddNewSceneObject(sceneObject, false);
+
+ SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
+
+ //System.Console.WriteLine("retrievedPart : {0}", retrievedPart);
+ // If the parts have the same UUID then we will consider them as one and the same
+ Assert.That(retrievedPart.UUID, Is.EqualTo(part.UUID));
}
}
}
\ No newline at end of file
diff --git a/OpenSim/Region/Examples/SimpleModule/ComplexObject.cs b/OpenSim/Region/Examples/SimpleModule/ComplexObject.cs
index 607a620..fd37d76 100644
--- a/OpenSim/Region/Examples/SimpleModule/ComplexObject.cs
+++ b/OpenSim/Region/Examples/SimpleModule/ComplexObject.cs
@@ -51,9 +51,9 @@ namespace OpenSim.Region.Examples.SimpleModule
{
}
- public RotatingWheel(SceneObjectGroup parent, UUID ownerID,
- Vector3 groupPosition, Vector3 offsetPosition, Quaternion rotationDirection)
- : base(parent, ownerID, PrimitiveBaseShape.Default, groupPosition, offsetPosition)
+ public RotatingWheel(
+ UUID ownerID, Vector3 groupPosition, Vector3 offsetPosition, Quaternion rotationDirection)
+ : base(ownerID, PrimitiveBaseShape.Default, groupPosition, Quaternion.Identity, offsetPosition)
{
m_rotationDirection = rotationDirection;
@@ -83,24 +83,24 @@ namespace OpenSim.Region.Examples.SimpleModule
m_rotationDirection = new Quaternion(0.05f, 0.1f, 0.15f);
AddPart(
- new RotatingWheel(this, ownerID, pos, new Vector3(0, 0, 0.75f),
+ new RotatingWheel(ownerID, pos, new Vector3(0, 0, 0.75f),
new Quaternion(0.05f, 0, 0)));
AddPart(
- new RotatingWheel(this, ownerID, pos, new Vector3(0, 0, -0.75f),
+ new RotatingWheel(ownerID, pos, new Vector3(0, 0, -0.75f),
new Quaternion(-0.05f, 0, 0)));
AddPart(
- new RotatingWheel(this, ownerID, pos, new Vector3(0, 0.75f, 0),
+ new RotatingWheel(ownerID, pos, new Vector3(0, 0.75f, 0),
new Quaternion(0.5f, 0, 0.05f)));
AddPart(
- new RotatingWheel(this, ownerID, pos, new Vector3(0, -0.75f, 0),
+ new RotatingWheel(ownerID, pos, new Vector3(0, -0.75f, 0),
new Quaternion(-0.5f, 0, -0.05f)));
AddPart(
- new RotatingWheel(this, ownerID, pos, new Vector3(0.75f, 0, 0),
+ new RotatingWheel(ownerID, pos, new Vector3(0.75f, 0, 0),
new Quaternion(0, 0.5f, 0.05f)));
AddPart(
- new RotatingWheel(this, ownerID, pos, new Vector3(-0.75f, 0, 0),
+ new RotatingWheel(ownerID, pos, new Vector3(-0.75f, 0, 0),
new Quaternion(0, -0.5f, -0.05f)));
RootPart.Flags |= PrimFlags.Touch;
--
cgit v1.1