Remove redundant SetScene() function in Scene.AddSceneObject()

This is always done later on in SceneGraph.AddSceneObject() if the call hasn't failed due to sanity checks.
There's no other purpose for this method to exist and it's dangerous/pointless to call in other conditions.
0.7.3-extended
Justin Clark-Casey (justincc) 2012-07-07 00:02:45 +01:00
parent d8f1d2892c
commit 068917bc29
7 changed files with 34 additions and 29 deletions

View File

@ -1082,7 +1082,7 @@ namespace OpenSim.Data.Tests
sop.Shape = PrimitiveBaseShape.Default; sop.Shape = PrimitiveBaseShape.Default;
SceneObjectGroup sog = new SceneObjectGroup(sop); SceneObjectGroup sog = new SceneObjectGroup(sop);
sog.SetScene(scene); // sog.SetScene(scene);
return sog; return sog;
} }

View File

@ -2506,8 +2506,6 @@ namespace OpenSim.Region.Framework.Scenes
/// <returns>True if the SceneObjectGroup was added, False if it was not</returns> /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
public bool AddSceneObject(SceneObjectGroup sceneObject) public bool AddSceneObject(SceneObjectGroup sceneObject)
{ {
sceneObject.SetScene(this);
// Force allocation of new LocalId // Force allocation of new LocalId
// //
SceneObjectPart[] parts = sceneObject.Parts; SceneObjectPart[] parts = sceneObject.Parts;

View File

@ -373,9 +373,9 @@ namespace OpenSim.Region.Framework.Scenes
if (Entities.ContainsKey(sceneObject.UUID)) if (Entities.ContainsKey(sceneObject.UUID))
{ {
// m_log.DebugFormat( m_log.DebugFormat(
// "[SCENEGRAPH]: Scene graph for {0} already contains object {1} in AddSceneObject()", "[SCENEGRAPH]: Scene graph for {0} already contains object {1} in AddSceneObject()",
// m_parentScene.RegionInfo.RegionName, sceneObject.UUID); m_parentScene.RegionInfo.RegionName, sceneObject.UUID);
return false; return false;
} }

View File

@ -1048,16 +1048,6 @@ namespace OpenSim.Region.Framework.Scenes
{ {
return Utils.FloatToUInt16(m_scene.TimeDilation, 0.0f, 1.0f); return Utils.FloatToUInt16(m_scene.TimeDilation, 0.0f, 1.0f);
} }
/// <summary>
/// Added as a way for the storage provider to reset the scene,
/// most likely a better way to do this sort of thing but for now...
/// </summary>
/// <param name="scene"></param>
public void SetScene(Scene scene)
{
m_scene = scene;
}
/// <summary> /// <summary>
/// Set a part to act as the root part for this scene object /// Set a part to act as the root part for this scene object

View File

@ -79,7 +79,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
/// Test creation of an NPC where the appearance data comes from a notecard /// Test creation of an NPC where the appearance data comes from a notecard
/// </summary> /// </summary>
[Test] [Test]
public void TestOsNpcCreateFromNotecard() public void TestOsNpcCreateUsingAppearanceFromNotecard()
{ {
TestHelpers.InMethod(); TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure(); // log4net.Config.XmlConfigurator.Configure();
@ -90,7 +90,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
sp.Appearance.AvatarHeight = newHeight; sp.Appearance.AvatarHeight = newHeight;
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId); SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10);
SceneObjectPart part = so.RootPart; SceneObjectPart part = so.RootPart;
m_scene.AddSceneObject(so); m_scene.AddSceneObject(so);
@ -114,10 +114,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
/// Test creation of an NPC where the appearance data comes from an avatar already in the region. /// Test creation of an NPC where the appearance data comes from an avatar already in the region.
/// </summary> /// </summary>
[Test] [Test]
public void TestOsNpcCreateFromAvatar() public void TestOsNpcCreateUsingAppearanceFromAvatar()
{ {
TestHelpers.InMethod(); TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure(); // TestHelpers.EnableLogging();
// Store an avatar with a different height from default in a notecard. // Store an avatar with a different height from default in a notecard.
UUID userId = TestHelpers.ParseTail(0x1); UUID userId = TestHelpers.ParseTail(0x1);
@ -125,7 +125,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
sp.Appearance.AvatarHeight = newHeight; sp.Appearance.AvatarHeight = newHeight;
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId); SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10);
SceneObjectPart part = so.RootPart; SceneObjectPart part = so.RootPart;
m_scene.AddSceneObject(so); m_scene.AddSceneObject(so);
@ -156,7 +156,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
sp.Appearance.AvatarHeight = newHeight; sp.Appearance.AvatarHeight = newHeight;
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId); SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10);
SceneObjectPart part = so.RootPart; SceneObjectPart part = so.RootPart;
m_scene.AddSceneObject(so); m_scene.AddSceneObject(so);
@ -197,7 +197,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, nonOwnerId); ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, nonOwnerId);
sp.Appearance.AvatarHeight = newHeight; sp.Appearance.AvatarHeight = newHeight;
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, ownerId); SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, ownerId, 0x10);
SceneObjectPart part = so.RootPart; SceneObjectPart part = so.RootPart;
m_scene.AddSceneObject(so); m_scene.AddSceneObject(so);

