From e9847a4dbd5657c16b11835301167a98e7ca7e55 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 14 May 2013 19:44:41 +0100 Subject: Comment out some debugging item permission messages since these are highly noisy on the console. Please re-enable when required --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 80581dc..6c79b13 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -422,13 +422,13 @@ namespace OpenSim.Region.Framework.Scenes // is not allowed to change the export flag. bool denyExportChange = false; - m_log.InfoFormat("[XXX]: B: {0} O: {1} E: {2}", itemUpd.BasePermissions, itemUpd.CurrentPermissions, itemUpd.EveryOnePermissions); +// m_log.DebugFormat("[XXX]: B: {0} O: {1} E: {2}", itemUpd.BasePermissions, itemUpd.CurrentPermissions, itemUpd.EveryOnePermissions); // If the user is not the creator or doesn't have "E" in both "B" and "O", deny setting export if ((item.BasePermissions & (uint)(PermissionMask.All | PermissionMask.Export)) != (uint)(PermissionMask.All | PermissionMask.Export) || (item.CurrentPermissions & (uint)PermissionMask.Export) == 0 || item.CreatorIdAsUuid != item.Owner) denyExportChange = true; - m_log.InfoFormat("[XXX]: Deny Export Update {0}", denyExportChange); +// m_log.DebugFormat("[XXX]: Deny Export Update {0}", denyExportChange); // If it is already set, force it set and also force full perm // else prevent setting it. It can and should never be set unless @@ -452,7 +452,7 @@ namespace OpenSim.Region.Framework.Scenes // If the new state is exportable, force full perm if ((itemUpd.EveryOnePermissions & (uint)PermissionMask.Export) != 0) { - m_log.InfoFormat("[XXX]: Force full perm"); +// m_log.DebugFormat("[XXX]: Force full perm"); itemUpd.NextPermissions = (uint)(PermissionMask.All); } } -- cgit v1.1 From df2a0fec5f2b0d7e9938c1bc1bdc965b767ec25f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 14 May 2013 20:11:58 +0100 Subject: Comment out log message about looking for asset data in remove asset service for now, in order to reduce log levels in a test region with many hg origin avatars --- OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs b/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs index afbe56b..a168bfe 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs @@ -426,7 +426,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (!assetServerURL.EndsWith("/") && !assetServerURL.EndsWith("=")) assetServerURL = assetServerURL + "/"; - m_log.DebugFormat("[J2KIMAGE]: texture {0} not found in local asset storage. Trying user's storage.", assetServerURL + id); +// m_log.DebugFormat("[J2KIMAGE]: texture {0} not found in local asset storage. Trying user's storage.", assetServerURL + id); AssetService.Get(assetServerURL + id, InventoryAccessModule, AssetReceived); return; } -- cgit v1.1 From 23ebae1828a540a7754dafae1794467582fe35d5 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 14 May 2013 13:40:07 -0700 Subject: Eliminate race condition where SimStatsReporter starts reporting stats before the region is completely initialized. --- OpenSim/Region/Framework/Scenes/SimStatsReporter.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs index b9d615e..95f9caf 100644 --- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs @@ -289,6 +289,9 @@ namespace OpenSim.Region.Framework.Scenes private void statsHeartBeat(object sender, EventArgs e) { + if (!m_scene.Active) + return; + SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[22]; SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); -- cgit v1.1 From 177a53fbcf521767f7277ccccabad689d7674953 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 15 May 2013 22:04:38 +0100 Subject: Fix issue where osMakeNotecard() would fail if given a list containing vectors or quaternions. http://opensimulator.org/mantis/view.php?id=6640 --- OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 60 ++++++++++++------------- 1 file changed, 30 insertions(+), 30 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index 44fdd1a..9ca5ca9 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs @@ -544,21 +544,33 @@ namespace OpenSim.Region.ScriptEngine.Shared set {m_data = value; } } - // Function to obtain LSL type from an index. This is needed - // because LSL lists allow for multiple types, and safely - // iterating in them requires a type check. + + /// + /// Obtain LSL type from an index. + /// + /// + /// This is needed because LSL lists allow for multiple types, and safely + /// iterating in them requires a type check. + /// + /// + /// public Type GetLSLListItemType(int itemIndex) { return m_data[itemIndex].GetType(); } - // Member functions to obtain item as specific types. - // For cases where implicit conversions would apply if items - // were not in a list (e.g. integer to float, but not float - // to integer) functions check for alternate types so as to - // down-cast from Object to the correct type. - // Note: no checks for item index being valid are performed - + /// + /// Obtain float from an index. + /// + /// + /// For cases where implicit conversions would apply if items + /// were not in a list (e.g. integer to float, but not float + /// to integer) functions check for alternate types so as to + /// down-cast from Object to the correct type. + /// Note: no checks for item index being valid are performed + /// + /// + /// public LSL_Types.LSLFloat GetLSLFloatItem(int itemIndex) { if (m_data[itemIndex] is LSL_Types.LSLInteger) @@ -589,26 +601,14 @@ namespace OpenSim.Region.ScriptEngine.Shared public LSL_Types.LSLString GetLSLStringItem(int itemIndex) { - if (m_data[itemIndex] is LSL_Types.key) - { - return (LSL_Types.key)m_data[itemIndex]; - } - else if (m_data[itemIndex] is String) - { - return new LSL_Types.LSLString((string)m_data[itemIndex]); - } - else if (m_data[itemIndex] is LSL_Types.LSLFloat) - { - return new LSL_Types.LSLString((LSLFloat)m_data[itemIndex]); - } - else if (m_data[itemIndex] is LSL_Types.LSLInteger) - { - return new LSL_Types.LSLString((LSLInteger)m_data[itemIndex]); - } - else - { - return (LSL_Types.LSLString)m_data[itemIndex]; - } + if (m_data[itemIndex] is LSL_Types.key) + { + return (LSL_Types.key)m_data[itemIndex]; + } + else + { + return new LSL_Types.LSLString(m_data[itemIndex].ToString()); + } } public LSL_Types.LSLInteger GetLSLIntegerItem(int itemIndex) -- cgit v1.1 From 46eb8465a01b7dd923b962035562c953d4eb78e4 Mon Sep 17 00:00:00 2001 From: dahlia Date: Wed, 15 May 2013 17:12:17 -0700 Subject: fall back to using a display mesh for physics proxy if no physics_mesh entry was wound in a mesh asset --- OpenSim/Region/Physics/Meshing/Meshmerizer.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index 8145d61..2d102de 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs @@ -358,6 +358,10 @@ namespace OpenSim.Region.Physics.Meshing physicsParms = (OSDMap)map["physics_shape"]; // old asset format else if (map.ContainsKey("physics_mesh")) physicsParms = (OSDMap)map["physics_mesh"]; // new asset format + else if (map.ContainsKey("medium_lod")) + physicsParms = (OSDMap)map["medium_lod"]; // if no physics mesh, try to fall back to medium LOD display mesh + else if (map.ContainsKey("high_lod")) + physicsParms = (OSDMap)map["high_lod"]; // if all else fails, use highest LOD display mesh and hope it works :) if (physicsParms == null) { -- cgit v1.1 From bd31821792a940709ff1355a91b9b60302cc1a17 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 16 May 2013 16:37:21 +0100 Subject: On logout, send close child agent requests to neighbours asynchronously, so user is not prevented from relogging if many neighbours are present but not responsive. The symptom here is that previous user connections are still present but are labelled active == false --- OpenSim/Region/Framework/Scenes/Scene.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 6bbcbd7..50bea6f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3435,16 +3435,13 @@ namespace OpenSim.Region.Framework.Scenes if (closeChildAgents && CapsModule != null) CapsModule.RemoveCaps(agentID); -// // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever -// // this method is doing is HORRIBLE!!! - // Commented pending deletion since this method no longer appears to do anything at all -// avatar.Scene.NeedSceneCacheClear(avatar.UUID); - if (closeChildAgents && !isChildAgent) { List regions = avatar.KnownRegionHandles; regions.Remove(RegionInfo.RegionHandle); - m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); + + // We must do this asynchronously so that a logout isn't held up where there are many present but unresponsive neighbours. + Util.FireAndForget(delegate { m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); }); } m_eventManager.TriggerClientClosed(agentID, this); -- cgit v1.1 From d214e2d0c4b8e1ea5e0d69e2ba94cd668be610bd Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 16 May 2013 17:12:02 +0100 Subject: On closing child agents, send separate asynchronous requests to each neighbour rather than sending all closes concurrently on a separate thread. This is to reduce race conditions where neighbours may be responding erratically, thus mixing up create and close agent requests in time. This mirrors OpenSimulator behaviour on enabling child agents where each region is contacted separately. --- OpenSim/Region/Framework/Scenes/Scene.cs | 4 ++-- OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs | 4 +--- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 ++---- 3 files changed, 5 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 50bea6f..8fe9b66 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3440,8 +3440,8 @@ namespace OpenSim.Region.Framework.Scenes List regions = avatar.KnownRegionHandles; regions.Remove(RegionInfo.RegionHandle); - // We must do this asynchronously so that a logout isn't held up where there are many present but unresponsive neighbours. - Util.FireAndForget(delegate { m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); }); + // This ends up being done asynchronously so that a logout isn't held up where there are many present but unresponsive neighbours. + m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); } m_eventManager.TriggerClientClosed(agentID, this); diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index 305f8a4..8c84c98 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs @@ -222,9 +222,7 @@ namespace OpenSim.Region.Framework.Scenes public void SendCloseChildAgentConnections(UUID agentID, List regionslst) { foreach (ulong handle in regionslst) - { - SendCloseChildAgent(agentID, handle); - } + Util.FireAndForget(delegate { SendCloseChildAgent(agentID, handle); }); } public List RequestNamedRegions(string name, int maxNumber) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 2a265db..9e9089b 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3135,10 +3135,8 @@ namespace OpenSim.Region.Framework.Scenes if (byebyeRegions.Count > 0) { m_log.Debug("[SCENE PRESENCE]: Closing " + byebyeRegions.Count + " child agents"); - Util.FireAndForget(delegate - { - m_scene.SceneGridService.SendCloseChildAgentConnections(ControllingClient.AgentId, byebyeRegions); - }); + + m_scene.SceneGridService.SendCloseChildAgentConnections(ControllingClient.AgentId, byebyeRegions); } foreach (ulong handle in byebyeRegions) -- cgit v1.1 From 3bc8cf65a4e933cfdd0597affc1685c74fb29dba Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 16 May 2013 17:30:30 +0100 Subject: Where this is not already happening, trigger asychoronous calls to CloseChildAgent() above the LocalSimulationConnector level. This is so that other callers (such as SceneCommunicationService.SendCloseChildAgentConnections() can perform all closes asynchronously without pointlessly firing another thread for local closes). No functional change apart from elimination of unnecessary chaining of new threads. --- .../Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | 1 + .../ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index eac0da7..9579449 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -937,6 +937,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer EnableChildAgents(sp); // Finally, kill the agent we just created at the destination. + // XXX: Possibly this should be done asynchronously. Scene.SimulationService.CloseAgent(finalDestination, sp.UUID); } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs index a413546..9427961 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs @@ -317,7 +317,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation // "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate", // s.RegionInfo.RegionName, destination.RegionHandle); - Util.FireAndForget(delegate { m_scenes[destination.RegionID].IncomingCloseAgent(id, false); }); + m_scenes[destination.RegionID].IncomingCloseAgent(id, false); return true; } -- cgit v1.1 From 61f4ab667447da953018b9e63821777ec5f144b0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 16 May 2013 18:25:04 +0100 Subject: minor: Remove completely unused IClientAPI.RequestClientInfo() call from EntityTransferModule.CrossAgentToNewRegionAsync() --- .../CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | 3 --- 1 file changed, 3 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 9579449..4f693c6 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -1482,9 +1482,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return agent; } - //AgentCircuitData circuitdata = m_controllingClient.RequestClientInfo(); - agent.ControllingClient.RequestClientInfo(); - //m_log.Debug("BEFORE CROSS"); //Scene.DumpChildrenSeeds(UUID); //DumpKnownRegions(); -- cgit v1.1 From ec818a506bd125b1a89b2ff04f15108521a0f2e9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 16 May 2013 18:26:22 +0100 Subject: minor: remove long commented out scene cache clearing code in EntityTransferModule.CrossAgentToNewRegionAsync() --- .../CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | 9 --------- 1 file changed, 9 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 4f693c6..f58a24f 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -1541,15 +1541,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer agent.CloseChildAgents(neighbourx, neighboury); AgentHasMovedAway(agent, false); - -// // the user may change their profile information in other region, -// // so the userinfo in UserProfileCache is not reliable any more, delete it -// // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE! -// if (agent.Scene.NeedSceneCacheClear(agent.UUID)) -// { -// m_log.DebugFormat( -// "[ENTITY TRANSFER MODULE]: User {0} is going to another region", agent.UUID); -// } //m_log.Debug("AFTER CROSS"); //Scene.DumpChildrenSeeds(UUID); -- cgit v1.1 From fa8f5bafb225624fe4a0df88acf1f4c227632fe0 Mon Sep 17 00:00:00 2001 From: dahlia Date: Sat, 18 May 2013 01:23:09 -0700 Subject: add prototype code to decode convex hulls from mesh assets. Please do not use yet; the interface will be defined in a later commit. --- OpenSim/Region/Physics/Meshing/Meshmerizer.cs | 131 +++++++++++++++++++++----- 1 file changed, 110 insertions(+), 21 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index 2d102de..825e622 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs @@ -79,6 +79,8 @@ namespace OpenSim.Region.Physics.Meshing private float minSizeForComplexMesh = 0.2f; // prims with all dimensions smaller than this will have a bounding box mesh + private List> mConvexHulls = null; + private Dictionary m_uniqueMeshes = new Dictionary(); public Meshmerizer(IConfigSource config) @@ -363,6 +365,57 @@ namespace OpenSim.Region.Physics.Meshing else if (map.ContainsKey("high_lod")) physicsParms = (OSDMap)map["high_lod"]; // if all else fails, use highest LOD display mesh and hope it works :) + if (map.ContainsKey("physics_convex")) + { // pull this out also in case physics engine can use it + try + { + OSDMap convexBlock = (OSDMap)map["physics_convex"]; + if (convexBlock.ContainsKey("HullList")) + { + byte[] hullList = convexBlock["HullList"].AsBinary(); + Vector3 min = new Vector3(-0.5f, -0.5f, -0.5f); + if (convexBlock.ContainsKey("Min")) min = convexBlock["Min"].AsVector3(); + Vector3 max = new Vector3(0.5f, 0.5f, 0.5f); + if (convexBlock.ContainsKey("Max")) max = convexBlock["Max"].AsVector3(); + + // decompress and decode hull points + byte[] posBytes = DecompressOsd(convexBlock["Positions"].AsBinary()).AsBinary(); + + List> hulls = new List>(); + int posNdx = 0; + + foreach (byte cnt in hullList) + { + int count = cnt == 0 ? 256 : cnt; + List hull = new List(); + + for (int i = 0; i < cnt; i++) + { + ushort uX = Utils.BytesToUInt16(posBytes, posNdx); posNdx += 2; + ushort uY = Utils.BytesToUInt16(posBytes, posNdx); posNdx += 2; + ushort uZ = Utils.BytesToUInt16(posBytes, posNdx); posNdx += 2; + + Vector3 pos = new Vector3( + Utils.UInt16ToFloat(uX, min.X, max.X) * size.X, + Utils.UInt16ToFloat(uY, min.Y, max.Y) * size.Y, + Utils.UInt16ToFloat(uZ, min.Z, max.Z) * size.Z + ); + + hull.Add(pos); + } + + hulls.Add(hull); + } + + mConvexHulls = hulls; + } + } + catch (Exception e) + { + m_log.WarnFormat("[MESH]: exception decoding convex block: {0}", e.Message); + } + } + if (physicsParms == null) { m_log.WarnFormat("[MESH]: No recognized physics mesh found in mesh asset for {0}", primName); @@ -381,27 +434,7 @@ namespace OpenSim.Region.Physics.Meshing // byte[] decompressed = new byte[physSize * 5]; try { - using (MemoryStream inMs = new MemoryStream(meshBytes)) - { - using (MemoryStream outMs = new MemoryStream()) - { - using (ZOutputStream zOut = new ZOutputStream(outMs)) - { - byte[] readBuffer = new byte[2048]; - int readLen = 0; - while ((readLen = inMs.Read(readBuffer, 0, readBuffer.Length)) > 0) - { - zOut.Write(readBuffer, 0, readLen); - } - zOut.Flush(); - outMs.Seek(0, SeekOrigin.Begin); - - byte[] decompressedBuf = outMs.GetBuffer(); - - decodedMeshOsd = OSDParser.DeserializeLLSDBinary(decompressedBuf); - } - } - } + decodedMeshOsd = DecompressOsd(meshBytes); } catch (Exception e) { @@ -428,6 +461,41 @@ namespace OpenSim.Region.Physics.Meshing return true; } + + /// + /// decompresses a gzipped OSD object + /// + /// the OSD object + /// + /// + private static OSD DecompressOsd(byte[] meshBytes) + { + OSD decodedOsd = null; + + using (MemoryStream inMs = new MemoryStream(meshBytes)) + { + using (MemoryStream outMs = new MemoryStream()) + { + using (ZOutputStream zOut = new ZOutputStream(outMs)) + { + byte[] readBuffer = new byte[2048]; + int readLen = 0; + while ((readLen = inMs.Read(readBuffer, 0, readBuffer.Length)) > 0) + { + zOut.Write(readBuffer, 0, readLen); + } + zOut.Flush(); + outMs.Seek(0, SeekOrigin.Begin); + + byte[] decompressedBuf = outMs.GetBuffer(); + + decodedOsd = OSDParser.DeserializeLLSDBinary(decompressedBuf); + } + } + } + return decodedOsd; + } + /// /// Generate the co-ords and faces necessary to construct a mesh from the sculpt data the accompanies a prim. /// @@ -704,6 +772,27 @@ namespace OpenSim.Region.Physics.Meshing return true; } + /// + /// temporary prototype code - please do not use until the interface has been finalized! + /// + /// value to scale the hull points by + /// a list of hulls if they exist and have been successfully decoded, otherwise null + public List> GetConvexHulls(Vector3 size) + { + if (mConvexHulls == null) + return null; + + List> hulls = new List>(); + foreach (var hull in mConvexHulls) + { + List verts = new List(); + foreach (var vert in hull) + verts.Add(vert * size); + } + + return hulls; + } + public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod) { return CreateMesh(primName, primShape, size, lod, false, true); -- cgit v1.1 From 477bee6468f35ca9264fc8f752a9124e32503901 Mon Sep 17 00:00:00 2001 From: dahlia Date: Sat, 18 May 2013 11:15:05 -0700 Subject: remove duplicate hull scaling --- OpenSim/Region/Physics/Meshing/Meshmerizer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index 825e622..a57146c 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs @@ -396,9 +396,9 @@ namespace OpenSim.Region.Physics.Meshing ushort uZ = Utils.BytesToUInt16(posBytes, posNdx); posNdx += 2; Vector3 pos = new Vector3( - Utils.UInt16ToFloat(uX, min.X, max.X) * size.X, - Utils.UInt16ToFloat(uY, min.Y, max.Y) * size.Y, - Utils.UInt16ToFloat(uZ, min.Z, max.Z) * size.Z + Utils.UInt16ToFloat(uX, min.X, max.X), + Utils.UInt16ToFloat(uY, min.Y, max.Y), + Utils.UInt16ToFloat(uZ, min.Z, max.Z) ); hull.Add(pos); -- cgit v1.1 From e65d1e459eb875cb2d0d5f9aa6042c640daa19fd Mon Sep 17 00:00:00 2001 From: dahlia Date: Sat, 18 May 2013 13:11:22 -0700 Subject: fix error in hull point indexing --- OpenSim/Region/Physics/Meshing/Meshmerizer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index a57146c..79edc12 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs @@ -389,7 +389,7 @@ namespace OpenSim.Region.Physics.Meshing int count = cnt == 0 ? 256 : cnt; List hull = new List(); - for (int i = 0; i < cnt; i++) + for (int i = 0; i < count; i++) { ushort uX = Utils.BytesToUInt16(posBytes, posNdx); posNdx += 2; ushort uY = Utils.BytesToUInt16(posBytes, posNdx); posNdx += 2; -- cgit v1.1