diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs
index 927415e850..7b5fb2e8f1 100644
--- a/OpenSim/Framework/PrimitiveBaseShape.cs
+++ b/OpenSim/Framework/PrimitiveBaseShape.cs
@@ -250,7 +250,7 @@ namespace OpenSim.Framework
{
get
{
- //m_log.DebugFormat("[SHAPE]: get m_textureEntry length {0}", m_textureEntry.Length);
+// m_log.DebugFormat("[SHAPE]: get m_textureEntry length {0}", m_textureEntry.Length);
try { return new Primitive.TextureEntry(m_textureEntry, 0, m_textureEntry.Length); }
catch { }
diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
index b6ec6dc9f2..ffb3221bc6 100644
--- a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
+++ b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
@@ -225,6 +225,12 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap
return me;
}
+ ///
+ /// Set the media entry on the face of the given part.
+ ///
+ /// /param>
+ ///
+ ///
public void SetMediaEntry(SceneObjectPart part, int face, MediaEntry me)
{
// m_log.DebugFormat("[MOAP]: SetMediaEntry for {0}, face {1}", part.Name, face);
@@ -249,9 +255,31 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap
part.TriggerScriptChangedEvent(Changed.MEDIA);
}
+ ///
+ /// Clear the media entry from the face of the given part.
+ ///
+ ///
+ ///
public void ClearMediaEntry(SceneObjectPart part, int face)
{
- SetMediaEntry(part, face, null);
+ CheckFaceParam(part, face);
+
+ // If no media has been set up yetthen we don't need to clear anything
+ if (null == part.Shape.Media)
+ return;
+
+ lock (part.Shape.Media)
+ part.Shape.Media[face] = null;
+
+ UpdateMediaUrl(part, UUID.Zero);
+
+ Primitive.TextureEntry te = part.Shape.Textures;
+ Primitive.TextureEntryFace teFace = te.CreateFace((uint)face);
+ teFace.MediaFlags = false;
+ part.Shape.Textures = te;
+
+ part.ScheduleFullUpdate();
+ part.TriggerScriptChangedEvent(Changed.MEDIA);
}
///
diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs
index 9e5c7ae5d2..7a68e55c7e 100644
--- a/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs
+++ b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs
@@ -48,21 +48,52 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap.Tests
[TestFixture]
public class MoapTests
{
+ protected TestScene m_scene;
+ protected MoapModule m_module;
+
+ [SetUp]
+ public void SetUp()
+ {
+ m_module = new MoapModule();
+ m_scene = SceneSetupHelpers.SetupScene();
+ SceneSetupHelpers.SetupSceneModules(m_scene, m_module);
+ }
+
+ [Test]
+ public void TestClearMediaUrl()
+ {
+ TestHelper.InMethod();
+// log4net.Config.XmlConfigurator.Configure();
+
+ SceneObjectPart part = SceneSetupHelpers.AddSceneObject(m_scene);
+ MediaEntry me = new MediaEntry();
+
+ m_module.SetMediaEntry(part, 1, me);
+ m_module.ClearMediaEntry(part, 1);
+
+ Assert.That(part.Shape.Media[1], Is.EqualTo(null));
+
+ // Although we've cleared one face, other faces may still be present. So we need to check for an
+ // update media url version
+ Assert.That(part.MediaUrl, Is.EqualTo("x-mv:0000000001/" + UUID.Zero));
+
+ // By changing media flag to false, the face texture once again becomes identical to the DefaultTexture.
+ // Therefore, when libOMV reserializes it, it disappears and we are left with no face texture in this slot.
+ // Not at all confusing, eh?
+ Assert.That(part.Shape.Textures.FaceTextures[1], Is.Null);
+ }
+
[Test]
public void TestSetMediaUrl()
{
TestHelper.InMethod();
- string homeUrl = "opensimulator.org";
+ string homeUrl = "opensimulator.org";
- MoapModule module = new MoapModule();
- TestScene scene = SceneSetupHelpers.SetupScene();
- SceneSetupHelpers.SetupSceneModules(scene, module);
-
- SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene);
+ SceneObjectPart part = SceneSetupHelpers.AddSceneObject(m_scene);
MediaEntry me = new MediaEntry() { HomeURL = homeUrl };
- module.SetMediaEntry(part, 1, me);
+ m_module.SetMediaEntry(part, 1, me);
Assert.That(part.Shape.Media[1].HomeURL, Is.EqualTo(homeUrl));
Assert.That(part.MediaUrl, Is.EqualTo("x-mv:0000000000/" + UUID.Zero));