From e75bcd4c59234382ac3efb743a228cd23d92ad45 Mon Sep 17 00:00:00 2001 From: marc Date: Fri, 25 Nov 2011 15:21:42 +0100 Subject: Workaround for mesh to correct the number of faces in GetNumberOfSides(). Meshs are handeled as sculpts but can have up to 8 faces (SL restriction the collada format can handle even more). The patch enables all LSL function that adressing faces to behave correct. Like llGetNumberOfSides(); llSetLinkPrimitiveParamsFast(); llSetPrimitiveParams(); llSetColor(); Signed-off-by: marc --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 24322a1..304a7a7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3272,7 +3272,15 @@ namespace OpenSim.Region.Framework.Scenes if (hasHollow) ret += 1; break; case PrimType.SCULPT: - ret = 1; + // Special mesh handling + if (this.Shape.SculptType == 5) + { + ret = 7; // its a mesh then max 8 faces + } + else + { + ret = 1; // its a sculpt then max 1 faces + } break; } return ret; -- cgit v1.1 From aba42d85434b0e0f367a4f691a9fab9d68fab99a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 3 Dec 2011 15:54:06 +0000 Subject: Correct SOP.GetNumberOfSides() to return 8 for meshes rather than 7 We are returning the actual number of 'sides', not the maximum index number. Also minor format corrections. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 304a7a7..dcbcfa3 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3273,16 +3273,13 @@ namespace OpenSim.Region.Framework.Scenes break; case PrimType.SCULPT: // Special mesh handling - if (this.Shape.SculptType == 5) - { - ret = 7; // its a mesh then max 8 faces - } + if (Shape.SculptType == (byte)SculptType.Mesh) + ret = 8; // if it's a mesh then max 8 faces else - { - ret = 1; // its a sculpt then max 1 faces - } + ret = 1; // if it's a sculpt then max 1 face break; } + return ret; } @@ -3295,6 +3292,7 @@ namespace OpenSim.Region.Framework.Scenes { if (Shape.SculptEntry) return PrimType.SCULPT; + if ((Shape.ProfileCurve & 0x07) == (byte)ProfileShape.Square) { if (Shape.PathCurve == (byte)Extrusion.Straight) -- cgit v1.1 From aac3f2d04ed5d828f48959f73fca893f884cec3b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 3 Dec 2011 16:04:11 +0000 Subject: Add agent circuit number checks to TestCloseAgent() --- OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs index f0bbf0b..f6a3d1f 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs @@ -103,11 +103,15 @@ namespace OpenSim.Region.Framework.Scenes.Tests ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Not.Null); + Assert.That(scene.AuthenticateHandler.AgentCircuits.Count, Is.EqualTo(1)); + Assert.That(scene.AuthenticateHandler.AgentCircuitsByUUID.Count, Is.EqualTo(1)); scene.IncomingCloseAgent(sp.UUID); Assert.That(scene.GetScenePresence(sp.UUID), Is.Null); Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Null); + Assert.That(scene.AuthenticateHandler.AgentCircuits.Count, Is.EqualTo(0)); + Assert.That(scene.AuthenticateHandler.AgentCircuitsByUUID.Count, Is.EqualTo(0)); } /// -- cgit v1.1 From c934901a056f142c49e6b449971fcaf59ff19d82 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 3 Dec 2011 16:11:47 +0000 Subject: Use GetAgentCircuits() to receive a copy of the AgentCircuitsByUUID dictionary rather than AgentCircuitManager.AgentCircuits directly in "show circuits" to avoid enumeration exceptions --- OpenSim/Region/Application/OpenSim.cs | 2 +- OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 4b38a2e..8d98cc9 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -1039,7 +1039,7 @@ namespace OpenSim { //this.HttpServer. acd.AppendFormat("{0}:\n", scene.RegionInfo.RegionName); - foreach (AgentCircuitData aCircuit in scene.AuthenticateHandler.AgentCircuits.Values) + foreach (AgentCircuitData aCircuit in scene.AuthenticateHandler.GetAgentCircuits().Values) acd.AppendFormat("\t{0} {1} ({2})\n", aCircuit.firstname, aCircuit.lastname, (aCircuit.child ? "Child" : "Root")); } ); diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs index f6a3d1f..57d22bd 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs @@ -103,15 +103,13 @@ namespace OpenSim.Region.Framework.Scenes.Tests ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Not.Null); - Assert.That(scene.AuthenticateHandler.AgentCircuits.Count, Is.EqualTo(1)); - Assert.That(scene.AuthenticateHandler.AgentCircuitsByUUID.Count, Is.EqualTo(1)); + Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1)); scene.IncomingCloseAgent(sp.UUID); Assert.That(scene.GetScenePresence(sp.UUID), Is.Null); Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Null); - Assert.That(scene.AuthenticateHandler.AgentCircuits.Count, Is.EqualTo(0)); - Assert.That(scene.AuthenticateHandler.AgentCircuitsByUUID.Count, Is.EqualTo(0)); + Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(0)); } /// -- cgit v1.1 From 4919c6056022053f8632b030a06fd8f48ac02a8e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 3 Dec 2011 18:59:54 +0000 Subject: Add beginning of ScenePresenceAgentTests.TestCreateChildScenePresence() This required an option to be added to NullRegionData via ConnectionString for it to act as a non-static instance, so that regression tests (which only load this class once) don't get hopeless confused and complex to compensate. Normal standalone operation unaffected. --- .../EntityTransfer/EntityTransferModule.cs | 1 - .../Grid/Tests/GridConnectorsTests.cs | 9 ++-- .../Scenes/Tests/ScenePresenceAgentTests.cs | 57 +++++++++++++++++----- 3 files changed, 51 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 99064c8..2f947fd 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -1341,7 +1341,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer string reason = String.Empty; - bool regionAccepted = m_scene.SimulationService.CreateAgent(reg, a, (uint)TeleportFlags.Default, out reason); if (regionAccepted && newAgent) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs index cd7d6bc..b286d17 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs @@ -31,11 +31,10 @@ using System.IO; using System.Reflection; using System.Threading; using log4net.Config; +using Nini.Config; using NUnit.Framework; using OpenMetaverse; using OpenSim.Framework; -using Nini.Config; - using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid; using OpenSim.Region.Framework.Scenes; using GridRegion = OpenSim.Services.Interfaces.GridRegion; @@ -69,6 +68,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests [Test] public void TestRegisterRegion() { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + SetUp(); // Create 4 regions @@ -191,7 +193,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests results = m_LocalConnector.GetHyperlinks(UUID.Zero); Assert.IsNotNull(results, "Retrieved GetHyperlinks list is null"); Assert.That(results.Count, Is.EqualTo(0), "Retrieved linked regions collection is not the number expected"); - } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs index 57d22bd..f479e12 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs @@ -31,7 +31,7 @@ using System.Reflection; using System.Text; using System.Threading; using System.Timers; -using Timer=System.Timers.Timer; +using Timer = System.Timers.Timer; using Nini.Config; using NUnit.Framework; using OpenMetaverse; @@ -39,11 +39,13 @@ using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.ClientStack.Linden; using OpenSim.Region.CoreModules.Framework.EntityTransfer; using OpenSim.Region.CoreModules.World.Serialiser; using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Region.Framework.Scenes.Tests { @@ -112,14 +114,40 @@ namespace OpenSim.Region.Framework.Scenes.Tests Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(0)); } + [Test] + public void TestCreateChildScenePresence() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + LocalSimulationConnectorModule lsc = new LocalSimulationConnectorModule(); + + IConfigSource configSource = new IniConfigSource(); + IConfig config = configSource.AddConfig("Modules"); + config.Set("SimulationServices", "LocalSimulationConnectorModule"); + + TestScene scene = SceneHelpers.SetupScene(); + SceneHelpers.SetupSceneModules(scene, configSource, lsc); + + UUID agentId = TestHelpers.ParseTail(0x01); + AgentCircuitData acd = SceneHelpers.GenerateAgentData(agentId); + + GridRegion region = scene.GridService.GetRegionByName(UUID.Zero, scene.RegionInfo.RegionName); + string reason; + scene.SimulationService.CreateAgent(region, acd, (uint)TeleportFlags.ViaLogin, out reason); + + Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(agentId), Is.Not.Null); + Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1)); + } + /// /// Test that if a root agent logs into a region, a child agent is also established in the neighbouring region /// /// - /// Please note that unlike the other tests here, this doesn't rely on structures + /// Please note that unlike the other tests here, this doesn't rely on anything set up in the instance fields. /// [Test] - public void TestChildAgentEstablished() + public void TestChildAgentEstablishedInNeighbour() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); @@ -127,18 +155,25 @@ namespace OpenSim.Region.Framework.Scenes.Tests UUID agent1Id = UUID.Parse("00000000-0000-0000-0000-000000000001"); TestScene myScene1 = SceneHelpers.SetupScene("Neighbour y", UUID.Random(), 1000, 1000); -// TestScene myScene2 = SceneHelpers.SetupScene("Neighbour y + 1", UUID.Random(), 1001, 1000); - + TestScene myScene2 = SceneHelpers.SetupScene("Neighbour y + 1", UUID.Random(), 1001, 1000); + IConfigSource configSource = new IniConfigSource(); - configSource.AddConfig("Modules").Set("EntityTransferModule", "BasicEntityTransferModule"); + IConfig config = configSource.AddConfig("Startup"); + config.Set("serverside_object_permissions", true); + config.Set("EventQueue", true); + EntityTransferModule etm = new EntityTransferModule(); + + EventQueueGetModule eqgm1 = new EventQueueGetModule(); + SceneHelpers.SetupSceneModules(myScene1, configSource, etm, eqgm1); + + EventQueueGetModule eqgm2 = new EventQueueGetModule(); + SceneHelpers.SetupSceneModules(myScene2, configSource, etm, eqgm2); - SceneHelpers.SetupSceneModules(myScene1, configSource, etm); - - SceneHelpers.AddScenePresence(myScene1, agent1Id); +// SceneHelpers.AddScenePresence(myScene1, agent1Id); // ScenePresence childPresence = myScene2.GetScenePresence(agent1); - - // TODO: Need to do a fair amount of work to allow synchronous establishment of child agents +// +// // TODO: Need to do a fair amount of work to allow synchronous establishment of child agents // Assert.That(childPresence, Is.Not.Null); // Assert.That(childPresence.IsChildAgent, Is.True); } -- cgit v1.1 From 3852f05e6e03425e06eec1faa19929146901c92e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 3 Dec 2011 19:10:32 +0000 Subject: Extend TestCreateChildScenePresence to make assertions both at CreateAgent stage and then at Scene.AddClient() --- .../Framework/Scenes/Tests/ScenePresenceAgentTests.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs index f479e12..df2dacb 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs @@ -131,13 +131,29 @@ namespace OpenSim.Region.Framework.Scenes.Tests UUID agentId = TestHelpers.ParseTail(0x01); AgentCircuitData acd = SceneHelpers.GenerateAgentData(agentId); + acd.child = true; GridRegion region = scene.GridService.GetRegionByName(UUID.Zero, scene.RegionInfo.RegionName); string reason; + // XXX: ViaLogin may not be correct here. scene.SimulationService.CreateAgent(region, acd, (uint)TeleportFlags.ViaLogin, out reason); Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(agentId), Is.Not.Null); Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1)); + + // There's no scene presence yet since only an agent circuit has been established. + Assert.That(scene.GetScenePresence(agentId), Is.Null); + + TestClient client = new TestClient(acd, scene); + scene.AddNewClient(client, PresenceType.User); + + Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(agentId), Is.Not.Null); + Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1)); + + ScenePresence sp = scene.GetScenePresence(agentId); + Assert.That(sp, Is.Not.Null); + Assert.That(sp.UUID, Is.EqualTo(agentId)); + Assert.That(sp.IsChildAgent, Is.True); } /// -- cgit v1.1 From a4d82895be6617ab409735c107903c6aaef2c234 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 3 Dec 2011 19:14:37 +0000 Subject: Remove T012_TestAddNeighbourRegion() and T013_TestRemoveNeighbourRegion() since they don't do anything useful. --- .../Scenes/Tests/ScenePresenceAgentTests.cs | 75 ++-------------------- 1 file changed, 5 insertions(+), 70 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs index df2dacb..946481c 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs @@ -135,6 +135,9 @@ namespace OpenSim.Region.Framework.Scenes.Tests GridRegion region = scene.GridService.GetRegionByName(UUID.Zero, scene.RegionInfo.RegionName); string reason; + + // *** This is the first stage, when a neighbouring region is told that a viewer is about to try and + // establish a child scene presence. We pass in the circuit code that the client has to connect with *** // XXX: ViaLogin may not be correct here. scene.SimulationService.CreateAgent(region, acd, (uint)TeleportFlags.ViaLogin, out reason); @@ -144,6 +147,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests // There's no scene presence yet since only an agent circuit has been established. Assert.That(scene.GetScenePresence(agentId), Is.Null); + // *** This is the second stage, where the client established a child agent/scene presence using the + // circuit code given to the scene in stage 1 *** TestClient client = new TestClient(acd, scene); scene.AddNewClient(client, PresenceType.User); @@ -247,48 +252,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests // Assert.That(presence, Is.Null, "presence is not null"); // } - [Test] - public void T012_TestAddNeighbourRegion() - { - TestHelpers.InMethod(); - - string reason; - - if (acd1 == null) - fixNullPresence(); - - scene.NewUserConnection(acd1, 0, out reason); - if (testclient == null) - testclient = new TestClient(acd1, scene); - scene.AddNewClient(testclient, PresenceType.User); - - ScenePresence presence = scene.GetScenePresence(agent1); - presence.MakeRootAgent(new Vector3(90,90,90),false); - - string cap = presence.ControllingClient.RequestClientInfo().CapsPath; - - presence.AddNeighbourRegion(region2, cap); - presence.AddNeighbourRegion(region3, cap); - - Assert.That(presence.KnownRegionCount, Is.EqualTo(2)); - } - - [Test] - public void T013_TestRemoveNeighbourRegion() - { - TestHelpers.InMethod(); - - ScenePresence presence = scene.GetScenePresence(agent1); - presence.RemoveNeighbourRegion(region3); - - Assert.That(presence.KnownRegionCount,Is.EqualTo(1)); - /* - presence.MakeChildAgent; - presence.MakeRootAgent; - CompleteAvatarMovement - */ - } - // I'm commenting this test because it does not represent // crossings. The Thread.Sleep's in here are not meaningful mocks, // and they sometimes fail in panda. @@ -391,33 +354,5 @@ namespace OpenSim.Region.Framework.Scenes.Tests Assert.That(presence2.IsChildAgent, Is.True, "Did not return from region as expected."); Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again."); } - - public void fixNullPresence() - { - string firstName = "testfirstname"; - - AgentCircuitData agent = new AgentCircuitData(); - agent.AgentID = agent1; - agent.firstname = firstName; - agent.lastname = "testlastname"; - agent.SessionID = UUID.Zero; - agent.SecureSessionID = UUID.Zero; - agent.circuitcode = 123; - agent.BaseFolder = UUID.Zero; - agent.InventoryFolder = UUID.Zero; - agent.startpos = Vector3.Zero; - agent.CapsPath = GetRandomCapsObjectPath(); - agent.Appearance = new AvatarAppearance(); - - acd1 = agent; - } - - public static string GetRandomCapsObjectPath() - { - UUID caps = UUID.Random(); - string capsPath = caps.ToString(); - capsPath = capsPath.Remove(capsPath.Length - 4, 4); - return capsPath; - } } } \ No newline at end of file -- cgit v1.1 From a82aea53f863566037fa4fe3d546f57a49a126fa Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 3 Dec 2011 19:32:59 +0000 Subject: Split up test SceneHelpers to provide an AddChildScenePresence() call --- OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs index 946481c..d4c299f 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs @@ -166,6 +166,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests /// /// /// Please note that unlike the other tests here, this doesn't rely on anything set up in the instance fields. + /// INCOMPLETE /// [Test] public void TestChildAgentEstablishedInNeighbour() -- cgit v1.1 From 66f4ce354f57646de32b376cba79dfc6ded17c14 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 5 Dec 2011 19:01:14 +0000 Subject: Fix CHANGED_TEXTURE and CHANGED_COLOR. --- .../DynamicTexture/DynamicTextureModule.cs | 4 +- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 82 +++++++++++----------- .../Scripting/Minimodule/SOPObjectMaterial.cs | 10 +-- .../Shared/Api/Implementation/LSL_Api.cs | 36 +++++----- 4 files changed, 67 insertions(+), 65 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs index f2c8b3d..18bd018 100644 --- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs @@ -355,7 +355,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture // I'm pretty sure noone whats to set fullbright true if it wasn't true before. // tmptex.DefaultTexture.Fullbright = true; - part.UpdateTexture(tmptex); + part.UpdateTextureEntry(tmptex.GetBytes()); } if (oldID != UUID.Zero && ((Disp & DISP_EXPIRE) != 0)) @@ -437,4 +437,4 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture #endregion } -} \ No newline at end of file +} diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index dcbcfa3..c8b39a4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3178,7 +3178,10 @@ namespace OpenSim.Region.Framework.Scenes /// public void SetFaceColor(Vector3 color, int face) { - Primitive.TextureEntry tex = Shape.Textures; + // The only way to get a deep copy/ If we don't do this, we can + // mever detect color changes further down. + Byte[] buf = Shape.Textures.GetBytes(); + Primitive.TextureEntry tex = new Primitive.TextureEntry(buf, 0, buf.Length); Color4 texcolor; if (face >= 0 && face < GetNumberOfSides()) { @@ -3187,8 +3190,7 @@ namespace OpenSim.Region.Framework.Scenes texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f); texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f); tex.FaceTextures[face].RGBA = texcolor; - UpdateTexture(tex); - TriggerScriptChangedEvent(Changed.COLOR); + UpdateTextureEntry(tex.GetBytes()); return; } else if (face == ALL_SIDES) @@ -3209,8 +3211,7 @@ namespace OpenSim.Region.Framework.Scenes texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f); tex.DefaultTexture.RGBA = texcolor; } - UpdateTexture(tex); - TriggerScriptChangedEvent(Changed.COLOR); + UpdateTextureEntry(tex.GetBytes()); return; } } @@ -4538,48 +4539,49 @@ namespace OpenSim.Region.Framework.Scenes } /// - /// Update the textures on the part. - /// - /// - /// Added to handle bug in libsecondlife's TextureEntry.ToBytes() - /// not handling RGBA properly. Cycles through, and "fixes" the color - /// info - /// - /// - public void UpdateTexture(Primitive.TextureEntry tex) - { - //Color4 tmpcolor; - //for (uint i = 0; i < 32; i++) - //{ - // if (tex.FaceTextures[i] != null) - // { - // tmpcolor = tex.GetFace((uint) i).RGBA; - // tmpcolor.A = tmpcolor.A*255; - // tmpcolor.R = tmpcolor.R*255; - // tmpcolor.G = tmpcolor.G*255; - // tmpcolor.B = tmpcolor.B*255; - // tex.FaceTextures[i].RGBA = tmpcolor; - // } - //} - //tmpcolor = tex.DefaultTexture.RGBA; - //tmpcolor.A = tmpcolor.A*255; - //tmpcolor.R = tmpcolor.R*255; - //tmpcolor.G = tmpcolor.G*255; - //tmpcolor.B = tmpcolor.B*255; - //tex.DefaultTexture.RGBA = tmpcolor; - UpdateTextureEntry(tex.GetBytes()); - } - - /// /// Update the texture entry for this part. /// /// public void UpdateTextureEntry(byte[] textureEntry) { - m_shape.TextureEntry = textureEntry; - TriggerScriptChangedEvent(Changed.TEXTURE); + Primitive.TextureEntry newTex = new Primitive.TextureEntry(textureEntry, 0, textureEntry.Length); + Primitive.TextureEntry oldTex = Shape.Textures; + + Changed changeFlags = 0; + for (int i = 0 ; i < GetNumberOfSides(); i++) + { + Primitive.TextureEntryFace newFace = newTex.DefaultTexture; + Primitive.TextureEntryFace oldFace = oldTex.DefaultTexture; + + if (oldTex.FaceTextures[i] != null) + oldFace = oldTex.FaceTextures[i]; + if (newTex.FaceTextures[i] != null) + newFace = newTex.FaceTextures[i]; + + Color4 oldRGBA = oldFace.RGBA; + Color4 newRGBA = newFace.RGBA; + + if (oldRGBA.R != newRGBA.R || + oldRGBA.G != newRGBA.G || + oldRGBA.B != newRGBA.B || + oldRGBA.A != newRGBA.A) + changeFlags |= Changed.COLOR; + + if (oldFace.TextureID != newFace.TextureID) + changeFlags |= Changed.TEXTURE; + + // Max change, skip the rest of testing + if (changeFlags == (Changed.TEXTURE | Changed.COLOR)) + break; + } + + m_shape.TextureEntry = textureEntry; + if (changeFlags != 0) + TriggerScriptChangedEvent(changeFlags); + UpdateFlag = UpdateRequired.FULL; ParentGroup.HasGroupChanged = true; + //This is madness.. //ParentGroup.ScheduleGroupForFullUpdate(); //This is sparta diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs index 0cba6af..cea738c 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs @@ -55,7 +55,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face); texface.RGBA = new Color4(value.R,value.G,value.B,value.A); tex.FaceTextures[m_face] = texface; - m_parent.UpdateTexture(tex); + m_parent.UpdateTextureEntry(tex.GetBytes()); } } @@ -72,7 +72,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face); texface.TextureID = value; tex.FaceTextures[m_face] = texface; - m_parent.UpdateTexture(tex); + m_parent.UpdateTextureEntry(tex.GetBytes()); } } @@ -97,7 +97,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face); texface.Fullbright = value; tex.FaceTextures[m_face] = texface; - m_parent.UpdateTexture(tex); + m_parent.UpdateTextureEntry(tex.GetBytes()); } } @@ -110,7 +110,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face); texface.Glow = (float) value; tex.FaceTextures[m_face] = texface; - m_parent.UpdateTexture(tex); + m_parent.UpdateTextureEntry(tex.GetBytes()); } } @@ -123,7 +123,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face); texface.Shiny = value ? Shininess.High : Shininess.None; tex.FaceTextures[m_face] = texface; - m_parent.UpdateTexture(tex); + m_parent.UpdateTextureEntry(tex.GetBytes()); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 6c418df..6d067b0 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -1424,7 +1424,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { tex.CreateFace((uint) face); tex.FaceTextures[face].TexMapType = textype; - part.UpdateTexture(tex); + part.UpdateTextureEntry(tex.GetBytes()); return; } else if (face == ScriptBaseClass.ALL_SIDES) @@ -1437,7 +1437,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } tex.DefaultTexture.TexMapType = textype; } - part.UpdateTexture(tex); + part.UpdateTextureEntry(tex.GetBytes()); return; } } @@ -1449,7 +1449,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { tex.CreateFace((uint) face); tex.FaceTextures[face].Glow = glow; - part.UpdateTexture(tex); + part.UpdateTextureEntry(tex.GetBytes()); return; } else if (face == ScriptBaseClass.ALL_SIDES) @@ -1462,7 +1462,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } tex.DefaultTexture.Glow = glow; } - part.UpdateTexture(tex); + part.UpdateTextureEntry(tex.GetBytes()); return; } } @@ -1497,7 +1497,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api tex.CreateFace((uint) face); tex.FaceTextures[face].Shiny = sval; tex.FaceTextures[face].Bump = bump; - part.UpdateTexture(tex); + part.UpdateTextureEntry(tex.GetBytes()); return; } else if (face == ScriptBaseClass.ALL_SIDES) @@ -1512,7 +1512,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api tex.DefaultTexture.Shiny = sval; tex.DefaultTexture.Bump = bump; } - part.UpdateTexture(tex); + part.UpdateTextureEntry(tex.GetBytes()); return; } } @@ -1524,7 +1524,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { tex.CreateFace((uint) face); tex.FaceTextures[face].Fullbright = bright; - part.UpdateTexture(tex); + part.UpdateTextureEntry(tex.GetBytes()); return; } else if (face == ScriptBaseClass.ALL_SIDES) @@ -1537,7 +1537,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } tex.DefaultTexture.Fullbright = bright; - part.UpdateTexture(tex); + part.UpdateTextureEntry(tex.GetBytes()); return; } } @@ -1593,7 +1593,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api texcolor = tex.CreateFace((uint)face).RGBA; texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f); tex.FaceTextures[face].RGBA = texcolor; - part.UpdateTexture(tex); + part.UpdateTextureEntry(tex.GetBytes()); return; } else if (face == ScriptBaseClass.ALL_SIDES) @@ -1617,7 +1617,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api tex.DefaultTexture.RGBA = texcolor; } - part.UpdateTexture(tex); + part.UpdateTextureEntry(tex.GetBytes()); return; } } @@ -1774,7 +1774,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api Primitive.TextureEntryFace texface = tex.CreateFace((uint)face); texface.TextureID = textureID; tex.FaceTextures[face] = texface; - part.UpdateTexture(tex); + part.UpdateTextureEntry(tex.GetBytes()); return; } else if (face == ScriptBaseClass.ALL_SIDES) @@ -1787,7 +1787,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } tex.DefaultTexture.TextureID = textureID; - part.UpdateTexture(tex); + part.UpdateTextureEntry(tex.GetBytes()); return; } } @@ -1809,7 +1809,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api texface.RepeatU = (float)u; texface.RepeatV = (float)v; tex.FaceTextures[face] = texface; - part.UpdateTexture(tex); + part.UpdateTextureEntry(tex.GetBytes()); return; } if (face == ScriptBaseClass.ALL_SIDES) @@ -1824,7 +1824,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } tex.DefaultTexture.RepeatU = (float)u; tex.DefaultTexture.RepeatV = (float)v; - part.UpdateTexture(tex); + part.UpdateTextureEntry(tex.GetBytes()); return; } } @@ -1845,7 +1845,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api texface.OffsetU = (float)u; texface.OffsetV = (float)v; tex.FaceTextures[face] = texface; - part.UpdateTexture(tex); + part.UpdateTextureEntry(tex.GetBytes()); return; } if (face == ScriptBaseClass.ALL_SIDES) @@ -1860,7 +1860,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } tex.DefaultTexture.OffsetU = (float)u; tex.DefaultTexture.OffsetV = (float)v; - part.UpdateTexture(tex); + part.UpdateTextureEntry(tex.GetBytes()); return; } } @@ -1880,7 +1880,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api Primitive.TextureEntryFace texface = tex.CreateFace((uint)face); texface.Rotation = (float)rotation; tex.FaceTextures[face] = texface; - part.UpdateTexture(tex); + part.UpdateTextureEntry(tex.GetBytes()); return; } if (face == ScriptBaseClass.ALL_SIDES) @@ -1893,7 +1893,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } tex.DefaultTexture.Rotation = (float)rotation; - part.UpdateTexture(tex); + part.UpdateTextureEntry(tex.GetBytes()); return; } } -- cgit v1.1