* 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
0.6.1-post-fixes
Justin Clarke Casey 2008-11-10 18:10:00 +00:00
parent 6df113845e
commit 5d1d5a22a9
6 changed files with 37 additions and 72 deletions

View File

@ -784,10 +784,11 @@ namespace OpenSim.Region.Environment.Scenes
/// <returns>null if no scene object group containing that prim is found</returns> /// <returns>null if no scene object group containing that prim is found</returns>
private SceneObjectGroup GetGroupByPrim(uint localID) private SceneObjectGroup GetGroupByPrim(uint localID)
{ {
//m_log.DebugFormat("Entered GetGroupByPrim with localID {0}", localID);
List<EntityBase> EntityList = GetEntities(); List<EntityBase> EntityList = GetEntities();
foreach (EntityBase ent in EntityList) foreach (EntityBase ent in EntityList)
{ {
//m_log.DebugFormat("Looking at entity {0}", ent.UUID);
if (ent is SceneObjectGroup) if (ent is SceneObjectGroup)
{ {
if (((SceneObjectGroup)ent).HasChildPrim(localID)) if (((SceneObjectGroup)ent).HasChildPrim(localID))
@ -891,6 +892,7 @@ namespace OpenSim.Region.Environment.Scenes
protected internal SceneObjectPart GetSceneObjectPart(UUID fullID) protected internal SceneObjectPart GetSceneObjectPart(UUID fullID)
{ {
SceneObjectGroup group = GetGroupByPrim(fullID); SceneObjectGroup group = GetGroupByPrim(fullID);
if (group != null) if (group != null)
return group.GetChildPart(fullID); return group.GetChildPart(fullID);
else else

View File

@ -164,7 +164,7 @@ namespace OpenSim.Region.Environment.Scenes
private Thread HeartbeatThread; private Thread HeartbeatThread;
private volatile bool shuttingdown = false; private volatile bool shuttingdown = false;
private object m_deleting_scene_object = new object(); private object m_deleting_scene_object = new object();
#endregion #endregion
@ -4009,7 +4009,7 @@ namespace OpenSim.Region.Environment.Scenes
} }
/// <summary> /// <summary>
/// /// Get a prim via its local id
/// </summary> /// </summary>
/// <param name="localID"></param> /// <param name="localID"></param>
/// <returns></returns> /// <returns></returns>
@ -4019,7 +4019,7 @@ namespace OpenSim.Region.Environment.Scenes
} }
/// <summary> /// <summary>
/// /// Get a prim via its UUID
/// </summary> /// </summary>
/// <param name="fullID"></param> /// <param name="fullID"></param>
/// <returns></returns> /// <returns></returns>

View File

@ -507,9 +507,9 @@ namespace OpenSim.Region.Environment.Scenes
public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape)
{ {
Vector3 rootOffset = new Vector3(0, 0, 0); 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; newPart.LinkNum = 0;
m_parts.Add(newPart.UUID, newPart); AddPart(newPart);
SetPartAsRoot(newPart); SetPartAsRoot(newPart);
} }
@ -904,7 +904,6 @@ namespace OpenSim.Region.Environment.Scenes
try try
{ {
m_parts.Add(part.UUID, part); m_parts.Add(part.UUID, part);
} }
catch (Exception e) catch (Exception e)
{ {
@ -1757,10 +1756,12 @@ namespace OpenSim.Region.Environment.Scenes
/// <returns>null if a child part with the local ID was not found</returns> /// <returns>null if a child part with the local ID was not found</returns>
public SceneObjectPart GetChildPart(uint localID) public SceneObjectPart GetChildPart(uint localID)
{ {
//m_log.DebugFormat("Entered looking for {0}", localID);
lock (m_parts) lock (m_parts)
{ {
foreach (SceneObjectPart part in m_parts.Values) foreach (SceneObjectPart part in m_parts.Values)
{ {
//m_log.DebugFormat("Found {0}", part.LocalId);
if (part.LocalId == localID) if (part.LocalId == localID)
{ {
return part; return part;
@ -1795,10 +1796,12 @@ namespace OpenSim.Region.Environment.Scenes
/// <returns></returns> /// <returns></returns>
public bool HasChildPrim(uint localID) public bool HasChildPrim(uint localID)
{ {
//m_log.DebugFormat("Entered HasChildPrim looking for {0}", localID);
lock (m_parts) lock (m_parts)
{ {
foreach (SceneObjectPart part in m_parts.Values) foreach (SceneObjectPart part in m_parts.Values)
{ {
//m_log.DebugFormat("Found {0}", part.LocalId);
if (part.LocalId == localID) if (part.LocalId == localID)
{ {
return true; return true;

View File

@ -216,28 +216,19 @@ namespace OpenSim.Region.Environment.Scenes
Rezzed = DateTime.Now; Rezzed = DateTime.Now;
} }
public SceneObjectPart(SceneObjectGroup parent, UUID ownerID,
PrimitiveBaseShape shape, Vector3 groupPosition, Vector3 offsetPosition)
: this(parent, ownerID, shape, groupPosition, Quaternion.Identity, offsetPosition)
{
}
/// <summary> /// <summary>
/// Create a completely new SceneObjectPart (prim) /// Create a completely new SceneObjectPart (prim). This will need to be added separately to a SceneObjectGroup
/// </summary> /// </summary>
/// <param name="regionHandle"></param>
/// <param name="parent"></param>
/// <param name="ownerID"></param> /// <param name="ownerID"></param>
/// <param name="shape"></param> /// <param name="shape"></param>
/// <param name="position"></param> /// <param name="position"></param>
/// <param name="rotationOffset"></param> /// <param name="rotationOffset"></param>
/// <param name="offsetPosition"></param> /// <param name="offsetPosition"></param>
public SceneObjectPart( public SceneObjectPart(
SceneObjectGroup parent, UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition, UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition,
Quaternion rotationOffset, Vector3 offsetPosition) Quaternion rotationOffset, Vector3 offsetPosition)
{ {
m_name = "Primitive"; m_name = "Primitive";
m_parentGroup = parent;
Rezzed = DateTime.Now; Rezzed = DateTime.Now;
_creationDate = (Int32) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; _creationDate = (Int32) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
@ -273,49 +264,6 @@ namespace OpenSim.Region.Environment.Scenes
//m_undo = new UndoStack<UndoState>(ParentGroup.GetSceneMaxUndo()); //m_undo = new UndoStack<UndoState>(ParentGroup.GetSceneMaxUndo());
} }
/// <summary>
/// Re/create a SceneObjectPart (prim)
/// currently not used, and maybe won't be
/// </summary>
/// <param name="regionHandle"></param>
/// <param name="parent"></param>
/// <param name="ownerID"></param>
/// <param name="localID"></param>
/// <param name="shape"></param>
/// <param name="position"></param>
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) protected SceneObjectPart(SerializationInfo info, StreamingContext context)
{ {
//System.Console.WriteLine("SceneObjectPart Deserialize BGN"); //System.Console.WriteLine("SceneObjectPart Deserialize BGN");
@ -3056,7 +3004,6 @@ if (m_shape != null) {
public void UpdatePrimFlags(bool UsePhysics, bool IsTemporary, bool IsPhantom) public void UpdatePrimFlags(bool UsePhysics, bool IsTemporary, bool IsPhantom)
{ {
bool wasUsingPhysics = ((ObjectFlags & (uint) PrimFlags.Physics) != 0); bool wasUsingPhysics = ((ObjectFlags & (uint) PrimFlags.Physics) != 0);
bool wasTemporary = ((ObjectFlags & (uint)PrimFlags.TemporaryOnRez) != 0); bool wasTemporary = ((ObjectFlags & (uint)PrimFlags.TemporaryOnRez) != 0);
bool wasPhantom = ((ObjectFlags & (uint)PrimFlags.Phantom) != 0); bool wasPhantom = ((ObjectFlags & (uint)PrimFlags.Phantom) != 0);

View File

@ -28,6 +28,7 @@
using System; using System;
using Nini.Config; using Nini.Config;
using NUnit.Framework; using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Communications; 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); = new Scene(regInfo, acm, cm, scs, null, sm, null, null, false, false, false, configSource, null);
SceneObjectGroup sceneObject = new SceneObjectGroup(); 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); 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));
} }
} }
} }

View File

@ -51,9 +51,9 @@ namespace OpenSim.Region.Examples.SimpleModule
{ {
} }
public RotatingWheel(SceneObjectGroup parent, UUID ownerID, public RotatingWheel(
Vector3 groupPosition, Vector3 offsetPosition, Quaternion rotationDirection) UUID ownerID, Vector3 groupPosition, Vector3 offsetPosition, Quaternion rotationDirection)
: base(parent, ownerID, PrimitiveBaseShape.Default, groupPosition, offsetPosition) : base(ownerID, PrimitiveBaseShape.Default, groupPosition, Quaternion.Identity, offsetPosition)
{ {
m_rotationDirection = rotationDirection; m_rotationDirection = rotationDirection;
@ -83,24 +83,24 @@ namespace OpenSim.Region.Examples.SimpleModule
m_rotationDirection = new Quaternion(0.05f, 0.1f, 0.15f); m_rotationDirection = new Quaternion(0.05f, 0.1f, 0.15f);
AddPart( 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))); new Quaternion(0.05f, 0, 0)));
AddPart( 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))); new Quaternion(-0.05f, 0, 0)));
AddPart( 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))); new Quaternion(0.5f, 0, 0.05f)));
AddPart( 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))); new Quaternion(-0.5f, 0, -0.05f)));
AddPart( 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))); new Quaternion(0, 0.5f, 0.05f)));
AddPart( 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))); new Quaternion(0, -0.5f, -0.05f)));
RootPart.Flags |= PrimFlags.Touch; RootPart.Flags |= PrimFlags.Touch;