From d5419f0a463d67ef40c2212484fc95ca0a4b3b5b Mon Sep 17 00:00:00 2001 From: dahlia Date: Thu, 18 Apr 2013 01:03:19 -0700 Subject: Initial experimental support for materials-capable viewers. This is in a very early stage and this module is disabled by default and should only be used by developers for testing as this module could cause data corruption and/or viewer crashes. No materials are persisted yet. --- .../Materials/MaterialsDemoModule.cs | 382 +++++++++++++++++++++ 1 file changed, 382 insertions(+) create mode 100644 OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs new file mode 100644 index 0000000..de2c3fc --- /dev/null +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs @@ -0,0 +1,382 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Security.Cryptography; // for computing md5 hash +using log4net; +using Mono.Addins; +using Nini.Config; + +using OpenMetaverse; +using OpenMetaverse.StructuredData; + +using OpenSim.Framework; +using OpenSim.Framework.Servers; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; + +using Ionic.Zlib; + +// You will need to uncomment these lines if you are adding a region module to some other assembly which does not already +// specify its assembly. Otherwise, the region modules in the assembly will not be picked up when OpenSimulator scans +// the available DLLs +//[assembly: Addin("MyModule", "1.0")] +//[assembly: AddinDependency("OpenSim", "0.5")] + +namespace OpenSim.Region.OptionalModules.MaterialsDemoModule +{ + /// + /// + // # # ## ##### # # # # # #### + // # # # # # # ## # # ## # # # + // # # # # # # # # # # # # # # + // # ## # ###### ##### # # # # # # # # ### + // ## ## # # # # # ## # # ## # # + // # # # # # # # # # # # #### + // + // + // + ////////////// WARNING ////////////////////////////////////////////////////////////////// + /// This is an *Experimental* module for developing support for materials-capable viewers + /// This module should NOT be used in a production environment! It may cause data corruption and + /// viewer crashes. It should be only used to evaluate implementations of materials. + /// + /// CURRENTLY NO MATERIALS ARE PERSISTED ACROSS SIMULATOR RESTARTS OR ARE STORED IN ANY INVENTORY OR ASSETS + /// This may change in future implementations. + /// + /// To enable this module, add this string at the bottom of OpenSim.ini: + /// [MaterialsDemoModule] + /// + /// + /// + + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MaterialsDemoModule")] + public class MaterialsDemoModule : INonSharedRegionModule + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public string Name { get { return "MaterialsDemoModule"; } } + + public Type ReplaceableInterface { get { return null; } } + + private Scene m_scene = null; + private bool m_enabled = false; + + public void Initialise(IConfigSource source) + { + m_enabled = (source.Configs["MaterialsDemoModule"] != null); + if (!m_enabled) + return; + + m_log.DebugFormat("[MaterialsDemoModule]: INITIALIZED MODULE"); + + } + + public void Close() + { + if (!m_enabled) + return; + + m_log.DebugFormat("[MaterialsDemoModule]: CLOSED MODULE"); + } + + public void AddRegion(Scene scene) + { + if (!m_enabled) + return; + + m_log.DebugFormat("[MaterialsDemoModule]: REGION {0} ADDED", scene.RegionInfo.RegionName); + m_scene = scene; + m_scene.EventManager.OnRegisterCaps += new EventManager.RegisterCapsEvent(OnRegisterCaps); + } + + void OnRegisterCaps(OpenMetaverse.UUID agentID, OpenSim.Framework.Capabilities.Caps caps) + { + string capsBase = "/CAPS/" + caps.CapsObjectPath; + + IRequestHandler renderMaterialsPostHandler = new RestStreamHandler("POST", capsBase + "/", RenderMaterialsPostCap); + caps.RegisterHandler("RenderMaterials", renderMaterialsPostHandler); + + // OpenSimulator CAPs infrastructure seems to be somewhat hostile towards any CAP that requires both GET + // and POST handlers, (at least at the time this was originally written), so we first set up a POST + // handler normally and then add a GET handler via MainServer + + IRequestHandler renderMaterialsGetHandler = new RestStreamHandler("GET", capsBase + "/", RenderMaterialsGetCap); + MainServer.Instance.AddStreamHandler(renderMaterialsGetHandler); + } + + public void RemoveRegion(Scene scene) + { + if (!m_enabled) + return; + + m_log.DebugFormat("[MaterialsDemoModule]: REGION {0} REMOVED", scene.RegionInfo.RegionName); + } + + public void RegionLoaded(Scene scene) + { + if (!m_enabled) + return; + m_log.DebugFormat("[MaterialsDemoModule]: REGION {0} LOADED", scene.RegionInfo.RegionName); + } + + public string RenderMaterialsPostCap(string request, string path, + string param, IOSHttpRequest httpRequest, + IOSHttpResponse httpResponse) + { + m_log.Debug("[MaterialsDemoModule]: POST cap handler"); + + OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); + OSDMap resp = new OSDMap(); + + OSDMap materialsFromViewer = null; + + if (req.ContainsKey("Zipped")) + { + OSD osd = null; + + byte[] inBytes = req["Zipped"].AsBinary(); + + try + { + osd = ZDecompressBytesToOsd(inBytes); + + if (osd != null && osd is OSDMap) + { + materialsFromViewer = osd as OSDMap; + + if (materialsFromViewer.ContainsKey("FullMaterialsPerFace")) + { + OSD matsOsd = materialsFromViewer["FullMaterialsPerFace"]; + if (matsOsd is OSDArray) + { + OSDArray matsArr = matsOsd as OSDArray; + + try + { + foreach (OSDMap matsMap in matsArr) + { + m_log.Debug("[MaterialsDemoModule]: processing matsMap: " + OSDParser.SerializeJsonString(matsMap)); + + uint matLocalID = 0; + try { matLocalID = matsMap["ID"].AsUInteger(); } + catch (Exception e) { m_log.Warn("[MaterialsDemoModule]: cannot decode \"ID\" from matsMap: " + e.Message); } + m_log.Debug("[MaterialsDemoModule]: matLocalId: " + matLocalID.ToString()); + + + OSDMap mat = null; + try { mat = matsMap["Material"] as OSDMap; } + catch (Exception e) { m_log.Warn("[MaterialsDemoModule]: cannot decode \"Material\" from matsMap: " + e.Message); } + m_log.Debug("[MaterialsDemoModule]: mat: " + OSDParser.SerializeJsonString(mat)); + + UUID id = HashOsd(mat); + m_knownMaterials[id] = mat; + + + var sop = m_scene.GetSceneObjectPart(matLocalID); + if (sop == null) + m_log.Debug("[MaterialsDemoModule]: null SOP for localId: " + matLocalID.ToString()); + else + { + var te = sop.Shape.Textures; + + if (te == null) + { + m_log.Debug("[MaterialsDemoModule]: null TextureEntry for localId: " + matLocalID.ToString()); + } + else + { + int face = -1; + + if (matsMap.ContainsKey("Face")) + { + face = matsMap["Face"].AsInteger(); + if (te.FaceTextures == null) // && face == 0) + { + if (te.DefaultTexture == null) + m_log.Debug("[MaterialsDemoModule]: te.DefaultTexture is null"); + else + { + if (te.DefaultTexture.MaterialID == null) + m_log.Debug("[MaterialsDemoModule]: te.DefaultTexture.MaterialID is null"); + else + { + te.DefaultTexture.MaterialID = id; + } + } + } + else + { + if (te.FaceTextures.Length >= face - 1) + { + if (te.FaceTextures[face] == null) + te.DefaultTexture.MaterialID = id; + else + te.FaceTextures[face].MaterialID = id; + } + } + } + else + { + if (te.DefaultTexture != null) + te.DefaultTexture.MaterialID = id; + } + + m_log.Debug("[MaterialsDemoModule]: setting material ID for face " + face.ToString() + " to " + id.ToString()); + + sop.UpdateTextureEntry(te); + } + } + } + } + catch (Exception e) + { + m_log.Warn("[MaterialsDemoModule]: exception processing received material: " + e.Message); + } + } + } + } + } + catch (Exception e) + { + m_log.Warn("[MaterialsDemoModule]: exception decoding zipped CAP payload: " + e.Message); + //return ""; + } + m_log.Debug("[MaterialsDemoModule]: knownMaterials.Count: " + m_knownMaterials.Count.ToString()); + } + + + string response = OSDParser.SerializeLLSDXmlString(resp); + + m_log.Debug("[MaterialsDemoModule]: cap request: " + request); + m_log.Debug("[MaterialsDemoModule]: cap response: " + response); + return response; + } + + + public string RenderMaterialsGetCap(string request, string path, + string param, IOSHttpRequest httpRequest, + IOSHttpResponse httpResponse) + { + m_log.Debug("[MaterialsDemoModule]: GET cap handler"); + + OSDMap resp = new OSDMap(); + + + int matsCount = 0; + + OSDArray allOsd = new OSDArray(); + + foreach (KeyValuePair kvp in m_knownMaterials) + { + OSDMap matMap = new OSDMap(); + + matMap["ID"] = OSD.FromBinary(kvp.Key.GetBytes()); + + matMap["Material"] = kvp.Value; + allOsd.Add(matMap); + matsCount++; + } + + + resp["Zipped"] = ZCompressOSD(allOsd, false); + m_log.Debug("[MaterialsDemoModule]: matsCount: " + matsCount.ToString()); + + return OSDParser.SerializeLLSDXmlString(resp); + } + + public Dictionary m_knownMaterials = new Dictionary(); + + /// + /// computes a UUID by hashing a OSD object + /// + /// + /// + private static UUID HashOsd(OSD osd) + { + using (var md5 = MD5.Create()) + using (MemoryStream ms = new MemoryStream(OSDParser.SerializeLLSDBinary(osd, false))) + return new UUID(md5.ComputeHash(ms), 0); + } + + public static OSD ZCompressOSD(OSD inOsd, bool useHeader = true) + { + OSD osd = null; + + using (MemoryStream msSinkCompressed = new MemoryStream()) + { + using (Ionic.Zlib.ZlibStream zOut = new Ionic.Zlib.ZlibStream(msSinkCompressed, + Ionic.Zlib.CompressionMode.Compress, CompressionLevel.BestCompression, true)) + { + CopyStream(new MemoryStream(OSDParser.SerializeLLSDBinary(inOsd, useHeader)), zOut); + zOut.Close(); + } + + msSinkCompressed.Seek(0L, SeekOrigin.Begin); + osd = OSD.FromBinary( msSinkCompressed.ToArray()); + } + + return osd; + } + + + public static OSD ZDecompressBytesToOsd(byte[] input) + { + OSD osd = null; + + using (MemoryStream msSinkUnCompressed = new MemoryStream()) + { + using (Ionic.Zlib.ZlibStream zOut = new Ionic.Zlib.ZlibStream(msSinkUnCompressed, CompressionMode.Decompress, true)) + { + CopyStream(new MemoryStream(input), zOut); + zOut.Close(); + } + msSinkUnCompressed.Seek(0L, SeekOrigin.Begin); + osd = OSDParser.DeserializeLLSDBinary(msSinkUnCompressed.ToArray()); + } + + return osd; + } + + static void CopyStream(System.IO.Stream input, System.IO.Stream output) + { + byte[] buffer = new byte[2048]; + int len; + while ((len = input.Read(buffer, 0, 2048)) > 0) + { + output.Write(buffer, 0, len); + } + + output.Flush(); + } + + } +} \ No newline at end of file -- cgit v1.1 From 06829c4082ba10fc9d3b4b37f42f01ab005c5e23 Mon Sep 17 00:00:00 2001 From: dahlia Date: Thu, 18 Apr 2013 01:29:50 -0700 Subject: remove default parameter value that apparently mono cant handle --- OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs index de2c3fc..74a4ea7 100644 --- a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs @@ -327,7 +327,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule return new UUID(md5.ComputeHash(ms), 0); } - public static OSD ZCompressOSD(OSD inOsd, bool useHeader = true) + public static OSD ZCompressOSD(OSD inOsd, bool useHeader) { OSD osd = null; -- cgit v1.1 From 258804cc043530927f442cd76337a3dab4ec742b Mon Sep 17 00:00:00 2001 From: dahlia Date: Fri, 19 Apr 2013 22:19:57 -0700 Subject: RenderMaterials POST Cap now return material entries when invoked with an OSDArray of MaterialIDs --- .../Materials/MaterialsDemoModule.cs | 169 +++++++++++++-------- 1 file changed, 108 insertions(+), 61 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs index 74a4ea7..7002e66 100644 --- a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs @@ -48,7 +48,7 @@ using Ionic.Zlib; // You will need to uncomment these lines if you are adding a region module to some other assembly which does not already // specify its assembly. Otherwise, the region modules in the assembly will not be picked up when OpenSimulator scans // the available DLLs -//[assembly: Addin("MyModule", "1.0")] +//[assembly: Addin("MaterialsDemoModule", "1.0")] //[assembly: AddinDependency("OpenSim", "0.5")] namespace OpenSim.Region.OptionalModules.MaterialsDemoModule @@ -159,6 +159,8 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule OSDMap materialsFromViewer = null; + OSDArray respArr = new OSDArray(); + if (req.ContainsKey("Zipped")) { OSD osd = null; @@ -169,101 +171,145 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule { osd = ZDecompressBytesToOsd(inBytes); - if (osd != null && osd is OSDMap) + if (osd != null) { - materialsFromViewer = osd as OSDMap; - - if (materialsFromViewer.ContainsKey("FullMaterialsPerFace")) + if (osd is OSDArray) // assume array of MaterialIDs designating requested material entries { - OSD matsOsd = materialsFromViewer["FullMaterialsPerFace"]; - if (matsOsd is OSDArray) + foreach (OSD elem in (OSDArray)osd) { - OSDArray matsArr = matsOsd as OSDArray; try { - foreach (OSDMap matsMap in matsArr) + UUID id = new UUID(elem.AsBinary(), 0); + + if (m_knownMaterials.ContainsKey(id)) + { + m_log.Info("[MaterialsDemoModule]: request for known material ID: " + id.ToString()); + OSDMap matMap = new OSDMap(); + matMap["ID"] = OSD.FromBinary(id.GetBytes()); + + matMap["Material"] = m_knownMaterials[id]; + respArr.Add(matMap); + } + else + m_log.Info("[MaterialsDemoModule]: request for UNKNOWN material ID: " + id.ToString()); + } + catch (Exception e) + { + // report something here? + continue; + } + } + } + else if (osd is OSDMap) // reqest to assign a material + { + materialsFromViewer = osd as OSDMap; + + if (materialsFromViewer.ContainsKey("FullMaterialsPerFace")) + { + OSD matsOsd = materialsFromViewer["FullMaterialsPerFace"]; + if (matsOsd is OSDArray) + { + OSDArray matsArr = matsOsd as OSDArray; + + try { - m_log.Debug("[MaterialsDemoModule]: processing matsMap: " + OSDParser.SerializeJsonString(matsMap)); + foreach (OSDMap matsMap in matsArr) + { + m_log.Debug("[MaterialsDemoModule]: processing matsMap: " + OSDParser.SerializeJsonString(matsMap)); - uint matLocalID = 0; - try { matLocalID = matsMap["ID"].AsUInteger(); } - catch (Exception e) { m_log.Warn("[MaterialsDemoModule]: cannot decode \"ID\" from matsMap: " + e.Message); } - m_log.Debug("[MaterialsDemoModule]: matLocalId: " + matLocalID.ToString()); + uint matLocalID = 0; + try { matLocalID = matsMap["ID"].AsUInteger(); } + catch (Exception e) { m_log.Warn("[MaterialsDemoModule]: cannot decode \"ID\" from matsMap: " + e.Message); } + m_log.Debug("[MaterialsDemoModule]: matLocalId: " + matLocalID.ToString()); - OSDMap mat = null; - try { mat = matsMap["Material"] as OSDMap; } - catch (Exception e) { m_log.Warn("[MaterialsDemoModule]: cannot decode \"Material\" from matsMap: " + e.Message); } - m_log.Debug("[MaterialsDemoModule]: mat: " + OSDParser.SerializeJsonString(mat)); + OSDMap mat = null; + try { mat = matsMap["Material"] as OSDMap; } + catch (Exception e) { m_log.Warn("[MaterialsDemoModule]: cannot decode \"Material\" from matsMap: " + e.Message); } + m_log.Debug("[MaterialsDemoModule]: mat: " + OSDParser.SerializeJsonString(mat)); - UUID id = HashOsd(mat); - m_knownMaterials[id] = mat; + UUID id = HashOsd(mat); + m_knownMaterials[id] = mat; - var sop = m_scene.GetSceneObjectPart(matLocalID); - if (sop == null) - m_log.Debug("[MaterialsDemoModule]: null SOP for localId: " + matLocalID.ToString()); - else - { - var te = sop.Shape.Textures; - - if (te == null) - { - m_log.Debug("[MaterialsDemoModule]: null TextureEntry for localId: " + matLocalID.ToString()); - } + var sop = m_scene.GetSceneObjectPart(matLocalID); + if (sop == null) + m_log.Debug("[MaterialsDemoModule]: null SOP for localId: " + matLocalID.ToString()); else { - int face = -1; + //var te = sop.Shape.Textures; + var te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length); - if (matsMap.ContainsKey("Face")) + if (te == null) + { + m_log.Debug("[MaterialsDemoModule]: null TextureEntry for localId: " + matLocalID.ToString()); + } + else { - face = matsMap["Face"].AsInteger(); - if (te.FaceTextures == null) // && face == 0) + int face = -1; + + if (matsMap.ContainsKey("Face")) { - if (te.DefaultTexture == null) - m_log.Debug("[MaterialsDemoModule]: te.DefaultTexture is null"); - else + face = matsMap["Face"].AsInteger(); + if (te.FaceTextures == null) // && face == 0) { - if (te.DefaultTexture.MaterialID == null) - m_log.Debug("[MaterialsDemoModule]: te.DefaultTexture.MaterialID is null"); + if (te.DefaultTexture == null) + m_log.Debug("[MaterialsDemoModule]: te.DefaultTexture is null"); else { - te.DefaultTexture.MaterialID = id; + if (te.DefaultTexture.MaterialID == null) + m_log.Debug("[MaterialsDemoModule]: te.DefaultTexture.MaterialID is null"); + else + { + te.DefaultTexture.MaterialID = id; + } + } + } + else + { + if (te.FaceTextures.Length >= face - 1) + { + if (te.FaceTextures[face] == null) + te.DefaultTexture.MaterialID = id; + else + te.FaceTextures[face].MaterialID = id; } } } else { - if (te.FaceTextures.Length >= face - 1) - { - if (te.FaceTextures[face] == null) - te.DefaultTexture.MaterialID = id; - else - te.FaceTextures[face].MaterialID = id; - } + if (te.DefaultTexture != null) + te.DefaultTexture.MaterialID = id; } - } - else - { - if (te.DefaultTexture != null) - te.DefaultTexture.MaterialID = id; - } - m_log.Debug("[MaterialsDemoModule]: setting material ID for face " + face.ToString() + " to " + id.ToString()); + m_log.Debug("[MaterialsDemoModule]: setting material ID for face " + face.ToString() + " to " + id.ToString()); + + //we cant use sop.UpdateTextureEntry(te); because it filters so do it manually - sop.UpdateTextureEntry(te); + if (sop.ParentGroup != null) + { + sop.Shape.TextureEntry = te.GetBytes(); + sop.TriggerScriptChangedEvent(Changed.TEXTURE); + sop.UpdateFlag = UpdateRequired.FULL; + sop.ParentGroup.HasGroupChanged = true; + + sop.ScheduleFullUpdate(); + + } + } } } } - } - catch (Exception e) - { - m_log.Warn("[MaterialsDemoModule]: exception processing received material: " + e.Message); + catch (Exception e) + { + m_log.Warn("[MaterialsDemoModule]: exception processing received material: " + e.Message); + } } } } } + } catch (Exception e) { @@ -273,7 +319,8 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule m_log.Debug("[MaterialsDemoModule]: knownMaterials.Count: " + m_knownMaterials.Count.ToString()); } - + + resp["Zipped"] = ZCompressOSD(respArr, false); string response = OSDParser.SerializeLLSDXmlString(resp); m_log.Debug("[MaterialsDemoModule]: cap request: " + request); -- cgit v1.1 From 233f76177997cbe12aa100a3511d45bc1e9ccc5f Mon Sep 17 00:00:00 2001 From: dahlia Date: Sat, 20 Apr 2013 02:08:22 -0700 Subject: handle PUT verb for RenderMaterials Cap --- OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs index 7002e66..4501dad 100644 --- a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs @@ -130,7 +130,11 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule // handler normally and then add a GET handler via MainServer IRequestHandler renderMaterialsGetHandler = new RestStreamHandler("GET", capsBase + "/", RenderMaterialsGetCap); - MainServer.Instance.AddStreamHandler(renderMaterialsGetHandler); + MainServer.Instance.AddStreamHandler(renderMaterialsGetHandler); + + // materials viewer seems to use either POST or PUT, so assign POST handler for PUT as well + IRequestHandler renderMaterialsPutHandler = new RestStreamHandler("PUT", capsBase + "/", RenderMaterialsPostCap); + MainServer.Instance.AddStreamHandler(renderMaterialsPutHandler); } public void RemoveRegion(Scene scene) -- cgit v1.1 From 69f07fdb349a2671fe86f96f119c0ea1276faacb Mon Sep 17 00:00:00 2001 From: dahlia Date: Sat, 20 Apr 2013 23:39:07 -0700 Subject: Materials persistence via SceneObjectPart.dynAttrs. This appears to work across region restarts and taking objects into inventory, but probably will not work across archiving via OAR or IAR as materials texture assets may not be adequately referenced to trigger archiving. --- .../Materials/MaterialsDemoModule.cs | 162 ++++++++++++++++++++- 1 file changed, 154 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs index 4501dad..4ab6609 100644 --- a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs @@ -62,15 +62,21 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule // ## ## # # # # # ## # # ## # # // # # # # # # # # # # # #### // - // + // THIS MODULE IS FOR EXPERIMENTAL USE ONLY AND MAY CAUSE REGION OR ASSET CORRUPTION! // ////////////// WARNING ////////////////////////////////////////////////////////////////// /// This is an *Experimental* module for developing support for materials-capable viewers /// This module should NOT be used in a production environment! It may cause data corruption and /// viewer crashes. It should be only used to evaluate implementations of materials. /// - /// CURRENTLY NO MATERIALS ARE PERSISTED ACROSS SIMULATOR RESTARTS OR ARE STORED IN ANY INVENTORY OR ASSETS - /// This may change in future implementations. + /// Materials are persisted via SceneObjectPart.dynattrs. This is a relatively new feature + /// of OpenSimulator and is not field proven at the time this module was written. Persistence + /// may fail or become corrupt and this could cause viewer crashes due to erroneous materials + /// data being sent to viewers. Materials descriptions might survive IAR, OAR, or other means + /// of archiving however the texture resources used by these materials probably will not as they + /// may not be adequately referenced to ensure proper archiving. + /// + /// /// /// To enable this module, add this string at the bottom of OpenSim.ini: /// [MaterialsDemoModule] @@ -89,6 +95,8 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule private Scene m_scene = null; private bool m_enabled = false; + + public Dictionary m_knownMaterials = new Dictionary(); public void Initialise(IConfigSource source) { @@ -97,7 +105,6 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule return; m_log.DebugFormat("[MaterialsDemoModule]: INITIALIZED MODULE"); - } public void Close() @@ -116,6 +123,14 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule m_log.DebugFormat("[MaterialsDemoModule]: REGION {0} ADDED", scene.RegionInfo.RegionName); m_scene = scene; m_scene.EventManager.OnRegisterCaps += new EventManager.RegisterCapsEvent(OnRegisterCaps); + m_scene.EventManager.OnObjectAddedToScene += new Action(EventManager_OnObjectAddedToScene); + } + + void EventManager_OnObjectAddedToScene(SceneObjectGroup obj) + { + foreach (var part in obj.Parts) + if (part != null) + GetStoredMaterialsForPart(part); } void OnRegisterCaps(OpenMetaverse.UUID agentID, OpenSim.Framework.Capabilities.Caps caps) @@ -147,11 +162,130 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule public void RegionLoaded(Scene scene) { - if (!m_enabled) + } + + OSDMap GetMaterial(UUID id) + { + OSDMap map = null; + if (m_knownMaterials.ContainsKey(id)) + { + map = new OSDMap(); + map["ID"] = OSD.FromBinary(id.GetBytes()); + map["Material"] = m_knownMaterials[id]; + } + return map; + } + + void GetStoredMaterialsForPart(SceneObjectPart part) + { + OSDMap OSMaterials = null; + OSDArray matsArr = null; + + if (part.DynAttrs == null) + { + m_log.Warn("[MaterialsDemoModule]: NULL DYNATTRS :( "); + } + + lock (part.DynAttrs) + { + if (part.DynAttrs.ContainsKey("OS:Materials")) + OSMaterials = part.DynAttrs["OS:Materials"]; + if (OSMaterials != null && OSMaterials.ContainsKey("Materials")) + { + + OSD osd = OSMaterials["Materials"]; + if (osd is OSDArray) + matsArr = osd as OSDArray; + } + } + + if (OSMaterials == null) return; - m_log.DebugFormat("[MaterialsDemoModule]: REGION {0} LOADED", scene.RegionInfo.RegionName); + + m_log.Info("[MaterialsDemoModule]: OSMaterials: " + OSDParser.SerializeJsonString(OSMaterials)); + + + if (matsArr == null) + { + m_log.Info("[MaterialsDemoModule]: matsArr is null :( "); + return; + } + + foreach (OSD elemOsd in matsArr) + { + if (elemOsd != null && elemOsd is OSDMap) + { + + OSDMap matMap = elemOsd as OSDMap; + if (matMap.ContainsKey("ID") && matMap.ContainsKey("Material")) + { + try + { + m_knownMaterials[matMap["ID"].AsUUID()] = (OSDMap)matMap["Material"]; + } + catch (Exception e) + { + m_log.Warn("[MaterialsDemoModule]: exception decoding persisted material: " + e.ToString()); + } + } + } + } } + + void StoreMaterialsForPart(SceneObjectPart part) + { + try + { + if (part == null || part.Shape == null) + return; + + Dictionary mats = new Dictionary(); + + Primitive.TextureEntry te = part.Shape.Textures; + + if (te.DefaultTexture != null) + { + if (m_knownMaterials.ContainsKey(te.DefaultTexture.MaterialID)) + mats[te.DefaultTexture.MaterialID] = m_knownMaterials[te.DefaultTexture.MaterialID]; + } + + if (te.FaceTextures != null) + { + foreach (var face in te.FaceTextures) + { + if (face != null) + { + if (m_knownMaterials.ContainsKey(face.MaterialID)) + mats[face.MaterialID] = m_knownMaterials[face.MaterialID]; + } + } + } + if (mats.Count == 0) + return; + + OSDArray matsArr = new OSDArray(); + foreach (KeyValuePair kvp in mats) + { + OSDMap matOsd = new OSDMap(); + matOsd["ID"] = OSD.FromUUID(kvp.Key); + matOsd["Material"] = kvp.Value; + matsArr.Add(matOsd); + } + + OSDMap OSMaterials = new OSDMap(); + OSMaterials["Materials"] = matsArr; + + lock (part.DynAttrs) + part.DynAttrs["OS:Materials"] = OSMaterials; + } + catch (Exception e) + { + m_log.Warn("[MaterialsDemoModule]: exception in StoreMaterialsForPart(): " + e.ToString()); + } + } + + public string RenderMaterialsPostCap(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) @@ -300,6 +434,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule sop.ScheduleFullUpdate(); + StoreMaterialsForPart(sop); } } } @@ -327,7 +462,8 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule resp["Zipped"] = ZCompressOSD(respArr, false); string response = OSDParser.SerializeLLSDXmlString(resp); - m_log.Debug("[MaterialsDemoModule]: cap request: " + request); + //m_log.Debug("[MaterialsDemoModule]: cap request: " + request); + m_log.Debug("[MaterialsDemoModule]: cap request (zipped portion): " + ZippedOsdBytesToString(req["Zipped"].AsBinary())); m_log.Debug("[MaterialsDemoModule]: cap response: " + response); return response; } @@ -364,7 +500,17 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule return OSDParser.SerializeLLSDXmlString(resp); } - public Dictionary m_knownMaterials = new Dictionary(); + static string ZippedOsdBytesToString(byte[] bytes) + { + try + { + return OSDParser.SerializeJsonString(ZDecompressBytesToOsd(bytes)); + } + catch (Exception e) + { + return "ZippedOsdBytesToString caught an exception: " + e.ToString(); + } + } /// /// computes a UUID by hashing a OSD object -- cgit v1.1 From 293a024c141d3567d42169f625bc449b89a1b59d Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 22 Apr 2013 22:24:41 +0200 Subject: Allow callers to set the invoice parameter for GenericMessage --- .../Agent/InternetRelayClientView/Server/IRCClientView.cs | 4 ++-- OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index 0ac56fa..915ebd8 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -971,12 +971,12 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server // TODO } - public void SendGenericMessage(string method, List message) + public void SendGenericMessage(string method, UUID invoice, List message) { } - public void SendGenericMessage(string method, List message) + public void SendGenericMessage(string method, UUID invoice, List message) { } diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 6bd27f0..0ee00e9 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -620,12 +620,12 @@ namespace OpenSim.Region.OptionalModules.World.NPC } - public void SendGenericMessage(string method, List message) + public void SendGenericMessage(string method, UUID invoice, List message) { } - public void SendGenericMessage(string method, List message) + public void SendGenericMessage(string method, UUID invoice, List message) { } -- cgit v1.1 From 115e0aaf830d31530680b38afd705380be3f284a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 23 Apr 2013 21:54:32 +0100 Subject: Fix issue in ConciergeModule where UpdateBroker was sending malformed XML if any number of avatars other than 1 was in the region. I don't know how well the rest of ConiergeModule works since I've practically never looked at this code. Addresses http://opensimulator.org/mantis/view.php?id=6605 --- OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs index 018357a..c48e585 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs @@ -375,11 +375,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge scene.GetRootAgentCount(), scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, DateTime.UtcNow.ToString("s"))); + scene.ForEachRootScenePresence(delegate(ScenePresence sp) { - list.Append(String.Format(" \n", sp.Name, sp.UUID)); - list.Append(""); + list.Append(String.Format(" \n", sp.Name, sp.UUID)); }); + + list.Append(""); string payload = list.ToString(); // post via REST to broker -- cgit v1.1 From ec4f981f1d371b329d227e17cb2f5aaaba364fad Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 25 Apr 2013 01:39:22 +0200 Subject: Adding the dynamic menu module which allows registering new menu options in compliant viewers --- .../ViewerSupport/DynamicMenuModule.cs | 282 +++++++++++++++++++++ 1 file changed, 282 insertions(+) create mode 100644 OpenSim/Region/OptionalModules/ViewerSupport/DynamicMenuModule.cs (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/ViewerSupport/DynamicMenuModule.cs b/OpenSim/Region/OptionalModules/ViewerSupport/DynamicMenuModule.cs new file mode 100644 index 0000000..917911f --- /dev/null +++ b/OpenSim/Region/OptionalModules/ViewerSupport/DynamicMenuModule.cs @@ -0,0 +1,282 @@ +// ****************************************************************** +// Copyright (c) 2008, 2009 Melanie Thielker +// +// All rights reserved +// + +using System; +using System.IO; +using System.Reflection; +using System.Text; +using System.Collections.Generic; +using OpenMetaverse; +using OpenMetaverse.StructuredData; +using OpenSim; +using OpenSim.Region; +using OpenSim.Region.Framework; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Framework; +//using OpenSim.Framework.Capabilities; +using OpenSim.Framework.Servers; +using OpenSim.Framework.Servers.HttpServer; +using Nini.Config; +using log4net; +using Mono.Addins; +using Caps = OpenSim.Framework.Capabilities.Caps; +using OSDMap = OpenMetaverse.StructuredData.OSDMap; + +namespace OpenSim.Region.OptionalModules.ViewerSupport +{ + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "DynamicMenu")] + public class DynamicMenuModule : INonSharedRegionModule, IDynamicMenuModule + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private class MenuItemData + { + public string Title; + public UUID AgentID; + public InsertLocation Location; + public UserMode Mode; + public CustomMenuHandler Handler; + } + + private Dictionary> m_menuItems = + new Dictionary>(); + + private Scene m_scene; + + public string Name + { + get { return "DynamicMenuModule"; } + } + + public Type ReplaceableInterface + { + get { return null; } + } + + public void Initialise(IConfigSource config) + { + } + + public void Close() + { + } + + public void AddRegion(Scene scene) + { + m_scene = scene; + scene.EventManager.OnRegisterCaps += OnRegisterCaps; + m_scene.RegisterModuleInterface(this); + } + + public void RegionLoaded(Scene scene) + { + ISimulatorFeaturesModule featuresModule = m_scene.RequestModuleInterface(); + + if (featuresModule != null) + featuresModule.OnSimulatorFeaturesRequest += OnSimulatorFeaturesRequest; + } + + public void RemoveRegion(Scene scene) + { + } + + private void OnSimulatorFeaturesRequest(UUID agentID, ref OSDMap features) + { + OSD menus = new OSDMap(); + if (features.ContainsKey("menus")) + menus = features["menus"]; + + OSDMap agent = new OSDMap(); + OSDMap world = new OSDMap(); + OSDMap tools = new OSDMap(); + OSDMap advanced = new OSDMap(); + OSDMap admin = new OSDMap(); + if (((OSDMap)menus).ContainsKey("agent")) + agent = (OSDMap)((OSDMap)menus)["agent"]; + if (((OSDMap)menus).ContainsKey("world")) + world = (OSDMap)((OSDMap)menus)["world"]; + if (((OSDMap)menus).ContainsKey("tools")) + tools = (OSDMap)((OSDMap)menus)["tools"]; + if (((OSDMap)menus).ContainsKey("advanced")) + advanced = (OSDMap)((OSDMap)menus)["advanced"]; + if (((OSDMap)menus).ContainsKey("admin")) + admin = (OSDMap)((OSDMap)menus)["admin"]; + + if (m_menuItems.ContainsKey(UUID.Zero)) + { + foreach (MenuItemData d in m_menuItems[UUID.Zero]) + { + if (d.Mode == UserMode.God && (!m_scene.Permissions.IsGod(agentID))) + continue; + + OSDMap loc = null; + switch (d.Location) + { + case InsertLocation.Agent: + loc = agent; + break; + case InsertLocation.World: + loc = world; + break; + case InsertLocation.Tools: + loc = tools; + break; + case InsertLocation.Advanced: + loc = advanced; + break; + case InsertLocation.Admin: + loc = admin; + break; + } + + if (loc == null) + continue; + + loc[d.Title] = OSD.FromString(d.Title); + } + } + + if (m_menuItems.ContainsKey(agentID)) + { + foreach (MenuItemData d in m_menuItems[agentID]) + { + if (d.Mode == UserMode.God && (!m_scene.Permissions.IsGod(agentID))) + continue; + + OSDMap loc = null; + switch (d.Location) + { + case InsertLocation.Agent: + loc = agent; + break; + case InsertLocation.World: + loc = world; + break; + case InsertLocation.Tools: + loc = tools; + break; + case InsertLocation.Advanced: + loc = advanced; + break; + case InsertLocation.Admin: + loc = admin; + break; + } + + if (loc == null) + continue; + + loc[d.Title] = OSD.FromString(d.Title); + } + } + + + ((OSDMap)menus)["agent"] = agent; + ((OSDMap)menus)["world"] = world; + ((OSDMap)menus)["tools"] = tools; + ((OSDMap)menus)["advanced"] = advanced; + ((OSDMap)menus)["admin"] = admin; + + features["menus"] = menus; + } + + private void OnRegisterCaps(UUID agentID, Caps caps) + { + string capUrl = "/CAPS/" + UUID.Random() + "/"; + + capUrl = "/CAPS/" + UUID.Random() + "/"; + caps.RegisterHandler("CustomMenuAction", new MenuActionHandler(capUrl, "CustomMenuAction", agentID, this, m_scene)); + } + + internal void HandleMenuSelection(string action, UUID agentID, List selection) + { + if (m_menuItems.ContainsKey(agentID)) + { + foreach (MenuItemData d in m_menuItems[agentID]) + { + if (d.Title == action) + d.Handler(action, agentID, selection); + } + } + + if (m_menuItems.ContainsKey(UUID.Zero)) + { + foreach (MenuItemData d in m_menuItems[UUID.Zero]) + { + if (d.Title == action) + d.Handler(action, agentID, selection); + } + } + } + + public void AddMenuItem(string title, InsertLocation location, UserMode mode, CustomMenuHandler handler) + { + AddMenuItem(UUID.Zero, title, location, mode, handler); + } + + public void AddMenuItem(UUID agentID, string title, InsertLocation location, UserMode mode, CustomMenuHandler handler) + { + if (!m_menuItems.ContainsKey(agentID)) + m_menuItems[agentID] = new List(); + + m_menuItems[agentID].Add(new MenuItemData() { Title = title, AgentID = agentID, Location = location, Mode = mode, Handler = handler }); + } + + public void RemoveMenuItem(string action) + { + foreach (KeyValuePair> kvp in m_menuItems) + { + List pendingDeletes = new List(); + foreach (MenuItemData d in kvp.Value) + { + if (d.Title == action) + pendingDeletes.Add(d); + } + + foreach (MenuItemData d in pendingDeletes) + kvp.Value.Remove(d); + } + } + } + + public class MenuActionHandler : BaseStreamHandler + { + private static readonly ILog m_log = + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private UUID m_agentID; + private Scene m_scene; + private DynamicMenuModule m_module; + + public MenuActionHandler(string path, string name, UUID agentID, DynamicMenuModule module, Scene scene) + :base("POST", path, name, agentID.ToString()) + { + m_agentID = agentID; + m_scene = scene; + m_module = module; + } + + public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) + { + StreamReader reader = new StreamReader(request); + string requestBody = reader.ReadToEnd(); + + OSD osd = OSDParser.DeserializeLLSDXml(requestBody); + + string action = ((OSDMap)osd)["action"].AsString(); + OSDArray selection = (OSDArray)((OSDMap)osd)["selection"]; + List sel = new List(); + for (int i = 0 ; i < selection.Count ; i++) + sel.Add(selection[i].AsUInteger()); + + Util.FireAndForget(x => { m_module.HandleMenuSelection(action, m_agentID, sel); }); + + Encoding encoding = Encoding.UTF8; + return encoding.GetBytes(OSDParser.SerializeLLSDXmlString(new OSD())); + } + } +} -- cgit v1.1 From 5d0a8ff39149a41d332dc40ae0bb1dc0972d0512 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 25 Apr 2013 20:48:12 +0100 Subject: Change copyright notice on DynamicMenuModule to proper BSD --- .../ViewerSupport/DynamicMenuModule.cs | 31 ++++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/ViewerSupport/DynamicMenuModule.cs b/OpenSim/Region/OptionalModules/ViewerSupport/DynamicMenuModule.cs index 917911f..1ea1c20 100644 --- a/OpenSim/Region/OptionalModules/ViewerSupport/DynamicMenuModule.cs +++ b/OpenSim/Region/OptionalModules/ViewerSupport/DynamicMenuModule.cs @@ -1,8 +1,29 @@ -// ****************************************************************** -// Copyright (c) 2008, 2009 Melanie Thielker -// -// All rights reserved -// +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ using System; using System.IO; -- cgit v1.1 From 03c9d8ae4fa9a47cda66814177071c258f5b4437 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 25 Apr 2013 21:35:18 +0100 Subject: Change EconomyDataRequest signature to use an IClientAPI rather than UUID. This is needed because recent LL viewer codebases call this earlier in login when the client is not yet established in the sim and can't be found by UUID. Sending the reply requires having the IClientAPI. --- .../World/MoneyModule/SampleMoneyModule.cs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs index 7bbf500..37af8c7 100644 --- a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs +++ b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs @@ -688,19 +688,14 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule /// Event called Economy Data Request handler. /// /// - public void EconomyDataRequestHandler(UUID agentId) + public void EconomyDataRequestHandler(IClientAPI user) { - IClientAPI user = LocateClientObject(agentId); + Scene s = LocateSceneClientIn(user.AgentId); - if (user != null) - { - Scene s = LocateSceneClientIn(user.AgentId); - - user.SendEconomyData(EnergyEfficiency, s.RegionInfo.ObjectCapacity, ObjectCount, PriceEnergyUnit, PriceGroupCreate, - PriceObjectClaim, PriceObjectRent, PriceObjectScaleFactor, PriceParcelClaim, PriceParcelClaimFactor, - PriceParcelRent, PricePublicObjectDecay, PricePublicObjectDelete, PriceRentLight, PriceUpload, - TeleportMinPrice, TeleportPriceExponent); - } + user.SendEconomyData(EnergyEfficiency, s.RegionInfo.ObjectCapacity, ObjectCount, PriceEnergyUnit, PriceGroupCreate, + PriceObjectClaim, PriceObjectRent, PriceObjectScaleFactor, PriceParcelClaim, PriceParcelClaimFactor, + PriceParcelRent, PricePublicObjectDecay, PricePublicObjectDelete, PriceRentLight, PriceUpload, + TeleportMinPrice, TeleportPriceExponent); } private void ValidateLandBuy(Object osender, EventManager.LandBuyArgs e) -- cgit v1.1 From ef08ab68a7a8870e4ec300a0da5533ea097a9577 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 27 Apr 2013 17:42:54 +0100 Subject: Small oversight in EconomyDataRequest - this would have affected everyone NOT using a money module. --- OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs | 2 -- 1 file changed, 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs index 37af8c7..5863379 100644 --- a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs +++ b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs @@ -690,8 +690,6 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule /// public void EconomyDataRequestHandler(IClientAPI user) { - Scene s = LocateSceneClientIn(user.AgentId); - user.SendEconomyData(EnergyEfficiency, s.RegionInfo.ObjectCapacity, ObjectCount, PriceEnergyUnit, PriceGroupCreate, PriceObjectClaim, PriceObjectRent, PriceObjectScaleFactor, PriceParcelClaim, PriceParcelClaimFactor, PriceParcelRent, PricePublicObjectDecay, PricePublicObjectDelete, PriceRentLight, PriceUpload, -- cgit v1.1 From cbb3bb62dae548917a899171bd69972e85a1642d Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 27 Apr 2013 17:56:39 +0100 Subject: Unbreak the sample money module --- OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs index 5863379..35f44d0 100644 --- a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs +++ b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs @@ -690,6 +690,8 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule /// public void EconomyDataRequestHandler(IClientAPI user) { + Scene s = (Scene)user.Scene; + user.SendEconomyData(EnergyEfficiency, s.RegionInfo.ObjectCapacity, ObjectCount, PriceEnergyUnit, PriceGroupCreate, PriceObjectClaim, PriceObjectRent, PriceObjectScaleFactor, PriceParcelClaim, PriceParcelClaimFactor, PriceParcelRent, PricePublicObjectDecay, PricePublicObjectDelete, PriceRentLight, PriceUpload, -- cgit v1.1 From 33aaa40bee37ca4d8a3afa10fbbea7c1be3a1d58 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Wed, 8 May 2013 13:13:51 -0700 Subject: Adds an event and a method so that handling of the CachedTexture packet can be pulled out of LLClientView and moved to AvatarFactory. The first pass at reusing textures (turned off by default) is included. When reusing textures, if the baked textures from a previous login are still in the asset service (which generally means that they are in the simulator's cache) then the avatar will not need to rebake. This is both a performance improvement (specifically that an avatars baked textures do not need to be sent to other users who have the old textures cached) and a resource improvement (don't have to deal with duplicate bakes in the asset service cache). --- .../Agent/InternetRelayClientView/Server/IRCClientView.cs | 6 ++++++ OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs | 6 ++++++ 2 files changed, 12 insertions(+) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index 915ebd8..3644856 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -660,6 +660,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server public event BakeTerrain OnBakeTerrain; public event EstateChangeInfo OnEstateChangeInfo; public event EstateManageTelehub OnEstateManageTelehub; + public event CachedTextureRequest OnCachedTextureRequest; public event SetAppearance OnSetAppearance; public event AvatarNowWearing OnAvatarNowWearing; public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv; @@ -938,7 +939,12 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server { } + + public void SendCachedTextureResponse(ISceneEntity avatar, int serial, List cachedTextures) + { + } + public void SendStartPingCheck(byte seq) { diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 0ee00e9..8aae300 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -391,6 +391,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC public event EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest; public event EstateChangeInfo OnEstateChangeInfo; public event EstateManageTelehub OnEstateManageTelehub; + public event CachedTextureRequest OnCachedTextureRequest; public event ScriptReset OnScriptReset; public event GetScriptRunning OnGetScriptRunning; public event SetScriptRunning OnSetScriptRunning; @@ -569,6 +570,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC { } + public void SendCachedTextureResponse(ISceneEntity avatar, int serial, List cachedTextures) + { + + } + public virtual void Kick(string message) { } -- cgit v1.1 From 3290cd09d3ecd45c52bd131ada2a793c48fd99dc Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 9 May 2013 18:12:17 +0100 Subject: remove pointless region handle paramter from IClientAPI.SendKillObject() --- .../Agent/InternetRelayClientView/Server/IRCClientView.cs | 2 +- OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index 3644856..384eb1f 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -950,7 +950,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server } - public void SendKillObject(ulong regionHandle, List localID) + public void SendKillObject(List localID) { } diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 8aae300..553443f 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -592,7 +592,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC } - public virtual void SendKillObject(ulong regionHandle, List localID) + public virtual void SendKillObject(List localID) { } -- cgit v1.1 From 681fbda4b6b9700421b82dc639f954c60871542e Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Fri, 24 May 2013 13:18:16 -0700 Subject: This is an experimental patch that adds support for comparing texture hashes for the purpose of accurately responding to AgentTextureCached packets. There is a change to IClientAPI to report the wearbles hashes that come in through the SetAppearance packet. Added storage of the texture hashes in the appearance. While these are added to the Pack/Unpack (with support for missing values) routines (which means Simian will store them properly), they are not currently persisted in Robust. --- .../Agent/InternetRelayClientView/Server/IRCClientView.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index 384eb1f..118635d 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -907,7 +907,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server // Mimicking LLClientView which gets always set appearance from client. AvatarAppearance appearance; m_scene.GetAvatarAppearance(this, out appearance); - OnSetAppearance(this, appearance.Texture, (byte[])appearance.VisualParams.Clone()); + OnSetAppearance(this, appearance.Texture, (byte[])appearance.VisualParams.Clone(), new List()); } public void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args) -- cgit v1.1 From 533bbf033df88fd231eb0e7d2b0aa5a0058163ea Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 25 May 2013 02:08:54 +0100 Subject: Update the money framework to allow sending the new style linden "serverside is now viewerside" messages regarding currency This will require all money modules to be refactored! --- .../Agent/InternetRelayClientView/Server/IRCClientView.cs | 7 +------ .../OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs | 2 +- .../OptionalModules/World/MoneyModule/SampleMoneyModule.cs | 13 +++++++++---- OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs | 7 +------ 4 files changed, 12 insertions(+), 17 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index 118635d..3726191 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -1056,7 +1056,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server { } - public void SendMoneyBalance(UUID transaction, bool success, byte[] description, int balance) + public void SendMoneyBalance(UUID transaction, bool success, byte[] description, int balance, int transactionType, UUID sourceID, bool sourceIsGroup, UUID destID, bool destIsGroup, int amount, string item) { } @@ -1196,11 +1196,6 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server } - public bool AddMoney(int debit) - { - return true; - } - public void SendSunPos(Vector3 sunPos, Vector3 sunVel, ulong CurrentTime, uint SecondsPerSunCycle, uint SecondsPerYear, float OrbitalPosition) { diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs index 29f9591..32fb54b 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs @@ -764,7 +764,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups remoteClient.SendCreateGroupReply(UUID.Zero, false, "You have got insufficient funds to create a group."); return UUID.Zero; } - money.ApplyCharge(GetRequestingAgentID(remoteClient), money.GroupCreationCharge, "Group Creation"); + money.ApplyCharge(GetRequestingAgentID(remoteClient), money.GroupCreationCharge, MoneyTransactionType.GroupCreate); } UUID groupID = m_groupData.CreateGroup(GetRequestingAgentID(remoteClient), name, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish, GetRequestingAgentID(remoteClient)); diff --git a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs index 35f44d0..1345db9 100644 --- a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs +++ b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs @@ -191,9 +191,14 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule // Please do not refactor these to be just one method // Existing implementations need the distinction // - public void ApplyCharge(UUID agentID, int amount, string text) + public void ApplyCharge(UUID agentID, int amount, MoneyTransactionType type, string extraData) { } + + public void ApplyCharge(UUID agentID, int amount, MoneyTransactionType type) + { + } + public void ApplyUploadCharge(UUID agentID, int amount, string text) { } @@ -322,7 +327,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule client.SendAlertMessage(e.Message + " "); } - client.SendMoneyBalance(TransactionID, true, new byte[0], returnfunds); + client.SendMoneyBalance(TransactionID, true, new byte[0], returnfunds, 0, UUID.Zero, false, UUID.Zero, false, 0, String.Empty); } else { @@ -385,12 +390,12 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule { if (sender != null) { - sender.SendMoneyBalance(UUID.Random(), transactionresult, Utils.StringToBytes(description), GetFundsForAgentID(senderID)); + sender.SendMoneyBalance(UUID.Random(), transactionresult, Utils.StringToBytes(description), GetFundsForAgentID(senderID), 0, UUID.Zero, false, UUID.Zero, false, 0, String.Empty); } if (receiver != null) { - receiver.SendMoneyBalance(UUID.Random(), transactionresult, Utils.StringToBytes(description), GetFundsForAgentID(receiverID)); + receiver.SendMoneyBalance(UUID.Random(), transactionresult, Utils.StringToBytes(description), GetFundsForAgentID(receiverID), 0, UUID.Zero, false, UUID.Zero, false, 0, String.Empty); } } } diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 553443f..592e4e1 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -694,7 +694,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC { } - public virtual void SendMoneyBalance(UUID transaction, bool success, byte[] description, int balance) + public virtual void SendMoneyBalance(UUID transaction, bool success, byte[] description, int balance, int transactionType, UUID sourceID, bool sourceIsGroup, UUID destID, bool destIsGroup, int amount, string item) { } @@ -866,11 +866,6 @@ namespace OpenSim.Region.OptionalModules.World.NPC { } - public bool AddMoney(int debit) - { - return false; - } - public void SendSunPos(Vector3 sunPos, Vector3 sunVel, ulong time, uint dlen, uint ylen, float phase) { } -- cgit v1.1 From 7e1c7f54c719910145a88bfebf16435b9f142901 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 28 May 2013 20:59:25 -0700 Subject: First change in Vivox for ages! -- added a lock to serialize calls to vivox servers. This may ameliorate things when lots of avies arrive in a sim at about the same time. Turns out that there are 4 http requests per avie to Vivox. --- .../Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | 39 ++++++++++++++-------- 1 file changed, 25 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs index cb69411..db4869d 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs @@ -117,6 +117,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice private IConfig m_config; + private object m_Lock; + public void Initialise(IConfigSource config) { @@ -128,6 +130,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice if (!m_config.GetBoolean("enabled", false)) return; + m_Lock = new object(); + try { // retrieve configuration variables @@ -1111,25 +1115,32 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice doc = new XmlDocument(); - try + // Let's serialize all calls to Vivox. Most of these are driven by + // the clients (CAPs), when the user arrives at the region. We don't + // want to issue many simultaneous http requests to Vivox, because mono + // doesn't like that + lock (m_Lock) { - // Otherwise prepare the request - m_log.DebugFormat("[VivoxVoice] Sending request <{0}>", requrl); + try + { + // Otherwise prepare the request + m_log.DebugFormat("[VivoxVoice] Sending request <{0}>", requrl); - HttpWebRequest req = (HttpWebRequest)WebRequest.Create(requrl); + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(requrl); - // We are sending just parameters, no content - req.ContentLength = 0; + // We are sending just parameters, no content + req.ContentLength = 0; - // Send request and retrieve the response - using (HttpWebResponse rsp = (HttpWebResponse)req.GetResponse()) + // Send request and retrieve the response + using (HttpWebResponse rsp = (HttpWebResponse)req.GetResponse()) using (Stream s = rsp.GetResponseStream()) - using (XmlTextReader rdr = new XmlTextReader(s)) - doc.Load(rdr); - } - catch (Exception e) - { - m_log.ErrorFormat("[VivoxVoice] Error in admin call : {0}", e.Message); + using (XmlTextReader rdr = new XmlTextReader(s)) + doc.Load(rdr); + } + catch (Exception e) + { + m_log.ErrorFormat("[VivoxVoice] Error in admin call : {0}", e.Message); + } } // If we're debugging server responses, dump the whole -- cgit v1.1 From 12a3b855619735b2e36a67ab99027029c8b57260 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 30 May 2013 22:20:02 +0100 Subject: Fix passing of voice distance attenuation to the Vivox voice server. Because of a typo, this wasn't being done at all - now the 'default' value as described in OpenSimDefaults.ini of 10m is passed (vivox_channel_clamping_distance) Thanks to Ai Austin for spotting this. --- .../Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs index db4869d..2d65530 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs @@ -836,7 +836,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice requrl = String.Format("{0}&chan_roll_off={1}", requrl, m_vivoxChannelRollOff); requrl = String.Format("{0}&chan_dist_model={1}", requrl, m_vivoxChannelDistanceModel); requrl = String.Format("{0}&chan_max_range={1}", requrl, m_vivoxChannelMaximumRange); - requrl = String.Format("{0}&chan_ckamping_distance={1}", requrl, m_vivoxChannelClampingDistance); + requrl = String.Format("{0}&chan_clamping_distance={1}", requrl, m_vivoxChannelClampingDistance); XmlElement resp = VivoxCall(requrl, true); if (XmlFind(resp, "response.level0.body.chan_uri", out channelUri)) -- cgit v1.1 From 0d2fd0d914581f755661455b8db2b9e399154632 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 17 Jun 2013 22:39:00 +0100 Subject: Make general server stats available on the robust console as well as the simulator console This means the "show stats" command is now active on the robust console. --- .../Framework/Monitoring/ServerStats.cs | 339 --------------------- 1 file changed, 339 deletions(-) delete mode 100644 OpenSim/Region/OptionalModules/Framework/Monitoring/ServerStats.cs (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Framework/Monitoring/ServerStats.cs b/OpenSim/Region/OptionalModules/Framework/Monitoring/ServerStats.cs deleted file mode 100644 index 6e74ce0..0000000 --- a/OpenSim/Region/OptionalModules/Framework/Monitoring/ServerStats.cs +++ /dev/null @@ -1,339 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Net.NetworkInformation; -using System.Text; -using System.Threading; - -using log4net; -using Mono.Addins; -using Nini.Config; - -using OpenSim.Framework; -using OpenSim.Framework.Console; -using OpenSim.Framework.Monitoring; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; - -using OpenMetaverse.StructuredData; - -namespace OpenSim.Region.OptionalModules.Framework.Monitoring -{ -[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ServerStatistics")] -public class ServerStats : ISharedRegionModule -{ - private readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - private readonly string LogHeader = "[SERVER STATS]"; - - public bool Enabled = false; - private static Dictionary RegisteredStats = new Dictionary(); - - public readonly string CategoryServer = "server"; - - public readonly string ContainerProcessor = "processor"; - public readonly string ContainerMemory = "memory"; - public readonly string ContainerNetwork = "network"; - public readonly string ContainerProcess = "process"; - - public string NetworkInterfaceTypes = "Ethernet"; - - readonly int performanceCounterSampleInterval = 500; - int lastperformanceCounterSampleTime = 0; - - private class PerfCounterControl - { - public PerformanceCounter perfCounter; - public int lastFetch; - public string name; - public PerfCounterControl(PerformanceCounter pPc) - : this(pPc, String.Empty) - { - } - public PerfCounterControl(PerformanceCounter pPc, string pName) - { - perfCounter = pPc; - lastFetch = 0; - name = pName; - } - } - - PerfCounterControl processorPercentPerfCounter = null; - - #region ISharedRegionModule - // IRegionModuleBase.Name - public string Name { get { return "Server Stats"; } } - // IRegionModuleBase.ReplaceableInterface - public Type ReplaceableInterface { get { return null; } } - // IRegionModuleBase.Initialize - public void Initialise(IConfigSource source) - { - IConfig cfg = source.Configs["Monitoring"]; - - if (cfg != null) - Enabled = cfg.GetBoolean("ServerStatsEnabled", true); - - if (Enabled) - { - NetworkInterfaceTypes = cfg.GetString("NetworkInterfaceTypes", "Ethernet"); - } - } - // IRegionModuleBase.Close - public void Close() - { - if (RegisteredStats.Count > 0) - { - foreach (Stat stat in RegisteredStats.Values) - { - StatsManager.DeregisterStat(stat); - stat.Dispose(); - } - RegisteredStats.Clear(); - } - } - // IRegionModuleBase.AddRegion - public void AddRegion(Scene scene) - { - } - // IRegionModuleBase.RemoveRegion - public void RemoveRegion(Scene scene) - { - } - // IRegionModuleBase.RegionLoaded - public void RegionLoaded(Scene scene) - { - } - // ISharedRegionModule.PostInitialize - public void PostInitialise() - { - if (RegisteredStats.Count == 0) - { - RegisterServerStats(); - } - } - #endregion ISharedRegionModule - - private void MakeStat(string pName, string pDesc, string pUnit, string pContainer, Action act) - { - string desc = pDesc; - if (desc == null) - desc = pName; - Stat stat = new Stat(pName, pName, desc, pUnit, CategoryServer, pContainer, StatType.Pull, act, StatVerbosity.Info); - StatsManager.RegisterStat(stat); - RegisteredStats.Add(pName, stat); - } - - public void RegisterServerStats() - { - lastperformanceCounterSampleTime = Util.EnvironmentTickCount(); - PerformanceCounter tempPC; - Stat tempStat; - string tempName; - - try - { - tempName = "CPUPercent"; - tempPC = new PerformanceCounter("Processor", "% Processor Time", "_Total"); - processorPercentPerfCounter = new PerfCounterControl(tempPC); - // A long time bug in mono is that CPU percent is reported as CPU percent idle. Windows reports CPU percent busy. - tempStat = new Stat(tempName, tempName, "", "percent", CategoryServer, ContainerProcessor, - StatType.Pull, (s) => { GetNextValue(s, processorPercentPerfCounter, Util.IsWindows() ? 1 : -1); }, - StatVerbosity.Info); - StatsManager.RegisterStat(tempStat); - RegisteredStats.Add(tempName, tempStat); - - MakeStat("TotalProcessorTime", null, "sec", ContainerProcessor, - (s) => { s.Value = Process.GetCurrentProcess().TotalProcessorTime.TotalSeconds; }); - - MakeStat("UserProcessorTime", null, "sec", ContainerProcessor, - (s) => { s.Value = Process.GetCurrentProcess().UserProcessorTime.TotalSeconds; }); - - MakeStat("PrivilegedProcessorTime", null, "sec", ContainerProcessor, - (s) => { s.Value = Process.GetCurrentProcess().PrivilegedProcessorTime.TotalSeconds; }); - - MakeStat("Threads", null, "threads", ContainerProcessor, - (s) => { s.Value = Process.GetCurrentProcess().Threads.Count; }); - } - catch (Exception e) - { - m_log.ErrorFormat("{0} Exception creating 'Process': {1}", LogHeader, e); - } - - try - { - List okInterfaceTypes = new List(NetworkInterfaceTypes.Split(',')); - - IEnumerable nics = NetworkInterface.GetAllNetworkInterfaces(); - foreach (NetworkInterface nic in nics) - { - if (nic.OperationalStatus != OperationalStatus.Up) - continue; - - string nicInterfaceType = nic.NetworkInterfaceType.ToString(); - if (!okInterfaceTypes.Contains(nicInterfaceType)) - { - m_log.DebugFormat("{0} Not including stats for network interface '{1}' of type '{2}'.", - LogHeader, nic.Name, nicInterfaceType); - m_log.DebugFormat("{0} To include, add to comma separated list in [Monitoring]NetworkInterfaceTypes={1}", - LogHeader, NetworkInterfaceTypes); - continue; - } - - if (nic.Supports(NetworkInterfaceComponent.IPv4)) - { - IPv4InterfaceStatistics nicStats = nic.GetIPv4Statistics(); - if (nicStats != null) - { - MakeStat("BytesRcvd/" + nic.Name, nic.Name, "KB", ContainerNetwork, - (s) => { LookupNic(s, (ns) => { return ns.BytesReceived; }, 1024.0); }); - MakeStat("BytesSent/" + nic.Name, nic.Name, "KB", ContainerNetwork, - (s) => { LookupNic(s, (ns) => { return ns.BytesSent; }, 1024.0); }); - MakeStat("TotalBytes/" + nic.Name, nic.Name, "KB", ContainerNetwork, - (s) => { LookupNic(s, (ns) => { return ns.BytesSent + ns.BytesReceived; }, 1024.0); }); - } - } - // TODO: add IPv6 (it may actually happen someday) - } - } - catch (Exception e) - { - m_log.ErrorFormat("{0} Exception creating 'Network Interface': {1}", LogHeader, e); - } - - MakeStat("ProcessMemory", null, "MB", ContainerMemory, - (s) => { s.Value = Process.GetCurrentProcess().WorkingSet64 / 1024d / 1024d; }); - MakeStat("ObjectMemory", null, "MB", ContainerMemory, - (s) => { s.Value = GC.GetTotalMemory(false) / 1024d / 1024d; }); - MakeStat("LastMemoryChurn", null, "MB/sec", ContainerMemory, - (s) => { s.Value = Math.Round(MemoryWatchdog.LastMemoryChurn * 1000d / 1024d / 1024d, 3); }); - MakeStat("AverageMemoryChurn", null, "MB/sec", ContainerMemory, - (s) => { s.Value = Math.Round(MemoryWatchdog.AverageMemoryChurn * 1000d / 1024d / 1024d, 3); }); - } - - // Notes on performance counters: - // "How To Read Performance Counters": http://blogs.msdn.com/b/bclteam/archive/2006/06/02/618156.aspx - // "How to get the CPU Usage in C#": http://stackoverflow.com/questions/278071/how-to-get-the-cpu-usage-in-c - // "Mono Performance Counters": http://www.mono-project.com/Mono_Performance_Counters - private delegate double PerfCounterNextValue(); - private void GetNextValue(Stat stat, PerfCounterControl perfControl) - { - GetNextValue(stat, perfControl, 1.0); - } - private void GetNextValue(Stat stat, PerfCounterControl perfControl, double factor) - { - if (Util.EnvironmentTickCountSubtract(perfControl.lastFetch) > performanceCounterSampleInterval) - { - if (perfControl != null && perfControl.perfCounter != null) - { - try - { - // Kludge for factor to run double duty. If -1, subtract the value from one - if (factor == -1) - stat.Value = 1 - perfControl.perfCounter.NextValue(); - else - stat.Value = perfControl.perfCounter.NextValue() / factor; - } - catch (Exception e) - { - m_log.ErrorFormat("{0} Exception on NextValue fetching {1}: {2}", LogHeader, stat.Name, e); - } - perfControl.lastFetch = Util.EnvironmentTickCount(); - } - } - } - - // Lookup the nic that goes with this stat and set the value by using a fetch action. - // Not sure about closure with delegates inside delegates. - private delegate double GetIPv4StatValue(IPv4InterfaceStatistics interfaceStat); - private void LookupNic(Stat stat, GetIPv4StatValue getter, double factor) - { - // Get the one nic that has the name of this stat - IEnumerable nics = NetworkInterface.GetAllNetworkInterfaces().Where( - (network) => network.Name == stat.Description); - try - { - foreach (NetworkInterface nic in nics) - { - IPv4InterfaceStatistics intrStats = nic.GetIPv4Statistics(); - if (intrStats != null) - { - double newVal = Math.Round(getter(intrStats) / factor, 3); - stat.Value = newVal; - } - break; - } - } - catch - { - // There are times interfaces go away so we just won't update the stat for this - m_log.ErrorFormat("{0} Exception fetching stat on interface '{1}'", LogHeader, stat.Description); - } - } -} - -public class ServerStatsAggregator : Stat -{ - public ServerStatsAggregator( - string shortName, - string name, - string description, - string unitName, - string category, - string container - ) - : base( - shortName, - name, - description, - unitName, - category, - container, - StatType.Push, - MeasuresOfInterest.None, - null, - StatVerbosity.Info) - { - } - public override string ToConsoleString() - { - StringBuilder sb = new StringBuilder(); - - return sb.ToString(); - } - - public override OSDMap ToOSDMap() - { - OSDMap ret = new OSDMap(); - - return ret; - } -} - -} -- cgit v1.1 From f7d09b898ad6df32b3f07cb64657623980178c2f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 27 Jun 2013 23:14:28 +0100 Subject: Make the concept of namespaces explicit in dynamic attributes This is in order to reduce the likelihood of naming clashes, make it easier to filter in/out attributes, ensure uniformity, etc. All dynattrs in the opensim distro itself or likely future ones should be in the "OpenSim" namespace. This does alter the underlying dynattrs data structure. All data in previous structures may not be available, though old structures should not cause errors. This is done without notice since this feature has been explicitly labelled as experimental, subject to change and has not been in a release. However, existing materials data is being preserved by moving it to the "Materials" store in the "OpenSim" namespace. --- .../Materials/MaterialsDemoModule.cs | 26 +++++++++------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs index 4ab6609..5b15a73 100644 --- a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs @@ -178,7 +178,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule void GetStoredMaterialsForPart(SceneObjectPart part) { - OSDMap OSMaterials = null; + OSD OSMaterials = null; OSDArray matsArr = null; if (part.DynAttrs == null) @@ -188,23 +188,20 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule lock (part.DynAttrs) { - if (part.DynAttrs.ContainsKey("OS:Materials")) - OSMaterials = part.DynAttrs["OS:Materials"]; - if (OSMaterials != null && OSMaterials.ContainsKey("Materials")) + if (part.DynAttrs.ContainsStore("OpenSim", "Materials")) { - - OSD osd = OSMaterials["Materials"]; - if (osd is OSDArray) - matsArr = osd as OSDArray; + OSDMap materialsStore = part.DynAttrs.GetStore("OpenSim", "Materials"); + materialsStore.TryGetValue("Materials", out OSMaterials); } - } - if (OSMaterials == null) - return; + if (OSMaterials != null && OSMaterials is OSDArray) + matsArr = OSMaterials as OSDArray; + else + return; + } m_log.Info("[MaterialsDemoModule]: OSMaterials: " + OSDParser.SerializeJsonString(OSMaterials)); - if (matsArr == null) { m_log.Info("[MaterialsDemoModule]: matsArr is null :( "); @@ -215,7 +212,6 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule { if (elemOsd != null && elemOsd is OSDMap) { - OSDMap matMap = elemOsd as OSDMap; if (matMap.ContainsKey("ID") && matMap.ContainsKey("Material")) { @@ -232,7 +228,6 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule } } - void StoreMaterialsForPart(SceneObjectPart part) { try @@ -277,7 +272,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule OSMaterials["Materials"] = matsArr; lock (part.DynAttrs) - part.DynAttrs["OS:Materials"] = OSMaterials; + part.DynAttrs.SetStore("OpenSim", "Materials", OSMaterials); } catch (Exception e) { @@ -285,7 +280,6 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule } } - public string RenderMaterialsPostCap(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) -- cgit v1.1 From 149487ea0f74a46a70c98b3a31259b667f4d29b2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 27 Jun 2013 23:42:35 +0100 Subject: refactor: Move code for gathering textures referenced by materials into MaterialsDemoModule from UuidGatherer This code is now triggered via EventManager.OnGatherUuids which modules can subscribe to. --- .../Materials/MaterialsDemoModule.cs | 72 +++++++++++++++++++++- 1 file changed, 70 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs index 5b15a73..e7b8928 100644 --- a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs @@ -121,9 +121,11 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule return; m_log.DebugFormat("[MaterialsDemoModule]: REGION {0} ADDED", scene.RegionInfo.RegionName); + m_scene = scene; - m_scene.EventManager.OnRegisterCaps += new EventManager.RegisterCapsEvent(OnRegisterCaps); - m_scene.EventManager.OnObjectAddedToScene += new Action(EventManager_OnObjectAddedToScene); + m_scene.EventManager.OnRegisterCaps += OnRegisterCaps; + m_scene.EventManager.OnObjectAddedToScene += EventManager_OnObjectAddedToScene; + m_scene.EventManager.OnGatherUuids += GatherMaterialsUuids; } void EventManager_OnObjectAddedToScene(SceneObjectGroup obj) @@ -157,6 +159,10 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule if (!m_enabled) return; + m_scene.EventManager.OnRegisterCaps -= OnRegisterCaps; + m_scene.EventManager.OnObjectAddedToScene -= EventManager_OnObjectAddedToScene; + m_scene.EventManager.OnGatherUuids -= GatherMaterialsUuids; + m_log.DebugFormat("[MaterialsDemoModule]: REGION {0} REMOVED", scene.RegionInfo.RegionName); } @@ -569,5 +575,67 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule output.Flush(); } + /// + /// Gather all of the texture asset UUIDs used to reference "Materials" such as normal and specular maps + /// + /// + /// + private void GatherMaterialsUuids(SceneObjectPart part, IDictionary assetUuids) + { + // scan thru the dynAttrs map of this part for any textures used as materials + OSD osdMaterials = null; + + lock (part.DynAttrs) + { + if (part.DynAttrs.ContainsStore("OpenSim", "Materials")) + { + OSDMap materialsStore = part.DynAttrs.GetStore("OpenSim", "Materials"); + materialsStore.TryGetValue("Materials", out osdMaterials); + } + + if (osdMaterials != null) + { + //m_log.Info("[UUID Gatherer]: found Materials: " + OSDParser.SerializeJsonString(osd)); + + if (osdMaterials is OSDArray) + { + OSDArray matsArr = osdMaterials as OSDArray; + foreach (OSDMap matMap in matsArr) + { + try + { + if (matMap.ContainsKey("Material")) + { + OSDMap mat = matMap["Material"] as OSDMap; + if (mat.ContainsKey("NormMap")) + { + UUID normalMapId = mat["NormMap"].AsUUID(); + if (normalMapId != UUID.Zero) + { + assetUuids[normalMapId] = AssetType.Texture; + //m_log.Info("[UUID Gatherer]: found normal map ID: " + normalMapId.ToString()); + } + } + if (mat.ContainsKey("SpecMap")) + { + UUID specularMapId = mat["SpecMap"].AsUUID(); + if (specularMapId != UUID.Zero) + { + assetUuids[specularMapId] = AssetType.Texture; + //m_log.Info("[UUID Gatherer]: found specular map ID: " + specularMapId.ToString()); + } + } + } + + } + catch (Exception e) + { + m_log.Warn("[MaterialsDemoModule]: exception getting materials: " + e.Message); + } + } + } + } + } + } } } \ No newline at end of file -- cgit v1.1 From c1b8f83dd4ad3e3c811a16b4b096edab7abccf8e Mon Sep 17 00:00:00 2001 From: dahlia Date: Thu, 27 Jun 2013 17:53:15 -0700 Subject: test for null return from DynAttrs.GetStore() --- OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs index e7b8928..be2d8da 100644 --- a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs @@ -590,6 +590,9 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule if (part.DynAttrs.ContainsStore("OpenSim", "Materials")) { OSDMap materialsStore = part.DynAttrs.GetStore("OpenSim", "Materials"); + if (materialsStore == null) + return; + materialsStore.TryGetValue("Materials", out osdMaterials); } -- cgit v1.1 From d47fc48b3230b6d5cb555014d6242960cd397810 Mon Sep 17 00:00:00 2001 From: dahlia Date: Thu, 27 Jun 2013 18:01:17 -0700 Subject: and yet another check for null returned from DynAttrs.GetStore() --- OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs index be2d8da..34dc552 100644 --- a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs @@ -197,6 +197,10 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule if (part.DynAttrs.ContainsStore("OpenSim", "Materials")) { OSDMap materialsStore = part.DynAttrs.GetStore("OpenSim", "Materials"); + + if (materialsStore == null) + return; + materialsStore.TryGetValue("Materials", out OSMaterials); } -- cgit v1.1 From f6ce87c96d037787963d203346c5cb1a1dd52747 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 28 Jun 2013 18:50:33 +0100 Subject: Reinsert code for gathering uuids reference by materials back directly into UuidGatherer for now. This cannot be triggered as an event from Scene.EventManager since some invocations of UuidGatherer (e.g. IAR saving) use scene objects which are not in scenes. There needs to be some way for modules to register for events which are not connected with a particular scene. --- .../Materials/MaterialsDemoModule.cs | 136 +++++++++++---------- 1 file changed, 69 insertions(+), 67 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs index 34dc552..1cfbab0 100644 --- a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs @@ -125,7 +125,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule m_scene = scene; m_scene.EventManager.OnRegisterCaps += OnRegisterCaps; m_scene.EventManager.OnObjectAddedToScene += EventManager_OnObjectAddedToScene; - m_scene.EventManager.OnGatherUuids += GatherMaterialsUuids; +// m_scene.EventManager.OnGatherUuids += GatherMaterialsUuids; } void EventManager_OnObjectAddedToScene(SceneObjectGroup obj) @@ -161,7 +161,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule m_scene.EventManager.OnRegisterCaps -= OnRegisterCaps; m_scene.EventManager.OnObjectAddedToScene -= EventManager_OnObjectAddedToScene; - m_scene.EventManager.OnGatherUuids -= GatherMaterialsUuids; +// m_scene.EventManager.OnGatherUuids -= GatherMaterialsUuids; m_log.DebugFormat("[MaterialsDemoModule]: REGION {0} REMOVED", scene.RegionInfo.RegionName); } @@ -579,70 +579,72 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule output.Flush(); } - /// - /// Gather all of the texture asset UUIDs used to reference "Materials" such as normal and specular maps - /// - /// - /// - private void GatherMaterialsUuids(SceneObjectPart part, IDictionary assetUuids) - { - // scan thru the dynAttrs map of this part for any textures used as materials - OSD osdMaterials = null; - - lock (part.DynAttrs) - { - if (part.DynAttrs.ContainsStore("OpenSim", "Materials")) - { - OSDMap materialsStore = part.DynAttrs.GetStore("OpenSim", "Materials"); - if (materialsStore == null) - return; - - materialsStore.TryGetValue("Materials", out osdMaterials); - } - - if (osdMaterials != null) - { - //m_log.Info("[UUID Gatherer]: found Materials: " + OSDParser.SerializeJsonString(osd)); - - if (osdMaterials is OSDArray) - { - OSDArray matsArr = osdMaterials as OSDArray; - foreach (OSDMap matMap in matsArr) - { - try - { - if (matMap.ContainsKey("Material")) - { - OSDMap mat = matMap["Material"] as OSDMap; - if (mat.ContainsKey("NormMap")) - { - UUID normalMapId = mat["NormMap"].AsUUID(); - if (normalMapId != UUID.Zero) - { - assetUuids[normalMapId] = AssetType.Texture; - //m_log.Info("[UUID Gatherer]: found normal map ID: " + normalMapId.ToString()); - } - } - if (mat.ContainsKey("SpecMap")) - { - UUID specularMapId = mat["SpecMap"].AsUUID(); - if (specularMapId != UUID.Zero) - { - assetUuids[specularMapId] = AssetType.Texture; - //m_log.Info("[UUID Gatherer]: found specular map ID: " + specularMapId.ToString()); - } - } - } - - } - catch (Exception e) - { - m_log.Warn("[MaterialsDemoModule]: exception getting materials: " + e.Message); - } - } - } - } - } - } + // FIXME: This code is currently still in UuidGatherer since we cannot use Scene.EventManager as some + // calls to the gatherer are done for objects with no scene. +// /// +// /// Gather all of the texture asset UUIDs used to reference "Materials" such as normal and specular maps +// /// +// /// +// /// +// private void GatherMaterialsUuids(SceneObjectPart part, IDictionary assetUuids) +// { +// // scan thru the dynAttrs map of this part for any textures used as materials +// OSD osdMaterials = null; +// +// lock (part.DynAttrs) +// { +// if (part.DynAttrs.ContainsStore("OpenSim", "Materials")) +// { +// OSDMap materialsStore = part.DynAttrs.GetStore("OpenSim", "Materials"); +// if (materialsStore == null) +// return; +// +// materialsStore.TryGetValue("Materials", out osdMaterials); +// } +// +// if (osdMaterials != null) +// { +// //m_log.Info("[UUID Gatherer]: found Materials: " + OSDParser.SerializeJsonString(osd)); +// +// if (osdMaterials is OSDArray) +// { +// OSDArray matsArr = osdMaterials as OSDArray; +// foreach (OSDMap matMap in matsArr) +// { +// try +// { +// if (matMap.ContainsKey("Material")) +// { +// OSDMap mat = matMap["Material"] as OSDMap; +// if (mat.ContainsKey("NormMap")) +// { +// UUID normalMapId = mat["NormMap"].AsUUID(); +// if (normalMapId != UUID.Zero) +// { +// assetUuids[normalMapId] = AssetType.Texture; +// //m_log.Info("[UUID Gatherer]: found normal map ID: " + normalMapId.ToString()); +// } +// } +// if (mat.ContainsKey("SpecMap")) +// { +// UUID specularMapId = mat["SpecMap"].AsUUID(); +// if (specularMapId != UUID.Zero) +// { +// assetUuids[specularMapId] = AssetType.Texture; +// //m_log.Info("[UUID Gatherer]: found specular map ID: " + specularMapId.ToString()); +// } +// } +// } +// +// } +// catch (Exception e) +// { +// m_log.Warn("[MaterialsDemoModule]: exception getting materials: " + e.Message); +// } +// } +// } +// } +// } +// } } } \ No newline at end of file -- cgit v1.1 From cbb51227296df9b158430d4a8adfcc96bdd55ed5 Mon Sep 17 00:00:00 2001 From: dahlia Date: Fri, 28 Jun 2013 14:00:28 -0700 Subject: add some locking to materials storage dictionary --- .../Materials/MaterialsDemoModule.cs | 72 +++++++++++++--------- 1 file changed, 42 insertions(+), 30 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs index 34dc552..19d8141 100644 --- a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs @@ -173,11 +173,14 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule OSDMap GetMaterial(UUID id) { OSDMap map = null; - if (m_knownMaterials.ContainsKey(id)) + lock (m_knownMaterials) { - map = new OSDMap(); - map["ID"] = OSD.FromBinary(id.GetBytes()); - map["Material"] = m_knownMaterials[id]; + if (m_knownMaterials.ContainsKey(id)) + { + map = new OSDMap(); + map["ID"] = OSD.FromBinary(id.GetBytes()); + map["Material"] = m_knownMaterials[id]; + } } return map; } @@ -227,7 +230,8 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule { try { - m_knownMaterials[matMap["ID"].AsUUID()] = (OSDMap)matMap["Material"]; + lock (m_knownMaterials) + m_knownMaterials[matMap["ID"].AsUUID()] = (OSDMap)matMap["Material"]; } catch (Exception e) { @@ -251,8 +255,11 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule if (te.DefaultTexture != null) { - if (m_knownMaterials.ContainsKey(te.DefaultTexture.MaterialID)) - mats[te.DefaultTexture.MaterialID] = m_knownMaterials[te.DefaultTexture.MaterialID]; + lock (m_knownMaterials) + { + if (m_knownMaterials.ContainsKey(te.DefaultTexture.MaterialID)) + mats[te.DefaultTexture.MaterialID] = m_knownMaterials[te.DefaultTexture.MaterialID]; + } } if (te.FaceTextures != null) @@ -261,8 +268,11 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule { if (face != null) { - if (m_knownMaterials.ContainsKey(face.MaterialID)) - mats[face.MaterialID] = m_knownMaterials[face.MaterialID]; + lock (m_knownMaterials) + { + if (m_knownMaterials.ContainsKey(face.MaterialID)) + mats[face.MaterialID] = m_knownMaterials[face.MaterialID]; + } } } } @@ -323,18 +333,21 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule try { UUID id = new UUID(elem.AsBinary(), 0); - - if (m_knownMaterials.ContainsKey(id)) + + lock (m_knownMaterials) { - m_log.Info("[MaterialsDemoModule]: request for known material ID: " + id.ToString()); - OSDMap matMap = new OSDMap(); - matMap["ID"] = OSD.FromBinary(id.GetBytes()); + if (m_knownMaterials.ContainsKey(id)) + { + m_log.Info("[MaterialsDemoModule]: request for known material ID: " + id.ToString()); + OSDMap matMap = new OSDMap(); + matMap["ID"] = OSD.FromBinary(id.GetBytes()); - matMap["Material"] = m_knownMaterials[id]; - respArr.Add(matMap); + matMap["Material"] = m_knownMaterials[id]; + respArr.Add(matMap); + } + else + m_log.Info("[MaterialsDemoModule]: request for UNKNOWN material ID: " + id.ToString()); } - else - m_log.Info("[MaterialsDemoModule]: request for UNKNOWN material ID: " + id.ToString()); } catch (Exception e) { @@ -372,7 +385,8 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule m_log.Debug("[MaterialsDemoModule]: mat: " + OSDParser.SerializeJsonString(mat)); UUID id = HashOsd(mat); - m_knownMaterials[id] = mat; + lock (m_knownMaterials) + m_knownMaterials[id] = mat; var sop = m_scene.GetSceneObjectPart(matLocalID); @@ -480,24 +494,22 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule m_log.Debug("[MaterialsDemoModule]: GET cap handler"); OSDMap resp = new OSDMap(); - - int matsCount = 0; - OSDArray allOsd = new OSDArray(); - foreach (KeyValuePair kvp in m_knownMaterials) + lock (m_knownMaterials) { - OSDMap matMap = new OSDMap(); - - matMap["ID"] = OSD.FromBinary(kvp.Key.GetBytes()); + foreach (KeyValuePair kvp in m_knownMaterials) + { + OSDMap matMap = new OSDMap(); - matMap["Material"] = kvp.Value; - allOsd.Add(matMap); - matsCount++; + matMap["ID"] = OSD.FromBinary(kvp.Key.GetBytes()); + matMap["Material"] = kvp.Value; + allOsd.Add(matMap); + matsCount++; + } } - resp["Zipped"] = ZCompressOSD(allOsd, false); m_log.Debug("[MaterialsDemoModule]: matsCount: " + matsCount.ToString()); -- cgit v1.1 From e19defde36ddbd5ff90d8304c6fe3b57110f8078 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 8 Jul 2013 22:03:07 +0100 Subject: Add "show caps stats by user" and "show caps stats by cap" console commands to print various counts of capability invocation by user and by cap This currently prints caps requests received and handled, so that overload of received compared to handled or deadlock can be detected. This involves making BaseStreamHandler and BaseOutputStream record the ints, which means inheritors should subclass ProcessRequest() instead of Handle() However, existing inheriting classes overriding Handle() will still work, albeit without stats recording. "show caps" becomes "show caps list" to disambiguate between show caps commands --- OpenSim/Region/OptionalModules/ViewerSupport/DynamicMenuModule.cs | 2 +- .../Region/OptionalModules/World/WorldView/WorldViewRequestHandler.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/ViewerSupport/DynamicMenuModule.cs b/OpenSim/Region/OptionalModules/ViewerSupport/DynamicMenuModule.cs index 1ea1c20..6e0a80a 100644 --- a/OpenSim/Region/OptionalModules/ViewerSupport/DynamicMenuModule.cs +++ b/OpenSim/Region/OptionalModules/ViewerSupport/DynamicMenuModule.cs @@ -281,7 +281,7 @@ namespace OpenSim.Region.OptionalModules.ViewerSupport m_module = module; } - public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) + protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { StreamReader reader = new StreamReader(request); string requestBody = reader.ReadToEnd(); diff --git a/OpenSim/Region/OptionalModules/World/WorldView/WorldViewRequestHandler.cs b/OpenSim/Region/OptionalModules/World/WorldView/WorldViewRequestHandler.cs index 550b5d4..8720cc7 100644 --- a/OpenSim/Region/OptionalModules/World/WorldView/WorldViewRequestHandler.cs +++ b/OpenSim/Region/OptionalModules/World/WorldView/WorldViewRequestHandler.cs @@ -55,7 +55,7 @@ namespace OpenSim.Region.OptionalModules.World.WorldView m_WorldViewModule = fmodule; } - public override byte[] Handle(string path, Stream requestData, + protected override byte[] ProcessRequest(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { httpResponse.ContentType = "image/jpeg"; -- cgit v1.1 From 013710168b3878fc0a93a92a1c026efb49da9935 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 8 Jul 2013 22:39:07 +0100 Subject: For stat purposes, add names to capability request handlers where these were not set --- .../Region/OptionalModules/Materials/MaterialsDemoModule.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs index 3a39971..00504d0 100644 --- a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs @@ -139,18 +139,21 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule { string capsBase = "/CAPS/" + caps.CapsObjectPath; - IRequestHandler renderMaterialsPostHandler = new RestStreamHandler("POST", capsBase + "/", RenderMaterialsPostCap); - caps.RegisterHandler("RenderMaterials", renderMaterialsPostHandler); + IRequestHandler renderMaterialsPostHandler + = new RestStreamHandler("POST", capsBase + "/", RenderMaterialsPostCap, "RenderMaterialsPost", null); + caps.RegisterHandler("RenderMaterialsPost", renderMaterialsPostHandler); // OpenSimulator CAPs infrastructure seems to be somewhat hostile towards any CAP that requires both GET // and POST handlers, (at least at the time this was originally written), so we first set up a POST // handler normally and then add a GET handler via MainServer - IRequestHandler renderMaterialsGetHandler = new RestStreamHandler("GET", capsBase + "/", RenderMaterialsGetCap); + IRequestHandler renderMaterialsGetHandler + = new RestStreamHandler("GET", capsBase + "/", RenderMaterialsGetCap, "RenderMaterialsGet", null); MainServer.Instance.AddStreamHandler(renderMaterialsGetHandler); // materials viewer seems to use either POST or PUT, so assign POST handler for PUT as well - IRequestHandler renderMaterialsPutHandler = new RestStreamHandler("PUT", capsBase + "/", RenderMaterialsPostCap); + IRequestHandler renderMaterialsPutHandler + = new RestStreamHandler("PUT", capsBase + "/", RenderMaterialsPostCap, "RenderMaterialsPut", null); MainServer.Instance.AddStreamHandler(renderMaterialsPutHandler); } -- cgit v1.1 From 33eea62606908ca39ac90eb9c99b0eee3c5f39de Mon Sep 17 00:00:00 2001 From: dahlia Date: Mon, 8 Jul 2013 17:12:39 -0700 Subject: remove an invalid null UUID check which caused a warning --- OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs index 00504d0..b997d4d 100644 --- a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs @@ -416,14 +416,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule if (te.DefaultTexture == null) m_log.Debug("[MaterialsDemoModule]: te.DefaultTexture is null"); else - { - if (te.DefaultTexture.MaterialID == null) - m_log.Debug("[MaterialsDemoModule]: te.DefaultTexture.MaterialID is null"); - else - { - te.DefaultTexture.MaterialID = id; - } - } + te.DefaultTexture.MaterialID = id; } else { -- cgit v1.1 From 065f8f56a248724c34d115f77a4d5b1a422f26f4 Mon Sep 17 00:00:00 2001 From: dahlia Date: Mon, 8 Jul 2013 19:18:01 -0700 Subject: remove some cruft and trigger a rebuild --- OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs index b997d4d..0a0d65c 100644 --- a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs @@ -397,7 +397,6 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule m_log.Debug("[MaterialsDemoModule]: null SOP for localId: " + matLocalID.ToString()); else { - //var te = sop.Shape.Textures; var te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length); if (te == null) -- cgit v1.1 From 1b265b213b65076ee346d85f62d2d61a72ea3ca6 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 10 Jul 2013 16:09:45 -0700 Subject: Added show client-stats [first last] command to expose what viewers are requesting. --- .../Agent/UDP/Linden/LindenUDPInfoModule.cs | 109 ++++++++++++++++++++- 1 file changed, 107 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs index 992f38e..b1aec81 100644 --- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs @@ -27,6 +27,7 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Reflection; using System.Text; using log4net; @@ -51,7 +52,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LindenUDPInfoModule")] public class LindenUDPInfoModule : ISharedRegionModule { -// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected Dictionary m_scenes = new Dictionary(); @@ -130,6 +131,15 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden "Go on/off emergency monitoring mode", "Go on/off emergency monitoring mode", HandleEmergencyMonitoring); + + scene.AddCommand( + "Comms", this, "show client-stats", + "show client-stats [first_name last_name]", + "Show client request stats", + "Without the 'first_name last_name' option, all clients are shown." + + " With the 'first_name last_name' option only a specific client is shown.", + (mod, cmd) => MainConsole.Instance.Output(HandleClientStatsReport(cmd))); + } public void RemoveRegion(Scene scene) @@ -587,6 +597,101 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden (throttleRates.Asset * 8) / 1000); return report.ToString(); - } + } + + /// + /// Show client stats data + /// + /// + /// + protected string HandleClientStatsReport(string[] showParams) + { + // NOTE: This writes to m_log on purpose. We want to store this information + // in case we need to analyze it later. + // + if (showParams.Length <= 3) + { + m_log.InfoFormat("[INFO]: {0,-12} {1,20} {2,6} {3,11} {4, 10}", "Region", "Name", "Root", "Time", "Reqs/min"); + foreach (Scene scene in m_scenes.Values) + { + scene.ForEachClient( + delegate(IClientAPI client) + { + if (client is LLClientView) + { + LLClientView llClient = client as LLClientView; + ClientInfo cinfo = llClient.UDPClient.GetClientInfo(); + int avg_reqs = cinfo.AsyncRequests.Count + cinfo.GenericRequests.Count + cinfo.SyncRequests.Count; + avg_reqs = avg_reqs / ((DateTime.Now - cinfo.StartedTime).Minutes + 1); + + m_log.InfoFormat("[INFO]: {0,-12} {1,20} {2,4} {3,9}min {4,10}", + scene.RegionInfo.RegionName, llClient.Name, + (llClient.SceneAgent.IsChildAgent ? "N" : "Y"), (DateTime.Now - cinfo.StartedTime).Minutes, avg_reqs); + } + }); + } + return string.Empty; + } + + string fname = "", lname = ""; + + if (showParams.Length > 2) + fname = showParams[2]; + if (showParams.Length > 3) + lname = showParams[3]; + + foreach (Scene scene in m_scenes.Values) + { + scene.ForEachClient( + delegate(IClientAPI client) + { + if (client is LLClientView) + { + LLClientView llClient = client as LLClientView; + + if (llClient.Name == fname + " " + lname) + { + + ClientInfo cinfo = llClient.GetClientInfo(); + AgentCircuitData aCircuit = scene.AuthenticateHandler.GetAgentCircuitData(llClient.CircuitCode); + if (aCircuit == null) // create a dummy one + aCircuit = new AgentCircuitData(); + + if (!llClient.SceneAgent.IsChildAgent) + m_log.InfoFormat("[INFO]: {0} # {1} # {2}", llClient.Name, aCircuit.Viewer, aCircuit.Id0); + + int avg_reqs = cinfo.AsyncRequests.Count + cinfo.GenericRequests.Count + cinfo.SyncRequests.Count; + avg_reqs = avg_reqs / ((DateTime.Now - cinfo.StartedTime).Minutes + 1); + + m_log.InfoFormat("[INFO]:"); + m_log.InfoFormat("[INFO]: {0} # {1} # Time: {2}min # Avg Reqs/min: {3}", scene.RegionInfo.RegionName, + (llClient.SceneAgent.IsChildAgent ? "Child" : "Root"), (DateTime.Now - cinfo.StartedTime).Minutes, avg_reqs); + + Dictionary sortedDict = (from entry in cinfo.AsyncRequests orderby entry.Value descending select entry) + .ToDictionary(pair => pair.Key, pair => pair.Value); + + m_log.InfoFormat("[INFO]: {0,25}", "TOP ASYNC"); + foreach (KeyValuePair kvp in sortedDict.Take(12)) + m_log.InfoFormat("[INFO]: {0,25} {1,-6}", kvp.Key, kvp.Value); + + m_log.InfoFormat("[INFO]:"); + sortedDict = (from entry in cinfo.SyncRequests orderby entry.Value descending select entry) + .ToDictionary(pair => pair.Key, pair => pair.Value); + m_log.InfoFormat("[INFO]: {0,25}", "TOP SYNC"); + foreach (KeyValuePair kvp in sortedDict.Take(12)) + m_log.InfoFormat("[INFO]: {0,25} {1,-6}", kvp.Key, kvp.Value); + + m_log.InfoFormat("[INFO]:"); + sortedDict = (from entry in cinfo.GenericRequests orderby entry.Value descending select entry) + .ToDictionary(pair => pair.Key, pair => pair.Value); + m_log.InfoFormat("[INFO]: {0,25}", "TOP GENERIC"); + foreach (KeyValuePair kvp in sortedDict.Take(12)) + m_log.InfoFormat("[INFO]: {0,25} {1,-6}", kvp.Key, kvp.Value); + } + } + }); + } + return string.Empty; + } } } \ No newline at end of file -- cgit v1.1 From bdaeb02863cb56e0d543b1e97eb3356571911f90 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 10 Jul 2013 17:14:20 -0700 Subject: show client stats: Fixed the requests/min. Also changed the spelling of the command, not without the dash. --- .../Agent/UDP/Linden/LindenUDPInfoModule.cs | 43 +++++++++++----------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs index b1aec81..79509ab 100644 --- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs @@ -133,8 +133,8 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden HandleEmergencyMonitoring); scene.AddCommand( - "Comms", this, "show client-stats", - "show client-stats [first_name last_name]", + "Comms", this, "show client stats", + "show client stats [first_name last_name]", "Show client request stats", "Without the 'first_name last_name' option, all clients are shown." + " With the 'first_name last_name' option only a specific client is shown.", @@ -609,7 +609,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden // NOTE: This writes to m_log on purpose. We want to store this information // in case we need to analyze it later. // - if (showParams.Length <= 3) + if (showParams.Length <= 4) { m_log.InfoFormat("[INFO]: {0,-12} {1,20} {2,6} {3,11} {4, 10}", "Region", "Name", "Root", "Time", "Reqs/min"); foreach (Scene scene in m_scenes.Values) @@ -621,7 +621,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden { LLClientView llClient = client as LLClientView; ClientInfo cinfo = llClient.UDPClient.GetClientInfo(); - int avg_reqs = cinfo.AsyncRequests.Count + cinfo.GenericRequests.Count + cinfo.SyncRequests.Count; + int avg_reqs = cinfo.AsyncRequests.Values.Sum() + cinfo.GenericRequests.Values.Sum() + cinfo.SyncRequests.Values.Sum(); avg_reqs = avg_reqs / ((DateTime.Now - cinfo.StartedTime).Minutes + 1); m_log.InfoFormat("[INFO]: {0,-12} {1,20} {2,4} {3,9}min {4,10}", @@ -635,10 +635,10 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden string fname = "", lname = ""; - if (showParams.Length > 2) - fname = showParams[2]; if (showParams.Length > 3) - lname = showParams[3]; + fname = showParams[3]; + if (showParams.Length > 4) + lname = showParams[4]; foreach (Scene scene in m_scenes.Values) { @@ -660,7 +660,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden if (!llClient.SceneAgent.IsChildAgent) m_log.InfoFormat("[INFO]: {0} # {1} # {2}", llClient.Name, aCircuit.Viewer, aCircuit.Id0); - int avg_reqs = cinfo.AsyncRequests.Count + cinfo.GenericRequests.Count + cinfo.SyncRequests.Count; + int avg_reqs = cinfo.AsyncRequests.Values.Sum() + cinfo.GenericRequests.Values.Sum() + cinfo.SyncRequests.Values.Sum(); avg_reqs = avg_reqs / ((DateTime.Now - cinfo.StartedTime).Minutes + 1); m_log.InfoFormat("[INFO]:"); @@ -669,29 +669,30 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden Dictionary sortedDict = (from entry in cinfo.AsyncRequests orderby entry.Value descending select entry) .ToDictionary(pair => pair.Key, pair => pair.Value); + PrintRequests("TOP ASYNC", sortedDict, cinfo.AsyncRequests.Values.Sum()); - m_log.InfoFormat("[INFO]: {0,25}", "TOP ASYNC"); - foreach (KeyValuePair kvp in sortedDict.Take(12)) - m_log.InfoFormat("[INFO]: {0,25} {1,-6}", kvp.Key, kvp.Value); - - m_log.InfoFormat("[INFO]:"); sortedDict = (from entry in cinfo.SyncRequests orderby entry.Value descending select entry) .ToDictionary(pair => pair.Key, pair => pair.Value); - m_log.InfoFormat("[INFO]: {0,25}", "TOP SYNC"); - foreach (KeyValuePair kvp in sortedDict.Take(12)) - m_log.InfoFormat("[INFO]: {0,25} {1,-6}", kvp.Key, kvp.Value); + PrintRequests("TOP SYNC", sortedDict, cinfo.SyncRequests.Values.Sum()); - m_log.InfoFormat("[INFO]:"); sortedDict = (from entry in cinfo.GenericRequests orderby entry.Value descending select entry) .ToDictionary(pair => pair.Key, pair => pair.Value); - m_log.InfoFormat("[INFO]: {0,25}", "TOP GENERIC"); - foreach (KeyValuePair kvp in sortedDict.Take(12)) - m_log.InfoFormat("[INFO]: {0,25} {1,-6}", kvp.Key, kvp.Value); + PrintRequests("TOP GENERIC", sortedDict, cinfo.GenericRequests.Values.Sum()); } } }); } return string.Empty; - } + } + + private void PrintRequests(string type, Dictionary sortedDict, int sum) + { + m_log.InfoFormat("[INFO]:"); + m_log.InfoFormat("[INFO]: {0,25}", type); + foreach (KeyValuePair kvp in sortedDict.Take(12)) + m_log.InfoFormat("[INFO]: {0,25} {1,-6}", kvp.Key, kvp.Value); + m_log.InfoFormat("[INFO]: {0,25}", "..."); + m_log.InfoFormat("[INFO]: {0,25} {1,-6}", "Total", sum); + } } } \ No newline at end of file -- cgit v1.1 From 0120e858b7985b0f9571461d036a9099a25af9ad Mon Sep 17 00:00:00 2001 From: dahlia Date: Wed, 10 Jul 2013 22:30:41 -0700 Subject: remove names from Capability handlers (added by justincc in commit 013710168b3878fc0a93a92a1c026efb49da9935) as they seem to disable the use of multiple access methods for a single Capability in MaterialsDemoModule --- .../Region/OptionalModules/Materials/MaterialsDemoModule.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs index 0a0d65c..088eb0f 100644 --- a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs @@ -139,21 +139,18 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule { string capsBase = "/CAPS/" + caps.CapsObjectPath; - IRequestHandler renderMaterialsPostHandler - = new RestStreamHandler("POST", capsBase + "/", RenderMaterialsPostCap, "RenderMaterialsPost", null); - caps.RegisterHandler("RenderMaterialsPost", renderMaterialsPostHandler); + IRequestHandler renderMaterialsPostHandler = new RestStreamHandler("POST", capsBase + "/", RenderMaterialsPostCap); + caps.RegisterHandler("RenderMaterials", renderMaterialsPostHandler); // OpenSimulator CAPs infrastructure seems to be somewhat hostile towards any CAP that requires both GET // and POST handlers, (at least at the time this was originally written), so we first set up a POST // handler normally and then add a GET handler via MainServer - IRequestHandler renderMaterialsGetHandler - = new RestStreamHandler("GET", capsBase + "/", RenderMaterialsGetCap, "RenderMaterialsGet", null); + IRequestHandler renderMaterialsGetHandler = new RestStreamHandler("GET", capsBase + "/", RenderMaterialsGetCap); MainServer.Instance.AddStreamHandler(renderMaterialsGetHandler); // materials viewer seems to use either POST or PUT, so assign POST handler for PUT as well - IRequestHandler renderMaterialsPutHandler - = new RestStreamHandler("PUT", capsBase + "/", RenderMaterialsPostCap, "RenderMaterialsPut", null); + IRequestHandler renderMaterialsPutHandler = new RestStreamHandler("PUT", capsBase + "/", RenderMaterialsPostCap); MainServer.Instance.AddStreamHandler(renderMaterialsPutHandler); } -- cgit v1.1 From ba8f9c9d0a7d07b7587663baef9c52293a3ac404 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 11 Jul 2013 23:51:10 +0100 Subject: Try naming the materials handlers again, this time registering the POST as RenderMaterials This was probably the mistake. The other handlers are named RenderMaterials as well but this actully has no affect apart from on stats, due to a (counterintuitive) disconnect between the registration name and the name of the request handler. Will be tested very soon and reverted if this still does not work. --- OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs index 088eb0f..d8f5563 100644 --- a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs @@ -139,18 +139,21 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule { string capsBase = "/CAPS/" + caps.CapsObjectPath; - IRequestHandler renderMaterialsPostHandler = new RestStreamHandler("POST", capsBase + "/", RenderMaterialsPostCap); + IRequestHandler renderMaterialsPostHandler + = new RestStreamHandler("POST", capsBase + "/", RenderMaterialsPostCap, "RenderMaterials", null); caps.RegisterHandler("RenderMaterials", renderMaterialsPostHandler); // OpenSimulator CAPs infrastructure seems to be somewhat hostile towards any CAP that requires both GET // and POST handlers, (at least at the time this was originally written), so we first set up a POST // handler normally and then add a GET handler via MainServer - IRequestHandler renderMaterialsGetHandler = new RestStreamHandler("GET", capsBase + "/", RenderMaterialsGetCap); + IRequestHandler renderMaterialsGetHandler + = new RestStreamHandler("GET", capsBase + "/", RenderMaterialsGetCap, "RenderMaterials", null); MainServer.Instance.AddStreamHandler(renderMaterialsGetHandler); // materials viewer seems to use either POST or PUT, so assign POST handler for PUT as well - IRequestHandler renderMaterialsPutHandler = new RestStreamHandler("PUT", capsBase + "/", RenderMaterialsPostCap); + IRequestHandler renderMaterialsPutHandler + = new RestStreamHandler("PUT", capsBase + "/", RenderMaterialsPostCap, "RenderMaterials", null); MainServer.Instance.AddStreamHandler(renderMaterialsPutHandler); } -- cgit v1.1 From 9f129938c9c75bb4513b0b93248985100fe0e921 Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Tue, 16 Jul 2013 17:43:36 -0700 Subject: Attachments module only registers when enabled. This enables alternative attachments module implementations. All calls to Scene.AttachmentsModule are checking for null. Ideally, if we support disabling attachments then we need a null attachments module to register with the scene. --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 7d46d92..69189b3 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -116,7 +116,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC return false; // Delete existing npc attachments - scene.AttachmentsModule.DeleteAttachmentsFromScene(npc, false); + if(scene.AttachmentsModule != null) + scene.AttachmentsModule.DeleteAttachmentsFromScene(npc, false); // XXX: We can't just use IAvatarFactoryModule.SetAppearance() yet // since it doesn't transfer attachments @@ -125,7 +126,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC npc.Appearance = npcAppearance; // Rez needed npc attachments - scene.AttachmentsModule.RezAttachments(npc); + if (scene.AttachmentsModule != null) + scene.AttachmentsModule.RezAttachments(npc); IAvatarFactoryModule module = scene.RequestModuleInterface(); -- cgit v1.1 From e5c677779b8501c245e5399240ffe3ca2519ec72 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 19 Jul 2013 00:16:09 +0100 Subject: Add measure of number of inbound AgentUpdates that were seen as significant to "show client stats" (i.e. sent on for further processing instead of being discarded) Added here since it was the most convenient place Number is in the last column, "Sig. AgentUpdates" along with percentage of all AgentUpdates Percentage largely falls over time, most cpu for processing AgentUpdates may be in UDP processing as turning this off even earlier (with "debug lludp toggle agentupdate" results in a big cpu fall Also tidies up display. --- .../OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs index 79509ab..c208b38 100644 --- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs @@ -611,7 +611,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden // if (showParams.Length <= 4) { - m_log.InfoFormat("[INFO]: {0,-12} {1,20} {2,6} {3,11} {4, 10}", "Region", "Name", "Root", "Time", "Reqs/min"); + m_log.InfoFormat("[INFO]: {0,-12} {1,-20} {2,-6} {3,-11} {4,-11} {5,-16}", "Region", "Name", "Root", "Time", "Reqs/min", "Sig. AgentUpdates"); foreach (Scene scene in m_scenes.Values) { scene.ForEachClient( @@ -624,9 +624,15 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden int avg_reqs = cinfo.AsyncRequests.Values.Sum() + cinfo.GenericRequests.Values.Sum() + cinfo.SyncRequests.Values.Sum(); avg_reqs = avg_reqs / ((DateTime.Now - cinfo.StartedTime).Minutes + 1); - m_log.InfoFormat("[INFO]: {0,-12} {1,20} {2,4} {3,9}min {4,10}", + m_log.InfoFormat("[INFO]: {0,-12} {1,-20} {2,-6} {3,-11} {4,-11}/min {5,-16}", scene.RegionInfo.RegionName, llClient.Name, - (llClient.SceneAgent.IsChildAgent ? "N" : "Y"), (DateTime.Now - cinfo.StartedTime).Minutes, avg_reqs); + llClient.SceneAgent.IsChildAgent ? "N" : "Y", + (DateTime.Now - cinfo.StartedTime).Minutes, + avg_reqs, + string.Format( + "{0}, {1}%", + llClient.TotalSignificantAgentUpdates, + (float)llClient.TotalSignificantAgentUpdates / cinfo.SyncRequests["AgentUpdate"] * 100)); } }); } -- cgit v1.1 From 61eda1f441092eb12936472de2dc73898e40aa16 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 19 Jul 2013 00:51:13 +0100 Subject: Make the check as to whether any particular inbound AgentUpdate packet is significant much earlier in UDP processing (i.e. before we pointlessly place such packets on internal queues, etc.) Appears to have some impact on cpu but needs testing. --- .../Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs index c208b38..3e6067d 100644 --- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs @@ -611,7 +611,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden // if (showParams.Length <= 4) { - m_log.InfoFormat("[INFO]: {0,-12} {1,-20} {2,-6} {3,-11} {4,-11} {5,-16}", "Region", "Name", "Root", "Time", "Reqs/min", "Sig. AgentUpdates"); + m_log.InfoFormat("[INFO]: {0,-12} {1,-20} {2,-6} {3,-11} {4,-11} {5,-16}", "Region", "Name", "Root", "Time", "Reqs/min", "Sig. AgentUpdates"); foreach (Scene scene in m_scenes.Values) { scene.ForEachClient( @@ -624,7 +624,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden int avg_reqs = cinfo.AsyncRequests.Values.Sum() + cinfo.GenericRequests.Values.Sum() + cinfo.SyncRequests.Values.Sum(); avg_reqs = avg_reqs / ((DateTime.Now - cinfo.StartedTime).Minutes + 1); - m_log.InfoFormat("[INFO]: {0,-12} {1,-20} {2,-6} {3,-11} {4,-11}/min {5,-16}", + m_log.InfoFormat("[INFO]: {0,-12} {1,-20} {2,-6} {3,-11} {4,-11} {5,-16}", scene.RegionInfo.RegionName, llClient.Name, llClient.SceneAgent.IsChildAgent ? "N" : "Y", (DateTime.Now - cinfo.StartedTime).Minutes, -- cgit v1.1 From 174105ad028c5ed318850238d97aa7c3b1d7f207 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 19 Jul 2013 22:11:32 -0700 Subject: Fixed the stats in show client stats. Also left some comments with observations about AgentUpdates. --- .../OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs index 3e6067d..15dea17 100644 --- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs @@ -611,7 +611,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden // if (showParams.Length <= 4) { - m_log.InfoFormat("[INFO]: {0,-12} {1,-20} {2,-6} {3,-11} {4,-11} {5,-16}", "Region", "Name", "Root", "Time", "Reqs/min", "Sig. AgentUpdates"); + m_log.InfoFormat("[INFO]: {0,-12} {1,-20} {2,-6} {3,-11} {4,-11} {5,-16}", "Region", "Name", "Root", "Time", "Reqs/min", "AgentUpdates"); foreach (Scene scene in m_scenes.Values) { scene.ForEachClient( @@ -630,9 +630,9 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden (DateTime.Now - cinfo.StartedTime).Minutes, avg_reqs, string.Format( - "{0}, {1}%", - llClient.TotalSignificantAgentUpdates, - (float)llClient.TotalSignificantAgentUpdates / cinfo.SyncRequests["AgentUpdate"] * 100)); + "{0} ({1:0.00}%)", + llClient.TotalAgentUpdates, + (float)cinfo.SyncRequests["AgentUpdate"] / llClient.TotalAgentUpdates * 100)); } }); } -- cgit v1.1 From d5a1779465b6d875ebe5822ce6f15df3378b759f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 20 Jul 2013 12:20:35 -0700 Subject: Manage AgentUpdates more sanely: - The existing event to scene has been split into 2: OnAgentUpdate and OnAgentCameraUpdate, to better reflect the two types of updates that the viewer sends. We can run one without the other, which is what happens when the avie is still but the user is camming around - Added thresholds (as opposed to equality) to determine whether the update is significant or not. I thin these thresholds are ok, but we can play with them later - Ignore updates of HeadRotation, which were problematic and aren't being used up stream --- .../Agent/InternetRelayClientView/Server/IRCClientView.cs | 1 + OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs | 1 + 2 files changed, 2 insertions(+) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index 3726191..9b69da3 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -687,6 +687,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server public event Action OnCompleteMovementToRegion; public event UpdateAgent OnPreAgentUpdate; public event UpdateAgent OnAgentUpdate; + public event UpdateAgent OnAgentCameraUpdate; public event AgentRequestSit OnAgentRequestSit; public event AgentSit OnAgentSit; public event AvatarPickerRequest OnAvatarPickerRequest; diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 592e4e1..6c38b65 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -258,6 +258,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC public event Action OnCompleteMovementToRegion; public event UpdateAgent OnPreAgentUpdate; public event UpdateAgent OnAgentUpdate; + public event UpdateAgent OnAgentCameraUpdate; public event AgentRequestSit OnAgentRequestSit; public event AgentSit OnAgentSit; public event AvatarPickerRequest OnAvatarPickerRequest; -- cgit v1.1 From b5ab0698d6328c90d779c2af29914da840335233 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 20 Jul 2013 17:58:32 -0700 Subject: EDIT BEAMS!!! They had been missing from OpenSim since ever. Thanks to lkalif for telling me how to route the information. The viewer effect is under the distance filter, so only avatars with cameras < 10m away see the beams. --- .../Agent/InternetRelayClientView/Server/IRCClientView.cs | 2 +- OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index 9b69da3..23a435d 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -1673,7 +1673,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server { } - public void StopFlying(ISceneEntity presence) + public void SendAgentTerseUpdate(ISceneEntity presence) { } diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 6c38b65..9a61702 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -1229,7 +1229,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC { } - public void StopFlying(ISceneEntity presence) + public void SendAgentTerseUpdate(ISceneEntity presence) { } -- cgit v1.1 From a08f01fa8323e18a63e920158c7f51ae78ac0e93 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 26 Jul 2013 18:43:15 +0100 Subject: Fix NPC regression test failures. These were genuine failures caused by ScenePresence.CompleteMovement() waiting for an UpdateAgent from NPC introduction that would never come. Instead, we do not wait if the agent is an NPC. --- OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index bf23040..f841d5c 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs @@ -155,7 +155,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests public void TestCreateWithAttachments() { TestHelpers.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); +// TestHelpers.EnableLogging(); UUID userId = TestHelpers.ParseTail(0x1); UserAccountHelpers.CreateUserWithInventory(m_scene, userId); -- cgit v1.1 From 428916a64d27e5f00e74d34fd4b0453f32c3d2de Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 26 Jul 2013 21:14:21 -0700 Subject: Commented out ChatSessionRequest capability in Vivox and Freeswitch. We aren't processing it in any meaningful way, and it seems to get invoked everytime someone types a message in group chat. --- .../Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 18 +++++++++--------- .../Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index ef1b92e..5a5a70c 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -326,15 +326,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice "ParcelVoiceInfoRequest", agentID.ToString())); - caps.RegisterHandler( - "ChatSessionRequest", - new RestStreamHandler( - "POST", - capsBase + m_chatSessionRequestPath, - (request, path, param, httpRequest, httpResponse) - => ChatSessionRequest(scene, request, path, param, agentID, caps), - "ChatSessionRequest", - agentID.ToString())); + //caps.RegisterHandler( + // "ChatSessionRequest", + // new RestStreamHandler( + // "POST", + // capsBase + m_chatSessionRequestPath, + // (request, path, param, httpRequest, httpResponse) + // => ChatSessionRequest(scene, request, path, param, agentID, caps), + // "ChatSessionRequest", + // agentID.ToString())); } /// diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs index 2d65530..cdab116 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs @@ -433,15 +433,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice "ParcelVoiceInfoRequest", agentID.ToString())); - caps.RegisterHandler( - "ChatSessionRequest", - new RestStreamHandler( - "POST", - capsBase + m_chatSessionRequestPath, - (request, path, param, httpRequest, httpResponse) - => ChatSessionRequest(scene, request, path, param, agentID, caps), - "ChatSessionRequest", - agentID.ToString())); + //caps.RegisterHandler( + // "ChatSessionRequest", + // new RestStreamHandler( + // "POST", + // capsBase + m_chatSessionRequestPath, + // (request, path, param, httpRequest, httpResponse) + // => ChatSessionRequest(scene, request, path, param, agentID, caps), + // "ChatSessionRequest", + // agentID.ToString())); } /// -- cgit v1.1 From 7b0b5c9d97dea840e1ede6e2318b3c049c804983 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 28 Jul 2013 13:49:58 -0700 Subject: Added BasicSearchModule.cs which handles OnDirFindQuery events. Removed that handler from both Groups modules in core, and replaced them with an operation on IGroupsModule. --- .../Avatar/XmlRpcGroups/GroupsModule.cs | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs index 32fb54b..f4734b7 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs @@ -250,7 +250,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups client.OnUUIDGroupNameRequest += HandleUUIDGroupNameRequest; client.OnAgentDataUpdateRequest += OnAgentDataUpdateRequest; - client.OnDirFindQuery += OnDirFindQuery; client.OnRequestAvatarProperties += OnRequestAvatarProperties; // Used for Notices and Group Invites/Accept/Reject @@ -303,21 +302,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups } */ - void OnDirFindQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags, int queryStart) - { - if (((DirFindFlags)queryFlags & DirFindFlags.Groups) == DirFindFlags.Groups) - { - if (m_debugEnabled) - m_log.DebugFormat( - "[GROUPS]: {0} called with queryText({1}) queryFlags({2}) queryStart({3})", - System.Reflection.MethodBase.GetCurrentMethod().Name, queryText, (DirFindFlags)queryFlags, queryStart); - - // TODO: This currently ignores pretty much all the query flags including Mature and sort order - remoteClient.SendDirGroupsReply(queryID, m_groupData.FindGroups(GetRequestingAgentID(remoteClient), queryText).ToArray()); - } - - } - private void OnAgentDataUpdateRequest(IClientAPI remoteClient, UUID dataForAgentID, UUID sessionID) { if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); @@ -1178,6 +1162,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups } } + public List FindGroups(IClientAPI remoteClient, string query) + { + return m_groupData.FindGroups(GetRequestingAgentID(remoteClient), query); + } + + #endregion #region Client/Update Tools -- cgit v1.1 From 6ad577d32bcb7520a33e4c0c7510d81a7cad674c Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 30 Jul 2013 15:22:32 -0700 Subject: BulletSim: test method for debugging of extended physics script operations. --- .../Scripting/ExtendedPhysics/ExtendedPhysics.cs | 54 ++++++++++++++++++---- 1 file changed, 46 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs index 6009dc5..0cbc5f9 100755 --- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs @@ -31,10 +31,10 @@ using System.Reflection; using System.Text; using OpenSim.Framework; +using OpenSim.Region.CoreModules; using OpenSim.Region.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.CoreModules; using Mono.Addins; using Nini.Config; @@ -49,6 +49,10 @@ public class ExtendedPhysics : INonSharedRegionModule private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static string LogHeader = "[EXTENDED PHYSICS]"; + // Since BulletSim is a plugin, this these values aren't defined easily in one place. + // This table must coorespond to an identical table in BSScene. + public const string PhysFunctSetLinksetType = "BulletSim.SetLinksetType"; + private IConfig Configuration { get; set; } private bool Enabled { get; set; } private Scene BaseScene { get; set; } @@ -143,13 +147,6 @@ public class ExtendedPhysics : INonSharedRegionModule [ScriptConstant] public static int PHYS_CENTER_OF_MASS = 1 << 0; - [ScriptConstant] - public static int PHYS_LINKSET_TYPE_CONSTRAINT = 1; - [ScriptConstant] - public static int PHYS_LINKSET_TYPE_COMPOUND = 2; - [ScriptConstant] - public static int PHYS_LINKSET_TYPE_MANUAL = 3; - [ScriptInvocation] public string physGetEngineType(UUID hostID, UUID scriptID) { @@ -163,9 +160,50 @@ public class ExtendedPhysics : INonSharedRegionModule return ret; } + [ScriptConstant] + public static int PHYS_LINKSET_TYPE_CONSTRAINT = 0; + [ScriptConstant] + public static int PHYS_LINKSET_TYPE_COMPOUND = 1; + [ScriptConstant] + public static int PHYS_LINKSET_TYPE_MANUAL = 2; + [ScriptInvocation] public void physSetLinksetType(UUID hostID, UUID scriptID, int linksetType) { + if (!Enabled) return; + + // The part that is requesting the change. + SceneObjectPart requestingPart = BaseScene.GetSceneObjectPart(hostID); + + if (requestingPart != null) + { + // The change is always made to the root of a linkset. + SceneObjectGroup containingGroup = requestingPart.ParentGroup; + SceneObjectPart rootPart = containingGroup.RootPart; + + if (rootPart != null) + { + Physics.Manager.PhysicsActor rootPhysActor = rootPart.PhysActor; + if (rootPhysActor != null) + { + rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType); + } + else + { + m_log.WarnFormat("{0} physSetLinksetType: root part does not have a physics actor. rootName={1}, hostID={2}", + LogHeader, rootPart.Name, hostID); + } + } + else + { + m_log.WarnFormat("{0} physSetLinksetType: root part does not exist. RequestingPartName={1}, hostID={2}", + LogHeader, requestingPart.Name, hostID); + } + } + else + { + m_log.WarnFormat("{0} physSetLinsetType: cannot find script object in scene. hostID={1}", LogHeader, hostID); + } } } } -- cgit v1.1 From 24df15dab7befd50f7a45eb54f001e6e481f0ec4 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 1 Aug 2013 17:43:06 -0700 Subject: BulletSim: add implementation of 'physSetLinksetType' and 'physGetLinksetType' and processing routines in BulletSim. Add linkset rebuild/conversion routine in BSLinkset. --- .../Scripting/ExtendedPhysics/ExtendedPhysics.cs | 65 ++++++++++++++++++++-- 1 file changed, 60 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs index 0cbc5f9..d1d318c 100755 --- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs @@ -49,10 +49,20 @@ public class ExtendedPhysics : INonSharedRegionModule private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static string LogHeader = "[EXTENDED PHYSICS]"; + // ============================================================= // Since BulletSim is a plugin, this these values aren't defined easily in one place. - // This table must coorespond to an identical table in BSScene. + // This table must correspond to an identical table in BSScene. + + // Per scene functions. See BSScene. + + // Per avatar functions. See BSCharacter. + + // Per prim functions. See BSPrim. + public const string PhysFunctGetLinksetType = "BulletSim.GetLinksetType"; public const string PhysFunctSetLinksetType = "BulletSim.SetLinksetType"; + // ============================================================= + private IConfig Configuration { get; set; } private bool Enabled { get; set; } private Scene BaseScene { get; set; } @@ -123,6 +133,7 @@ public class ExtendedPhysics : INonSharedRegionModule // Register as LSL functions all the [ScriptInvocation] marked methods. Comms.RegisterScriptInvocations(this); + Comms.RegisterConstants(this); // When an object is modified, we might need to update its extended physics parameters BaseScene.EventManager.OnObjectAddedToScene += EventManager_OnObjectAddedToScene; @@ -136,7 +147,6 @@ public class ExtendedPhysics : INonSharedRegionModule private void EventManager_OnObjectAddedToScene(SceneObjectGroup obj) { - throw new NotImplementedException(); } // Event generated when some property of a prim changes. @@ -168,9 +178,11 @@ public class ExtendedPhysics : INonSharedRegionModule public static int PHYS_LINKSET_TYPE_MANUAL = 2; [ScriptInvocation] - public void physSetLinksetType(UUID hostID, UUID scriptID, int linksetType) + public int physSetLinksetType(UUID hostID, UUID scriptID, int linksetType) { - if (!Enabled) return; + int ret = -1; + + if (!Enabled) return ret; // The part that is requesting the change. SceneObjectPart requestingPart = BaseScene.GetSceneObjectPart(hostID); @@ -186,7 +198,7 @@ public class ExtendedPhysics : INonSharedRegionModule Physics.Manager.PhysicsActor rootPhysActor = rootPart.PhysActor; if (rootPhysActor != null) { - rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType); + ret = (int)rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType); } else { @@ -204,6 +216,49 @@ public class ExtendedPhysics : INonSharedRegionModule { m_log.WarnFormat("{0} physSetLinsetType: cannot find script object in scene. hostID={1}", LogHeader, hostID); } + return ret; + } + + [ScriptInvocation] + public int physGetLinksetType(UUID hostID, UUID scriptID) + { + int ret = -1; + + if (!Enabled) return ret; + + // The part that is requesting the change. + SceneObjectPart requestingPart = BaseScene.GetSceneObjectPart(hostID); + + if (requestingPart != null) + { + // The type is is always on the root of a linkset. + SceneObjectGroup containingGroup = requestingPart.ParentGroup; + SceneObjectPart rootPart = containingGroup.RootPart; + + if (rootPart != null) + { + Physics.Manager.PhysicsActor rootPhysActor = rootPart.PhysActor; + if (rootPhysActor != null) + { + ret = (int)rootPhysActor.Extension(PhysFunctGetLinksetType); + } + else + { + m_log.WarnFormat("{0} physGetLinksetType: root part does not have a physics actor. rootName={1}, hostID={2}", + LogHeader, rootPart.Name, hostID); + } + } + else + { + m_log.WarnFormat("{0} physGetLinksetType: root part does not exist. RequestingPartName={1}, hostID={2}", + LogHeader, requestingPart.Name, hostID); + } + } + else + { + m_log.WarnFormat("{0} physGetLinsetType: cannot find script object in scene. hostID={1}", LogHeader, hostID); + } + return ret; } } } -- cgit v1.1 From de6ad380f659edbc102e9bde01033acd19034c2d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 12 Aug 2013 19:31:45 +0100 Subject: Get rid of issue where removing NPCs would through an exception by routing close through Scene.IncomingCloseAgent() and NPCAvatar.Close() rather than directly to Scene.RemoveClient(). This exception was actually harmless since it occurred at the very last stage of the remove client process. --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 69189b3..c26fdfc 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -385,7 +385,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC m_log.DebugFormat("[NPC MODULE]: Found {0} {1} to remove", agentID, av.Name); */ - scene.RemoveClient(agentID, false); + + scene.IncomingCloseAgent(agentID, false); +// scene.RemoveClient(agentID, false); m_avatars.Remove(agentID); /* m_log.DebugFormat("[NPC MODULE]: Removed NPC {0} {1}", -- cgit v1.1 From 377fe63c60b6632777da5f0a8a0c4c2d32a1f4ac Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 12 Aug 2013 21:02:50 +0100 Subject: Don't try and send group updates to NPCs via event queue, since NPCs have no event queue. I think there is an argument for sending this information to NPCs anyway since in some cases it appears a lot easier to write server-side bots by hooking into such internal events. However, would need to stop event messages building up on NPC queues if they are never retrieved. --- OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs index f4734b7..d744a14 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs @@ -1212,7 +1212,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups AgentDataMap.Add("AgentID", OSD.FromUUID(dataForAgentID)); AgentData.Add(AgentDataMap); - OSDArray GroupData = new OSDArray(data.Length); OSDArray NewGroupData = new OSDArray(data.Length); -- cgit v1.1 From e384ff604e081970ae9351431115a87e82345b18 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 20 Aug 2013 17:43:02 +0100 Subject: Add experimental "sit user name" and "stand user name" console commands in SitStandCommandsModule. "sit user name" will currently only sit the given avatar on prims which have a sit target set and are not already sat upon. Chiefly for debug purposes. --- .../Avatar/SitStand/SitStandCommandsModule.cs | 180 +++++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100644 OpenSim/Region/OptionalModules/Avatar/SitStand/SitStandCommandsModule.cs (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Avatar/SitStand/SitStandCommandsModule.cs b/OpenSim/Region/OptionalModules/Avatar/SitStand/SitStandCommandsModule.cs new file mode 100644 index 0000000..874723c --- /dev/null +++ b/OpenSim/Region/OptionalModules/Avatar/SitStand/SitStandCommandsModule.cs @@ -0,0 +1,180 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using log4net; +using Mono.Addins; +using Nini.Config; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Framework.Console; +using OpenSim.Framework.Monitoring; +using OpenSim.Region.ClientStack.LindenUDP; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Scenes.Animation; +using OpenSim.Services.Interfaces; + +namespace OpenSim.Region.OptionalModules.Avatar.SitStand +{ + /// + /// A module that just holds commands for changing avatar sitting and standing states. + /// + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AnimationsCommandModule")] + public class SitStandCommandModule : INonSharedRegionModule + { +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private Scene m_scene; + + public string Name { get { return "SitStand Command Module"; } } + + public Type ReplaceableInterface { get { return null; } } + + public void Initialise(IConfigSource source) + { +// m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: INITIALIZED MODULE"); + } + + public void PostInitialise() + { +// m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: POST INITIALIZED MODULE"); + } + + public void Close() + { +// m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: CLOSED MODULE"); + } + + public void AddRegion(Scene scene) + { +// m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName); + } + + public void RemoveRegion(Scene scene) + { +// m_log.DebugFormat("[ATTACHMENTS COMMAND MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName); + } + + public void RegionLoaded(Scene scene) + { +// m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); + + m_scene = scene; + + scene.AddCommand( + "Users", this, "sit user name", + "sit user name ", + "Sit the named user on an unoccupied object with a sit target.\n" + + "If there are no such objects then nothing happens", + HandleSitUserNameCommand); + + scene.AddCommand( + "Users", this, "stand user name", + "stand user name ", + "Stand the named user.", + HandleStandUserNameCommand); + } + + protected void HandleSitUserNameCommand(string module, string[] cmd) + { + if (MainConsole.Instance.ConsoleScene != m_scene && MainConsole.Instance.ConsoleScene != null) + return; + + if (cmd.Length != 5) + { + MainConsole.Instance.Output("Usage: sit user name "); + return; + } + + string firstName = cmd[3]; + string lastName = cmd[4]; + + ScenePresence sp = m_scene.GetScenePresence(firstName, lastName); + + if (sp == null || sp.IsChildAgent) + return; + + SceneObjectPart sitPart = null; + List sceneObjects = m_scene.GetSceneObjectGroups(); + + foreach (SceneObjectGroup sceneObject in sceneObjects) + { + foreach (SceneObjectPart part in sceneObject.Parts) + { + if (part.IsSitTargetSet && part.SitTargetAvatar == UUID.Zero) + { + sitPart = part; + break; + } + } + } + + if (sitPart != null) + { + MainConsole.Instance.OutputFormat( + "Sitting {0} on {1} {2} in {3}", + sp.Name, sitPart.ParentGroup.Name, sitPart.ParentGroup.UUID, m_scene.Name); + + sp.HandleAgentRequestSit(sp.ControllingClient, sp.UUID, sitPart.UUID, Vector3.Zero); + sp.HandleAgentSit(sp.ControllingClient, sp.UUID); + } + else + { + MainConsole.Instance.OutputFormat( + "Could not find any unoccupied set seat on which to sit {0} in {1}", + sp.Name, m_scene.Name); + } + } + + protected void HandleStandUserNameCommand(string module, string[] cmd) + { + if (MainConsole.Instance.ConsoleScene != m_scene && MainConsole.Instance.ConsoleScene != null) + return; + + if (cmd.Length != 5) + { + MainConsole.Instance.Output("Usage: stand user name "); + return; + } + + string firstName = cmd[3]; + string lastName = cmd[4]; + + ScenePresence sp = m_scene.GetScenePresence(firstName, lastName); + + if (sp == null || sp.IsChildAgent) + return; + + sp.StandUp(); + } + } +} \ No newline at end of file -- cgit v1.1 From 43940f656210d5e572ef05bd223b3959513ee687 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 20 Aug 2013 18:13:40 +0100 Subject: Add --regex options to "sit user name" and "stand user name" console commands to sit/stand many avatars at once. Currently, first name and last name are input separate but are concatenated with a space in the middle to form a regex. So to sit all bots with the first name "ima", for instance, the command is "sit user name --regex ima .*" --- .../Avatar/SitStand/SitStandCommandsModule.cs | 131 +++++++++++++-------- 1 file changed, 81 insertions(+), 50 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Avatar/SitStand/SitStandCommandsModule.cs b/OpenSim/Region/OptionalModules/Avatar/SitStand/SitStandCommandsModule.cs index 874723c..e9cb213 100644 --- a/OpenSim/Region/OptionalModules/Avatar/SitStand/SitStandCommandsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/SitStand/SitStandCommandsModule.cs @@ -30,18 +30,16 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; +using System.Text.RegularExpressions; using log4net; using Mono.Addins; +using NDesk.Options; using Nini.Config; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Console; -using OpenSim.Framework.Monitoring; -using OpenSim.Region.ClientStack.LindenUDP; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.Framework.Scenes.Animation; -using OpenSim.Services.Interfaces; namespace OpenSim.Region.OptionalModules.Avatar.SitStand { @@ -92,89 +90,122 @@ namespace OpenSim.Region.OptionalModules.Avatar.SitStand scene.AddCommand( "Users", this, "sit user name", - "sit user name ", - "Sit the named user on an unoccupied object with a sit target.\n" - + "If there are no such objects then nothing happens", + "sit user name [--regex] ", + "Sit the named user on an unoccupied object with a sit target.", + "If there are no such objects then nothing happens.\n" + + "If --regex is specified then the names are treated as regular expressions.", HandleSitUserNameCommand); scene.AddCommand( "Users", this, "stand user name", - "stand user name ", + "stand user name [--regex] ", "Stand the named user.", + "If --regex is specified then the names are treated as regular expressions.", HandleStandUserNameCommand); } - protected void HandleSitUserNameCommand(string module, string[] cmd) + private void HandleSitUserNameCommand(string module, string[] cmd) { if (MainConsole.Instance.ConsoleScene != m_scene && MainConsole.Instance.ConsoleScene != null) return; - if (cmd.Length != 5) + if (cmd.Length < 5) { - MainConsole.Instance.Output("Usage: sit user name "); + MainConsole.Instance.Output("Usage: sit user name [--regex] "); return; } - string firstName = cmd[3]; - string lastName = cmd[4]; + List scenePresences = GetScenePresences(cmd); - ScenePresence sp = m_scene.GetScenePresence(firstName, lastName); - - if (sp == null || sp.IsChildAgent) - return; - - SceneObjectPart sitPart = null; - List sceneObjects = m_scene.GetSceneObjectGroups(); - - foreach (SceneObjectGroup sceneObject in sceneObjects) + foreach (ScenePresence sp in scenePresences) { - foreach (SceneObjectPart part in sceneObject.Parts) + SceneObjectPart sitPart = null; + List sceneObjects = m_scene.GetSceneObjectGroups(); + + foreach (SceneObjectGroup sceneObject in sceneObjects) { - if (part.IsSitTargetSet && part.SitTargetAvatar == UUID.Zero) + foreach (SceneObjectPart part in sceneObject.Parts) { - sitPart = part; - break; + if (part.IsSitTargetSet && part.SitTargetAvatar == UUID.Zero) + { + sitPart = part; + break; + } } } - } - if (sitPart != null) - { - MainConsole.Instance.OutputFormat( - "Sitting {0} on {1} {2} in {3}", - sp.Name, sitPart.ParentGroup.Name, sitPart.ParentGroup.UUID, m_scene.Name); + if (sitPart != null) + { + MainConsole.Instance.OutputFormat( + "Sitting {0} on {1} {2} in {3}", + sp.Name, sitPart.ParentGroup.Name, sitPart.ParentGroup.UUID, m_scene.Name); - sp.HandleAgentRequestSit(sp.ControllingClient, sp.UUID, sitPart.UUID, Vector3.Zero); - sp.HandleAgentSit(sp.ControllingClient, sp.UUID); - } - else - { - MainConsole.Instance.OutputFormat( - "Could not find any unoccupied set seat on which to sit {0} in {1}", - sp.Name, m_scene.Name); + sp.HandleAgentRequestSit(sp.ControllingClient, sp.UUID, sitPart.UUID, Vector3.Zero); + sp.HandleAgentSit(sp.ControllingClient, sp.UUID); + } + else + { + MainConsole.Instance.OutputFormat( + "Could not find any unoccupied set seat on which to sit {0} in {1}. Aborting", + sp.Name, m_scene.Name); + + break; + } } } - protected void HandleStandUserNameCommand(string module, string[] cmd) + private void HandleStandUserNameCommand(string module, string[] cmd) { if (MainConsole.Instance.ConsoleScene != m_scene && MainConsole.Instance.ConsoleScene != null) return; - if (cmd.Length != 5) + if (cmd.Length < 5) { - MainConsole.Instance.Output("Usage: stand user name "); + MainConsole.Instance.Output("Usage: stand user name [--regex] "); return; } - string firstName = cmd[3]; - string lastName = cmd[4]; + List scenePresences = GetScenePresences(cmd); - ScenePresence sp = m_scene.GetScenePresence(firstName, lastName); - - if (sp == null || sp.IsChildAgent) - return; + foreach (ScenePresence sp in scenePresences) + { + MainConsole.Instance.OutputFormat("Standing {0} in {1}", sp.Name, m_scene.Name); + sp.StandUp(); + } + } + + private List GetScenePresences(string[] cmdParams) + { + bool useRegex = false; + OptionSet options = new OptionSet().Add("regex", v=> useRegex = v != null ); + + List mainParams = options.Parse(cmdParams); + + string firstName = mainParams[3]; + string lastName = mainParams[4]; + + List scenePresencesMatched = new List(); + + if (useRegex) + { + Regex nameRegex = new Regex(string.Format("{0} {1}", firstName, lastName)); + List scenePresences = m_scene.GetScenePresences(); + + foreach (ScenePresence sp in scenePresences) + { + if (!sp.IsChildAgent && nameRegex.IsMatch(sp.Name)) + scenePresencesMatched.Add(sp); + } + } + else + { + ScenePresence sp = m_scene.GetScenePresence(firstName, lastName); + + if (sp != null && !sp.IsChildAgent) + scenePresencesMatched.Add(sp); + } - sp.StandUp(); + return scenePresencesMatched; } } } \ No newline at end of file -- cgit v1.1 From 832c35d4d5288de0f976e40ede1c8f2ad7df4bcf Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 22 Aug 2013 20:05:57 +0100 Subject: Stop "sit user name" and "stand user name" console commands from trying to sit/stand avatars already sitting/standing --- .../OptionalModules/Avatar/SitStand/SitStandCommandsModule.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Avatar/SitStand/SitStandCommandsModule.cs b/OpenSim/Region/OptionalModules/Avatar/SitStand/SitStandCommandsModule.cs index e9cb213..4a591cf 100644 --- a/OpenSim/Region/OptionalModules/Avatar/SitStand/SitStandCommandsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/SitStand/SitStandCommandsModule.cs @@ -119,6 +119,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.SitStand foreach (ScenePresence sp in scenePresences) { + if (sp.SitGround || sp.IsSatOnObject) + continue; + SceneObjectPart sitPart = null; List sceneObjects = m_scene.GetSceneObjectGroups(); @@ -169,8 +172,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.SitStand foreach (ScenePresence sp in scenePresences) { - MainConsole.Instance.OutputFormat("Standing {0} in {1}", sp.Name, m_scene.Name); - sp.StandUp(); + if (sp.SitGround || sp.IsSatOnObject) + { + MainConsole.Instance.OutputFormat("Standing {0} in {1}", sp.Name, m_scene.Name); + sp.StandUp(); + } } } -- cgit v1.1 From beb9d966f9efb571b3d6635ba2500b6b0e685fc0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 22 Aug 2013 22:49:23 +0100 Subject: Stop "handle sit user name" command from trying to sit avatars on objects which have sit positions but are attachments --- .../Region/OptionalModules/Avatar/SitStand/SitStandCommandsModule.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Avatar/SitStand/SitStandCommandsModule.cs b/OpenSim/Region/OptionalModules/Avatar/SitStand/SitStandCommandsModule.cs index 4a591cf..5a6b284 100644 --- a/OpenSim/Region/OptionalModules/Avatar/SitStand/SitStandCommandsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/SitStand/SitStandCommandsModule.cs @@ -127,6 +127,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.SitStand foreach (SceneObjectGroup sceneObject in sceneObjects) { + if (sceneObject.IsAttachment) + continue; + foreach (SceneObjectPart part in sceneObject.Parts) { if (part.IsSitTargetSet && part.SitTargetAvatar == UUID.Zero) -- cgit v1.1 From dc74a50225a901e969ea83008555170f5742ca7a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 4 Sep 2013 23:48:24 +0100 Subject: Stop "show client stats" from throwing an exception if somehow Scene.m_clientManager still retains a reference to a dead client. Instead, "show client stats" now prints "Off!" so that exception is not thrown and we know which entries in ClientManager are in this state. There's a race condition which could trigger this, but the window is extremely short and exceptions would not be thrown consistently (which is the behaviour observed). It should otherwise be impossible for this condition to occur, so there may be a weakness in client manager IClientAPI removal. --- .../OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs index 15dea17..1eb0a6b 100644 --- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs @@ -624,9 +624,16 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden int avg_reqs = cinfo.AsyncRequests.Values.Sum() + cinfo.GenericRequests.Values.Sum() + cinfo.SyncRequests.Values.Sum(); avg_reqs = avg_reqs / ((DateTime.Now - cinfo.StartedTime).Minutes + 1); + string childAgentStatus; + + if (llClient.SceneAgent != null) + childAgentStatus = llClient.SceneAgent.IsChildAgent ? "N" : "Y"; + else + childAgentStatus = "Off!"; + m_log.InfoFormat("[INFO]: {0,-12} {1,-20} {2,-6} {3,-11} {4,-11} {5,-16}", scene.RegionInfo.RegionName, llClient.Name, - llClient.SceneAgent.IsChildAgent ? "N" : "Y", + childAgentStatus, (DateTime.Now - cinfo.StartedTime).Minutes, avg_reqs, string.Format( -- cgit v1.1 From 725751fd6c0101b8610e84716d28b6af91e20b61 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 6 Aug 2013 10:32:56 -0700 Subject: BulletSim: fixes for change linkset implementation of physical linksets. --- .../Scripting/ExtendedPhysics/ExtendedPhysics.cs | 29 +++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs index d1d318c..4455df4 100755 --- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs @@ -29,6 +29,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; +using System.Threading; using OpenSim.Framework; using OpenSim.Region.CoreModules; @@ -198,7 +199,33 @@ public class ExtendedPhysics : INonSharedRegionModule Physics.Manager.PhysicsActor rootPhysActor = rootPart.PhysActor; if (rootPhysActor != null) { - ret = (int)rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType); + if (rootPhysActor.IsPhysical) + { + // Change a physical linkset by making non-physical, waiting for one heartbeat so all + // the prim and linkset state is updated, changing the type and making the + // linkset physical again. + containingGroup.ScriptSetPhysicsStatus(false); + Thread.Sleep(150); // longer than one heartbeat tick + + // A kludge for the moment. + // Since compound linksets move the children but don't generate position updates to the + // simulator, it is possible for compound linkset children to have out-of-sync simulator + // and physical positions. The following causes the simulator to push the real child positions + // down into the physics engine to get everything synced. + containingGroup.UpdateGroupPosition(containingGroup.AbsolutePosition); + containingGroup.UpdateGroupRotationR(containingGroup.GroupRotation); + + ret = (int)rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType); + Thread.Sleep(150); // longer than one heartbeat tick + + containingGroup.ScriptSetPhysicsStatus(true); + } + else + { + // Non-physical linksets don't have a physical instantiation so there is no state to + // worry about being updated. + ret = (int)rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType); + } } else { -- cgit v1.1 From f3cc20050e8e4ce047509589f828ccafbc59e3a9 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 7 Aug 2013 11:13:53 -0700 Subject: BulletSim: initial implementation of physChangeLinkFixed that resets a linkset's link back to a fixed, non-moving connection. --- .../Scripting/ExtendedPhysics/ExtendedPhysics.cs | 82 +++++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs index 4455df4..decb61a 100755 --- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs @@ -61,6 +61,10 @@ public class ExtendedPhysics : INonSharedRegionModule // Per prim functions. See BSPrim. public const string PhysFunctGetLinksetType = "BulletSim.GetLinksetType"; public const string PhysFunctSetLinksetType = "BulletSim.SetLinksetType"; + public const string PhysFunctChangeLinkFixed = "BulletSim.ChangeLinkFixed"; + public const string PhysFunctChangeLinkHinge = "BulletSim.ChangeLinkHinge"; + public const string PhysFunctChangeLinkSpring = "BulletSim.ChangeLinkSpring"; + public const string PhysFunctChangeLinkSlider = "BulletSim.ChangeLinkSlider"; // ============================================================= @@ -250,7 +254,6 @@ public class ExtendedPhysics : INonSharedRegionModule public int physGetLinksetType(UUID hostID, UUID scriptID) { int ret = -1; - if (!Enabled) return ret; // The part that is requesting the change. @@ -287,5 +290,82 @@ public class ExtendedPhysics : INonSharedRegionModule } return ret; } + + [ScriptInvocation] + public int physChangeLinkFixed(UUID hostID, UUID scriptID, int linkNum) + { + int ret = -1; + if (!Enabled) return ret; + + // The part that is requesting the change. + SceneObjectPart requestingPart = BaseScene.GetSceneObjectPart(hostID); + + if (requestingPart != null) + { + // The type is is always on the root of a linkset. + SceneObjectGroup containingGroup = requestingPart.ParentGroup; + SceneObjectPart rootPart = containingGroup.RootPart; + + if (rootPart != null) + { + Physics.Manager.PhysicsActor rootPhysActor = rootPart.PhysActor; + if (rootPhysActor != null) + { + SceneObjectPart linkPart = containingGroup.GetLinkNumPart(linkNum); + if (linkPart != null) + { + Physics.Manager.PhysicsActor linkPhysActor = linkPart.PhysActor; + if (linkPhysActor != null) + { + ret = (int)rootPhysActor.Extension(PhysFunctChangeLinkFixed, linkNum, linkPhysActor); + } + else + { + m_log.WarnFormat("{0} physChangeLinkFixed: Link part has no physical actor. rootName={1}, hostID={2}, linknum={3}", + LogHeader, rootPart.Name, hostID, linkNum); + } + } + else + { + m_log.WarnFormat("{0} physChangeLinkFixed: Could not find linknum part. rootName={1}, hostID={2}, linknum={3}", + LogHeader, rootPart.Name, hostID, linkNum); + } + } + else + { + m_log.WarnFormat("{0} physChangeLinkFixed: Root part does not have a physics actor. rootName={1}, hostID={2}", + LogHeader, rootPart.Name, hostID); + } + } + else + { + m_log.WarnFormat("{0} physChangeLinkFixed: Root part does not exist. RequestingPartName={1}, hostID={2}", + LogHeader, requestingPart.Name, hostID); + } + } + else + { + m_log.WarnFormat("{0} physGetLinsetType: cannot find script object in scene. hostID={1}", LogHeader, hostID); + } + return ret; + } + + [ScriptInvocation] + public int physChangeLinkHinge(UUID hostID, UUID scriptID, int linkNum) + { + return 0; + } + + [ScriptInvocation] + public int physChangeLinkSpring(UUID hostID, UUID scriptID, int linkNum) + { + return 0; + } + + [ScriptInvocation] + public int physChangeLinkSlider(UUID hostID, UUID scriptID, int linkNum) + { + return 0; + } } } -- cgit v1.1 From 6aee08ac3c48b55ebd8e945c8b11f17dc1ab3151 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 8 Aug 2013 08:36:36 -0700 Subject: BulletSim: add physChangeLinkSpring to change linkset link to be a spring constraint. Add implementation to create spring constraint. Send up property updates for linkset children at the end of flexible linkset links. The simulator probably doesn't do the right thing yet. --- .../Scripting/ExtendedPhysics/ExtendedPhysics.cs | 73 +++++++++++++++++++++- 1 file changed, 70 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs index decb61a..278e9e7 100755 --- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs @@ -291,6 +291,10 @@ public class ExtendedPhysics : INonSharedRegionModule return ret; } + // physChangeLinkFixed(integer linkNum) + // Change the link between the root and the linkNum into a fixed, static physical connection. + // This needs to change 'linkNum' into the physical object because lower level code has + // no access to the link numbers. [ScriptInvocation] public int physChangeLinkFixed(UUID hostID, UUID scriptID, int linkNum) { @@ -353,13 +357,76 @@ public class ExtendedPhysics : INonSharedRegionModule [ScriptInvocation] public int physChangeLinkHinge(UUID hostID, UUID scriptID, int linkNum) { - return 0; + return -1; } [ScriptInvocation] - public int physChangeLinkSpring(UUID hostID, UUID scriptID, int linkNum) + public int physChangeLinkSpring(UUID hostID, UUID scriptID, int linkNum, + Vector3 frameInAloc, Quaternion frameInArot, + Vector3 frameInBloc, Quaternion frameInBrot, + Vector3 linearLimitLow, Vector3 linearLimitHigh, + Vector3 angularLimitLow, Vector3 angularLimitHigh + ) { - return 0; + int ret = -1; + if (!Enabled) return ret; + + // The part that is requesting the change. + SceneObjectPart requestingPart = BaseScene.GetSceneObjectPart(hostID); + + if (requestingPart != null) + { + // The type is is always on the root of a linkset. + SceneObjectGroup containingGroup = requestingPart.ParentGroup; + SceneObjectPart rootPart = containingGroup.RootPart; + + if (rootPart != null) + { + Physics.Manager.PhysicsActor rootPhysActor = rootPart.PhysActor; + if (rootPhysActor != null) + { + SceneObjectPart linkPart = containingGroup.GetLinkNumPart(linkNum); + if (linkPart != null) + { + Physics.Manager.PhysicsActor linkPhysActor = linkPart.PhysActor; + if (linkPhysActor != null) + { + ret = (int)rootPhysActor.Extension(PhysFunctChangeLinkSpring, linkNum, linkPhysActor, + frameInAloc, frameInArot, + frameInBloc, frameInBrot, + linearLimitLow, linearLimitHigh, + angularLimitLow, angularLimitHigh + ); + } + else + { + m_log.WarnFormat("{0} physChangeLinkFixed: Link part has no physical actor. rootName={1}, hostID={2}, linknum={3}", + LogHeader, rootPart.Name, hostID, linkNum); + } + } + else + { + m_log.WarnFormat("{0} physChangeLinkFixed: Could not find linknum part. rootName={1}, hostID={2}, linknum={3}", + LogHeader, rootPart.Name, hostID, linkNum); + } + } + else + { + m_log.WarnFormat("{0} physChangeLinkFixed: Root part does not have a physics actor. rootName={1}, hostID={2}", + LogHeader, rootPart.Name, hostID); + } + } + else + { + m_log.WarnFormat("{0} physChangeLinkFixed: Root part does not exist. RequestingPartName={1}, hostID={2}", + LogHeader, requestingPart.Name, hostID); + } + } + else + { + m_log.WarnFormat("{0} physGetLinsetType: cannot find script object in scene. hostID={1}", LogHeader, hostID); + } + return ret; } [ScriptInvocation] -- cgit v1.1 From 455d36c4c70a55c5d48dc1410b8729929fafedf6 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 9 Aug 2013 10:59:10 -0700 Subject: BulletSim: add physChangeLinkParams to set individual parameters on link constraints. Not fully functional. Remove double definition of ExtendedPhysics parameters by having BulletSim reference the optional module (addition to prebuild.xml and usings). --- .../Scripting/ExtendedPhysics/ExtendedPhysics.cs | 265 +++++++++++++-------- 1 file changed, 171 insertions(+), 94 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs index 278e9e7..baf5a5b 100755 --- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs @@ -36,6 +36,7 @@ using OpenSim.Region.CoreModules; using OpenSim.Region.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Physics.Manager; using Mono.Addins; using Nini.Config; @@ -62,9 +63,8 @@ public class ExtendedPhysics : INonSharedRegionModule public const string PhysFunctGetLinksetType = "BulletSim.GetLinksetType"; public const string PhysFunctSetLinksetType = "BulletSim.SetLinksetType"; public const string PhysFunctChangeLinkFixed = "BulletSim.ChangeLinkFixed"; - public const string PhysFunctChangeLinkHinge = "BulletSim.ChangeLinkHinge"; - public const string PhysFunctChangeLinkSpring = "BulletSim.ChangeLinkSpring"; - public const string PhysFunctChangeLinkSlider = "BulletSim.ChangeLinkSlider"; + public const string PhysFunctChangeLinkType = "BulletSim.ChangeLinkType"; + public const string PhysFunctChangeLinkParams = "BulletSim.ChangeLinkParams"; // ============================================================= @@ -200,7 +200,7 @@ public class ExtendedPhysics : INonSharedRegionModule if (rootPart != null) { - Physics.Manager.PhysicsActor rootPhysActor = rootPart.PhysActor; + PhysicsActor rootPhysActor = rootPart.PhysActor; if (rootPhysActor != null) { if (rootPhysActor.IsPhysical) @@ -219,7 +219,7 @@ public class ExtendedPhysics : INonSharedRegionModule containingGroup.UpdateGroupPosition(containingGroup.AbsolutePosition); containingGroup.UpdateGroupRotationR(containingGroup.GroupRotation); - ret = (int)rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType); + ret = MakeIntError(rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType)); Thread.Sleep(150); // longer than one heartbeat tick containingGroup.ScriptSetPhysicsStatus(true); @@ -228,7 +228,7 @@ public class ExtendedPhysics : INonSharedRegionModule { // Non-physical linksets don't have a physical instantiation so there is no state to // worry about being updated. - ret = (int)rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType); + ret = MakeIntError(rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType)); } } else @@ -267,10 +267,10 @@ public class ExtendedPhysics : INonSharedRegionModule if (rootPart != null) { - Physics.Manager.PhysicsActor rootPhysActor = rootPart.PhysActor; + PhysicsActor rootPhysActor = rootPart.PhysActor; if (rootPhysActor != null) { - ret = (int)rootPhysActor.Extension(PhysFunctGetLinksetType); + ret = MakeIntError(rootPhysActor.Extension(PhysFunctGetLinksetType)); } else { @@ -291,148 +291,225 @@ public class ExtendedPhysics : INonSharedRegionModule return ret; } + [ScriptConstant] + public static int PHYS_LINK_TYPE_FIXED = 1234; + [ScriptConstant] + public static int PHYS_LINK_TYPE_HINGE = 4; + [ScriptConstant] + public static int PHYS_LINK_TYPE_SPRING = 9; + [ScriptConstant] + public static int PHYS_LINK_TYPE_6DOF = 6; + [ScriptConstant] + public static int PHYS_LINK_TYPE_SLIDER = 7; + + // physChangeLinkType(integer linkNum, integer typeCode) + [ScriptInvocation] + public int physChangeLinkType(UUID hostID, UUID scriptID, int linkNum, int typeCode) + { + int ret = -1; + if (!Enabled) return ret; + + PhysicsActor rootPhysActor; + PhysicsActor childPhysActor; + + if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor)) + { + ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, childPhysActor, typeCode)); + } + + return ret; + } + // physChangeLinkFixed(integer linkNum) // Change the link between the root and the linkNum into a fixed, static physical connection. - // This needs to change 'linkNum' into the physical object because lower level code has - // no access to the link numbers. [ScriptInvocation] public int physChangeLinkFixed(UUID hostID, UUID scriptID, int linkNum) { int ret = -1; if (!Enabled) return ret; - // The part that is requesting the change. - SceneObjectPart requestingPart = BaseScene.GetSceneObjectPart(hostID); + PhysicsActor rootPhysActor; + PhysicsActor childPhysActor; + + if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor)) + { + ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, childPhysActor, PHYS_LINK_TYPE_FIXED)); + } + + return ret; + } + + // Code for specifying params. + // The choice if 14400 is arbitrary and only serves to catch parameter code misuse. + public static int PHYS_PARAM_MIN = 14401; + [ScriptConstant] + public static int PHYS_PARAM_FRAMEINA_LOC = 14401; + [ScriptConstant] + public static int PHYS_PARAM_FRAMEINA_ROT = 14402; + [ScriptConstant] + public static int PHYS_PARAM_FRAMEINB_LOC = 14403; + [ScriptConstant] + public static int PHYS_PARAM_FRAMEINB_ROT = 14404; + [ScriptConstant] + public static int PHYS_PARAM_LINEAR_LIMIT_LOW = 14405; + [ScriptConstant] + public static int PHYS_PARAM_LINEAR_LIMIT_HIGH = 14406; + [ScriptConstant] + public static int PHYS_PARAM_ANGULAR_LIMIT_LOW = 14407; + [ScriptConstant] + public static int PHYS_PARAM_ANGULAR_LIMIT_HIGH = 14408; + [ScriptConstant] + public static int PHYS_PARAM_USE_FRAME_OFFSET = 14409; + [ScriptConstant] + public static int PHYS_PARAM_ENABLE_TRANSMOTOR = 14410; + [ScriptConstant] + public static int PHYS_PARAM_TRANSMOTOR_MAXVEL = 14411; + [ScriptConstant] + public static int PHYS_PARAM_TRANSMOTOR_MAXFORCE = 14412; + [ScriptConstant] + public static int PHYS_PARAM_CFM = 14413; + [ScriptConstant] + public static int PHYS_PARAM_ERP = 14414; + [ScriptConstant] + public static int PHYS_PARAM_SOLVER_ITERATIONS = 14415; + [ScriptConstant] + public static int PHYS_PARAM_SPRING_DAMPING = 14416; + [ScriptConstant] + public static int PHYS_PARAM_SPRING_STIFFNESS = 14417; + public static int PHYS_PARAM_MAX = 14417; + // physChangeLinkParams(integer linkNum, [ PHYS_PARAM_*, value, PHYS_PARAM_*, value, ...]) + [ScriptInvocation] + public int physChangeLinkParams(UUID hostID, UUID scriptID, int linkNum, object[] parms) + { + int ret = -1; + if (!Enabled) return ret; + + PhysicsActor rootPhysActor; + PhysicsActor childPhysActor; + + if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor)) + { + ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkParams, childPhysActor, parms)); + } + + return ret; + } + + private bool GetRootPhysActor(UUID hostID, out PhysicsActor rootPhysActor) + { + SceneObjectGroup containingGroup; + SceneObjectPart rootPart; + return GetRootPhysActor(hostID, out containingGroup, out rootPart, out rootPhysActor); + } + + private bool GetRootPhysActor(UUID hostID, out SceneObjectGroup containingGroup, out SceneObjectPart rootPart, out PhysicsActor rootPhysActor) + { + bool ret = false; + rootPhysActor = null; + containingGroup = null; + rootPart = null; + + SceneObjectPart requestingPart; + + requestingPart = BaseScene.GetSceneObjectPart(hostID); if (requestingPart != null) { // The type is is always on the root of a linkset. - SceneObjectGroup containingGroup = requestingPart.ParentGroup; - SceneObjectPart rootPart = containingGroup.RootPart; - - if (rootPart != null) + containingGroup = requestingPart.ParentGroup; + if (containingGroup != null && !containingGroup.IsDeleted) { - Physics.Manager.PhysicsActor rootPhysActor = rootPart.PhysActor; - if (rootPhysActor != null) + rootPart = containingGroup.RootPart; + if (rootPart != null) { - SceneObjectPart linkPart = containingGroup.GetLinkNumPart(linkNum); - if (linkPart != null) + rootPhysActor = rootPart.PhysActor; + if (rootPhysActor != null) { - Physics.Manager.PhysicsActor linkPhysActor = linkPart.PhysActor; - if (linkPhysActor != null) - { - ret = (int)rootPhysActor.Extension(PhysFunctChangeLinkFixed, linkNum, linkPhysActor); - } - else - { - m_log.WarnFormat("{0} physChangeLinkFixed: Link part has no physical actor. rootName={1}, hostID={2}, linknum={3}", - LogHeader, rootPart.Name, hostID, linkNum); - } + ret = true; } else { - m_log.WarnFormat("{0} physChangeLinkFixed: Could not find linknum part. rootName={1}, hostID={2}, linknum={3}", - LogHeader, rootPart.Name, hostID, linkNum); + m_log.WarnFormat("{0} GetRootAndChildPhysActors: Root part does not have a physics actor. rootName={1}, hostID={2}", + LogHeader, rootPart.Name, hostID); } } else { - m_log.WarnFormat("{0} physChangeLinkFixed: Root part does not have a physics actor. rootName={1}, hostID={2}", - LogHeader, rootPart.Name, hostID); + m_log.WarnFormat("{0} GetRootAndChildPhysActors: Root part does not exist. RequestingPartName={1}, hostID={2}", + LogHeader, requestingPart.Name, hostID); } } else { - m_log.WarnFormat("{0} physChangeLinkFixed: Root part does not exist. RequestingPartName={1}, hostID={2}", - LogHeader, requestingPart.Name, hostID); + m_log.WarnFormat("{0} GetRootAndChildPhysActors: Containing group missing or deleted. hostID={1}", LogHeader, hostID); } } else { - m_log.WarnFormat("{0} physGetLinsetType: cannot find script object in scene. hostID={1}", LogHeader, hostID); + m_log.WarnFormat("{0} GetRootAndChildPhysActors: cannot find script object in scene. hostID={1}", LogHeader, hostID); } + return ret; } - [ScriptInvocation] - public int physChangeLinkHinge(UUID hostID, UUID scriptID, int linkNum) + // Find the root and child PhysActors based on the linkNum. + // Return 'true' if both are found and returned. + private bool GetRootAndChildPhysActors(UUID hostID, int linkNum, out PhysicsActor rootPhysActor, out PhysicsActor childPhysActor) { - return -1; - } + bool ret = false; + rootPhysActor = null; + childPhysActor = null; - [ScriptInvocation] - public int physChangeLinkSpring(UUID hostID, UUID scriptID, int linkNum, - Vector3 frameInAloc, Quaternion frameInArot, - Vector3 frameInBloc, Quaternion frameInBrot, - Vector3 linearLimitLow, Vector3 linearLimitHigh, - Vector3 angularLimitLow, Vector3 angularLimitHigh - ) - { - int ret = -1; - if (!Enabled) return ret; + SceneObjectGroup containingGroup; + SceneObjectPart rootPart; - // The part that is requesting the change. - SceneObjectPart requestingPart = BaseScene.GetSceneObjectPart(hostID); - - if (requestingPart != null) + if (GetRootPhysActor(hostID, out containingGroup, out rootPart, out rootPhysActor)) { - // The type is is always on the root of a linkset. - SceneObjectGroup containingGroup = requestingPart.ParentGroup; - SceneObjectPart rootPart = containingGroup.RootPart; - - if (rootPart != null) + SceneObjectPart linkPart = containingGroup.GetLinkNumPart(linkNum); + if (linkPart != null) { - Physics.Manager.PhysicsActor rootPhysActor = rootPart.PhysActor; - if (rootPhysActor != null) + childPhysActor = linkPart.PhysActor; + if (childPhysActor != null) { - SceneObjectPart linkPart = containingGroup.GetLinkNumPart(linkNum); - if (linkPart != null) - { - Physics.Manager.PhysicsActor linkPhysActor = linkPart.PhysActor; - if (linkPhysActor != null) - { - ret = (int)rootPhysActor.Extension(PhysFunctChangeLinkSpring, linkNum, linkPhysActor, - frameInAloc, frameInArot, - frameInBloc, frameInBrot, - linearLimitLow, linearLimitHigh, - angularLimitLow, angularLimitHigh - ); - } - else - { - m_log.WarnFormat("{0} physChangeLinkFixed: Link part has no physical actor. rootName={1}, hostID={2}, linknum={3}", - LogHeader, rootPart.Name, hostID, linkNum); - } - } - else - { - m_log.WarnFormat("{0} physChangeLinkFixed: Could not find linknum part. rootName={1}, hostID={2}, linknum={3}", - LogHeader, rootPart.Name, hostID, linkNum); - } + ret = true; } else { - m_log.WarnFormat("{0} physChangeLinkFixed: Root part does not have a physics actor. rootName={1}, hostID={2}", - LogHeader, rootPart.Name, hostID); + m_log.WarnFormat("{0} GetRootAndChildPhysActors: Link part has no physical actor. rootName={1}, hostID={2}, linknum={3}", + LogHeader, rootPart.Name, hostID, linkNum); } } else { - m_log.WarnFormat("{0} physChangeLinkFixed: Root part does not exist. RequestingPartName={1}, hostID={2}", - LogHeader, requestingPart.Name, hostID); + m_log.WarnFormat("{0} GetRootAndChildPhysActors: Could not find linknum part. rootName={1}, hostID={2}, linknum={3}", + LogHeader, rootPart.Name, hostID, linkNum); } } else { - m_log.WarnFormat("{0} physGetLinsetType: cannot find script object in scene. hostID={1}", LogHeader, hostID); + m_log.WarnFormat("{0} GetRootAndChildPhysActors: Root part does not have a physics actor. rootName={1}, hostID={2}", + LogHeader, rootPart.Name, hostID); } + return ret; } - [ScriptInvocation] - public int physChangeLinkSlider(UUID hostID, UUID scriptID, int linkNum) + // Extension() returns an object. Convert that object into the integer error we expect to return. + private int MakeIntError(object extensionRet) { - return 0; + int ret = -1; + if (extensionRet != null) + { + try + { + ret = (int)extensionRet; + } + catch + { + ret = -1; + } + } + return ret; } } } -- cgit v1.1 From f6fdfd16f55c3e1bd55775f1f21e0ac9e44ff2ee Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 9 Aug 2013 17:01:35 -0700 Subject: BulletSim: change ExtendedPhysics constants to 'const' so they can be used as case variables in switch statements. --- .../Scripting/ExtendedPhysics/ExtendedPhysics.cs | 56 +++++++++++----------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs index baf5a5b..e0f16d6 100755 --- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs @@ -160,7 +160,7 @@ public class ExtendedPhysics : INonSharedRegionModule } [ScriptConstant] - public static int PHYS_CENTER_OF_MASS = 1 << 0; + public const int PHYS_CENTER_OF_MASS = 1 << 0; [ScriptInvocation] public string physGetEngineType(UUID hostID, UUID scriptID) @@ -176,11 +176,11 @@ public class ExtendedPhysics : INonSharedRegionModule } [ScriptConstant] - public static int PHYS_LINKSET_TYPE_CONSTRAINT = 0; + public const int PHYS_LINKSET_TYPE_CONSTRAINT = 0; [ScriptConstant] - public static int PHYS_LINKSET_TYPE_COMPOUND = 1; + public const int PHYS_LINKSET_TYPE_COMPOUND = 1; [ScriptConstant] - public static int PHYS_LINKSET_TYPE_MANUAL = 2; + public const int PHYS_LINKSET_TYPE_MANUAL = 2; [ScriptInvocation] public int physSetLinksetType(UUID hostID, UUID scriptID, int linksetType) @@ -292,15 +292,15 @@ public class ExtendedPhysics : INonSharedRegionModule } [ScriptConstant] - public static int PHYS_LINK_TYPE_FIXED = 1234; + public const int PHYS_LINK_TYPE_FIXED = 1234; [ScriptConstant] - public static int PHYS_LINK_TYPE_HINGE = 4; + public const int PHYS_LINK_TYPE_HINGE = 4; [ScriptConstant] - public static int PHYS_LINK_TYPE_SPRING = 9; + public const int PHYS_LINK_TYPE_SPRING = 9; [ScriptConstant] - public static int PHYS_LINK_TYPE_6DOF = 6; + public const int PHYS_LINK_TYPE_6DOF = 6; [ScriptConstant] - public static int PHYS_LINK_TYPE_SLIDER = 7; + public const int PHYS_LINK_TYPE_SLIDER = 7; // physChangeLinkType(integer linkNum, integer typeCode) [ScriptInvocation] @@ -341,42 +341,42 @@ public class ExtendedPhysics : INonSharedRegionModule // Code for specifying params. // The choice if 14400 is arbitrary and only serves to catch parameter code misuse. - public static int PHYS_PARAM_MIN = 14401; + public const int PHYS_PARAM_MIN = 14401; [ScriptConstant] - public static int PHYS_PARAM_FRAMEINA_LOC = 14401; + public const int PHYS_PARAM_FRAMEINA_LOC = 14401; [ScriptConstant] - public static int PHYS_PARAM_FRAMEINA_ROT = 14402; + public const int PHYS_PARAM_FRAMEINA_ROT = 14402; [ScriptConstant] - public static int PHYS_PARAM_FRAMEINB_LOC = 14403; + public const int PHYS_PARAM_FRAMEINB_LOC = 14403; [ScriptConstant] - public static int PHYS_PARAM_FRAMEINB_ROT = 14404; + public const int PHYS_PARAM_FRAMEINB_ROT = 14404; [ScriptConstant] - public static int PHYS_PARAM_LINEAR_LIMIT_LOW = 14405; + public const int PHYS_PARAM_LINEAR_LIMIT_LOW = 14405; [ScriptConstant] - public static int PHYS_PARAM_LINEAR_LIMIT_HIGH = 14406; + public const int PHYS_PARAM_LINEAR_LIMIT_HIGH = 14406; [ScriptConstant] - public static int PHYS_PARAM_ANGULAR_LIMIT_LOW = 14407; + public const int PHYS_PARAM_ANGULAR_LIMIT_LOW = 14407; [ScriptConstant] - public static int PHYS_PARAM_ANGULAR_LIMIT_HIGH = 14408; + public const int PHYS_PARAM_ANGULAR_LIMIT_HIGH = 14408; [ScriptConstant] - public static int PHYS_PARAM_USE_FRAME_OFFSET = 14409; + public const int PHYS_PARAM_USE_FRAME_OFFSET = 14409; [ScriptConstant] - public static int PHYS_PARAM_ENABLE_TRANSMOTOR = 14410; + public const int PHYS_PARAM_ENABLE_TRANSMOTOR = 14410; [ScriptConstant] - public static int PHYS_PARAM_TRANSMOTOR_MAXVEL = 14411; + public const int PHYS_PARAM_TRANSMOTOR_MAXVEL = 14411; [ScriptConstant] - public static int PHYS_PARAM_TRANSMOTOR_MAXFORCE = 14412; + public const int PHYS_PARAM_TRANSMOTOR_MAXFORCE = 14412; [ScriptConstant] - public static int PHYS_PARAM_CFM = 14413; + public const int PHYS_PARAM_CFM = 14413; [ScriptConstant] - public static int PHYS_PARAM_ERP = 14414; + public const int PHYS_PARAM_ERP = 14414; [ScriptConstant] - public static int PHYS_PARAM_SOLVER_ITERATIONS = 14415; + public const int PHYS_PARAM_SOLVER_ITERATIONS = 14415; [ScriptConstant] - public static int PHYS_PARAM_SPRING_DAMPING = 14416; + public const int PHYS_PARAM_SPRING_DAMPING = 14416; [ScriptConstant] - public static int PHYS_PARAM_SPRING_STIFFNESS = 14417; - public static int PHYS_PARAM_MAX = 14417; + public const int PHYS_PARAM_SPRING_STIFFNESS = 14417; + public const int PHYS_PARAM_MAX = 14417; // physChangeLinkParams(integer linkNum, [ PHYS_PARAM_*, value, PHYS_PARAM_*, value, ...]) [ScriptInvocation] -- cgit v1.1 From e1120cb74db9092cc0f9a7fc245d2f2ed6160b7a Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 16 Aug 2013 13:44:31 -0700 Subject: BulletSim: add extended physics function physGetLinkType(linkNum). Add implementation of physChangeLinkParams() in BSLinksetConstraint. --- .../Scripting/ExtendedPhysics/ExtendedPhysics.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs index e0f16d6..d035f7b 100755 --- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs @@ -64,6 +64,7 @@ public class ExtendedPhysics : INonSharedRegionModule public const string PhysFunctSetLinksetType = "BulletSim.SetLinksetType"; public const string PhysFunctChangeLinkFixed = "BulletSim.ChangeLinkFixed"; public const string PhysFunctChangeLinkType = "BulletSim.ChangeLinkType"; + public const string PhysFunctGetLinkType = "BulletSim.GetLinkType"; public const string PhysFunctChangeLinkParams = "BulletSim.ChangeLinkParams"; // ============================================================= @@ -320,6 +321,24 @@ public class ExtendedPhysics : INonSharedRegionModule return ret; } + // physGetLinkType(integer linkNum) + [ScriptInvocation] + public int physGetLinkType(UUID hostID, UUID scriptID, int linkNum, int typeCode) + { + int ret = -1; + if (!Enabled) return ret; + + PhysicsActor rootPhysActor; + PhysicsActor childPhysActor; + + if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor)) + { + ret = MakeIntError(rootPhysActor.Extension(PhysFunctGetLinkType, childPhysActor)); + } + + return ret; + } + // physChangeLinkFixed(integer linkNum) // Change the link between the root and the linkNum into a fixed, static physical connection. [ScriptInvocation] -- cgit v1.1 From 4781297b4ee5908b76039ce3b38291eb2e89e157 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 20 Aug 2013 08:14:08 -0700 Subject: BulletSim: Extension parameters passed through the classes made to pass just and array of objects rather than a mixture of parameters and array. Makes understanding and parsing what is being passed much easier. --- .../Scripting/ExtendedPhysics/ExtendedPhysics.cs | 23 +++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs index d035f7b..90cf15a 100755 --- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs @@ -315,7 +315,8 @@ public class ExtendedPhysics : INonSharedRegionModule if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor)) { - ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, childPhysActor, typeCode)); + object[] parms = { childPhysActor, typeCode }; + ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, parms)); } return ret; @@ -323,7 +324,7 @@ public class ExtendedPhysics : INonSharedRegionModule // physGetLinkType(integer linkNum) [ScriptInvocation] - public int physGetLinkType(UUID hostID, UUID scriptID, int linkNum, int typeCode) + public int physGetLinkType(UUID hostID, UUID scriptID, int linkNum) { int ret = -1; if (!Enabled) return ret; @@ -333,7 +334,8 @@ public class ExtendedPhysics : INonSharedRegionModule if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor)) { - ret = MakeIntError(rootPhysActor.Extension(PhysFunctGetLinkType, childPhysActor)); + object[] parms = { childPhysActor }; + ret = MakeIntError(rootPhysActor.Extension(PhysFunctGetLinkType, parms)); } return ret; @@ -352,7 +354,8 @@ public class ExtendedPhysics : INonSharedRegionModule if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor)) { - ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, childPhysActor, PHYS_LINK_TYPE_FIXED)); + object[] parms = { childPhysActor , PHYS_LINK_TYPE_FIXED }; + ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, parms)); } return ret; @@ -409,7 +412,8 @@ public class ExtendedPhysics : INonSharedRegionModule if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor)) { - ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkParams, childPhysActor, parms)); + object[] parms2 = AddToBeginningOfArray(childPhysActor, parms); + ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkParams, parms2)); } return ret; @@ -513,6 +517,15 @@ public class ExtendedPhysics : INonSharedRegionModule return ret; } + // Return an array of objects with the passed object as the first object of a new array + private object[] AddToBeginningOfArray(object firstOne, object[] prevArray) + { + object[] newArray = new object[1 + prevArray.Length]; + newArray[0] = firstOne; + prevArray.CopyTo(newArray, 1); + return newArray; + } + // Extension() returns an object. Convert that object into the integer error we expect to return. private int MakeIntError(object extensionRet) { -- cgit v1.1 From d09c35f5063114880aecb94a938bfc49f5af5f7d Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 20 Aug 2013 13:09:40 -0700 Subject: BulletSim: pass both root and child BSPhysObjects to Extension function. Update routines to use the new parameters list from above change. --- .../Scripting/ExtendedPhysics/ExtendedPhysics.cs | 30 ++++++++++++---------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs index 90cf15a..10e13b9 100755 --- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs @@ -220,7 +220,8 @@ public class ExtendedPhysics : INonSharedRegionModule containingGroup.UpdateGroupPosition(containingGroup.AbsolutePosition); containingGroup.UpdateGroupRotationR(containingGroup.GroupRotation); - ret = MakeIntError(rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType)); + object[] parms2 = { rootPhysActor, null, linksetType }; + ret = MakeIntError(rootPhysActor.Extension(PhysFunctSetLinksetType, parms2)); Thread.Sleep(150); // longer than one heartbeat tick containingGroup.ScriptSetPhysicsStatus(true); @@ -229,7 +230,8 @@ public class ExtendedPhysics : INonSharedRegionModule { // Non-physical linksets don't have a physical instantiation so there is no state to // worry about being updated. - ret = MakeIntError(rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType)); + object[] parms2 = { rootPhysActor, null, linksetType }; + ret = MakeIntError(rootPhysActor.Extension(PhysFunctSetLinksetType, parms2)); } } else @@ -271,7 +273,8 @@ public class ExtendedPhysics : INonSharedRegionModule PhysicsActor rootPhysActor = rootPart.PhysActor; if (rootPhysActor != null) { - ret = MakeIntError(rootPhysActor.Extension(PhysFunctGetLinksetType)); + object[] parms2 = { rootPhysActor, null }; + ret = MakeIntError(rootPhysActor.Extension(PhysFunctGetLinksetType, parms2)); } else { @@ -315,8 +318,8 @@ public class ExtendedPhysics : INonSharedRegionModule if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor)) { - object[] parms = { childPhysActor, typeCode }; - ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, parms)); + object[] parms2 = { rootPhysActor, childPhysActor, typeCode }; + ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, parms2)); } return ret; @@ -334,8 +337,8 @@ public class ExtendedPhysics : INonSharedRegionModule if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor)) { - object[] parms = { childPhysActor }; - ret = MakeIntError(rootPhysActor.Extension(PhysFunctGetLinkType, parms)); + object[] parms2 = { rootPhysActor, childPhysActor }; + ret = MakeIntError(rootPhysActor.Extension(PhysFunctGetLinkType, parms2)); } return ret; @@ -354,8 +357,8 @@ public class ExtendedPhysics : INonSharedRegionModule if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor)) { - object[] parms = { childPhysActor , PHYS_LINK_TYPE_FIXED }; - ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, parms)); + object[] parms2 = { rootPhysActor, childPhysActor , PHYS_LINK_TYPE_FIXED }; + ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, parms2)); } return ret; @@ -412,7 +415,7 @@ public class ExtendedPhysics : INonSharedRegionModule if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor)) { - object[] parms2 = AddToBeginningOfArray(childPhysActor, parms); + object[] parms2 = AddToBeginningOfArray(rootPhysActor, childPhysActor, parms); ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkParams, parms2)); } @@ -518,11 +521,12 @@ public class ExtendedPhysics : INonSharedRegionModule } // Return an array of objects with the passed object as the first object of a new array - private object[] AddToBeginningOfArray(object firstOne, object[] prevArray) + private object[] AddToBeginningOfArray(object firstOne, object secondOne, object[] prevArray) { - object[] newArray = new object[1 + prevArray.Length]; + object[] newArray = new object[2 + prevArray.Length]; newArray[0] = firstOne; - prevArray.CopyTo(newArray, 1); + newArray[1] = secondOne; + prevArray.CopyTo(newArray, 2); return newArray; } -- cgit v1.1 From 30b3657a66e5a4012b96baae2c0424ec13409f83 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 22 Aug 2013 09:08:58 -0700 Subject: BulletSim: implementation of setting spring specific physical parameters. Add setting of linkset type to physChangeLinkParams. Lots of detail logging for setting of linkset constraint parameters. --- .../OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs index 10e13b9..2f88e2b 100755 --- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs @@ -367,6 +367,7 @@ public class ExtendedPhysics : INonSharedRegionModule // Code for specifying params. // The choice if 14400 is arbitrary and only serves to catch parameter code misuse. public const int PHYS_PARAM_MIN = 14401; + [ScriptConstant] public const int PHYS_PARAM_FRAMEINA_LOC = 14401; [ScriptConstant] @@ -401,7 +402,10 @@ public class ExtendedPhysics : INonSharedRegionModule public const int PHYS_PARAM_SPRING_DAMPING = 14416; [ScriptConstant] public const int PHYS_PARAM_SPRING_STIFFNESS = 14417; - public const int PHYS_PARAM_MAX = 14417; + [ScriptConstant] + public const int PHYS_PARAM_LINK_TYPE = 14418; + + public const int PHYS_PARAM_MAX = 14418; // physChangeLinkParams(integer linkNum, [ PHYS_PARAM_*, value, PHYS_PARAM_*, value, ...]) [ScriptInvocation] -- cgit v1.1 From 7c54630a2dde768e92b3034d76314cb1e061c348 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 22 Aug 2013 16:31:17 -0700 Subject: BulletSim: add axis parameter for specifying enable, damping, and stiffness for spring constraints. Renumber parameter ops since I can as no one is using them yet. --- .../Scripting/ExtendedPhysics/ExtendedPhysics.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs index 2f88e2b..ef106bd 100755 --- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs @@ -399,13 +399,15 @@ public class ExtendedPhysics : INonSharedRegionModule [ScriptConstant] public const int PHYS_PARAM_SOLVER_ITERATIONS = 14415; [ScriptConstant] - public const int PHYS_PARAM_SPRING_DAMPING = 14416; + public const int PHYS_PARAM_SPRING_AXIS_ENABLE = 14416; [ScriptConstant] - public const int PHYS_PARAM_SPRING_STIFFNESS = 14417; + public const int PHYS_PARAM_SPRING_DAMPING = 14417; [ScriptConstant] - public const int PHYS_PARAM_LINK_TYPE = 14418; + public const int PHYS_PARAM_SPRING_STIFFNESS = 14418; + [ScriptConstant] + public const int PHYS_PARAM_LINK_TYPE = 14419; - public const int PHYS_PARAM_MAX = 14418; + public const int PHYS_PARAM_MAX = 14419; // physChangeLinkParams(integer linkNum, [ PHYS_PARAM_*, value, PHYS_PARAM_*, value, ...]) [ScriptInvocation] -- cgit v1.1 From cf2cdc191d0a93860da1ff4c42d34138e8f369fb Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sat, 24 Aug 2013 08:33:28 -0700 Subject: BulletSim: ability to specify groups of axis to modify in constraint parameters that control multiple axis. Add useLinearReferenceFrameA constraint parameter. --- .../Scripting/ExtendedPhysics/ExtendedPhysics.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs index ef106bd..94367f5 100755 --- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs @@ -406,8 +406,18 @@ public class ExtendedPhysics : INonSharedRegionModule public const int PHYS_PARAM_SPRING_STIFFNESS = 14418; [ScriptConstant] public const int PHYS_PARAM_LINK_TYPE = 14419; + [ScriptConstant] + public const int PHYS_PARAM_USE_LINEAR_FRAMEA = 14420; + + public const int PHYS_PARAM_MAX = 14420; - public const int PHYS_PARAM_MAX = 14419; + // Used when specifying a parameter that has settings for the three linear and three angular axis + [ScriptConstant] + public const int PHYS_AXIS_ALL = -1; + [ScriptConstant] + public const int PHYS_AXIS_ALL_LINEAR = -2; + [ScriptConstant] + public const int PHYS_AXIS_ALL_ANGULAR = -3; // physChangeLinkParams(integer linkNum, [ PHYS_PARAM_*, value, PHYS_PARAM_*, value, ...]) [ScriptInvocation] -- cgit v1.1 From 5827b6e1aabf2e19624faf0141b9611917fb84c5 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 4 Sep 2013 07:56:59 -0700 Subject: BulletSim: add extended physics LSL constants for axis specification. Add specific error warnings for mis-matched parameter types in extended physics functions. --- .../Scripting/ExtendedPhysics/ExtendedPhysics.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs index 94367f5..b0b0bc6 100755 --- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs @@ -415,9 +415,21 @@ public class ExtendedPhysics : INonSharedRegionModule [ScriptConstant] public const int PHYS_AXIS_ALL = -1; [ScriptConstant] - public const int PHYS_AXIS_ALL_LINEAR = -2; + public const int PHYS_AXIS_LINEAR_ALL = -2; [ScriptConstant] - public const int PHYS_AXIS_ALL_ANGULAR = -3; + public const int PHYS_AXIS_ANGULAR_ALL = -3; + [ScriptConstant] + public const int PHYS_AXIS_LINEAR_X = 0; + [ScriptConstant] + public const int PHYS_AXIS_LINEAR_Y = 1; + [ScriptConstant] + public const int PHYS_AXIS_LINEAR_Z = 2; + [ScriptConstant] + public const int PHYS_AXIS_ANGULAR_X = 3; + [ScriptConstant] + public const int PHYS_AXIS_ANGULAR_Y = 4; + [ScriptConstant] + public const int PHYS_AXIS_ANGULAR_Z = 5; // physChangeLinkParams(integer linkNum, [ PHYS_PARAM_*, value, PHYS_PARAM_*, value, ...]) [ScriptInvocation] -- cgit v1.1 From c5eabb28b4c933cfacefa85381e290372fbc094e Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 9 Sep 2013 14:53:16 -0700 Subject: BulletSim: add LSL function and plumbing for setting a spring equilibrium point in the physics engine constraint. --- .../OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs index b0b0bc6..9daf9d7 100755 --- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs @@ -408,8 +408,10 @@ public class ExtendedPhysics : INonSharedRegionModule public const int PHYS_PARAM_LINK_TYPE = 14419; [ScriptConstant] public const int PHYS_PARAM_USE_LINEAR_FRAMEA = 14420; + [ScriptConstant] + public const int PHYS_PARAM_SPRING_EQUILIBRIUM_POINT = 14421; - public const int PHYS_PARAM_MAX = 14420; + public const int PHYS_PARAM_MAX = 14421; // Used when specifying a parameter that has settings for the three linear and three angular axis [ScriptConstant] -- cgit v1.1 From 6bdef1f70b782b69090e5846f9463942857d97cd Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 19 Sep 2013 20:49:55 +0100 Subject: minor: Stop debug logging whenever an npc is moved, other npc log related formatting cleanups --- .../Region/OptionalModules/World/NPC/NPCModule.cs | 31 +++++++++++----------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index c26fdfc..b863370 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -146,9 +146,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC int.MaxValue); m_log.DebugFormat( - "[NPC MODULE]: Creating NPC {0} {1} {2}, owner={3}, senseAsAgent={4} at {5} in {6}", - firstname, lastname, npcAvatar.AgentId, owner, - senseAsAgent, position, scene.RegionInfo.RegionName); + "[NPC MODULE]: Creating NPC {0} {1} {2}, owner={3}, senseAsAgent={4} at {5} in {6}", + firstname, lastname, npcAvatar.AgentId, owner, + senseAsAgent, position, scene.RegionInfo.RegionName); AgentCircuitData acd = new AgentCircuitData(); acd.AgentID = npcAvatar.AgentId; @@ -188,16 +188,16 @@ namespace OpenSim.Region.OptionalModules.World.NPC sp.CompleteMovement(npcAvatar, false); m_avatars.Add(npcAvatar.AgentId, npcAvatar); - m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", - npcAvatar.AgentId, sp.Name); + m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", npcAvatar.AgentId, sp.Name); return npcAvatar.AgentId; } else { m_log.WarnFormat( - "[NPC MODULE]: Could not find scene presence for NPC {0} {1}", - sp.Name, sp.UUID); + "[NPC MODULE]: Could not find scene presence for NPC {0} {1}", + sp.Name, sp.UUID); + return UUID.Zero; } } @@ -213,10 +213,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC ScenePresence sp; if (scene.TryGetScenePresence(agentID, out sp)) { - m_log.DebugFormat( - "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}", - sp.Name, pos, scene.RegionInfo.RegionName, - noFly, landAtTarget); +// m_log.DebugFormat( +// "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}", +// sp.Name, pos, scene.RegionInfo.RegionName, +// noFly, landAtTarget); sp.MoveToTarget(pos, noFly, landAtTarget); sp.SetAlwaysRun = running; @@ -293,9 +293,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC ScenePresence sp; if (scene.TryGetScenePresence(agentID, out sp)) { - sp.HandleAgentRequestSit(m_avatars[agentID], agentID, - partID, Vector3.Zero); - //sp.HandleAgentSit(m_avatars[agentID], agentID); + sp.HandleAgentRequestSit(m_avatars[agentID], agentID, partID, Vector3.Zero); return true; } @@ -387,8 +385,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC */ scene.IncomingCloseAgent(agentID, false); -// scene.RemoveClient(agentID, false); + m_avatars.Remove(agentID); + /* m_log.DebugFormat("[NPC MODULE]: Removed NPC {0} {1}", agentID, av.Name); @@ -427,4 +426,4 @@ namespace OpenSim.Region.OptionalModules.World.NPC av.OwnerID == callerID; } } -} +} \ No newline at end of file -- cgit v1.1 From b16bc7b01ca0691758e66f85238d657f02271082 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 27 Sep 2013 19:14:21 +0100 Subject: refactor: rename Scene.IncomingCloseAgent() to CloseAgent() in order to make it clear that all non-clientstack callers should be using this rather than RemoveClient() in order to step through the ScenePresence state machine properly. Adds IScene.CloseAgent() to replace RemoveClient() --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index b863370..740f75a 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -384,7 +384,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC agentID, av.Name); */ - scene.IncomingCloseAgent(agentID, false); + scene.CloseAgent(agentID, false); m_avatars.Remove(agentID); -- cgit v1.1 From 2cd95fac736cc99b1a2ad661e4a03810225ffaca Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 27 Sep 2013 22:27:39 +0100 Subject: refactor: Rename Scene.AddNewClient() to AddNewAgent() to make it obvious in the code that this is symmetric with CloseAgent() --- .../Agent/InternetRelayClientView/Server/IRCClientView.cs | 2 +- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index 23a435d..a4fc4ae 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -903,7 +903,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server public void Start() { - m_scene.AddNewClient(this, PresenceType.User); + m_scene.AddNewAgent(this, PresenceType.User); // Mimicking LLClientView which gets always set appearance from client. AvatarAppearance appearance; diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 740f75a..fffe1ab 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -175,7 +175,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC { scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd); - scene.AddNewClient(npcAvatar, PresenceType.Npc); + scene.AddNewAgent(npcAvatar, PresenceType.Npc); ScenePresence sp; if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) -- cgit v1.1 From 970249a3c7b1d9cffe88eb8d7075cce6fa8ca3d9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 4 Oct 2013 19:40:43 +0100 Subject: Add OnChatToNPC and OnInstantMessageToNPC messages to NPCAvatar to allow region modules to directly subscribe to chat and messages received by NPCs Currently still requires INPC from NPCModule.GetNPC() to be cast to an NPCAvatar. --- .../Region/OptionalModules/World/NPC/NPCAvatar.cs | 27 +++++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 9a61702..a895ee1 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -44,6 +44,20 @@ namespace OpenSim.Region.OptionalModules.World.NPC { public bool SenseAsAgent { get; set; } + public delegate void ChatToNPC( + string message, byte type, Vector3 fromPos, string fromName, + UUID fromAgentID, UUID ownerID, byte source, byte audible); + + /// + /// Fired when the NPC receives a chat message. + /// + public event ChatToNPC OnChatToNPC; + + /// + /// Fired when the NPC receives an instant message. + /// + public event Action OnInstantMessageToNPC; + private readonly string m_firstname; private readonly string m_lastname; private readonly Vector3 m_startPos; @@ -614,17 +628,18 @@ namespace OpenSim.Region.OptionalModules.World.NPC string message, byte type, Vector3 fromPos, string fromName, UUID fromAgentID, UUID ownerID, byte source, byte audible) { - } + ChatToNPC ctn = OnChatToNPC; - public virtual void SendChatMessage( - byte[] message, byte type, Vector3 fromPos, string fromName, - UUID fromAgentID, UUID ownerID, byte source, byte audible) - { + if (ctn != null) + ctn(message, type, fromPos, fromName, fromAgentID, ownerID, source, audible); } public void SendInstantMessage(GridInstantMessage im) { - + Action oimtn = OnInstantMessageToNPC; + + if (oimtn != null) + oimtn(im); } public void SendGenericMessage(string method, UUID invoice, List message) -- cgit v1.1 From 42bdf446585007029faf4cd21abd289487f0f797 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 4 Oct 2013 23:33:47 +0100 Subject: Bump OPenSimulator version and assembly versions up to 0.8.0 Dev --- OpenSim/Region/OptionalModules/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Properties/AssemblyInfo.cs b/OpenSim/Region/OptionalModules/Properties/AssemblyInfo.cs index 70bda72..ba0b578 100644 --- a/OpenSim/Region/OptionalModules/Properties/AssemblyInfo.cs +++ b/OpenSim/Region/OptionalModules/Properties/AssemblyInfo.cs @@ -30,7 +30,7 @@ using Mono.Addins; // Build Number // Revision // -[assembly: AssemblyVersion("0.7.6.*")] +[assembly: AssemblyVersion("0.8.0.*")] [assembly: Addin("OpenSim.Region.OptionalModules", "0.1")] -- cgit v1.1 From 5ca7395e175b476fd20fcf97383c8eb09b64ae3a Mon Sep 17 00:00:00 2001 From: Kevin Cozens Date: Fri, 2 Aug 2013 15:26:28 -0400 Subject: Added support for attachments to group notices when using Flotsam groups. --- .../Avatar/XmlRpcGroups/GroupsModule.cs | 172 +++++++++++++++------ 1 file changed, 122 insertions(+), 50 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs index d744a14..d09d3ad 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs @@ -39,6 +39,7 @@ using OpenSim.Framework.Communications; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; +using System.Text; using DirFindFlags = OpenMetaverse.DirectoryManager.DirFindFlags; namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups @@ -421,44 +422,75 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups string Subject = im.message.Substring(0, im.message.IndexOf('|')); string Message = im.message.Substring(Subject.Length + 1); + InventoryItemBase item = null; + bool hasAttachment = false; + UUID itemID = UUID.Zero; //Assignment to quiet compiler + UUID ownerID = UUID.Zero; //Assignment to quiet compiler byte[] bucket; - if ((im.binaryBucket.Length == 1) && (im.binaryBucket[0] == 0)) - { - bucket = new byte[19]; - bucket[0] = 0; //dunno - bucket[1] = 0; //dunno - GroupID.ToBytes(bucket, 2); - bucket[18] = 0; //dunno - } - else + if (im.binaryBucket.Length >= 1 && im.binaryBucket[0] > 0) { string binBucket = OpenMetaverse.Utils.BytesToString(im.binaryBucket); binBucket = binBucket.Remove(0, 14).Trim(); - if (m_debugEnabled) + + OSDMap binBucketOSD = (OSDMap)OSDParser.DeserializeLLSDXml(binBucket); + if (binBucketOSD is OSD) { - m_log.WarnFormat("I don't understand a group notice binary bucket of: {0}", binBucket); + OSDMap binBucketMap = (OSDMap)binBucketOSD; + + itemID = binBucketMap["item_id"].AsUUID(); + ownerID = binBucketMap["owner_id"].AsUUID(); - OSDMap binBucketOSD = (OSDMap)OSDParser.DeserializeLLSDXml(binBucket); - - foreach (string key in binBucketOSD.Keys) + //Attempt to get the details of the attached item. + //If sender doesn't own the attachment, the item + //variable will be set to null and attachment will + //not be included with the group notice. + Scene scene = (Scene)remoteClient.Scene; + item = new InventoryItemBase(itemID, ownerID); + item = scene.InventoryService.GetItem(item); + + if (item != null) { - if (binBucketOSD.ContainsKey(key)) - { - m_log.WarnFormat("{0}: {1}", key, binBucketOSD[key].ToString()); - } + //Got item details so include the attachment. + hasAttachment = true; } } - - // treat as if no attachment + else + { + m_log.DebugFormat("[Groups]: Received OSD with unexpected type: {0}", binBucketOSD.GetType()); + } + } + + if (hasAttachment) + { + //Bucket contains information about attachment. + // + //Byte offset and description of bucket data: + //0: 1 byte indicating if attachment is present + //1: 1 byte indicating the type of attachment + //2: 16 bytes - Group UUID + //18: 16 bytes - UUID of the attachment owner + //34: 16 bytes - UUID of the attachment + //50: variable - Name of the attachment + //??: NUL byte to terminate the attachment name + byte[] name = Encoding.UTF8.GetBytes(item.Name); + bucket = new byte[51 + name.Length];//3 bytes, 3 UUIDs, and name + bucket[0] = 1; //Has attachment flag + bucket[1] = (byte)item.InvType; //Type of Attachment + GroupID.ToBytes(bucket, 2); + ownerID.ToBytes(bucket, 18); + itemID.ToBytes(bucket, 34); + name.CopyTo(bucket, 50); + } + else + { bucket = new byte[19]; - bucket[0] = 0; //dunno - bucket[1] = 0; //dunno + bucket[0] = 0; //Has attachment flag + bucket[1] = 0; //Type of attachment GroupID.ToBytes(bucket, 2); - bucket[18] = 0; //dunno + bucket[18] = 0; //NUL terminate name of attachment } - m_groupData.AddGroupNotice(GetRequestingAgentID(remoteClient), GroupID, NoticeID, im.fromAgentName, Subject, Message, bucket); if (OnNewGroupNotice != null) { @@ -483,7 +515,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups if (member.AcceptNotices) { - // Build notice IIM + // Build notice IM GridInstantMessage msg = CreateGroupNoticeIM(UUID.Zero, NoticeID, (byte)OpenMetaverse.InstantMessageDialog.GroupNotice); msg.toAgentID = member.AgentID.Guid; @@ -492,10 +524,40 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups } } } - + + if (im.dialog == (byte)InstantMessageDialog.GroupNoticeInventoryAccepted) + { + //Is bucket large enough to hold UUID of the attachment? + if (im.binaryBucket.Length < 16) + return; + + UUID noticeID = new UUID(im.imSessionID); + + GroupNoticeInfo notice = m_groupData.GetGroupNotice(GetRequestingAgentID(remoteClient), noticeID); + if (notice != null) + { + UUID giver = new UUID(notice.BinaryBucket, 18); + UUID attachmentUUID = new UUID(notice.BinaryBucket, 34); + + if (m_debugEnabled) + m_log.DebugFormat("[Groups]: Giving inventory from {0} to {1}", giver, remoteClient.AgentId); + + InventoryItemBase itemCopy = ((Scene)(remoteClient.Scene)).GiveInventoryItem(remoteClient.AgentId, + giver, attachmentUUID); + + if (itemCopy == null) + { + remoteClient.SendAgentAlertMessage("Can't find item to give. Nothing given.", false); + return; + } + + remoteClient.SendInventoryItemCreateUpdate(itemCopy, 0); + } + } + // Interop, received special 210 code for ejecting a group member // this only works within the comms servers domain, and won't work hypergrid - // TODO:FIXME: Use a presense server of some kind to find out where the + // TODO:FIXME: Use a presence server of some kind to find out where the // client actually is, and try contacting that region directly to notify them, // or provide the notification via xmlrpc update queue if ((im.dialog == 210)) @@ -873,26 +935,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups if (data != null) { - GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), data.GroupID, null); - - GridInstantMessage msg = new GridInstantMessage(); - msg.imSessionID = UUID.Zero.Guid; - msg.fromAgentID = data.GroupID.Guid; - msg.toAgentID = GetRequestingAgentID(remoteClient).Guid; - msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); - msg.fromAgentName = "Group Notice : " + groupInfo == null ? "Unknown" : groupInfo.GroupName; - msg.message = data.noticeData.Subject + "|" + data.Message; - msg.dialog = (byte)OpenMetaverse.InstantMessageDialog.GroupNoticeRequested; - msg.fromGroup = true; - msg.offline = (byte)0; - msg.ParentEstateID = 0; - msg.Position = Vector3.Zero; - msg.RegionID = UUID.Zero.Guid; - msg.binaryBucket = data.BinaryBucket; + GridInstantMessage msg = CreateGroupNoticeIM(remoteClient.AgentId, groupNoticeID, (byte)InstantMessageDialog.GroupNoticeRequested); OutgoingInstantMessage(msg, GetRequestingAgentID(remoteClient)); } - } public GridInstantMessage CreateGroupNoticeIM(UUID agentID, UUID groupNoticeID, byte dialog) @@ -900,10 +946,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); GridInstantMessage msg = new GridInstantMessage(); - msg.imSessionID = UUID.Zero.Guid; + byte[] bucket; + + msg.imSessionID = groupNoticeID.Guid; msg.toAgentID = agentID.Guid; msg.dialog = dialog; - // msg.dialog = (byte)OpenMetaverse.InstantMessageDialog.GroupNotice; msg.fromGroup = true; msg.offline = (byte)0; msg.ParentEstateID = 0; @@ -917,13 +964,38 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups msg.timestamp = info.noticeData.Timestamp; msg.fromAgentName = info.noticeData.FromName; msg.message = info.noticeData.Subject + "|" + info.Message; - msg.binaryBucket = info.BinaryBucket; + + if (info.BinaryBucket[0] > 0) + { + //32 is due to not needing space for two of the UUIDs. + //(Don't need UUID of attachment or its owner in IM) + //50 offset gets us to start of attachment name. + //We are skipping the attachment flag, type, and + //the three UUID fields at the start of the bucket. + bucket = new byte[info.BinaryBucket.Length-32]; + bucket[0] = 1; //Has attachment + bucket[1] = info.BinaryBucket[1]; + Array.Copy(info.BinaryBucket, 50, + bucket, 18, info.BinaryBucket.Length-50); + } + else + { + bucket = new byte[19]; + bucket[0] = 0; //No attachment + bucket[1] = 0; //Attachment type + bucket[18] = 0; //NUL terminate name + } + + info.GroupID.ToBytes(bucket, 2); + msg.binaryBucket = bucket; } else { - if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Group Notice {0} not found, composing empty message.", groupNoticeID); + if (m_debugEnabled) + m_log.DebugFormat("[GROUPS]: Group Notice {0} not found, composing empty message.", groupNoticeID); + msg.fromAgentID = UUID.Zero.Guid; - msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); ; + msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); msg.fromAgentName = string.Empty; msg.message = string.Empty; msg.binaryBucket = new byte[0]; @@ -1047,7 +1119,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups // Message to ejector // Interop, received special 210 code for ejecting a group member // this only works within the comms servers domain, and won't work hypergrid - // TODO:FIXME: Use a presense server of some kind to find out where the + // TODO:FIXME: Use a presence server of some kind to find out where the // client actually is, and try contacting that region directly to notify them, // or provide the notification via xmlrpc update queue -- cgit v1.1 From 7cab41f4223b7febd3fdd42fa7cfefef25e4a9c9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 15 Nov 2013 21:45:08 +0000 Subject: refactor: replace verbose checks with String.IsNullOrEmpty where applicable. Thanks to Kira for this patch from http://opensimulator.org/mantis/view.php?id=6845 --- OpenSim/Region/OptionalModules/Avatar/Chat/ChannelState.cs | 2 +- .../OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | 8 ++++---- .../Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs | 5 ++--- .../Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs | 5 ++--- 4 files changed, 9 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/ChannelState.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/ChannelState.cs index 5a37fad..b5d9fda 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Chat/ChannelState.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Chat/ChannelState.cs @@ -461,7 +461,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat string result = instr; - if (result == null || result.Length == 0) + if (string.IsNullOrEmpty(result)) return result; // Repeatedly scan the string until all possible diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs index cdab116..b4fae9d 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs @@ -822,11 +822,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice { string requrl = String.Format(m_vivoxChannelPath, m_vivoxServer, "create", channelId, m_authToken); - if (parent != null && parent != String.Empty) + if (!string.IsNullOrEmpty(parent)) { requrl = String.Format("{0}&chan_parent={1}", requrl, parent); } - if (description != null && description != String.Empty) + if (!string.IsNullOrEmpty(description)) { requrl = String.Format("{0}&chan_desc={1}", requrl, description); } @@ -862,7 +862,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice // requrl = String.Format("{0}&chan_parent={1}", requrl, parent); // } - if (description != null && description != String.Empty) + if (!string.IsNullOrEmpty(description)) { requrl = String.Format("{0}&chan_desc={1}", requrl, description); } @@ -1047,7 +1047,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice private XmlElement VivoxDeleteChannel(string parent, string channelid) { string requrl = String.Format(m_vivoxChannelDel, m_vivoxServer, "delete", channelid, m_authToken); - if (parent != null && parent != String.Empty) + if (!string.IsNullOrEmpty(parent)) { requrl = String.Format("{0}&chan_parent={1}", requrl, parent); } diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs index 7bae8f7..8095b28 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs @@ -212,8 +212,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]: Initializing {0}", this.Name); m_groupsServerURI = groupsConfig.GetString("GroupsServerURI", string.Empty); - if ((m_groupsServerURI == null) || - (m_groupsServerURI == string.Empty)) + if (string.IsNullOrEmpty(m_groupsServerURI)) { m_log.ErrorFormat("Please specify a valid Simian Server for GroupsServerURI in OpenSim.ini, [Groups]"); m_connectorEnabled = false; @@ -438,7 +437,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups return null; } } - else if ((groupName != null) && (groupName != string.Empty)) + else if (!string.IsNullOrEmpty(groupName)) { if (!SimianGetFirstGenericEntry("Group", groupName, out groupID, out GroupInfoMap)) { diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs index 71b24ac..e28d0c2 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs @@ -168,8 +168,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups m_log.DebugFormat("[XMLRPC-GROUPS-CONNECTOR]: Initializing {0}", this.Name); m_groupsServerURI = groupsConfig.GetString("GroupsServerURI", string.Empty); - if ((m_groupsServerURI == null) || - (m_groupsServerURI == string.Empty)) + if (string.IsNullOrEmpty(m_groupsServerURI)) { m_log.ErrorFormat("Please specify a valid URL for GroupsServerURI in OpenSim.ini, [Groups]"); m_connectorEnabled = false; @@ -354,7 +353,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups { param["GroupID"] = GroupID.ToString(); } - if ((GroupName != null) && (GroupName != string.Empty)) + if (!string.IsNullOrEmpty(GroupName)) { param["Name"] = GroupName.ToString(); } -- cgit v1.1 From 73dadef8df794868f8db59cc2dca0cae090bb536 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Wed, 27 Nov 2013 12:01:09 -0800 Subject: Change the log level for the LOGIN DISABLED and LOGIN ENABLED messages is the RegionReady module to be warn so that the message will show up in the log for simulators running in a more production mode (knowing when logins are functional is useful). --- .../Scripting/RegionReadyModule/RegionReadyModule.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs index c550c44..c717128 100644 --- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs @@ -105,7 +105,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady m_scene.LoginLock = true; m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue; - m_log.InfoFormat("[RegionReady]: Region {0} - LOGINS DISABLED DURING INITIALIZATION.", m_scene.Name); + // Warn level because the region cannot be used while logins are disabled + m_log.WarnFormat("[RegionReady]: Region {0} - LOGINS DISABLED DURING INITIALIZATION.", m_scene.Name); if (m_uri != string.Empty) { @@ -215,7 +216,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady // m_log.InfoFormat("[RegionReady]: Logins enabled for {0}, Oar {1}", // m_scene.RegionInfo.RegionName, m_oarFileLoading.ToString()); - m_log.InfoFormat( + // Warn level because the region cannot be used while logins are disabled + m_log.WarnFormat( "[RegionReady]: INITIALIZATION COMPLETE FOR {0} - LOGINS ENABLED", m_scene.Name); } -- cgit v1.1 From 5b73b9c4a85335ba837280688b903fef44be8f35 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 11 Dec 2013 01:39:56 +0000 Subject: Committing the Avination Scene Presence and related texture code - Parts of region crossing code - New bakes handling code - Bakes now sent from sim to sim without central storage - Appearance handling changes - Some changes to sitting - A number of unrelated fixes and improvements --- .../Agent/InternetRelayClientView/Server/IRCClientView.cs | 2 +- OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index a4fc4ae..b3fdd22 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -908,7 +908,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server // Mimicking LLClientView which gets always set appearance from client. AvatarAppearance appearance; m_scene.GetAvatarAppearance(this, out appearance); - OnSetAppearance(this, appearance.Texture, (byte[])appearance.VisualParams.Clone(), new List()); + OnSetAppearance(this, appearance.Texture, (byte[])appearance.VisualParams.Clone(),appearance.AvatarSize, new WearableCacheItem[0]); } public void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args) diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index f841d5c..e1ef4d0 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs @@ -110,6 +110,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests // ScenePresence.SendInitialData() to reset our entire appearance. m_scene.AssetService.Store(AssetHelpers.CreateNotecardAsset(originalFace8TextureId)); +/* m_afMod.SetAppearance(sp, originalTe, null); UUID npcId = m_npcMod.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, sp.Appearance); @@ -125,6 +126,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests // Have to account for both SP and NPC. Assert.That(m_scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(2)); +*/ } [Test] -- cgit v1.1 From 54cc22976868dcdc0dd0143a0134fba7392af525 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 14 Dec 2013 00:10:32 +0000 Subject: Fix TestSitAndStandWithNoSitTarget NPC and SP tests. These stopped working because current code calculates sit heights based on avatar physics rather than appearance data. Also changed BasicPhysics to not divide Z param of all set sizes by 2 - there's no obvious good reason for this and basicphysics is only used in tests --- OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index e1ef4d0..d552229 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs @@ -337,7 +337,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests public void TestSitAndStandWithNoSitTarget() { TestHelpers.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); +// TestHelpers.EnableLogging(); ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); @@ -355,13 +355,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); Assert.That(npc.ParentID, Is.EqualTo(part.LocalId)); - // FIXME: This is different for live avatars - z position is adjusted. This is half the height of the - // default avatar. - // Curiously, Vector3.ToString() will not display the last two places of the float. For example, - // printing out npc.AbsolutePosition will give <0, 0, 0.8454993> not <0, 0, 0.845499337> Assert.That( npc.AbsolutePosition, - Is.EqualTo(part.AbsolutePosition + new Vector3(0, 0, 0.845499337f))); + Is.EqualTo(part.AbsolutePosition + new Vector3(0, 0, sp.PhysicsActor.Size.Z / 2))); m_npcMod.Stand(npc.UUID, m_scene); -- cgit v1.1 From bcb8c4068e4d9ddbd1d4f29c7528f089d11f1d02 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 14 Dec 2013 00:36:25 +0000 Subject: Comment out sit position checks in TestSitAndStandWithSitTarget() in SP and NPC tests until positions are known to be stable. Also resolve issues with NoSitTarget() tests where I was trying to use a destroyed PhysActor --- OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index d552229..7f9e440 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs @@ -323,9 +323,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests Assert.That(part.SitTargetAvatar, Is.EqualTo(npcId)); Assert.That(npc.ParentID, Is.EqualTo(part.LocalId)); - Assert.That( - npc.AbsolutePosition, - Is.EqualTo(part.AbsolutePosition + part.SitTargetPosition + ScenePresence.SIT_TARGET_ADJUSTMENT)); +// Assert.That( +// npc.AbsolutePosition, +// Is.EqualTo(part.AbsolutePosition + part.SitTargetPosition + ScenePresence.SIT_TARGET_ADJUSTMENT)); m_npcMod.Stand(npc.UUID, m_scene); @@ -355,6 +355,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); Assert.That(npc.ParentID, Is.EqualTo(part.LocalId)); + // We should really be using the NPC size but this would mean preserving the physics actor since it is + // removed on sit. Assert.That( npc.AbsolutePosition, Is.EqualTo(part.AbsolutePosition + new Vector3(0, 0, sp.PhysicsActor.Size.Z / 2))); -- cgit v1.1 From 996a6c2eeacf25456d2ffc12e59c34240cf8a578 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 14 Dec 2013 01:34:28 +0000 Subject: After previous discussion, put eye-catcher 'SCRIPT READY' messages to console rather than log as warning The problem with logging at warn is that these aren't actually warnings, and so are false positives to scripts that monitor for problems. Ideally, log4net would have a separate "status" logging level, but currently we will compromise by putting them to console, as they are user-oriented --- .../Scripting/RegionReadyModule/RegionReadyModule.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs index c717128..eb386fe 100644 --- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs @@ -216,9 +216,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady // m_log.InfoFormat("[RegionReady]: Logins enabled for {0}, Oar {1}", // m_scene.RegionInfo.RegionName, m_oarFileLoading.ToString()); - // Warn level because the region cannot be used while logins are disabled - m_log.WarnFormat( - "[RegionReady]: INITIALIZATION COMPLETE FOR {0} - LOGINS ENABLED", m_scene.Name); + // Putting this out to console to make it eye-catching for people who are running OpenSimulator + // without info log messages enabled. Making this a warning is arguably misleading since it isn't a + // warning, and monitor scripts looking for warn/error/fatal messages will received false positives. + // Arguably, log4net needs a status log level (like Apache). + MainConsole.Instance.OutputFormat("INITIALIZATION COMPLETE FOR {0} - LOGINS ENABLED", m_scene.Name); } m_scene.SceneGridService.InformNeighborsThatRegionisUp( -- cgit v1.1 From a5ca15c42893681a777d091c737d5c7615af4f48 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 18 Dec 2013 23:35:38 +0000 Subject: Create regression test TestSendAgentGroupDataUpdate() for groups agent data sending --- .../Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs | 65 +++++++++++++++++++++- 1 file changed, 62 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs index c1bdacb..26d2597 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs @@ -26,13 +26,23 @@ */ using System; +using System.Collections; +using System.Net; using System.Reflection; using Nini.Config; using NUnit.Framework; using OpenMetaverse; +using OpenMetaverse.Messages.Linden; +using OpenMetaverse.Packets; +using OpenMetaverse.StructuredData; using OpenSim.Framework; using OpenSim.Framework.Communications; +using OpenSim.Framework.Servers; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Region.ClientStack.Linden; +using OpenSim.Region.CoreModules.Framework; using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; @@ -44,11 +54,28 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.Tests [TestFixture] public class GroupsModuleTests : OpenSimTestCase { + [SetUp] + public override void SetUp() + { + base.SetUp(); + + uint port = 9999; + uint sslPort = 9998; + + // This is an unfortunate bit of clean up we have to do because MainServer manages things through static + // variables and the VM is not restarted between tests. + MainServer.RemoveHttpServer(port); + + BaseHttpServer server = new BaseHttpServer(port, false, sslPort, ""); + MainServer.AddHttpServer(server); + MainServer.Instance = server; + } + [Test] - public void TestBasic() + public void TestSendAgentGroupDataUpdate() { TestHelpers.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); +// TestHelpers.EnableLogging(); TestScene scene = new SceneHelpers().SetupScene(); IConfigSource configSource = new IniConfigSource(); @@ -56,8 +83,40 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.Tests config.Set("Enabled", true); config.Set("Module", "GroupsModule"); config.Set("DebugEnabled", true); + + GroupsModule gm = new GroupsModule(); + EventQueueGetModule eqgm = new EventQueueGetModule(); + + // We need a capabilities module active so that adding the scene presence creates an event queue in the + // EventQueueGetModule SceneHelpers.SetupSceneModules( - scene, configSource, new object[] { new MockGroupsServicesConnector() }); + scene, configSource, gm, new MockGroupsServicesConnector(), new CapabilitiesModule(), eqgm); + + ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseStem("1")); + + gm.SendAgentGroupDataUpdate(sp.ControllingClient); + + Hashtable eventsResponse = eqgm.GetEvents(UUID.Zero, sp.UUID); + + Assert.That((int)eventsResponse["int_response_code"], Is.EqualTo((int)HttpStatusCode.OK)); + +// Console.WriteLine("Response [{0}]", (string)eventsResponse["str_response_string"]); + + OSDMap rawOsd = (OSDMap)OSDParser.DeserializeLLSDXml((string)eventsResponse["str_response_string"]); + OSDArray eventsOsd = (OSDArray)rawOsd["events"]; + + bool foundUpdate = false; + foreach (OSD osd in eventsOsd) + { + OSDMap eventOsd = (OSDMap)osd; + + if (eventOsd["message"] == "AgentGroupDataUpdate") + foundUpdate = true; + } + + Assert.That(foundUpdate, Is.True, "Did not find AgentGroupDataUpdate in response"); + + // TODO: More checking of more actual event data. } } } \ No newline at end of file -- cgit v1.1 From e8273fa8ad85323f18fb67ecf6d5f07eced87178 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Tue, 26 Nov 2013 10:37:32 +0200 Subject: - Materials: support the viewer removing the material (in which case matsMap["Material"] is missing) - Reduced logging --- .../Materials/MaterialsDemoModule.cs | 77 ++++++++++++---------- 1 file changed, 42 insertions(+), 35 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs index d8f5563..44b1a4a 100644 --- a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs @@ -104,7 +104,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule if (!m_enabled) return; - m_log.DebugFormat("[MaterialsDemoModule]: INITIALIZED MODULE"); + m_log.DebugFormat("[MaterialsDemoModule]: Initialized"); } public void Close() @@ -112,7 +112,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule if (!m_enabled) return; - m_log.DebugFormat("[MaterialsDemoModule]: CLOSED MODULE"); + //m_log.DebugFormat("[MaterialsDemoModule]: CLOSED MODULE"); } public void AddRegion(Scene scene) @@ -120,7 +120,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule if (!m_enabled) return; - m_log.DebugFormat("[MaterialsDemoModule]: REGION {0} ADDED", scene.RegionInfo.RegionName); + //m_log.DebugFormat("[MaterialsDemoModule]: REGION {0} ADDED", scene.RegionInfo.RegionName); m_scene = scene; m_scene.EventManager.OnRegisterCaps += OnRegisterCaps; @@ -166,7 +166,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule m_scene.EventManager.OnObjectAddedToScene -= EventManager_OnObjectAddedToScene; // m_scene.EventManager.OnGatherUuids -= GatherMaterialsUuids; - m_log.DebugFormat("[MaterialsDemoModule]: REGION {0} REMOVED", scene.RegionInfo.RegionName); + //m_log.DebugFormat("[MaterialsDemoModule]: REGION {0} REMOVED", scene.RegionInfo.RegionName); } public void RegionLoaded(Scene scene) @@ -195,7 +195,8 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule if (part.DynAttrs == null) { - m_log.Warn("[MaterialsDemoModule]: NULL DYNATTRS :( "); + //m_log.Warn("[MaterialsDemoModule]: NULL DYNATTRS :( "); + return; } lock (part.DynAttrs) @@ -216,11 +217,11 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule return; } - m_log.Info("[MaterialsDemoModule]: OSMaterials: " + OSDParser.SerializeJsonString(OSMaterials)); + //m_log.Info("[MaterialsDemoModule]: OSMaterials: " + OSDParser.SerializeJsonString(OSMaterials)); if (matsArr == null) { - m_log.Info("[MaterialsDemoModule]: matsArr is null :( "); + //m_log.Info("[MaterialsDemoModule]: matsArr is null :( "); return; } @@ -238,7 +239,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule } catch (Exception e) { - m_log.Warn("[MaterialsDemoModule]: exception decoding persisted material: " + e.ToString()); + m_log.Warn("[MaterialsDemoModule]: exception decoding persisted material ", e); } } } @@ -299,7 +300,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule } catch (Exception e) { - m_log.Warn("[MaterialsDemoModule]: exception in StoreMaterialsForPart(): " + e.ToString()); + m_log.Warn("[MaterialsDemoModule]: exception in StoreMaterialsForPart() ", e); } } @@ -307,7 +308,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { - m_log.Debug("[MaterialsDemoModule]: POST cap handler"); + //m_log.Debug("[MaterialsDemoModule]: POST cap handler"); OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); OSDMap resp = new OSDMap(); @@ -341,7 +342,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule { if (m_knownMaterials.ContainsKey(id)) { - m_log.Info("[MaterialsDemoModule]: request for known material ID: " + id.ToString()); + //m_log.Info("[MaterialsDemoModule]: request for known material ID: " + id.ToString()); OSDMap matMap = new OSDMap(); matMap["ID"] = OSD.FromBinary(id.GetBytes()); @@ -374,34 +375,40 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule { foreach (OSDMap matsMap in matsArr) { - m_log.Debug("[MaterialsDemoModule]: processing matsMap: " + OSDParser.SerializeJsonString(matsMap)); + //m_log.Debug("[MaterialsDemoModule]: processing matsMap: " + OSDParser.SerializeJsonString(matsMap)); - uint matLocalID = 0; - try { matLocalID = matsMap["ID"].AsUInteger(); } + uint primLocalID = 0; + try { primLocalID = matsMap["ID"].AsUInteger(); } catch (Exception e) { m_log.Warn("[MaterialsDemoModule]: cannot decode \"ID\" from matsMap: " + e.Message); } - m_log.Debug("[MaterialsDemoModule]: matLocalId: " + matLocalID.ToString()); - + //m_log.Debug("[MaterialsDemoModule]: primLocalID: " + primLocalID.ToString()); OSDMap mat = null; try { mat = matsMap["Material"] as OSDMap; } catch (Exception e) { m_log.Warn("[MaterialsDemoModule]: cannot decode \"Material\" from matsMap: " + e.Message); } - m_log.Debug("[MaterialsDemoModule]: mat: " + OSDParser.SerializeJsonString(mat)); - - UUID id = HashOsd(mat); - lock (m_knownMaterials) - m_knownMaterials[id] = mat; - - - var sop = m_scene.GetSceneObjectPart(matLocalID); + //m_log.Debug("[MaterialsDemoModule]: mat: " + OSDParser.SerializeJsonString(mat)); + + UUID id; + if (mat == null) + { + id = UUID.Zero; + } + else + { + id = HashOsd(mat); + lock (m_knownMaterials) + m_knownMaterials[id] = mat; + } + + var sop = m_scene.GetSceneObjectPart(primLocalID); if (sop == null) - m_log.Debug("[MaterialsDemoModule]: null SOP for localId: " + matLocalID.ToString()); + m_log.Debug("[MaterialsDemoModule]: null SOP for localId: " + primLocalID.ToString()); else { var te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length); if (te == null) { - m_log.Debug("[MaterialsDemoModule]: null TextureEntry for localId: " + matLocalID.ToString()); + m_log.Debug("[MaterialsDemoModule]: null TextureEntry for localId: " + primLocalID.ToString()); } else { @@ -434,7 +441,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule te.DefaultTexture.MaterialID = id; } - m_log.Debug("[MaterialsDemoModule]: setting material ID for face " + face.ToString() + " to " + id.ToString()); + //m_log.DebugFormat("[MaterialsDemoModule]: in \"{0}\", setting material ID for face {1} to {2}", sop.Name, face, id); //we cant use sop.UpdateTextureEntry(te); because it filters so do it manually @@ -455,7 +462,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule } catch (Exception e) { - m_log.Warn("[MaterialsDemoModule]: exception processing received material: " + e.Message); + m_log.Warn("[MaterialsDemoModule]: exception processing received material ", e); } } } @@ -465,10 +472,10 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule } catch (Exception e) { - m_log.Warn("[MaterialsDemoModule]: exception decoding zipped CAP payload: " + e.Message); + m_log.Warn("[MaterialsDemoModule]: exception decoding zipped CAP payload ", e); //return ""; } - m_log.Debug("[MaterialsDemoModule]: knownMaterials.Count: " + m_knownMaterials.Count.ToString()); + //m_log.Debug("[MaterialsDemoModule]: knownMaterials.Count: " + m_knownMaterials.Count.ToString()); } @@ -476,8 +483,8 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule string response = OSDParser.SerializeLLSDXmlString(resp); //m_log.Debug("[MaterialsDemoModule]: cap request: " + request); - m_log.Debug("[MaterialsDemoModule]: cap request (zipped portion): " + ZippedOsdBytesToString(req["Zipped"].AsBinary())); - m_log.Debug("[MaterialsDemoModule]: cap response: " + response); + //m_log.Debug("[MaterialsDemoModule]: cap request (zipped portion): " + ZippedOsdBytesToString(req["Zipped"].AsBinary())); + //m_log.Debug("[MaterialsDemoModule]: cap response: " + response); return response; } @@ -486,7 +493,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { - m_log.Debug("[MaterialsDemoModule]: GET cap handler"); + //m_log.Debug("[MaterialsDemoModule]: GET cap handler"); OSDMap resp = new OSDMap(); int matsCount = 0; @@ -506,7 +513,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule } resp["Zipped"] = ZCompressOSD(allOsd, false); - m_log.Debug("[MaterialsDemoModule]: matsCount: " + matsCount.ToString()); + //m_log.Debug("[MaterialsDemoModule]: matsCount: " + matsCount.ToString()); return OSDParser.SerializeLLSDXmlString(resp); } @@ -654,4 +661,4 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule // } // } } -} \ No newline at end of file +} -- cgit v1.1 From ca0336d8349382ddb46df4c7e7f6377c64151f25 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Thu, 5 Dec 2013 14:18:59 +0200 Subject: Renamed MaterialsDemoModule to MaterialsModule --- .../Materials/MaterialsDemoModule.cs | 664 --------------------- .../OptionalModules/Materials/MaterialsModule.cs | 664 +++++++++++++++++++++ 2 files changed, 664 insertions(+), 664 deletions(-) delete mode 100644 OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs create mode 100644 OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs deleted file mode 100644 index 44b1a4a..0000000 --- a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs +++ /dev/null @@ -1,664 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using System.Security.Cryptography; // for computing md5 hash -using log4net; -using Mono.Addins; -using Nini.Config; - -using OpenMetaverse; -using OpenMetaverse.StructuredData; - -using OpenSim.Framework; -using OpenSim.Framework.Servers; -using OpenSim.Framework.Servers.HttpServer; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; - -using Ionic.Zlib; - -// You will need to uncomment these lines if you are adding a region module to some other assembly which does not already -// specify its assembly. Otherwise, the region modules in the assembly will not be picked up when OpenSimulator scans -// the available DLLs -//[assembly: Addin("MaterialsDemoModule", "1.0")] -//[assembly: AddinDependency("OpenSim", "0.5")] - -namespace OpenSim.Region.OptionalModules.MaterialsDemoModule -{ - /// - /// - // # # ## ##### # # # # # #### - // # # # # # # ## # # ## # # # - // # # # # # # # # # # # # # # - // # ## # ###### ##### # # # # # # # # ### - // ## ## # # # # # ## # # ## # # - // # # # # # # # # # # # #### - // - // THIS MODULE IS FOR EXPERIMENTAL USE ONLY AND MAY CAUSE REGION OR ASSET CORRUPTION! - // - ////////////// WARNING ////////////////////////////////////////////////////////////////// - /// This is an *Experimental* module for developing support for materials-capable viewers - /// This module should NOT be used in a production environment! It may cause data corruption and - /// viewer crashes. It should be only used to evaluate implementations of materials. - /// - /// Materials are persisted via SceneObjectPart.dynattrs. This is a relatively new feature - /// of OpenSimulator and is not field proven at the time this module was written. Persistence - /// may fail or become corrupt and this could cause viewer crashes due to erroneous materials - /// data being sent to viewers. Materials descriptions might survive IAR, OAR, or other means - /// of archiving however the texture resources used by these materials probably will not as they - /// may not be adequately referenced to ensure proper archiving. - /// - /// - /// - /// To enable this module, add this string at the bottom of OpenSim.ini: - /// [MaterialsDemoModule] - /// - /// - /// - - [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MaterialsDemoModule")] - public class MaterialsDemoModule : INonSharedRegionModule - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - public string Name { get { return "MaterialsDemoModule"; } } - - public Type ReplaceableInterface { get { return null; } } - - private Scene m_scene = null; - private bool m_enabled = false; - - public Dictionary m_knownMaterials = new Dictionary(); - - public void Initialise(IConfigSource source) - { - m_enabled = (source.Configs["MaterialsDemoModule"] != null); - if (!m_enabled) - return; - - m_log.DebugFormat("[MaterialsDemoModule]: Initialized"); - } - - public void Close() - { - if (!m_enabled) - return; - - //m_log.DebugFormat("[MaterialsDemoModule]: CLOSED MODULE"); - } - - public void AddRegion(Scene scene) - { - if (!m_enabled) - return; - - //m_log.DebugFormat("[MaterialsDemoModule]: REGION {0} ADDED", scene.RegionInfo.RegionName); - - m_scene = scene; - m_scene.EventManager.OnRegisterCaps += OnRegisterCaps; - m_scene.EventManager.OnObjectAddedToScene += EventManager_OnObjectAddedToScene; -// m_scene.EventManager.OnGatherUuids += GatherMaterialsUuids; - } - - void EventManager_OnObjectAddedToScene(SceneObjectGroup obj) - { - foreach (var part in obj.Parts) - if (part != null) - GetStoredMaterialsForPart(part); - } - - void OnRegisterCaps(OpenMetaverse.UUID agentID, OpenSim.Framework.Capabilities.Caps caps) - { - string capsBase = "/CAPS/" + caps.CapsObjectPath; - - IRequestHandler renderMaterialsPostHandler - = new RestStreamHandler("POST", capsBase + "/", RenderMaterialsPostCap, "RenderMaterials", null); - caps.RegisterHandler("RenderMaterials", renderMaterialsPostHandler); - - // OpenSimulator CAPs infrastructure seems to be somewhat hostile towards any CAP that requires both GET - // and POST handlers, (at least at the time this was originally written), so we first set up a POST - // handler normally and then add a GET handler via MainServer - - IRequestHandler renderMaterialsGetHandler - = new RestStreamHandler("GET", capsBase + "/", RenderMaterialsGetCap, "RenderMaterials", null); - MainServer.Instance.AddStreamHandler(renderMaterialsGetHandler); - - // materials viewer seems to use either POST or PUT, so assign POST handler for PUT as well - IRequestHandler renderMaterialsPutHandler - = new RestStreamHandler("PUT", capsBase + "/", RenderMaterialsPostCap, "RenderMaterials", null); - MainServer.Instance.AddStreamHandler(renderMaterialsPutHandler); - } - - public void RemoveRegion(Scene scene) - { - if (!m_enabled) - return; - - m_scene.EventManager.OnRegisterCaps -= OnRegisterCaps; - m_scene.EventManager.OnObjectAddedToScene -= EventManager_OnObjectAddedToScene; -// m_scene.EventManager.OnGatherUuids -= GatherMaterialsUuids; - - //m_log.DebugFormat("[MaterialsDemoModule]: REGION {0} REMOVED", scene.RegionInfo.RegionName); - } - - public void RegionLoaded(Scene scene) - { - } - - OSDMap GetMaterial(UUID id) - { - OSDMap map = null; - lock (m_knownMaterials) - { - if (m_knownMaterials.ContainsKey(id)) - { - map = new OSDMap(); - map["ID"] = OSD.FromBinary(id.GetBytes()); - map["Material"] = m_knownMaterials[id]; - } - } - return map; - } - - void GetStoredMaterialsForPart(SceneObjectPart part) - { - OSD OSMaterials = null; - OSDArray matsArr = null; - - if (part.DynAttrs == null) - { - //m_log.Warn("[MaterialsDemoModule]: NULL DYNATTRS :( "); - return; - } - - lock (part.DynAttrs) - { - if (part.DynAttrs.ContainsStore("OpenSim", "Materials")) - { - OSDMap materialsStore = part.DynAttrs.GetStore("OpenSim", "Materials"); - - if (materialsStore == null) - return; - - materialsStore.TryGetValue("Materials", out OSMaterials); - } - - if (OSMaterials != null && OSMaterials is OSDArray) - matsArr = OSMaterials as OSDArray; - else - return; - } - - //m_log.Info("[MaterialsDemoModule]: OSMaterials: " + OSDParser.SerializeJsonString(OSMaterials)); - - if (matsArr == null) - { - //m_log.Info("[MaterialsDemoModule]: matsArr is null :( "); - return; - } - - foreach (OSD elemOsd in matsArr) - { - if (elemOsd != null && elemOsd is OSDMap) - { - OSDMap matMap = elemOsd as OSDMap; - if (matMap.ContainsKey("ID") && matMap.ContainsKey("Material")) - { - try - { - lock (m_knownMaterials) - m_knownMaterials[matMap["ID"].AsUUID()] = (OSDMap)matMap["Material"]; - } - catch (Exception e) - { - m_log.Warn("[MaterialsDemoModule]: exception decoding persisted material ", e); - } - } - } - } - } - - void StoreMaterialsForPart(SceneObjectPart part) - { - try - { - if (part == null || part.Shape == null) - return; - - Dictionary mats = new Dictionary(); - - Primitive.TextureEntry te = part.Shape.Textures; - - if (te.DefaultTexture != null) - { - lock (m_knownMaterials) - { - if (m_knownMaterials.ContainsKey(te.DefaultTexture.MaterialID)) - mats[te.DefaultTexture.MaterialID] = m_knownMaterials[te.DefaultTexture.MaterialID]; - } - } - - if (te.FaceTextures != null) - { - foreach (var face in te.FaceTextures) - { - if (face != null) - { - lock (m_knownMaterials) - { - if (m_knownMaterials.ContainsKey(face.MaterialID)) - mats[face.MaterialID] = m_knownMaterials[face.MaterialID]; - } - } - } - } - if (mats.Count == 0) - return; - - OSDArray matsArr = new OSDArray(); - foreach (KeyValuePair kvp in mats) - { - OSDMap matOsd = new OSDMap(); - matOsd["ID"] = OSD.FromUUID(kvp.Key); - matOsd["Material"] = kvp.Value; - matsArr.Add(matOsd); - } - - OSDMap OSMaterials = new OSDMap(); - OSMaterials["Materials"] = matsArr; - - lock (part.DynAttrs) - part.DynAttrs.SetStore("OpenSim", "Materials", OSMaterials); - } - catch (Exception e) - { - m_log.Warn("[MaterialsDemoModule]: exception in StoreMaterialsForPart() ", e); - } - } - - public string RenderMaterialsPostCap(string request, string path, - string param, IOSHttpRequest httpRequest, - IOSHttpResponse httpResponse) - { - //m_log.Debug("[MaterialsDemoModule]: POST cap handler"); - - OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); - OSDMap resp = new OSDMap(); - - OSDMap materialsFromViewer = null; - - OSDArray respArr = new OSDArray(); - - if (req.ContainsKey("Zipped")) - { - OSD osd = null; - - byte[] inBytes = req["Zipped"].AsBinary(); - - try - { - osd = ZDecompressBytesToOsd(inBytes); - - if (osd != null) - { - if (osd is OSDArray) // assume array of MaterialIDs designating requested material entries - { - foreach (OSD elem in (OSDArray)osd) - { - - try - { - UUID id = new UUID(elem.AsBinary(), 0); - - lock (m_knownMaterials) - { - if (m_knownMaterials.ContainsKey(id)) - { - //m_log.Info("[MaterialsDemoModule]: request for known material ID: " + id.ToString()); - OSDMap matMap = new OSDMap(); - matMap["ID"] = OSD.FromBinary(id.GetBytes()); - - matMap["Material"] = m_knownMaterials[id]; - respArr.Add(matMap); - } - else - m_log.Info("[MaterialsDemoModule]: request for UNKNOWN material ID: " + id.ToString()); - } - } - catch (Exception e) - { - // report something here? - continue; - } - } - } - else if (osd is OSDMap) // reqest to assign a material - { - materialsFromViewer = osd as OSDMap; - - if (materialsFromViewer.ContainsKey("FullMaterialsPerFace")) - { - OSD matsOsd = materialsFromViewer["FullMaterialsPerFace"]; - if (matsOsd is OSDArray) - { - OSDArray matsArr = matsOsd as OSDArray; - - try - { - foreach (OSDMap matsMap in matsArr) - { - //m_log.Debug("[MaterialsDemoModule]: processing matsMap: " + OSDParser.SerializeJsonString(matsMap)); - - uint primLocalID = 0; - try { primLocalID = matsMap["ID"].AsUInteger(); } - catch (Exception e) { m_log.Warn("[MaterialsDemoModule]: cannot decode \"ID\" from matsMap: " + e.Message); } - //m_log.Debug("[MaterialsDemoModule]: primLocalID: " + primLocalID.ToString()); - - OSDMap mat = null; - try { mat = matsMap["Material"] as OSDMap; } - catch (Exception e) { m_log.Warn("[MaterialsDemoModule]: cannot decode \"Material\" from matsMap: " + e.Message); } - //m_log.Debug("[MaterialsDemoModule]: mat: " + OSDParser.SerializeJsonString(mat)); - - UUID id; - if (mat == null) - { - id = UUID.Zero; - } - else - { - id = HashOsd(mat); - lock (m_knownMaterials) - m_knownMaterials[id] = mat; - } - - var sop = m_scene.GetSceneObjectPart(primLocalID); - if (sop == null) - m_log.Debug("[MaterialsDemoModule]: null SOP for localId: " + primLocalID.ToString()); - else - { - var te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length); - - if (te == null) - { - m_log.Debug("[MaterialsDemoModule]: null TextureEntry for localId: " + primLocalID.ToString()); - } - else - { - int face = -1; - - if (matsMap.ContainsKey("Face")) - { - face = matsMap["Face"].AsInteger(); - if (te.FaceTextures == null) // && face == 0) - { - if (te.DefaultTexture == null) - m_log.Debug("[MaterialsDemoModule]: te.DefaultTexture is null"); - else - te.DefaultTexture.MaterialID = id; - } - else - { - if (te.FaceTextures.Length >= face - 1) - { - if (te.FaceTextures[face] == null) - te.DefaultTexture.MaterialID = id; - else - te.FaceTextures[face].MaterialID = id; - } - } - } - else - { - if (te.DefaultTexture != null) - te.DefaultTexture.MaterialID = id; - } - - //m_log.DebugFormat("[MaterialsDemoModule]: in \"{0}\", setting material ID for face {1} to {2}", sop.Name, face, id); - - //we cant use sop.UpdateTextureEntry(te); because it filters so do it manually - - if (sop.ParentGroup != null) - { - sop.Shape.TextureEntry = te.GetBytes(); - sop.TriggerScriptChangedEvent(Changed.TEXTURE); - sop.UpdateFlag = UpdateRequired.FULL; - sop.ParentGroup.HasGroupChanged = true; - - sop.ScheduleFullUpdate(); - - StoreMaterialsForPart(sop); - } - } - } - } - } - catch (Exception e) - { - m_log.Warn("[MaterialsDemoModule]: exception processing received material ", e); - } - } - } - } - } - - } - catch (Exception e) - { - m_log.Warn("[MaterialsDemoModule]: exception decoding zipped CAP payload ", e); - //return ""; - } - //m_log.Debug("[MaterialsDemoModule]: knownMaterials.Count: " + m_knownMaterials.Count.ToString()); - } - - - resp["Zipped"] = ZCompressOSD(respArr, false); - string response = OSDParser.SerializeLLSDXmlString(resp); - - //m_log.Debug("[MaterialsDemoModule]: cap request: " + request); - //m_log.Debug("[MaterialsDemoModule]: cap request (zipped portion): " + ZippedOsdBytesToString(req["Zipped"].AsBinary())); - //m_log.Debug("[MaterialsDemoModule]: cap response: " + response); - return response; - } - - - public string RenderMaterialsGetCap(string request, string path, - string param, IOSHttpRequest httpRequest, - IOSHttpResponse httpResponse) - { - //m_log.Debug("[MaterialsDemoModule]: GET cap handler"); - - OSDMap resp = new OSDMap(); - int matsCount = 0; - OSDArray allOsd = new OSDArray(); - - lock (m_knownMaterials) - { - foreach (KeyValuePair kvp in m_knownMaterials) - { - OSDMap matMap = new OSDMap(); - - matMap["ID"] = OSD.FromBinary(kvp.Key.GetBytes()); - matMap["Material"] = kvp.Value; - allOsd.Add(matMap); - matsCount++; - } - } - - resp["Zipped"] = ZCompressOSD(allOsd, false); - //m_log.Debug("[MaterialsDemoModule]: matsCount: " + matsCount.ToString()); - - return OSDParser.SerializeLLSDXmlString(resp); - } - - static string ZippedOsdBytesToString(byte[] bytes) - { - try - { - return OSDParser.SerializeJsonString(ZDecompressBytesToOsd(bytes)); - } - catch (Exception e) - { - return "ZippedOsdBytesToString caught an exception: " + e.ToString(); - } - } - - /// - /// computes a UUID by hashing a OSD object - /// - /// - /// - private static UUID HashOsd(OSD osd) - { - using (var md5 = MD5.Create()) - using (MemoryStream ms = new MemoryStream(OSDParser.SerializeLLSDBinary(osd, false))) - return new UUID(md5.ComputeHash(ms), 0); - } - - public static OSD ZCompressOSD(OSD inOsd, bool useHeader) - { - OSD osd = null; - - using (MemoryStream msSinkCompressed = new MemoryStream()) - { - using (Ionic.Zlib.ZlibStream zOut = new Ionic.Zlib.ZlibStream(msSinkCompressed, - Ionic.Zlib.CompressionMode.Compress, CompressionLevel.BestCompression, true)) - { - CopyStream(new MemoryStream(OSDParser.SerializeLLSDBinary(inOsd, useHeader)), zOut); - zOut.Close(); - } - - msSinkCompressed.Seek(0L, SeekOrigin.Begin); - osd = OSD.FromBinary( msSinkCompressed.ToArray()); - } - - return osd; - } - - - public static OSD ZDecompressBytesToOsd(byte[] input) - { - OSD osd = null; - - using (MemoryStream msSinkUnCompressed = new MemoryStream()) - { - using (Ionic.Zlib.ZlibStream zOut = new Ionic.Zlib.ZlibStream(msSinkUnCompressed, CompressionMode.Decompress, true)) - { - CopyStream(new MemoryStream(input), zOut); - zOut.Close(); - } - msSinkUnCompressed.Seek(0L, SeekOrigin.Begin); - osd = OSDParser.DeserializeLLSDBinary(msSinkUnCompressed.ToArray()); - } - - return osd; - } - - static void CopyStream(System.IO.Stream input, System.IO.Stream output) - { - byte[] buffer = new byte[2048]; - int len; - while ((len = input.Read(buffer, 0, 2048)) > 0) - { - output.Write(buffer, 0, len); - } - - output.Flush(); - } - - // FIXME: This code is currently still in UuidGatherer since we cannot use Scene.EventManager as some - // calls to the gatherer are done for objects with no scene. -// /// -// /// Gather all of the texture asset UUIDs used to reference "Materials" such as normal and specular maps -// /// -// /// -// /// -// private void GatherMaterialsUuids(SceneObjectPart part, IDictionary assetUuids) -// { -// // scan thru the dynAttrs map of this part for any textures used as materials -// OSD osdMaterials = null; -// -// lock (part.DynAttrs) -// { -// if (part.DynAttrs.ContainsStore("OpenSim", "Materials")) -// { -// OSDMap materialsStore = part.DynAttrs.GetStore("OpenSim", "Materials"); -// if (materialsStore == null) -// return; -// -// materialsStore.TryGetValue("Materials", out osdMaterials); -// } -// -// if (osdMaterials != null) -// { -// //m_log.Info("[UUID Gatherer]: found Materials: " + OSDParser.SerializeJsonString(osd)); -// -// if (osdMaterials is OSDArray) -// { -// OSDArray matsArr = osdMaterials as OSDArray; -// foreach (OSDMap matMap in matsArr) -// { -// try -// { -// if (matMap.ContainsKey("Material")) -// { -// OSDMap mat = matMap["Material"] as OSDMap; -// if (mat.ContainsKey("NormMap")) -// { -// UUID normalMapId = mat["NormMap"].AsUUID(); -// if (normalMapId != UUID.Zero) -// { -// assetUuids[normalMapId] = AssetType.Texture; -// //m_log.Info("[UUID Gatherer]: found normal map ID: " + normalMapId.ToString()); -// } -// } -// if (mat.ContainsKey("SpecMap")) -// { -// UUID specularMapId = mat["SpecMap"].AsUUID(); -// if (specularMapId != UUID.Zero) -// { -// assetUuids[specularMapId] = AssetType.Texture; -// //m_log.Info("[UUID Gatherer]: found specular map ID: " + specularMapId.ToString()); -// } -// } -// } -// -// } -// catch (Exception e) -// { -// m_log.Warn("[MaterialsDemoModule]: exception getting materials: " + e.Message); -// } -// } -// } -// } -// } -// } - } -} diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs new file mode 100644 index 0000000..e707154 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs @@ -0,0 +1,664 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Security.Cryptography; // for computing md5 hash +using log4net; +using Mono.Addins; +using Nini.Config; + +using OpenMetaverse; +using OpenMetaverse.StructuredData; + +using OpenSim.Framework; +using OpenSim.Framework.Servers; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; + +using Ionic.Zlib; + +// You will need to uncomment these lines if you are adding a region module to some other assembly which does not already +// specify its assembly. Otherwise, the region modules in the assembly will not be picked up when OpenSimulator scans +// the available DLLs +//[assembly: Addin("MaterialsDemoModule", "1.0")] +//[assembly: AddinDependency("OpenSim", "0.5")] + +namespace OpenSim.Region.OptionalModules.MaterialsDemoModule +{ + /// + /// + // # # ## ##### # # # # # #### + // # # # # # # ## # # ## # # # + // # # # # # # # # # # # # # # + // # ## # ###### ##### # # # # # # # # ### + // ## ## # # # # # ## # # ## # # + // # # # # # # # # # # # #### + // + // THIS MODULE IS FOR EXPERIMENTAL USE ONLY AND MAY CAUSE REGION OR ASSET CORRUPTION! + // + ////////////// WARNING ////////////////////////////////////////////////////////////////// + /// This is an *Experimental* module for developing support for materials-capable viewers + /// This module should NOT be used in a production environment! It may cause data corruption and + /// viewer crashes. It should be only used to evaluate implementations of materials. + /// + /// Materials are persisted via SceneObjectPart.dynattrs. This is a relatively new feature + /// of OpenSimulator and is not field proven at the time this module was written. Persistence + /// may fail or become corrupt and this could cause viewer crashes due to erroneous materials + /// data being sent to viewers. Materials descriptions might survive IAR, OAR, or other means + /// of archiving however the texture resources used by these materials probably will not as they + /// may not be adequately referenced to ensure proper archiving. + /// + /// + /// + /// To enable this module, add this string at the bottom of OpenSim.ini: + /// [MaterialsDemoModule] + /// + /// + /// + + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MaterialsDemoModule")] + public class MaterialsDemoModule : INonSharedRegionModule + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public string Name { get { return "MaterialsDemoModule"; } } + + public Type ReplaceableInterface { get { return null; } } + + private Scene m_scene = null; + private bool m_enabled = false; + + public Dictionary m_knownMaterials = new Dictionary(); + + public void Initialise(IConfigSource source) + { + m_enabled = (source.Configs["MaterialsDemoModule"] != null); + if (!m_enabled) + return; + + m_log.DebugFormat("[MaterialsDemoModule]: Initialized"); + } + + public void Close() + { + if (!m_enabled) + return; + + //m_log.DebugFormat("[MaterialsDemoModule]: CLOSED MODULE"); + } + + public void AddRegion(Scene scene) + { + if (!m_enabled) + return; + + //m_log.DebugFormat("[MaterialsDemoModule]: REGION {0} ADDED", scene.RegionInfo.RegionName); + + m_scene = scene; + m_scene.EventManager.OnRegisterCaps += OnRegisterCaps; + m_scene.EventManager.OnObjectAddedToScene += EventManager_OnObjectAddedToScene; +// m_scene.EventManager.OnGatherUuids += GatherMaterialsUuids; + } + + void EventManager_OnObjectAddedToScene(SceneObjectGroup obj) + { + foreach (var part in obj.Parts) + if (part != null) + GetStoredMaterialsForPart(part); + } + + void OnRegisterCaps(OpenMetaverse.UUID agentID, OpenSim.Framework.Capabilities.Caps caps) + { + string capsBase = "/CAPS/" + caps.CapsObjectPath; + + IRequestHandler renderMaterialsPostHandler + = new RestStreamHandler("POST", capsBase + "/", RenderMaterialsPostCap, "RenderMaterials", null); + caps.RegisterHandler("RenderMaterials", renderMaterialsPostHandler); + + // OpenSimulator CAPs infrastructure seems to be somewhat hostile towards any CAP that requires both GET + // and POST handlers, (at least at the time this was originally written), so we first set up a POST + // handler normally and then add a GET handler via MainServer + + IRequestHandler renderMaterialsGetHandler + = new RestStreamHandler("GET", capsBase + "/", RenderMaterialsGetCap, "RenderMaterials", null); + MainServer.Instance.AddStreamHandler(renderMaterialsGetHandler); + + // materials viewer seems to use either POST or PUT, so assign POST handler for PUT as well + IRequestHandler renderMaterialsPutHandler + = new RestStreamHandler("PUT", capsBase + "/", RenderMaterialsPostCap, "RenderMaterials", null); + MainServer.Instance.AddStreamHandler(renderMaterialsPutHandler); + } + + public void RemoveRegion(Scene scene) + { + if (!m_enabled) + return; + + m_scene.EventManager.OnRegisterCaps -= OnRegisterCaps; + m_scene.EventManager.OnObjectAddedToScene -= EventManager_OnObjectAddedToScene; +// m_scene.EventManager.OnGatherUuids -= GatherMaterialsUuids; + + //m_log.DebugFormat("[MaterialsDemoModule]: REGION {0} REMOVED", scene.RegionInfo.RegionName); + } + + public void RegionLoaded(Scene scene) + { + } + + OSDMap GetMaterial(UUID id) + { + OSDMap map = null; + lock (m_knownMaterials) + { + if (m_knownMaterials.ContainsKey(id)) + { + map = new OSDMap(); + map["ID"] = OSD.FromBinary(id.GetBytes()); + map["Material"] = m_knownMaterials[id]; + } + } + return map; + } + + void GetStoredMaterialsForPart(SceneObjectPart part) + { + OSD OSMaterials = null; + OSDArray matsArr = null; + + if (part.DynAttrs == null) + { + //m_log.Warn("[MaterialsDemoModule]: NULL DYNATTRS :( "); + return; + } + + lock (part.DynAttrs) + { + if (part.DynAttrs.ContainsStore("OpenSim", "Materials")) + { + OSDMap materialsStore = part.DynAttrs.GetStore("OpenSim", "Materials"); + + if (materialsStore == null) + return; + + materialsStore.TryGetValue("Materials", out OSMaterials); + } + + if (OSMaterials != null && OSMaterials is OSDArray) + matsArr = OSMaterials as OSDArray; + else + return; + } + + //m_log.Info("[MaterialsDemoModule]: OSMaterials: " + OSDParser.SerializeJsonString(OSMaterials)); + + if (matsArr == null) + { + //m_log.Info("[MaterialsDemoModule]: matsArr is null :( "); + return; + } + + foreach (OSD elemOsd in matsArr) + { + if (elemOsd != null && elemOsd is OSDMap) + { + OSDMap matMap = elemOsd as OSDMap; + if (matMap.ContainsKey("ID") && matMap.ContainsKey("Material")) + { + try + { + lock (m_knownMaterials) + m_knownMaterials[matMap["ID"].AsUUID()] = (OSDMap)matMap["Material"]; + } + catch (Exception e) + { + m_log.Warn("[MaterialsDemoModule]: exception decoding persisted material ", e); + } + } + } + } + } + + void StoreMaterialsForPart(SceneObjectPart part) + { + try + { + if (part == null || part.Shape == null) + return; + + Dictionary mats = new Dictionary(); + + Primitive.TextureEntry te = part.Shape.Textures; + + if (te.DefaultTexture != null) + { + lock (m_knownMaterials) + { + if (m_knownMaterials.ContainsKey(te.DefaultTexture.MaterialID)) + mats[te.DefaultTexture.MaterialID] = m_knownMaterials[te.DefaultTexture.MaterialID]; + } + } + + if (te.FaceTextures != null) + { + foreach (var face in te.FaceTextures) + { + if (face != null) + { + lock (m_knownMaterials) + { + if (m_knownMaterials.ContainsKey(face.MaterialID)) + mats[face.MaterialID] = m_knownMaterials[face.MaterialID]; + } + } + } + } + if (mats.Count == 0) + return; + + OSDArray matsArr = new OSDArray(); + foreach (KeyValuePair kvp in mats) + { + OSDMap matOsd = new OSDMap(); + matOsd["ID"] = OSD.FromUUID(kvp.Key); + matOsd["Material"] = kvp.Value; + matsArr.Add(matOsd); + } + + OSDMap OSMaterials = new OSDMap(); + OSMaterials["Materials"] = matsArr; + + lock (part.DynAttrs) + part.DynAttrs.SetStore("OpenSim", "Materials", OSMaterials); + } + catch (Exception e) + { + m_log.Warn("[MaterialsDemoModule]: exception in StoreMaterialsForPart() ", e); + } + } + + public string RenderMaterialsPostCap(string request, string path, + string param, IOSHttpRequest httpRequest, + IOSHttpResponse httpResponse) + { + //m_log.Debug("[MaterialsDemoModule]: POST cap handler"); + + OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); + OSDMap resp = new OSDMap(); + + OSDMap materialsFromViewer = null; + + OSDArray respArr = new OSDArray(); + + if (req.ContainsKey("Zipped")) + { + OSD osd = null; + + byte[] inBytes = req["Zipped"].AsBinary(); + + try + { + osd = ZDecompressBytesToOsd(inBytes); + + if (osd != null) + { + if (osd is OSDArray) // assume array of MaterialIDs designating requested material entries + { + foreach (OSD elem in (OSDArray)osd) + { + + try + { + UUID id = new UUID(elem.AsBinary(), 0); + + lock (m_knownMaterials) + { + if (m_knownMaterials.ContainsKey(id)) + { + //m_log.Info("[MaterialsDemoModule]: request for known material ID: " + id.ToString()); + OSDMap matMap = new OSDMap(); + matMap["ID"] = OSD.FromBinary(id.GetBytes()); + + matMap["Material"] = m_knownMaterials[id]; + respArr.Add(matMap); + } + else + m_log.Info("[MaterialsDemoModule]: request for UNKNOWN material ID: " + id.ToString()); + } + } + catch (Exception e) + { + // report something here? + continue; + } + } + } + else if (osd is OSDMap) // reqest to assign a material + { + materialsFromViewer = osd as OSDMap; + + if (materialsFromViewer.ContainsKey("FullMaterialsPerFace")) + { + OSD matsOsd = materialsFromViewer["FullMaterialsPerFace"]; + if (matsOsd is OSDArray) + { + OSDArray matsArr = matsOsd as OSDArray; + + try + { + foreach (OSDMap matsMap in matsArr) + { + //m_log.Debug("[MaterialsDemoModule]: processing matsMap: " + OSDParser.SerializeJsonString(matsMap)); + + uint primLocalID = 0; + try { primLocalID = matsMap["ID"].AsUInteger(); } + catch (Exception e) { m_log.Warn("[MaterialsDemoModule]: cannot decode \"ID\" from matsMap: " + e.Message); } + //m_log.Debug("[MaterialsDemoModule]: primLocalID: " + primLocalID.ToString()); + + OSDMap mat = null; + try { mat = matsMap["Material"] as OSDMap; } + catch (Exception e) { m_log.Warn("[MaterialsDemoModule]: cannot decode \"Material\" from matsMap: " + e.Message); } + //m_log.Debug("[MaterialsDemoModule]: mat: " + OSDParser.SerializeJsonString(mat)); + + UUID id; + if (mat == null) + { + id = UUID.Zero; + } + else + { + id = HashOsd(mat); + lock (m_knownMaterials) + m_knownMaterials[id] = mat; + } + + var sop = m_scene.GetSceneObjectPart(primLocalID); + if (sop == null) + m_log.Debug("[MaterialsDemoModule]: null SOP for localId: " + primLocalID.ToString()); + else + { + var te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length); + + if (te == null) + { + m_log.Debug("[MaterialsDemoModule]: null TextureEntry for localId: " + primLocalID.ToString()); + } + else + { + int face = -1; + + if (matsMap.ContainsKey("Face")) + { + face = matsMap["Face"].AsInteger(); + if (te.FaceTextures == null) // && face == 0) + { + if (te.DefaultTexture == null) + m_log.Debug("[MaterialsDemoModule]: te.DefaultTexture is null"); + else + te.DefaultTexture.MaterialID = id; + } + else + { + if (te.FaceTextures.Length >= face - 1) + { + if (te.FaceTextures[face] == null) + te.DefaultTexture.MaterialID = id; + else + te.FaceTextures[face].MaterialID = id; + } + } + } + else + { + if (te.DefaultTexture != null) + te.DefaultTexture.MaterialID = id; + } + + //m_log.DebugFormat("[MaterialsDemoModule]: in \"{0}\", setting material ID for face {1} to {2}", sop.Name, face, id); + + //we cant use sop.UpdateTextureEntry(te); because it filters so do it manually + + if (sop.ParentGroup != null) + { + sop.Shape.TextureEntry = te.GetBytes(); + sop.TriggerScriptChangedEvent(Changed.TEXTURE); + sop.UpdateFlag = UpdateRequired.FULL; + sop.ParentGroup.HasGroupChanged = true; + + sop.ScheduleFullUpdate(); + + StoreMaterialsForPart(sop); + } + } + } + } + } + catch (Exception e) + { + m_log.Warn("[MaterialsDemoModule]: exception processing received material ", e); + } + } + } + } + } + + } + catch (Exception e) + { + m_log.Warn("[MaterialsDemoModule]: exception decoding zipped CAP payload ", e); + //return ""; + } + //m_log.Debug("[MaterialsDemoModule]: knownMaterials.Count: " + m_knownMaterials.Count.ToString()); + } + + + resp["Zipped"] = ZCompressOSD(respArr, false); + string response = OSDParser.SerializeLLSDXmlString(resp); + + //m_log.Debug("[MaterialsDemoModule]: cap request: " + request); + //m_log.Debug("[MaterialsDemoModule]: cap request (zipped portion): " + ZippedOsdBytesToString(req["Zipped"].AsBinary())); + //m_log.Debug("[MaterialsDemoModule]: cap response: " + response); + return response; + } + + + public string RenderMaterialsGetCap(string request, string path, + string param, IOSHttpRequest httpRequest, + IOSHttpResponse httpResponse) + { + //m_log.Debug("[MaterialsDemoModule]: GET cap handler"); + + OSDMap resp = new OSDMap(); + int matsCount = 0; + OSDArray allOsd = new OSDArray(); + + lock (m_knownMaterials) + { + foreach (KeyValuePair kvp in m_knownMaterials) + { + OSDMap matMap = new OSDMap(); + + matMap["ID"] = OSD.FromBinary(kvp.Key.GetBytes()); + matMap["Material"] = kvp.Value; + allOsd.Add(matMap); + matsCount++; + } + } + + resp["Zipped"] = ZCompressOSD(allOsd, false); + //m_log.Debug("[MaterialsDemoModule]: matsCount: " + matsCount.ToString()); + + return OSDParser.SerializeLLSDXmlString(resp); + } + + static string ZippedOsdBytesToString(byte[] bytes) + { + try + { + return OSDParser.SerializeJsonString(ZDecompressBytesToOsd(bytes)); + } + catch (Exception e) + { + return "ZippedOsdBytesToString caught an exception: " + e.ToString(); + } + } + + /// + /// computes a UUID by hashing a OSD object + /// + /// + /// + private static UUID HashOsd(OSD osd) + { + using (var md5 = MD5.Create()) + using (MemoryStream ms = new MemoryStream(OSDParser.SerializeLLSDBinary(osd, false))) + return new UUID(md5.ComputeHash(ms), 0); + } + + public static OSD ZCompressOSD(OSD inOsd, bool useHeader) + { + OSD osd = null; + + using (MemoryStream msSinkCompressed = new MemoryStream()) + { + using (Ionic.Zlib.ZlibStream zOut = new Ionic.Zlib.ZlibStream(msSinkCompressed, + Ionic.Zlib.CompressionMode.Compress, CompressionLevel.BestCompression, true)) + { + CopyStream(new MemoryStream(OSDParser.SerializeLLSDBinary(inOsd, useHeader)), zOut); + zOut.Close(); + } + + msSinkCompressed.Seek(0L, SeekOrigin.Begin); + osd = OSD.FromBinary( msSinkCompressed.ToArray()); + } + + return osd; + } + + + public static OSD ZDecompressBytesToOsd(byte[] input) + { + OSD osd = null; + + using (MemoryStream msSinkUnCompressed = new MemoryStream()) + { + using (Ionic.Zlib.ZlibStream zOut = new Ionic.Zlib.ZlibStream(msSinkUnCompressed, CompressionMode.Decompress, true)) + { + CopyStream(new MemoryStream(input), zOut); + zOut.Close(); + } + msSinkUnCompressed.Seek(0L, SeekOrigin.Begin); + osd = OSDParser.DeserializeLLSDBinary(msSinkUnCompressed.ToArray()); + } + + return osd; + } + + static void CopyStream(System.IO.Stream input, System.IO.Stream output) + { + byte[] buffer = new byte[2048]; + int len; + while ((len = input.Read(buffer, 0, 2048)) > 0) + { + output.Write(buffer, 0, len); + } + + output.Flush(); + } + + // FIXME: This code is currently still in UuidGatherer since we cannot use Scene.EventManager as some + // calls to the gatherer are done for objects with no scene. +// /// +// /// Gather all of the texture asset UUIDs used to reference "Materials" such as normal and specular maps +// /// +// /// +// /// +// private void GatherMaterialsUuids(SceneObjectPart part, IDictionary assetUuids) +// { +// // scan thru the dynAttrs map of this part for any textures used as materials +// OSD osdMaterials = null; +// +// lock (part.DynAttrs) +// { +// if (part.DynAttrs.ContainsStore("OpenSim", "Materials")) +// { +// OSDMap materialsStore = part.DynAttrs.GetStore("OpenSim", "Materials"); +// if (materialsStore == null) +// return; +// +// materialsStore.TryGetValue("Materials", out osdMaterials); +// } +// +// if (osdMaterials != null) +// { +// //m_log.Info("[UUID Gatherer]: found Materials: " + OSDParser.SerializeJsonString(osd)); +// +// if (osdMaterials is OSDArray) +// { +// OSDArray matsArr = osdMaterials as OSDArray; +// foreach (OSDMap matMap in matsArr) +// { +// try +// { +// if (matMap.ContainsKey("Material")) +// { +// OSDMap mat = matMap["Material"] as OSDMap; +// if (mat.ContainsKey("NormMap")) +// { +// UUID normalMapId = mat["NormMap"].AsUUID(); +// if (normalMapId != UUID.Zero) +// { +// assetUuids[normalMapId] = AssetType.Texture; +// //m_log.Info("[UUID Gatherer]: found normal map ID: " + normalMapId.ToString()); +// } +// } +// if (mat.ContainsKey("SpecMap")) +// { +// UUID specularMapId = mat["SpecMap"].AsUUID(); +// if (specularMapId != UUID.Zero) +// { +// assetUuids[specularMapId] = AssetType.Texture; +// //m_log.Info("[UUID Gatherer]: found specular map ID: " + specularMapId.ToString()); +// } +// } +// } +// +// } +// catch (Exception e) +// { +// m_log.Warn("[MaterialsDemoModule]: exception getting materials: " + e.Message); +// } +// } +// } +// } +// } +// } + } +} -- cgit v1.1 From 3018b2c5d7c9de0e8da6d158f0848c840b7864ab Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Fri, 6 Dec 2013 16:21:11 +0200 Subject: Materials module: a) Store materials as assets; b) Finalized it (removed the "Demo" label; removed most of the logging); c) Enabled by default Changed UuidGatherer to use 'sbyte' to identify assets instead of 'AssetType'. This lets UuidGatherer handle Materials, which are defined in a different enum from 'AssetType'. --- .../OptionalModules/Materials/MaterialsModule.cs | 518 ++++++++------------- 1 file changed, 191 insertions(+), 327 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs index e707154..09041e8 100644 --- a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs @@ -42,77 +42,49 @@ using OpenSim.Framework.Servers; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +using OpenSimAssetType = OpenSim.Framework.SLUtil.OpenSimAssetType; using Ionic.Zlib; // You will need to uncomment these lines if you are adding a region module to some other assembly which does not already // specify its assembly. Otherwise, the region modules in the assembly will not be picked up when OpenSimulator scans // the available DLLs -//[assembly: Addin("MaterialsDemoModule", "1.0")] +//[assembly: Addin("MaterialsModule", "1.0")] //[assembly: AddinDependency("OpenSim", "0.5")] -namespace OpenSim.Region.OptionalModules.MaterialsDemoModule +namespace OpenSim.Region.OptionalModules.Materials { - /// - /// - // # # ## ##### # # # # # #### - // # # # # # # ## # # ## # # # - // # # # # # # # # # # # # # # - // # ## # ###### ##### # # # # # # # # ### - // ## ## # # # # # ## # # ## # # - // # # # # # # # # # # # #### - // - // THIS MODULE IS FOR EXPERIMENTAL USE ONLY AND MAY CAUSE REGION OR ASSET CORRUPTION! - // - ////////////// WARNING ////////////////////////////////////////////////////////////////// - /// This is an *Experimental* module for developing support for materials-capable viewers - /// This module should NOT be used in a production environment! It may cause data corruption and - /// viewer crashes. It should be only used to evaluate implementations of materials. - /// - /// Materials are persisted via SceneObjectPart.dynattrs. This is a relatively new feature - /// of OpenSimulator and is not field proven at the time this module was written. Persistence - /// may fail or become corrupt and this could cause viewer crashes due to erroneous materials - /// data being sent to viewers. Materials descriptions might survive IAR, OAR, or other means - /// of archiving however the texture resources used by these materials probably will not as they - /// may not be adequately referenced to ensure proper archiving. - /// - /// - /// - /// To enable this module, add this string at the bottom of OpenSim.ini: - /// [MaterialsDemoModule] - /// - /// - /// - - [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MaterialsDemoModule")] - public class MaterialsDemoModule : INonSharedRegionModule + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MaterialsModule")] + public class MaterialsModule : INonSharedRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public string Name { get { return "MaterialsDemoModule"; } } + public string Name { get { return "MaterialsModule"; } } public Type ReplaceableInterface { get { return null; } } private Scene m_scene = null; private bool m_enabled = false; - public Dictionary m_knownMaterials = new Dictionary(); + public Dictionary m_regionMaterials = new Dictionary(); public void Initialise(IConfigSource source) { - m_enabled = (source.Configs["MaterialsDemoModule"] != null); + IConfig config = source.Configs["Materials"]; + if (config == null) + return; + + m_enabled = config.GetBoolean("enable_materials", true); if (!m_enabled) return; - m_log.DebugFormat("[MaterialsDemoModule]: Initialized"); + m_log.DebugFormat("[Materials]: Initialized"); } public void Close() { if (!m_enabled) return; - - //m_log.DebugFormat("[MaterialsDemoModule]: CLOSED MODULE"); } public void AddRegion(Scene scene) @@ -120,22 +92,19 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule if (!m_enabled) return; - //m_log.DebugFormat("[MaterialsDemoModule]: REGION {0} ADDED", scene.RegionInfo.RegionName); - m_scene = scene; m_scene.EventManager.OnRegisterCaps += OnRegisterCaps; m_scene.EventManager.OnObjectAddedToScene += EventManager_OnObjectAddedToScene; -// m_scene.EventManager.OnGatherUuids += GatherMaterialsUuids; } - void EventManager_OnObjectAddedToScene(SceneObjectGroup obj) + private void EventManager_OnObjectAddedToScene(SceneObjectGroup obj) { foreach (var part in obj.Parts) if (part != null) - GetStoredMaterialsForPart(part); + GetStoredMaterialsInPart(part); } - void OnRegisterCaps(OpenMetaverse.UUID agentID, OpenSim.Framework.Capabilities.Caps caps) + private void OnRegisterCaps(OpenMetaverse.UUID agentID, OpenSim.Framework.Capabilities.Caps caps) { string capsBase = "/CAPS/" + caps.CapsObjectPath; @@ -164,143 +133,65 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule m_scene.EventManager.OnRegisterCaps -= OnRegisterCaps; m_scene.EventManager.OnObjectAddedToScene -= EventManager_OnObjectAddedToScene; -// m_scene.EventManager.OnGatherUuids -= GatherMaterialsUuids; - - //m_log.DebugFormat("[MaterialsDemoModule]: REGION {0} REMOVED", scene.RegionInfo.RegionName); } public void RegionLoaded(Scene scene) { } - OSDMap GetMaterial(UUID id) - { - OSDMap map = null; - lock (m_knownMaterials) - { - if (m_knownMaterials.ContainsKey(id)) - { - map = new OSDMap(); - map["ID"] = OSD.FromBinary(id.GetBytes()); - map["Material"] = m_knownMaterials[id]; - } - } - return map; - } - - void GetStoredMaterialsForPart(SceneObjectPart part) + /// + /// Find the materials used in the SOP, and add them to 'm_regionMaterials'. + /// + private void GetStoredMaterialsInPart(SceneObjectPart part) { - OSD OSMaterials = null; - OSDArray matsArr = null; - - if (part.DynAttrs == null) - { - //m_log.Warn("[MaterialsDemoModule]: NULL DYNATTRS :( "); + if (part.Shape == null) return; - } - - lock (part.DynAttrs) - { - if (part.DynAttrs.ContainsStore("OpenSim", "Materials")) - { - OSDMap materialsStore = part.DynAttrs.GetStore("OpenSim", "Materials"); - - if (materialsStore == null) - return; - - materialsStore.TryGetValue("Materials", out OSMaterials); - } - - if (OSMaterials != null && OSMaterials is OSDArray) - matsArr = OSMaterials as OSDArray; - else - return; - } - - //m_log.Info("[MaterialsDemoModule]: OSMaterials: " + OSDParser.SerializeJsonString(OSMaterials)); - - if (matsArr == null) - { - //m_log.Info("[MaterialsDemoModule]: matsArr is null :( "); + var te = new Primitive.TextureEntry(part.Shape.TextureEntry, 0, part.Shape.TextureEntry.Length); + if (te == null) return; - } - foreach (OSD elemOsd in matsArr) + GetStoredMaterialInFace(part, te.DefaultTexture); + + foreach (Primitive.TextureEntryFace face in te.FaceTextures) { - if (elemOsd != null && elemOsd is OSDMap) - { - OSDMap matMap = elemOsd as OSDMap; - if (matMap.ContainsKey("ID") && matMap.ContainsKey("Material")) - { - try - { - lock (m_knownMaterials) - m_knownMaterials[matMap["ID"].AsUUID()] = (OSDMap)matMap["Material"]; - } - catch (Exception e) - { - m_log.Warn("[MaterialsDemoModule]: exception decoding persisted material ", e); - } - } - } + if (face != null) + GetStoredMaterialInFace(part, face); } } - void StoreMaterialsForPart(SceneObjectPart part) + /// + /// Find the materials used in one Face, and add them to 'm_regionMaterials'. + /// + private void GetStoredMaterialInFace(SceneObjectPart part, Primitive.TextureEntryFace face) { - try + UUID id = face.MaterialID; + if (id == UUID.Zero) + return; + + lock (m_regionMaterials) { - if (part == null || part.Shape == null) + if (m_regionMaterials.ContainsKey(id)) return; - - Dictionary mats = new Dictionary(); - - Primitive.TextureEntry te = part.Shape.Textures; - - if (te.DefaultTexture != null) + + byte[] data = m_scene.AssetService.GetData(id.ToString()); + if (data == null) { - lock (m_knownMaterials) - { - if (m_knownMaterials.ContainsKey(te.DefaultTexture.MaterialID)) - mats[te.DefaultTexture.MaterialID] = m_knownMaterials[te.DefaultTexture.MaterialID]; - } + m_log.WarnFormat("[Materials]: Prim \"{0}\" ({1}) contains unknown material ID {2}", part.Name, part.UUID, id); + return; } - if (te.FaceTextures != null) + OSDMap mat; + try { - foreach (var face in te.FaceTextures) - { - if (face != null) - { - lock (m_knownMaterials) - { - if (m_knownMaterials.ContainsKey(face.MaterialID)) - mats[face.MaterialID] = m_knownMaterials[face.MaterialID]; - } - } - } + mat = (OSDMap)OSDParser.DeserializeLLSDXml(data); } - if (mats.Count == 0) - return; - - OSDArray matsArr = new OSDArray(); - foreach (KeyValuePair kvp in mats) + catch (Exception e) { - OSDMap matOsd = new OSDMap(); - matOsd["ID"] = OSD.FromUUID(kvp.Key); - matOsd["Material"] = kvp.Value; - matsArr.Add(matOsd); + m_log.WarnFormat("[Materials]: cannot decode material asset {0}: {1}", id, e.Message); + return; } - OSDMap OSMaterials = new OSDMap(); - OSMaterials["Materials"] = matsArr; - - lock (part.DynAttrs) - part.DynAttrs.SetStore("OpenSim", "Materials", OSMaterials); - } - catch (Exception e) - { - m_log.Warn("[MaterialsDemoModule]: exception in StoreMaterialsForPart() ", e); + m_regionMaterials[id] = mat; } } @@ -308,8 +199,6 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { - //m_log.Debug("[MaterialsDemoModule]: POST cap handler"); - OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); OSDMap resp = new OSDMap(); @@ -333,34 +222,38 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule { foreach (OSD elem in (OSDArray)osd) { - try { UUID id = new UUID(elem.AsBinary(), 0); - lock (m_knownMaterials) + lock (m_regionMaterials) { - if (m_knownMaterials.ContainsKey(id)) + if (m_regionMaterials.ContainsKey(id)) { - //m_log.Info("[MaterialsDemoModule]: request for known material ID: " + id.ToString()); OSDMap matMap = new OSDMap(); matMap["ID"] = OSD.FromBinary(id.GetBytes()); - - matMap["Material"] = m_knownMaterials[id]; + matMap["Material"] = m_regionMaterials[id]; respArr.Add(matMap); } else - m_log.Info("[MaterialsDemoModule]: request for UNKNOWN material ID: " + id.ToString()); + { + m_log.Warn("[Materials]: request for unknown material ID: " + id.ToString()); + + // Theoretically we could try to load the material from the assets service, + // but that shouldn't be necessary because the viewer should only request + // materials that exist in a prim on the region, and all of these materials + // are already stored in m_regionMaterials. + } } } catch (Exception e) { - // report something here? + m_log.Error("Error getting materials in response to viewer request", e); continue; } } } - else if (osd is OSDMap) // reqest to assign a material + else if (osd is OSDMap) // request to assign a material { materialsFromViewer = osd as OSDMap; @@ -375,94 +268,118 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule { foreach (OSDMap matsMap in matsArr) { - //m_log.Debug("[MaterialsDemoModule]: processing matsMap: " + OSDParser.SerializeJsonString(matsMap)); - uint primLocalID = 0; - try { primLocalID = matsMap["ID"].AsUInteger(); } - catch (Exception e) { m_log.Warn("[MaterialsDemoModule]: cannot decode \"ID\" from matsMap: " + e.Message); } - //m_log.Debug("[MaterialsDemoModule]: primLocalID: " + primLocalID.ToString()); + try { + primLocalID = matsMap["ID"].AsUInteger(); + } + catch (Exception e) { + m_log.Warn("[Materials]: cannot decode \"ID\" from matsMap: " + e.Message); + continue; + } OSDMap mat = null; - try { mat = matsMap["Material"] as OSDMap; } - catch (Exception e) { m_log.Warn("[MaterialsDemoModule]: cannot decode \"Material\" from matsMap: " + e.Message); } - //m_log.Debug("[MaterialsDemoModule]: mat: " + OSDParser.SerializeJsonString(mat)); + try + { + mat = matsMap["Material"] as OSDMap; + } + catch (Exception e) + { + m_log.Warn("[Materials]: cannot decode \"Material\" from matsMap: " + e.Message); + continue; + } + + SceneObjectPart sop = m_scene.GetSceneObjectPart(primLocalID); + if (sop == null) + { + m_log.WarnFormat("[Materials]: SOP not found for localId: {0}", primLocalID.ToString()); + continue; + } + + Primitive.TextureEntry te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length); + if (te == null) + { + m_log.WarnFormat("[Materials]: Error in TextureEntry for SOP {0} {1}", sop.Name, sop.UUID); + continue; + } + UUID id; if (mat == null) { + // This happens then the user removes a material from a prim id = UUID.Zero; } else { - id = HashOsd(mat); - lock (m_knownMaterials) - m_knownMaterials[id] = mat; + // Material UUID = hash of the material's data. + // This makes materials deduplicate across the entire grid (but isn't otherwise required). + byte[] data = System.Text.Encoding.ASCII.GetBytes(OSDParser.SerializeLLSDXmlString(mat)); + using (var md5 = MD5.Create()) + id = new UUID(md5.ComputeHash(data), 0); + + lock (m_regionMaterials) + { + if (!m_regionMaterials.ContainsKey(id)) + { + m_regionMaterials[id] = mat; + + // This asset might exist already, but it's ok to try to store it again + string name = "Material " + ChooseMaterialName(mat, sop); + name = name.Substring(0, Math.Min(64, name.Length)).Trim(); + AssetBase asset = new AssetBase(id, name, (sbyte)OpenSimAssetType.Material, sop.OwnerID.ToString()); + asset.Data = data; + m_scene.AssetService.Store(asset); + } + } } - var sop = m_scene.GetSceneObjectPart(primLocalID); - if (sop == null) - m_log.Debug("[MaterialsDemoModule]: null SOP for localId: " + primLocalID.ToString()); - else - { - var te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length); - if (te == null) + int face = -1; + + if (matsMap.ContainsKey("Face")) + { + face = matsMap["Face"].AsInteger(); + if (te.FaceTextures == null) // && face == 0) { - m_log.Debug("[MaterialsDemoModule]: null TextureEntry for localId: " + primLocalID.ToString()); + if (te.DefaultTexture == null) + m_log.WarnFormat("[Materials]: te.DefaultTexture is null in {0} {1}", sop.Name, sop.UUID); + else + te.DefaultTexture.MaterialID = id; } else { - int face = -1; - - if (matsMap.ContainsKey("Face")) - { - face = matsMap["Face"].AsInteger(); - if (te.FaceTextures == null) // && face == 0) - { - if (te.DefaultTexture == null) - m_log.Debug("[MaterialsDemoModule]: te.DefaultTexture is null"); - else - te.DefaultTexture.MaterialID = id; - } - else - { - if (te.FaceTextures.Length >= face - 1) - { - if (te.FaceTextures[face] == null) - te.DefaultTexture.MaterialID = id; - else - te.FaceTextures[face].MaterialID = id; - } - } - } - else + if (te.FaceTextures.Length >= face - 1) { - if (te.DefaultTexture != null) + if (te.FaceTextures[face] == null) te.DefaultTexture.MaterialID = id; + else + te.FaceTextures[face].MaterialID = id; } + } + } + else + { + if (te.DefaultTexture != null) + te.DefaultTexture.MaterialID = id; + } - //m_log.DebugFormat("[MaterialsDemoModule]: in \"{0}\", setting material ID for face {1} to {2}", sop.Name, face, id); - - //we cant use sop.UpdateTextureEntry(te); because it filters so do it manually - - if (sop.ParentGroup != null) - { - sop.Shape.TextureEntry = te.GetBytes(); - sop.TriggerScriptChangedEvent(Changed.TEXTURE); - sop.UpdateFlag = UpdateRequired.FULL; - sop.ParentGroup.HasGroupChanged = true; + //m_log.DebugFormat("[Materials]: in \"{0}\" {1}, setting material ID for face {2} to {3}", sop.Name, sop.UUID, face, id); - sop.ScheduleFullUpdate(); + // We can't use sop.UpdateTextureEntry(te) because it filters, so do it manually + sop.Shape.TextureEntry = te.GetBytes(); - StoreMaterialsForPart(sop); - } - } + if (sop.ParentGroup != null) + { + sop.TriggerScriptChangedEvent(Changed.TEXTURE); + sop.UpdateFlag = UpdateRequired.FULL; + sop.ParentGroup.HasGroupChanged = true; + sop.ScheduleFullUpdate(); } } } catch (Exception e) { - m_log.Warn("[MaterialsDemoModule]: exception processing received material ", e); + m_log.Warn("[Materials]: exception processing received material ", e); } } } @@ -472,36 +389,63 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule } catch (Exception e) { - m_log.Warn("[MaterialsDemoModule]: exception decoding zipped CAP payload ", e); + m_log.Warn("[Materials]: exception decoding zipped CAP payload ", e); //return ""; } - //m_log.Debug("[MaterialsDemoModule]: knownMaterials.Count: " + m_knownMaterials.Count.ToString()); } resp["Zipped"] = ZCompressOSD(respArr, false); string response = OSDParser.SerializeLLSDXmlString(resp); - //m_log.Debug("[MaterialsDemoModule]: cap request: " + request); - //m_log.Debug("[MaterialsDemoModule]: cap request (zipped portion): " + ZippedOsdBytesToString(req["Zipped"].AsBinary())); - //m_log.Debug("[MaterialsDemoModule]: cap response: " + response); + //m_log.Debug("[Materials]: cap request: " + request); + //m_log.Debug("[Materials]: cap request (zipped portion): " + ZippedOsdBytesToString(req["Zipped"].AsBinary())); + //m_log.Debug("[Materials]: cap response: " + response); return response; } + /// + /// Use heuristics to choose a good name for the material. + /// + private string ChooseMaterialName(OSDMap mat, SceneObjectPart sop) + { + UUID normMap = mat["NormMap"].AsUUID(); + if (normMap != UUID.Zero) + { + AssetBase asset = m_scene.AssetService.GetCached(normMap.ToString()); + if ((asset != null) && (asset.Name.Length > 0) && !asset.Name.Equals("From IAR")) + return asset.Name; + } + + UUID specMap = mat["SpecMap"].AsUUID(); + if (specMap != UUID.Zero) + { + AssetBase asset = m_scene.AssetService.GetCached(specMap.ToString()); + if ((asset != null) && (asset.Name.Length > 0) && !asset.Name.Equals("From IAR")) + return asset.Name; + } + + if (sop.Name != "Primitive") + return sop.Name; + + if ((sop.ParentGroup != null) && (sop.ParentGroup.Name != "Primitive")) + return sop.ParentGroup.Name; + + return ""; + } + public string RenderMaterialsGetCap(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { - //m_log.Debug("[MaterialsDemoModule]: GET cap handler"); - OSDMap resp = new OSDMap(); int matsCount = 0; OSDArray allOsd = new OSDArray(); - lock (m_knownMaterials) + lock (m_regionMaterials) { - foreach (KeyValuePair kvp in m_knownMaterials) + foreach (KeyValuePair kvp in m_regionMaterials) { OSDMap matMap = new OSDMap(); @@ -513,12 +457,11 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule } resp["Zipped"] = ZCompressOSD(allOsd, false); - //m_log.Debug("[MaterialsDemoModule]: matsCount: " + matsCount.ToString()); return OSDParser.SerializeLLSDXmlString(resp); } - static string ZippedOsdBytesToString(byte[] bytes) + private static string ZippedOsdBytesToString(byte[] bytes) { try { @@ -537,26 +480,27 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule /// private static UUID HashOsd(OSD osd) { + byte[] data = OSDParser.SerializeLLSDBinary(osd, false); using (var md5 = MD5.Create()) - using (MemoryStream ms = new MemoryStream(OSDParser.SerializeLLSDBinary(osd, false))) - return new UUID(md5.ComputeHash(ms), 0); + return new UUID(md5.ComputeHash(data), 0); } public static OSD ZCompressOSD(OSD inOsd, bool useHeader) { OSD osd = null; + byte[] data = OSDParser.SerializeLLSDBinary(inOsd, useHeader); + using (MemoryStream msSinkCompressed = new MemoryStream()) { using (Ionic.Zlib.ZlibStream zOut = new Ionic.Zlib.ZlibStream(msSinkCompressed, Ionic.Zlib.CompressionMode.Compress, CompressionLevel.BestCompression, true)) { - CopyStream(new MemoryStream(OSDParser.SerializeLLSDBinary(inOsd, useHeader)), zOut); - zOut.Close(); + zOut.Write(data, 0, data.Length); } msSinkCompressed.Seek(0L, SeekOrigin.Begin); - osd = OSD.FromBinary( msSinkCompressed.ToArray()); + osd = OSD.FromBinary(msSinkCompressed.ToArray()); } return osd; @@ -571,94 +515,14 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule { using (Ionic.Zlib.ZlibStream zOut = new Ionic.Zlib.ZlibStream(msSinkUnCompressed, CompressionMode.Decompress, true)) { - CopyStream(new MemoryStream(input), zOut); - zOut.Close(); + zOut.Write(input, 0, input.Length); } + msSinkUnCompressed.Seek(0L, SeekOrigin.Begin); osd = OSDParser.DeserializeLLSDBinary(msSinkUnCompressed.ToArray()); } return osd; } - - static void CopyStream(System.IO.Stream input, System.IO.Stream output) - { - byte[] buffer = new byte[2048]; - int len; - while ((len = input.Read(buffer, 0, 2048)) > 0) - { - output.Write(buffer, 0, len); - } - - output.Flush(); - } - - // FIXME: This code is currently still in UuidGatherer since we cannot use Scene.EventManager as some - // calls to the gatherer are done for objects with no scene. -// /// -// /// Gather all of the texture asset UUIDs used to reference "Materials" such as normal and specular maps -// /// -// /// -// /// -// private void GatherMaterialsUuids(SceneObjectPart part, IDictionary assetUuids) -// { -// // scan thru the dynAttrs map of this part for any textures used as materials -// OSD osdMaterials = null; -// -// lock (part.DynAttrs) -// { -// if (part.DynAttrs.ContainsStore("OpenSim", "Materials")) -// { -// OSDMap materialsStore = part.DynAttrs.GetStore("OpenSim", "Materials"); -// if (materialsStore == null) -// return; -// -// materialsStore.TryGetValue("Materials", out osdMaterials); -// } -// -// if (osdMaterials != null) -// { -// //m_log.Info("[UUID Gatherer]: found Materials: " + OSDParser.SerializeJsonString(osd)); -// -// if (osdMaterials is OSDArray) -// { -// OSDArray matsArr = osdMaterials as OSDArray; -// foreach (OSDMap matMap in matsArr) -// { -// try -// { -// if (matMap.ContainsKey("Material")) -// { -// OSDMap mat = matMap["Material"] as OSDMap; -// if (mat.ContainsKey("NormMap")) -// { -// UUID normalMapId = mat["NormMap"].AsUUID(); -// if (normalMapId != UUID.Zero) -// { -// assetUuids[normalMapId] = AssetType.Texture; -// //m_log.Info("[UUID Gatherer]: found normal map ID: " + normalMapId.ToString()); -// } -// } -// if (mat.ContainsKey("SpecMap")) -// { -// UUID specularMapId = mat["SpecMap"].AsUUID(); -// if (specularMapId != UUID.Zero) -// { -// assetUuids[specularMapId] = AssetType.Texture; -// //m_log.Info("[UUID Gatherer]: found specular map ID: " + specularMapId.ToString()); -// } -// } -// } -// -// } -// catch (Exception e) -// { -// m_log.Warn("[MaterialsDemoModule]: exception getting materials: " + e.Message); -// } -// } -// } -// } -// } -// } } } -- cgit v1.1 From 68d83425c6b39614210b28e97d5006a882ea3097 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Thu, 12 Dec 2013 15:14:24 +0200 Subject: When asked to change the Material for one face, change only that face; not the default material --- .../OptionalModules/Materials/MaterialsModule.cs | 23 +++++----------------- 1 file changed, 5 insertions(+), 18 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs index 09041e8..9779594 100644 --- a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs @@ -339,27 +339,14 @@ namespace OpenSim.Region.OptionalModules.Materials if (matsMap.ContainsKey("Face")) { face = matsMap["Face"].AsInteger(); - if (te.FaceTextures == null) // && face == 0) - { - if (te.DefaultTexture == null) - m_log.WarnFormat("[Materials]: te.DefaultTexture is null in {0} {1}", sop.Name, sop.UUID); - else - te.DefaultTexture.MaterialID = id; - } - else - { - if (te.FaceTextures.Length >= face - 1) - { - if (te.FaceTextures[face] == null) - te.DefaultTexture.MaterialID = id; - else - te.FaceTextures[face].MaterialID = id; - } - } + Primitive.TextureEntryFace faceEntry = te.CreateFace((uint)face); + faceEntry.MaterialID = id; } else { - if (te.DefaultTexture != null) + if (te.DefaultTexture == null) + m_log.WarnFormat("[Materials]: TextureEntry.DefaultTexture is null in {0} {1}", sop.Name, sop.UUID); + else te.DefaultTexture.MaterialID = id; } -- cgit v1.1 From d1f16c4b4b3f5c0938f3f0572c70e92cb90b6a0b Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Sun, 5 Jan 2014 14:03:10 +0200 Subject: Check agent permissions before modifying an object's materials. Also, when creating a Material asset, set the current agent as the Creator. --- .../OptionalModules/Materials/MaterialsModule.cs | 31 +++++++++++++++------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs index 9779594..4b635d8 100644 --- a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs @@ -109,7 +109,10 @@ namespace OpenSim.Region.OptionalModules.Materials string capsBase = "/CAPS/" + caps.CapsObjectPath; IRequestHandler renderMaterialsPostHandler - = new RestStreamHandler("POST", capsBase + "/", RenderMaterialsPostCap, "RenderMaterials", null); + = new RestStreamHandler("POST", capsBase + "/", + (request, path, param, httpRequest, httpResponse) + => RenderMaterialsPostCap(request, agentID), + "RenderMaterials", null); caps.RegisterHandler("RenderMaterials", renderMaterialsPostHandler); // OpenSimulator CAPs infrastructure seems to be somewhat hostile towards any CAP that requires both GET @@ -117,12 +120,18 @@ namespace OpenSim.Region.OptionalModules.Materials // handler normally and then add a GET handler via MainServer IRequestHandler renderMaterialsGetHandler - = new RestStreamHandler("GET", capsBase + "/", RenderMaterialsGetCap, "RenderMaterials", null); + = new RestStreamHandler("GET", capsBase + "/", + (request, path, param, httpRequest, httpResponse) + => RenderMaterialsGetCap(request), + "RenderMaterials", null); MainServer.Instance.AddStreamHandler(renderMaterialsGetHandler); // materials viewer seems to use either POST or PUT, so assign POST handler for PUT as well IRequestHandler renderMaterialsPutHandler - = new RestStreamHandler("PUT", capsBase + "/", RenderMaterialsPostCap, "RenderMaterials", null); + = new RestStreamHandler("PUT", capsBase + "/", + (request, path, param, httpRequest, httpResponse) + => RenderMaterialsPostCap(request, agentID), + "RenderMaterials", null); MainServer.Instance.AddStreamHandler(renderMaterialsPutHandler); } @@ -195,9 +204,7 @@ namespace OpenSim.Region.OptionalModules.Materials } } - public string RenderMaterialsPostCap(string request, string path, - string param, IOSHttpRequest httpRequest, - IOSHttpResponse httpResponse) + public string RenderMaterialsPostCap(string request, UUID agentID) { OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); OSDMap resp = new OSDMap(); @@ -295,6 +302,12 @@ namespace OpenSim.Region.OptionalModules.Materials continue; } + if (!m_scene.Permissions.CanEditObject(sop.UUID, agentID)) + { + m_log.WarnFormat("User {0} can't edit object {1} {2}", agentID, sop.Name, sop.UUID); + continue; + } + Primitive.TextureEntry te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length); if (te == null) { @@ -326,7 +339,7 @@ namespace OpenSim.Region.OptionalModules.Materials // This asset might exist already, but it's ok to try to store it again string name = "Material " + ChooseMaterialName(mat, sop); name = name.Substring(0, Math.Min(64, name.Length)).Trim(); - AssetBase asset = new AssetBase(id, name, (sbyte)OpenSimAssetType.Material, sop.OwnerID.ToString()); + AssetBase asset = new AssetBase(id, name, (sbyte)OpenSimAssetType.Material, agentID.ToString()); asset.Data = data; m_scene.AssetService.Store(asset); } @@ -422,9 +435,7 @@ namespace OpenSim.Region.OptionalModules.Materials } - public string RenderMaterialsGetCap(string request, string path, - string param, IOSHttpRequest httpRequest, - IOSHttpResponse httpResponse) + public string RenderMaterialsGetCap(string request) { OSDMap resp = new OSDMap(); int matsCount = 0; -- cgit v1.1 From 28723beb0ccec654ac24ee1632b137b424fd3360 Mon Sep 17 00:00:00 2001 From: dahlia Date: Mon, 20 Jan 2014 02:57:08 -0800 Subject: Add code to convert legacy materials stored in DynAttrs to new asset format and store them as assets --- .../OptionalModules/Materials/MaterialsModule.cs | 122 +++++++++++++++++---- 1 file changed, 102 insertions(+), 20 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs index 4b635d8..1b5a7a3 100644 --- a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs @@ -149,12 +149,87 @@ namespace OpenSim.Region.OptionalModules.Materials } /// + /// Searches the part for any legacy materials stored in DynAttrs and converts them to assets, replacing + /// the MaterialIDs in the TextureEntries for the part. + /// Deletes the legacy materials from the part as they are no longer needed. + /// + /// + private void ConvertLegacyMaterialsInPart(SceneObjectPart part) + { + if (part.DynAttrs == null) + return; + + var te = new Primitive.TextureEntry(part.Shape.TextureEntry, 0, part.Shape.TextureEntry.Length); + if (te == null) + return; + + OSD OSMaterials = null; + OSDArray matsArr = null; + + lock (part.DynAttrs) + { + if (part.DynAttrs.ContainsStore("OpenSim", "Materials")) + { + OSDMap materialsStore = part.DynAttrs.GetStore("OpenSim", "Materials"); + + if (materialsStore == null) + return; + + materialsStore.TryGetValue("Materials", out OSMaterials); + } + + if (OSMaterials != null && OSMaterials is OSDArray) + matsArr = OSMaterials as OSDArray; + else + return; + } + + if (matsArr == null) + return; + + foreach (OSD elemOsd in matsArr) + { + if (elemOsd != null && elemOsd is OSDMap) + { + OSDMap matMap = elemOsd as OSDMap; + if (matMap.ContainsKey("ID") && matMap.ContainsKey("Material")) + { + UUID id = matMap["ID"].AsUUID(); + OSDMap material = (OSDMap)matMap["Material"]; + bool used = false; + + foreach (var face in te.FaceTextures) + if (face.MaterialID == id) + used = true; + + if (used) + { // store legacy material in new asset format, and update the part texture entry with the new hashed UUID + + var newId = StoreMaterialAsAsset(part.CreatorID, material, part); + foreach (var face in te.FaceTextures) + if (face.MaterialID == id) + face.MaterialID = newId; + } + } + } + } + + part.Shape.TextureEntry = te.GetBytes(); + + lock (part.DynAttrs) + part.DynAttrs.RemoveStore("OpenSim", "Materials"); + } + + /// /// Find the materials used in the SOP, and add them to 'm_regionMaterials'. /// private void GetStoredMaterialsInPart(SceneObjectPart part) { if (part.Shape == null) return; + + ConvertLegacyMaterialsInPart(part); + var te = new Primitive.TextureEntry(part.Shape.TextureEntry, 0, part.Shape.TextureEntry.Length); if (te == null) return; @@ -324,26 +399,7 @@ namespace OpenSim.Region.OptionalModules.Materials } else { - // Material UUID = hash of the material's data. - // This makes materials deduplicate across the entire grid (but isn't otherwise required). - byte[] data = System.Text.Encoding.ASCII.GetBytes(OSDParser.SerializeLLSDXmlString(mat)); - using (var md5 = MD5.Create()) - id = new UUID(md5.ComputeHash(data), 0); - - lock (m_regionMaterials) - { - if (!m_regionMaterials.ContainsKey(id)) - { - m_regionMaterials[id] = mat; - - // This asset might exist already, but it's ok to try to store it again - string name = "Material " + ChooseMaterialName(mat, sop); - name = name.Substring(0, Math.Min(64, name.Length)).Trim(); - AssetBase asset = new AssetBase(id, name, (sbyte)OpenSimAssetType.Material, agentID.ToString()); - asset.Data = data; - m_scene.AssetService.Store(asset); - } - } + id = StoreMaterialAsAsset(agentID, mat, sop); } @@ -404,6 +460,32 @@ namespace OpenSim.Region.OptionalModules.Materials return response; } + private UUID StoreMaterialAsAsset(UUID agentID, OSDMap mat, SceneObjectPart sop) + { + UUID id; + // Material UUID = hash of the material's data. + // This makes materials deduplicate across the entire grid (but isn't otherwise required). + byte[] data = System.Text.Encoding.ASCII.GetBytes(OSDParser.SerializeLLSDXmlString(mat)); + using (var md5 = MD5.Create()) + id = new UUID(md5.ComputeHash(data), 0); + + lock (m_regionMaterials) + { + if (!m_regionMaterials.ContainsKey(id)) + { + m_regionMaterials[id] = mat; + + // This asset might exist already, but it's ok to try to store it again + string name = "Material " + ChooseMaterialName(mat, sop); + name = name.Substring(0, Math.Min(64, name.Length)).Trim(); + AssetBase asset = new AssetBase(id, name, (sbyte)OpenSimAssetType.Material, agentID.ToString()); + asset.Data = data; + m_scene.AssetService.Store(asset); + } + } + return id; + } + /// /// Use heuristics to choose a good name for the material. /// -- cgit v1.1 From 95c926b2cd8585dd5b84ad7827d21b6122ea1001 Mon Sep 17 00:00:00 2001 From: dahlia Date: Mon, 20 Jan 2014 03:02:30 -0800 Subject: delay texture entry parsing until absolutely necessary while converting legacy materials --- OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs index 1b5a7a3..d8ec979 100644 --- a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs @@ -159,10 +159,6 @@ namespace OpenSim.Region.OptionalModules.Materials if (part.DynAttrs == null) return; - var te = new Primitive.TextureEntry(part.Shape.TextureEntry, 0, part.Shape.TextureEntry.Length); - if (te == null) - return; - OSD OSMaterials = null; OSDArray matsArr = null; @@ -187,6 +183,10 @@ namespace OpenSim.Region.OptionalModules.Materials if (matsArr == null) return; + var te = new Primitive.TextureEntry(part.Shape.TextureEntry, 0, part.Shape.TextureEntry.Length); + if (te == null) + return; + foreach (OSD elemOsd in matsArr) { if (elemOsd != null && elemOsd is OSDMap) -- cgit v1.1 From 36d8a24a867fbbc95214653fec463aced8ba7c5f Mon Sep 17 00:00:00 2001 From: dahlia Date: Mon, 20 Jan 2014 03:11:01 -0800 Subject: force SOG update when converting legacy materials to ensure changes are persisted --- OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs index d8ec979..ce2a56a 100644 --- a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs @@ -215,6 +215,8 @@ namespace OpenSim.Region.OptionalModules.Materials } part.Shape.TextureEntry = te.GetBytes(); + part.ParentGroup.HasGroupChanged = true; + part.ScheduleFullUpdate(); lock (part.DynAttrs) part.DynAttrs.RemoveStore("OpenSim", "Materials"); -- cgit v1.1 From 2e78e89c36e661f72773e54f97bec3f04af67b79 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Mon, 20 Jan 2014 11:33:49 -0800 Subject: Clean up orphaned json stores. This can happen when an object is removed, when a script is removed, or when a script is reset. Also added a stats command to track the number of json stores used by a region. Will probably add some more commands later. --- .../Scripting/JsonStore/JsonStoreCommands.cs | 195 +++++++++++++++++++++ .../Scripting/JsonStore/JsonStoreModule.cs | 41 ++++- .../Scripting/JsonStore/JsonStoreScriptModule.cs | 41 ++++- 3 files changed, 274 insertions(+), 3 deletions(-) create mode 100644 OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreCommands.cs (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreCommands.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreCommands.cs new file mode 100644 index 0000000..d4b19dd --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreCommands.cs @@ -0,0 +1,195 @@ +/* + * Copyright (c) Contributors + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +using Mono.Addins; + +using System; +using System.Reflection; +using System.Threading; +using System.Text; +using System.Net; +using System.Net.Sockets; +using log4net; +using Nini.Config; +using OpenMetaverse; +using OpenMetaverse.StructuredData; +using OpenSim.Framework; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using System.Collections.Generic; +using System.Text.RegularExpressions; + +namespace OpenSim.Region.OptionalModules.Scripting.JsonStore +{ + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "JsonStoreCommandsModule")] + + public class JsonStoreCommandsModule : INonSharedRegionModule + { + private static readonly ILog m_log = + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private IConfig m_config = null; + private bool m_enabled = false; + + private Scene m_scene = null; + //private IJsonStoreModule m_store; + private JsonStoreModule m_store; + +#region Region Module interface + + // ----------------------------------------------------------------- + /// + /// Name of this shared module is it's class name + /// + // ----------------------------------------------------------------- + public string Name + { + get { return this.GetType().Name; } + } + + // ----------------------------------------------------------------- + /// + /// Initialise this shared module + /// + /// this region is getting initialised + /// nini config, we are not using this + // ----------------------------------------------------------------- + public void Initialise(IConfigSource config) + { + try + { + if ((m_config = config.Configs["JsonStore"]) == null) + { + // There is no configuration, the module is disabled + // m_log.InfoFormat("[JsonStore] no configuration info"); + return; + } + + m_enabled = m_config.GetBoolean("Enabled", m_enabled); + } + catch (Exception e) + { + m_log.Error("[JsonStore]: initialization error: {0}", e); + return; + } + + if (m_enabled) + m_log.DebugFormat("[JsonStore]: module is enabled"); + } + + // ----------------------------------------------------------------- + /// + /// everything is loaded, perform post load configuration + /// + // ----------------------------------------------------------------- + public void PostInitialise() + { + } + + // ----------------------------------------------------------------- + /// + /// Nothing to do on close + /// + // ----------------------------------------------------------------- + public void Close() + { + } + + // ----------------------------------------------------------------- + /// + /// + // ----------------------------------------------------------------- + public void AddRegion(Scene scene) + { + if (m_enabled) + { + m_scene = scene; + + } + } + + // ----------------------------------------------------------------- + /// + /// + // ----------------------------------------------------------------- + public void RemoveRegion(Scene scene) + { + // need to remove all references to the scene in the subscription + // list to enable full garbage collection of the scene object + } + + // ----------------------------------------------------------------- + /// + /// Called when all modules have been added for a region. This is + /// where we hook up events + /// + // ----------------------------------------------------------------- + public void RegionLoaded(Scene scene) + { + if (m_enabled) + { + m_scene = scene; + + m_store = (JsonStoreModule) m_scene.RequestModuleInterface(); + if (m_store == null) + { + m_log.ErrorFormat("[JsonStoreCommands]: JsonModule interface not defined"); + m_enabled = false; + return; + } + + scene.AddCommand("JsonStore", this, "jsonstore stats", "jsonstore stats", + "Display statistics about the state of the JsonStore module", "", + CmdStats); + } + } + + /// ----------------------------------------------------------------- + /// + /// + // ----------------------------------------------------------------- + public Type ReplaceableInterface + { + get { return null; } + } + +#endregion + +#region Commands + + private void CmdStats(string module, string[] cmd) + { + if (MainConsole.Instance.ConsoleScene != m_scene && MainConsole.Instance.ConsoleScene != null) + return; + + JsonStoreStats stats = m_store.GetStoreStats(); + MainConsole.Instance.OutputFormat("{0}\t{1}",m_scene.RegionInfo.RegionName,stats.StoreCount); + } + +#endregion + + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs index 5fbfcc5..b502a55 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs @@ -42,7 +42,6 @@ using OpenSim.Region.Framework.Scenes; using System.Collections.Generic; using System.Text.RegularExpressions; - namespace OpenSim.Region.OptionalModules.Scripting.JsonStore { [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "JsonStoreModule")] @@ -60,6 +59,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore private Scene m_scene = null; private Dictionary m_JsonValueStore; + private UUID m_sharedStore; #region Region Module interface @@ -140,6 +140,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore m_sharedStore = UUID.Zero; m_JsonValueStore = new Dictionary(); m_JsonValueStore.Add(m_sharedStore,new JsonStore("")); + + scene.EventManager.OnObjectBeingRemovedFromScene += EventManagerOnObjectBeingRemovedFromScene; } } @@ -149,6 +151,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore // ----------------------------------------------------------------- public void RemoveRegion(Scene scene) { + scene.EventManager.OnObjectBeingRemovedFromScene -= EventManagerOnObjectBeingRemovedFromScene; + // need to remove all references to the scene in the subscription // list to enable full garbage collection of the scene object } @@ -161,7 +165,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore // ----------------------------------------------------------------- public void RegionLoaded(Scene scene) { - if (m_enabled) {} + if (m_enabled) + { + } } /// ----------------------------------------------------------------- @@ -175,8 +181,39 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore #endregion +#region SceneEvents + // ----------------------------------------------------------------- + /// + /// + /// + // ----------------------------------------------------------------- + public void EventManagerOnObjectBeingRemovedFromScene(SceneObjectGroup obj) + { + obj.ForEachPart(delegate(SceneObjectPart sop) { DestroyStore(sop.UUID); } ); + } + +#endregion + #region ScriptInvocationInteface + + // ----------------------------------------------------------------- + /// + /// + /// + // ----------------------------------------------------------------- + public JsonStoreStats GetStoreStats() + { + JsonStoreStats stats; + + lock (m_JsonValueStore) + { + stats.StoreCount = m_JsonValueStore.Count; + } + + return stats; + } + // ----------------------------------------------------------------- /// /// diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs index 1bb5aee..9fbfb66 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs @@ -59,7 +59,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore private IScriptModuleComms m_comms; private IJsonStoreModule m_store; - + + private Dictionary> m_scriptStores = new Dictionary>(); + #region Region Module interface // ----------------------------------------------------------------- @@ -126,6 +128,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore // ----------------------------------------------------------------- public void AddRegion(Scene scene) { + scene.EventManager.OnScriptReset += HandleScriptReset; + scene.EventManager.OnRemoveScript += HandleScriptReset; } // ----------------------------------------------------------------- @@ -134,12 +138,34 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore // ----------------------------------------------------------------- public void RemoveRegion(Scene scene) { + scene.EventManager.OnScriptReset -= HandleScriptReset; + scene.EventManager.OnRemoveScript -= HandleScriptReset; + // need to remove all references to the scene in the subscription // list to enable full garbage collection of the scene object } // ----------------------------------------------------------------- /// + /// + // ----------------------------------------------------------------- + private void HandleScriptReset(uint localID, UUID itemID) + { + HashSet stores; + + lock (m_scriptStores) + { + if (! m_scriptStores.TryGetValue(itemID, out stores)) + return; + m_scriptStores.Remove(itemID); + } + + foreach (UUID id in stores) + m_store.DestroyStore(id); + } + + // ----------------------------------------------------------------- + /// /// Called when all modules have been added for a region. This is /// where we hook up events /// @@ -250,6 +276,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore if (! m_store.CreateStore(value, ref uuid)) GenerateRuntimeError("Failed to create Json store"); + lock (m_scriptStores) + { + if (! m_scriptStores.ContainsKey(scriptID)) + m_scriptStores[scriptID] = new HashSet(); + + m_scriptStores[scriptID].Add(uuid); + } return uuid; } @@ -261,6 +294,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore [ScriptInvocation] public int JsonDestroyStore(UUID hostID, UUID scriptID, UUID storeID) { + lock(m_scriptStores) + { + if (m_scriptStores.ContainsKey(scriptID)) + m_scriptStores[scriptID].Remove(storeID); + } + return m_store.DestroyStore(storeID) ? 1 : 0; } -- cgit v1.1 From 1cae3664a52fe48965954afc19804b11720c4add Mon Sep 17 00:00:00 2001 From: dahlia Date: Mon, 20 Jan 2014 11:53:33 -0800 Subject: add null texture entry face check before converting legacy materials --- OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs index ce2a56a..c4bc8a0 100644 --- a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs @@ -199,7 +199,7 @@ namespace OpenSim.Region.OptionalModules.Materials bool used = false; foreach (var face in te.FaceTextures) - if (face.MaterialID == id) + if (face != null && face.MaterialID == id) used = true; if (used) @@ -207,7 +207,7 @@ namespace OpenSim.Region.OptionalModules.Materials var newId = StoreMaterialAsAsset(part.CreatorID, material, part); foreach (var face in te.FaceTextures) - if (face.MaterialID == id) + if (face != null && face.MaterialID == id) face.MaterialID = newId; } } -- cgit v1.1 From af58631f00b95081dc99f4f75e8ec6b031b8cf2a Mon Sep 17 00:00:00 2001 From: dahlia Date: Mon, 20 Jan 2014 13:57:14 -0800 Subject: rather than converting existing materials to assets, just retrieve them and make them available for viewing. Any new materials added to the scene will become assets. --- .../OptionalModules/Materials/MaterialsModule.cs | 44 ++++++---------------- 1 file changed, 12 insertions(+), 32 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs index c4bc8a0..afb788b 100644 --- a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs @@ -149,12 +149,10 @@ namespace OpenSim.Region.OptionalModules.Materials } /// - /// Searches the part for any legacy materials stored in DynAttrs and converts them to assets, replacing - /// the MaterialIDs in the TextureEntries for the part. - /// Deletes the legacy materials from the part as they are no longer needed. + /// Finds any legacy materials stored in DynAttrs that may exist for this part and add them to 'm_regionMaterials'. /// /// - private void ConvertLegacyMaterialsInPart(SceneObjectPart part) + private void GetLegacyStoredMaterialsInPart(SceneObjectPart part) { if (part.DynAttrs == null) return; @@ -183,10 +181,6 @@ namespace OpenSim.Region.OptionalModules.Materials if (matsArr == null) return; - var te = new Primitive.TextureEntry(part.Shape.TextureEntry, 0, part.Shape.TextureEntry.Length); - if (te == null) - return; - foreach (OSD elemOsd in matsArr) { if (elemOsd != null && elemOsd is OSDMap) @@ -194,32 +188,18 @@ namespace OpenSim.Region.OptionalModules.Materials OSDMap matMap = elemOsd as OSDMap; if (matMap.ContainsKey("ID") && matMap.ContainsKey("Material")) { - UUID id = matMap["ID"].AsUUID(); - OSDMap material = (OSDMap)matMap["Material"]; - bool used = false; - - foreach (var face in te.FaceTextures) - if (face != null && face.MaterialID == id) - used = true; - - if (used) - { // store legacy material in new asset format, and update the part texture entry with the new hashed UUID - - var newId = StoreMaterialAsAsset(part.CreatorID, material, part); - foreach (var face in te.FaceTextures) - if (face != null && face.MaterialID == id) - face.MaterialID = newId; + try + { + lock (m_regionMaterials) + m_regionMaterials[matMap["ID"].AsUUID()] = (OSDMap)matMap["Material"]; + } + catch (Exception e) + { + m_log.Warn("[Materials]: exception decoding persisted legacy material: " + e.ToString()); } } } } - - part.Shape.TextureEntry = te.GetBytes(); - part.ParentGroup.HasGroupChanged = true; - part.ScheduleFullUpdate(); - - lock (part.DynAttrs) - part.DynAttrs.RemoveStore("OpenSim", "Materials"); } /// @@ -230,12 +210,12 @@ namespace OpenSim.Region.OptionalModules.Materials if (part.Shape == null) return; - ConvertLegacyMaterialsInPart(part); - var te = new Primitive.TextureEntry(part.Shape.TextureEntry, 0, part.Shape.TextureEntry.Length); if (te == null) return; + GetLegacyStoredMaterialsInPart(part); + GetStoredMaterialInFace(part, te.DefaultTexture); foreach (Primitive.TextureEntryFace face in te.FaceTextures) -- cgit v1.1 From 4a9796a50680ef7aeaa8c9c617b90205724879c8 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 24 Jan 2014 19:31:31 +0000 Subject: Skip IClientAPIs that don't implement IStatsCollector (such as NPCAvatar) from the "show queues" console report to stop screwing up formatting. "show pquques" already did this --- .../Agent/UDP/Linden/LindenUDPInfoModule.cs | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs index 1eb0a6b..3bf5585 100644 --- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs @@ -434,24 +434,24 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden scene.ForEachClient( delegate(IClientAPI client) { - bool isChild = client.SceneAgent.IsChildAgent; - if (isChild && !showChildren) - return; - - string name = client.Name; - if (pname != "" && name != pname) - return; - - string regionName = scene.RegionInfo.RegionName; - - report.Append(GetColumnEntry(name, maxNameLength, columnPadding)); - report.Append(GetColumnEntry(regionName, maxRegionNameLength, columnPadding)); - report.Append(GetColumnEntry(isChild ? "Cd" : "Rt", maxTypeLength, columnPadding)); - if (client is IStatsCollector) { - IStatsCollector stats = (IStatsCollector)client; + + bool isChild = client.SceneAgent.IsChildAgent; + if (isChild && !showChildren) + return; + string name = client.Name; + if (pname != "" && name != pname) + return; + + string regionName = scene.RegionInfo.RegionName; + + report.Append(GetColumnEntry(name, maxNameLength, columnPadding)); + report.Append(GetColumnEntry(regionName, maxRegionNameLength, columnPadding)); + report.Append(GetColumnEntry(isChild ? "Cd" : "Rt", maxTypeLength, columnPadding)); + + IStatsCollector stats = (IStatsCollector)client; report.AppendLine(stats.Report()); } }); -- cgit v1.1 From c9b5ba78d959e6368a525630fecc6103f317f1da Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 24 Jan 2014 19:36:12 +0000 Subject: minor: correct the usage statement on the "show image queues" console command - should not have been "image queues show" --- OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs index 3bf5585..034082e 100644 --- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs @@ -304,7 +304,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden private string GetImageQueuesReport(string[] showParams) { if (showParams.Length < 5 || showParams.Length > 6) - return "Usage: image queues show [full]"; + return "Usage: show image queues [full]"; string firstName = showParams[3]; string lastName = showParams[4]; -- cgit v1.1 From fea8345f560370d20e13f8362fc8f63396c2247f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 24 Jan 2014 19:40:14 +0000 Subject: minor: remove long unused state queue from "show queues" console reports --- .../OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs index 034082e..ec18db0 100644 --- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs @@ -395,7 +395,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden report.Append(GetColumnEntry("Type", maxTypeLength, columnPadding)); report.AppendFormat( - "{0,7} {1,7} {2,7} {3,7} {4,9} {5,7} {6,7} {7,7} {8,7} {9,7} {10,8} {11,7} {12,7}\n", + "{0,7} {1,7} {2,7} {3,7} {4,9} {5,7} {6,7} {7,7} {8,7} {9,7} {10,8} {11,7}\n", "Since", "Pkts", "Pkts", @@ -407,12 +407,11 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden "Q Pkts", "Q Pkts", "Q Pkts", - "Q Pkts", "Q Pkts"); report.AppendFormat("{0,-" + totalInfoFieldsLength + "}", ""); report.AppendFormat( - "{0,7} {1,7} {2,7} {3,7} {4,9} {5,7} {6,7} {7,7} {8,7} {9,7} {10,8} {11,7} {12,7}\n", + "{0,7} {1,7} {2,7} {3,7} {4,9} {5,7} {6,7} {7,7} {8,7} {9,7} {10,8} {11,7}\n", "Last In", "In", "Out", @@ -424,8 +423,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden "Cloud", "Task", "Texture", - "Asset", - "State"); + "Asset"); lock (m_scenes) { -- cgit v1.1 From e2fbc88d98b8e23b26716b6b800ab540ac0ca821 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 27 Jan 2014 22:56:51 +0000 Subject: Re-enabled NPCModuleTests.TestCreate() --- OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index 7f9e440..c65794e 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs @@ -110,8 +110,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests // ScenePresence.SendInitialData() to reset our entire appearance. m_scene.AssetService.Store(AssetHelpers.CreateNotecardAsset(originalFace8TextureId)); -/* - m_afMod.SetAppearance(sp, originalTe, null); + m_afMod.SetAppearance(sp, originalTe, null, null); UUID npcId = m_npcMod.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, sp.Appearance); @@ -126,7 +125,6 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests // Have to account for both SP and NPC. Assert.That(m_scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(2)); -*/ } [Test] -- cgit v1.1