diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index a3602e93f2..ada4e89b00 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -2136,7 +2136,7 @@ namespace OpenSim.Framework /// the secret part public static bool ParseUniversalUserIdentifier(string value, out UUID uuid, out string url, out string firstname, out string lastname, out string secret) { - uuid = UUID.Zero; url = string.Empty; firstname = "Unknown"; lastname = "User"; secret = string.Empty; + uuid = UUID.Zero; url = string.Empty; firstname = "Unknown"; lastname = "UserUPUUI"; secret = string.Empty; string[] parts = value.Split(';'); if (parts.Length >= 1) diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 8056030843..4613344325 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -371,7 +371,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends foreach (string fid in outstanding) { UUID fromAgentID; - string firstname = "Unknown", lastname = "User"; + string firstname = "Unknown", lastname = "UserFMSFOIN"; if (!GetAgentInfo(client.Scene.RegionInfo.ScopeID, fid, out fromAgentID, out firstname, out lastname)) { m_log.DebugFormat("[FRIENDS MODULE]: skipping malformed friend {0}", fid); @@ -397,7 +397,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends protected virtual bool GetAgentInfo(UUID scopeID, string fid, out UUID agentID, out string first, out string last) { - first = "Unknown"; last = "User"; + first = "Unknown"; last = "UserFMGAI"; if (!UUID.TryParse(fid, out agentID)) return false; diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs index bf5c0bb46b..b3e3aa2e97 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs @@ -293,7 +293,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends protected override bool GetAgentInfo(UUID scopeID, string fid, out UUID agentID, out string first, out string last) { - first = "Unknown"; last = "User"; + first = "Unknown"; last = "UserHGGAI"; if (base.GetAgentInfo(scopeID, fid, out agentID, out first, out last)) return true; diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index 6847e572fb..a720d7bad6 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs @@ -157,13 +157,16 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement } else { - string[] names = GetUserNames(uuid); + string[] names; + bool foundRealName = TryGetUserNames(uuid, out names); + if (names.Length == 2) { - //m_log.DebugFormat("[XXX] HandleUUIDNameRequest {0} is {1} {2}", uuid, names[0], names[1]); + if (!foundRealName) + m_log.DebugFormat("[USER MANAGEMENT MODULE]: Sending {0} {1} for {2} to {3} since no bound name found", names[0], names[1], uuid, remote_client.Name); + remote_client.SendNameReply(uuid, names[0], names[1]); } - } } @@ -246,10 +249,15 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement } // search the local cache - foreach (UserData data in m_UserCache.Values) - if (users.Find(delegate(UserData d) { return d.Id == data.Id; }) == null && - (data.FirstName.ToLower().StartsWith(query.ToLower()) || data.LastName.ToLower().StartsWith(query.ToLower()))) - users.Add(data); + lock (m_UserCache) + { + foreach (UserData data in m_UserCache.Values) + { + if (users.Find(delegate(UserData d) { return d.Id == data.Id; }) == null && + (data.FirstName.ToLower().StartsWith(query.ToLower()) || data.LastName.ToLower().StartsWith(query.ToLower()))) + users.Add(data); + } + } AddAdditionalUsers(query, users); @@ -272,17 +280,24 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement } } - private string[] GetUserNames(UUID uuid) + /// + /// Try to get the names bound to the given uuid. + /// + /// True if the name was found, false if not. + /// + /// The array of names if found. If not found, then names[0] = "Unknown" and names[1] = "User" + private bool TryGetUserNames(UUID uuid, out string[] names) { - string[] returnstring = new string[2]; + names = new string[2]; lock (m_UserCache) { if (m_UserCache.ContainsKey(uuid)) { - returnstring[0] = m_UserCache[uuid].FirstName; - returnstring[1] = m_UserCache[uuid].LastName; - return returnstring; + names[0] = m_UserCache[uuid].FirstName; + names[1] = m_UserCache[uuid].LastName; + + return true; } } @@ -290,8 +305,8 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement if (account != null) { - returnstring[0] = account.FirstName; - returnstring[1] = account.LastName; + names[0] = account.FirstName; + names[1] = account.LastName; UserData user = new UserData(); user.FirstName = account.FirstName; @@ -299,14 +314,16 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement lock (m_UserCache) m_UserCache[uuid] = user; + + return true; } else { - returnstring[0] = "Unknown"; - returnstring[1] = "User"; - } + names[0] = "Unknown"; + names[1] = "UserUMMTGUN"; - return returnstring; + return false; + } } #region IUserManagement @@ -342,15 +359,17 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement public string GetUserName(UUID uuid) { - string[] names = GetUserNames(uuid); + string[] names; + TryGetUserNames(uuid, out names); + if (names.Length == 2) { string firstname = names[0]; string lastname = names[1]; return firstname + " " + lastname; - } + return "(hippos)"; } @@ -466,12 +485,13 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement //ignore updates without creator data return; } + //try update unknown users //and creator's home URL's if ((oldUser.FirstName == "Unknown" && !creatorData.Contains ("Unknown")) || (oldUser.HomeURL != null && !creatorData.StartsWith (oldUser.HomeURL))) { m_UserCache.Remove (id); -// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Re-adding user with id {0}, creatorData [{1}] and old HomeURL {2}", id, creatorData,oldUser.HomeURL); + m_log.DebugFormat("[USER MANAGEMENT MODULE]: Re-adding user with id {0}, creatorData [{1}] and old HomeURL {2}", id, creatorData, oldUser.HomeURL); } else { @@ -516,7 +536,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement else { user.FirstName = "Unknown"; - user.LastName = "User"; + user.LastName = "UserUMMAU"; } AddUserInternal (user); @@ -547,6 +567,13 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement protected void RegisterConsoleCmds() { + MainConsole.Instance.Commands.AddCommand("Users", true, + "show name", + "show name ", + "Show the bindings between a single user UUID and a user name", + String.Empty, + HandleShowUser); + MainConsole.Instance.Commands.AddCommand("Users", true, "show names", "show names", @@ -555,26 +582,54 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement HandleShowUsers); } - private void HandleShowUsers(string module, string[] cmd) + private void HandleShowUser(string module, string[] cmd) { - lock (m_UserCache) + if (cmd.Length < 3) { - if (m_UserCache.Count == 0) - { - MainConsole.Instance.Output("No users found"); - return; - } - - MainConsole.Instance.Output("UUID User Name"); - MainConsole.Instance.Output("-----------------------------------------------------------------------------"); - foreach (KeyValuePair kvp in m_UserCache) - { - MainConsole.Instance.Output(String.Format("{0} {1} {2} ({3})", - kvp.Key, kvp.Value.FirstName, kvp.Value.LastName, kvp.Value.HomeURL)); - } - + MainConsole.Instance.OutputFormat("Usage: show name "); return; } + + UUID userId; + if (!ConsoleUtil.TryParseConsoleUuid(MainConsole.Instance, cmd[2], out userId)) + return; + + string[] names; + + UserData ud; + + lock (m_UserCache) + { + if (!m_UserCache.TryGetValue(userId, out ud)) + { + MainConsole.Instance.OutputFormat("No name known for user with id {0}", userId); + return; + } + } + + ConsoleDisplayTable cdt = new ConsoleDisplayTable(); + cdt.AddColumn("UUID", 36); + cdt.AddColumn("Name", 30); + cdt.AddColumn("HomeURL", 40); + cdt.AddRow(userId, string.Format("{0} {1}", ud.FirstName, ud.LastName), ud.HomeURL); + + MainConsole.Instance.Output(cdt.ToString()); + } + + private void HandleShowUsers(string module, string[] cmd) + { + ConsoleDisplayTable cdt = new ConsoleDisplayTable(); + cdt.AddColumn("UUID", 36); + cdt.AddColumn("Name", 30); + cdt.AddColumn("HomeURL", 40); + + lock (m_UserCache) + { + foreach (KeyValuePair kvp in m_UserCache) + cdt.AddRow(kvp.Key, string.Format("{0} {1}", kvp.Value.FirstName, kvp.Value.LastName), kvp.Value.HomeURL); + } + + MainConsole.Instance.Output(cdt.ToString()); } } } \ No newline at end of file diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index 2d102de78f..79edc12dde 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 < count; 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), + Utils.UInt16ToFloat(uY, min.Y, max.Y), + Utils.UInt16ToFloat(uZ, min.Z, max.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);