View File

@ -97,11 +97,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
sp.Appearance.AvatarHeight = newHeight; sp.Appearance.AvatarHeight = newHeight;
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId); SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10);
SceneObjectPart part = so.RootPart; SceneObjectPart part = so.RootPart;
m_scene.AddSceneObject(so); m_scene.AddSceneObject(so);
SceneObjectGroup otherSo = SceneHelpers.CreateSceneObject(1, otherUserId); SceneObjectGroup otherSo = SceneHelpers.CreateSceneObject(1, otherUserId, 0x20);
SceneObjectPart otherPart = otherSo.RootPart; SceneObjectPart otherPart = otherSo.RootPart;
m_scene.AddSceneObject(otherSo); m_scene.AddSceneObject(otherSo);
@ -148,7 +148,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
sp.Appearance.AvatarHeight = newHeight; sp.Appearance.AvatarHeight = newHeight;
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId); SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10);
SceneObjectPart part = so.RootPart; SceneObjectPart part = so.RootPart;
m_scene.AddSceneObject(so); m_scene.AddSceneObject(so);

View File

@ -601,19 +601,36 @@ namespace OpenSim.Tests.Common
ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero)
{ Name = name, UUID = id, Scale = new Vector3(1, 1, 1) }; { Name = name, UUID = id, Scale = new Vector3(1, 1, 1) };
} }
/// <summary> /// <summary>
/// Create a scene object but do not add it to the scene. /// Create a scene object but do not add it to the scene.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// UUID always starts at 00000000-0000-0000-0000-000000000001 /// UUID always starts at 00000000-0000-0000-0000-000000000001. For some purposes, (e.g. serializing direct
/// to another object's inventory) we do not need a scene unique ID. So it would be better to add the
/// UUID when we actually add an object to a scene rather than on creation.
/// </remarks> /// </remarks>
/// <param name="parts">The number of parts that should be in the scene object</param> /// <param name="parts">The number of parts that should be in the scene object</param>
/// <param name="ownerId"></param> /// <param name="ownerId"></param>
/// <returns></returns> /// <returns></returns>
public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId) public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId)
{ {
return CreateSceneObject(parts, ownerId, "", 0x1); return CreateSceneObject(parts, ownerId, 0x1);
}
/// <summary>
/// Create a scene object but do not add it to the scene.
/// </summary>
/// <param name="parts">The number of parts that should be in the scene object</param>
/// <param name="ownerId"></param>
/// <param name="uuidTail">
/// The hexadecimal last part of the UUID for parts created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}"
/// will be given to the root part, and incremented for each part thereafter.
/// </param>
/// <returns></returns>
public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId, int uuidTail)
{
return CreateSceneObject(parts, ownerId, "", uuidTail);
} }
/// <summary> /// <summary>